Text length for Style Sheet ToolW11.1

krzychub83krzychub83 Member Posts: 120
I would like to transfer blob memo fields through Style Sheet ToolW11.1 to Ms Word. I expect memos about 10kB length. This tool does not support blobs, so I must modify codeunit 682 (Style Sheet Data Management).

variables: BSTRConv as 'Navision Attain Hash 1.0'.BSTRConverter
ChildNode as 'Microsoft XML, v4.0'.IXMLDOMNode

ChildNode := ParentNode.ownerDocument.createNode('element',NodeName,'');
CREATE(BSTRConv);
WHILE NodeTextStream.EOS = FALSE DO BEGIN
NodeTextStream.READTEXT(temp, 1024);
BSTRConv.AppendNextStringPortion (temp);
END;
ChildNode.text (BSTRConv.BSTR); //error at this line
ParentNode.appendChild(ChildNode);
CreatedChildNode := ChildNode;

When stream has more than 1024 characters, I’ve got an error: “The length of the text string exceeds the size of the string buffer”.

Is any way to solve this problem?
PS: NAV 5.0 SP1

Comments

  • XypherXypher Member Posts: 297
    edited 2009-09-23
    If you haven't already noticed, Navision has many limitations. The 1024 buffer limitation with passing information via OCX/Automations (as well as similar cap on local data, aside from Blob & BigText)


    You did, however, overlook the fact that Microsoft XML (MSXML) Automation allows streams.

    (I've gotta make a b-line for the door since I'm off work but here is some code. I am sure you will find what you are looking for in this example)

    //tblob's are TempBlob records (Temporary = YES)
    tblob.Blob.CREATEOUTSTREAM(ostream);
    tblob.Blob.CREATEINSTREAM(istream);
    tblobb.Blob.CREATEINSTREAM(istreamb);
    tblobb.Blob.CREATEOUTSTREAM(ostreamb);
    
    //Large file I have (26k) for test
    tblobb.Blob.IMPORT('C:\Documents And Settings\myname\Desktop\txt.txt');
    
    ostream.WRITETEXT('<MyXML><cNode>');
    ostream.WRITETEXT();
    bt.READ(istreamb);
    bt.WRITE(ostream);
    ostream.WRITETEXT('</cNode></MyXML>');
    
    IF ISCLEAR(xmldom) THEN
      CREATE(xmldom);
    
    IF ISCLEAR(xmldomm) THEN
      CREATE(xmldomm);
    
    xmldom.load(istream); //<-- Here's where you will benefit the most :D
    xmlnode := xmldom.selectSingleNode('//MyXML/cNode');
    xmldomm.loadXML('<dummynode></dummynode>');
    xmlele  := xmldomm.documentElement;
    xmlele.AppendChild(xmlnode);
    
    
    xmldomm.save('C:\Documents And Settings\myname\Desktop\result.txt'); //Output to see the results
    CLEAR(xmldom);
    CLEAR(xmldomm);
    
  • krzychub83krzychub83 Member Posts: 120
    Thanks for this example. I understand the idea. But I’m not sure, if I found proper types for xml* variables.

    I’ve declared xmldom as 'Microsoft XML, v4.0'.IXMLDOMDocument2, but I’ve got error message: Could not create an instance of the OLE control or Automation server identified by GUID {guid} 4.0: {guid}: ‘Microsoft XML, v4.0’.IXMLDOMDocument2.
  • XypherXypher Member Posts: 297
    Declare xmldom (or whatever you want to name it) as 'Microsoft XML, v4.0'.DOMDocument

    And make sure to create an instance of the automation...
    IF ISCLEAR(xmldom) THEN
      CREATE(xmldom);
    
  • krzychub83krzychub83 Member Posts: 120
    THX for reply

    I menage to overcome this problem but now I have another error, which I don't know how to solve.
    [i]AddElementBlob(ParentNode,NodeName,NodeTextStream,CreatedChildNode)[/i]
    //preapre stream for xml
      tmp680."Style Sheet Document".CREATEINSTREAM (sin1);
      tmp680."Style Sheet Document".CREATEOUTSTREAM (sout1);
      sout1.WRITETEXT('<document><'+NodeName+'>');
      sout1.WRITETEXT();
      bt.READ (NodeTextStream);
      bt.WRITE (sout1);
      sout1.WRITETEXT('</'+NodeName+'></document>');
    //end: preapre stream for xml
    
    // ChildNode := 
    ParentNode.ownerDocument.createNode('element',NodeName,'');
    
    IF ISCLEAR(xmldom) THEN
      CREATE(xmldom);
    
    xmldom.load(sin1);
    ChildNode := xmldom.selectSingleNode('//document/'+NodeName+'');
    
    
    // ERROR AT THIS LINE: 
    ParentNode.appendChild(ChildNode);
    CreatedChildNode := ChildNode;
    CLEAR(xmldom);
    

    The Error popup says:
    The call to member appendChild failed. msxml4.dll returned the fallowing message:
    It is an error to mix objects from different versions of MSXML
  • XypherXypher Member Posts: 297
    Make sure your Microsoft XML automation variables are all of the same MSXML version.
  • krzychub83krzychub83 Member Posts: 120
    Make sure your Microsoft XML automation variables are all of the same MSXML version.

    They are of the same version. But thank You for a try. Maybe some other ideas...
  • XypherXypher Member Posts: 297
    Paste your variable declarations & code please
  • BiboBibo Member Posts: 22
    Had the same error message "Make sure your Microsoft XML automation variables are all of the same MSXML version", when I was trying to run Style Sheet Tool 2.0 on 5.0 SP1 client.

    Downgrading automation variables from "'Microsoft XML, v6.0'.DOMDocument60" to "'Microsoft XML, v4.0'.DOMDocument40" solved the issue...
  • DoomhammerDoomhammer Member Posts: 211
    Bibo wrote:
    Downgrading automation variables from "'Microsoft XML, v6.0'.DOMDocument60" to "'Microsoft XML, v4.0'.DOMDocument40" solved the issue...
    thanks for idea. i encountered same problem in style sheet tool 2.0 on NAV 5.0 and your solution worked fine. then i tried to change automation server definitions to 'Microsoft XML, v6.0'.DOMDocument40" and this worked too.
    Martin Bokůvka, AxiomProvis
Sign In or Register to comment.