XML Dom Automation Error

Betrachter84
Member Posts: 62
Hi
I have a very strange problem concerning a XML Dom Node v.6 Automation Variable.
I'm getting a RuntimeError saying the automation variable was not instantiated, and i should do this by crating or assigning it. Obviousely i do this (see the code below).
Now the particular problem. If you copy the code below in a new codeunit on the on run trigger or on a first level function it won't give you back any error. If you copy the code in function B which is Called by function A which is called on run (3rd level function) the described error appears..., at least in my codeunit.
It is not a sulution to move the code to a 1st level function because it es embedded in a quite complex codeunit.
Is it possible, that automation variables make problems if one calls them from 3rd or higher level functions?
Thanks a lot for any help, i'm kind of desperate at this point
Have a look at the following code:
Globals
Name DataType Subtype Length
XMLDOMDocument Automation 'Microsoft XML, v6.0'.DOMDocument
XMLDOC Automation 'Microsoft XML, v6.0'.DOMDocument
XMLNode Automation 'Microsoft XML, v6.0'.IXMLDOMNode
XMLNode2 Automation 'Microsoft XML, v6.0'.IXMLDOMNode
XMLNode3 Automation 'Microsoft XML, v6.0'.IXMLDOMNode
XMLDomAttribute Automation 'Microsoft XML, v6.0'.IXMLDOMAttribute
XMLChildDomNode Automation 'Microsoft XML, v6.0'.IXMLDOMNode
Separator Text 30
Ch10 Char
Ch13 Char
Ch9 Char
XMLProcIns Automation 'Microsoft XML, v6.0'.IXMLDOMProcessingInstruction
XMLDomRootNode Automation 'Microsoft XML, v6.0'.IXMLDOMNode
NodeNameGlobal Text 30
XMLDocHeader Automation 'Microsoft XML, v6.0'.DOMDocument
XMLDomHeaderRootNode Automation 'Microsoft XML, v6.0'.IXMLDOMNode
Code
NodeNameGlobal := 'OrderEnv';
IF ISCLEAR(XMLDocHeader) THEN BEGIN
CREATE(XMLDocHeader);
XMLDocHeader.async := FALSE;
END;
Ch10 := 10;
Ch13 := 13;
Ch9 := 9;
Separator := FORMAT(Ch13) + FORMAT(Ch10) + FORMAT(Ch9);
//Cancel validation because loadXML will try to send to parser and it will fail because of external DTD
XMLDocHeader.validateOnParse(FALSE);
//Insert the header you want/need to use. It seems you must have root or something like it.
//You can add a boolean in front of this command to verify that it loaded.
XMLDocHeader.loadXML(
'<?xml version="1.0" encoding="UTF-8" ?>' + Separator +
'<!DOCTYPE OrderEnv SYSTEM "http://integratex.quality.techdata.de:8080/ix/dtd/ixOrder4.dtd">' + Separator +
'<'+ NodeNameGlobal +'></'+ NodeNameGlobal +'>');
XMLDomHeaderRootNode := XMLDocHeader.selectSingleNode(NodeNameGlobal);
MESSAGE(FORMAT(XMLDomHeaderRootNode.nodeName)); // -> here the Error appears
Here the whole Codeunit where you may check what i described by either activating the code in the 1st level function or the 2nd level function.
I have a very strange problem concerning a XML Dom Node v.6 Automation Variable.
I'm getting a RuntimeError saying the automation variable was not instantiated, and i should do this by crating or assigning it. Obviousely i do this (see the code below).
Now the particular problem. If you copy the code below in a new codeunit on the on run trigger or on a first level function it won't give you back any error. If you copy the code in function B which is Called by function A which is called on run (3rd level function) the described error appears..., at least in my codeunit.
It is not a sulution to move the code to a 1st level function because it es embedded in a quite complex codeunit.
Is it possible, that automation variables make problems if one calls them from 3rd or higher level functions?
Thanks a lot for any help, i'm kind of desperate at this point
Have a look at the following code:
Globals
Name DataType Subtype Length
XMLDOMDocument Automation 'Microsoft XML, v6.0'.DOMDocument
XMLDOC Automation 'Microsoft XML, v6.0'.DOMDocument
XMLNode Automation 'Microsoft XML, v6.0'.IXMLDOMNode
XMLNode2 Automation 'Microsoft XML, v6.0'.IXMLDOMNode
XMLNode3 Automation 'Microsoft XML, v6.0'.IXMLDOMNode
XMLDomAttribute Automation 'Microsoft XML, v6.0'.IXMLDOMAttribute
XMLChildDomNode Automation 'Microsoft XML, v6.0'.IXMLDOMNode
Separator Text 30
Ch10 Char
Ch13 Char
Ch9 Char
XMLProcIns Automation 'Microsoft XML, v6.0'.IXMLDOMProcessingInstruction
XMLDomRootNode Automation 'Microsoft XML, v6.0'.IXMLDOMNode
NodeNameGlobal Text 30
XMLDocHeader Automation 'Microsoft XML, v6.0'.DOMDocument
XMLDomHeaderRootNode Automation 'Microsoft XML, v6.0'.IXMLDOMNode
Code
NodeNameGlobal := 'OrderEnv';
IF ISCLEAR(XMLDocHeader) THEN BEGIN
CREATE(XMLDocHeader);
XMLDocHeader.async := FALSE;
END;
Ch10 := 10;
Ch13 := 13;
Ch9 := 9;
Separator := FORMAT(Ch13) + FORMAT(Ch10) + FORMAT(Ch9);
//Cancel validation because loadXML will try to send to parser and it will fail because of external DTD
XMLDocHeader.validateOnParse(FALSE);
//Insert the header you want/need to use. It seems you must have root or something like it.
//You can add a boolean in front of this command to verify that it loaded.
XMLDocHeader.loadXML(
'<?xml version="1.0" encoding="UTF-8" ?>' + Separator +
'<!DOCTYPE OrderEnv SYSTEM "http://integratex.quality.techdata.de:8080/ix/dtd/ixOrder4.dtd">' + Separator +
'<'+ NodeNameGlobal +'></'+ NodeNameGlobal +'>');
XMLDomHeaderRootNode := XMLDocHeader.selectSingleNode(NodeNameGlobal);
MESSAGE(FORMAT(XMLDomHeaderRootNode.nodeName)); // -> here the Error appears
Here the whole Codeunit where you may check what i described by either activating the code in the 1st level function or the 2nd level function.
OBJECT Codeunit 50092 XML Info and Doctype { OBJECT-PROPERTIES { Date=18.03.11; Time=15:05:37; Modified=Yes; Version List=EXAMPLE; } PROPERTIES { OnRun=BEGIN CLEAR(XMLDOMDocument); CREATE(XMLDOMDocument); ChangeXMLFile(XMLDOMDocument); END; } CODE { VAR XMLDOMDocument@1000000000 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{F6D90F11-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v6.0'.DOMDocument"; XMLDOC@1000000016 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{F6D90F11-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v6.0'.DOMDocument"; XMLNode@1000000007 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNode"; XMLNode2@1000000008 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNode"; XMLNode3@1000000019 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNode"; XMLDomAttribute@1000000014 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF85-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMAttribute"; XMLChildDomNode@1000000015 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNode"; Separator@1000000009 : Text[30]; Ch10@1000000010 : Char; Ch13@1000000011 : Char; Ch9@1000000012 : Char; XMLProcIns@1000000013 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF89-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMProcessingInstruction"; XMLDomRootNode@1000000020 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNode"; NodeNameGlobal@1000000021 : Text[30]; XMLDocHeader@1000000017 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{F6D90F11-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v6.0'.DOMDocument"; XMLDomHeaderRootNode@1000000006 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v6.0'.IXMLDOMNode"; PROCEDURE ChangeXMLFile@1100000002(VAR MSDOM2@1000000000 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{F6D90F11-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v6.0'.DOMDocument"); BEGIN //GenerateXMLHeaderFile('OrderEnv'); //////////////////// NodeNameGlobal := 'OrderEnv'; IF ISCLEAR(XMLDocHeader) THEN BEGIN CREATE(XMLDocHeader); XMLDocHeader.async := FALSE; END; Ch10 := 10; Ch13 := 13; Ch9 := 9; Separator := FORMAT(Ch13) + FORMAT(Ch10) + FORMAT(Ch9); //Cancel validation because loadXML will try to send to parser and it will fail because of external DTD XMLDocHeader.validateOnParse(FALSE); //Insert the header you want/need to use. It seems you must have root or something like it. //You can add a boolean in front of this command to verify that it loaded. XMLDocHeader.loadXML( '<?xml version="1.0" encoding="UTF-8" ?>' + Separator + '<!DOCTYPE OrderEnv SYSTEM "http://integratex.quality.techdata.de:8080/ix/dtd/ixOrder4.dtd">' + Separator + '<'+ NodeNameGlobal +'></'+ NodeNameGlobal +'>'); XMLDomHeaderRootNode := XMLDocHeader.selectSingleNode(NodeNameGlobal); MESSAGE(FORMAT(XMLDomHeaderRootNode.nodeName)); //////////////////// IF ISCLEAR(XMLDOC) THEN BEGIN CREATE(XMLDOC); XMLDOC.async := FALSE; END; XMLNode := XMLDOC.createNode(1,FORMAT('OrderEnv'),''); XMLDOC.appendChild(XMLNode); XMLDomRootNode := XMLNode; XMLNode2 := XMLDOC.createNode(1,FORMAT('TestNode'),''); XMLNode.appendChild(XMLNode2); XMLChildDomNode := XMLNode2; XMLDomAttribute := XMLDOC.createAttribute('attribute1'); XMLDomAttribute.value := FORMAT('attribute 1 value'); XMLChildDomNode.attributes.setNamedItem(XMLDomAttribute); XMLNode2 := XMLDOC.createNode(1,FORMAT('TestNode2'),''); XMLNode.appendChild(XMLNode2); //XMLDocHeader.replaceChild(XMLDomRootNode,XMLDomHeaderRootNode); //These were made for testing... //XMLDocHeader.save('C:\Temp\Header1.xml'); XMLDOC.save('C:\Temp\Content2.xml'); END; PROCEDURE GenerateXMLHeaderFile@1000000012(NodeNameLocal@1000000000 : Text[30]); VAR Ch10@1000000004 : Integer; CH13@1000000003 : Integer; CH9@1000000002 : Integer; Separator@1000000001 : Text[30]; BEGIN IF ISCLEAR(XMLDocHeader) THEN BEGIN CREATE(XMLDocHeader); XMLDocHeader.async := FALSE; END; Ch10 := 10; CH13 := 13; CH9 := 9; Separator := FORMAT(CH13) + FORMAT(Ch10) + FORMAT(CH9); //Cancel validation because loadXML will try to send to parser and it will fail because of external DTD XMLDocHeader.validateOnParse(FALSE); //Insert the header you want/need to use. It seems you must have root or something like it. //You can add a boolean in front of this command to verify that it loaded. XMLDocHeader.loadXML( '<?xml version="1.0" encoding="UTF-8" ?>' + Separator + '<!DOCTYPE OrderEnv SYSTEM "http://integratex.quality.techdata.de:8080/ix/dtd/ixOrder4.dtd">' + Separator + '<'+ NodeNameLocal +'></'+ NodeNameLocal +'>'); XMLDomHeaderRootNode := XMLDocHeader.selectSingleNode(NodeNameLocal); MESSAGE(FORMAT(XMLDomHeaderRootNode.nodeName)); END; EVENT XMLDOMDocument@1000000000::ondataavailable@198(); BEGIN END; EVENT XMLDOMDocument@1000000000::onreadystatechange@-609(); BEGIN END; EVENT XMLDOC@1000000016::ondataavailable@198(); BEGIN END; EVENT XMLDOC@1000000016::onreadystatechange@-609(); BEGIN END; EVENT XMLDocHeader@1000000017::ondataavailable@198(); BEGIN END; EVENT XMLDocHeader@1000000017::onreadystatechange@-609(); BEGIN END; BEGIN { NodeNameGlobal := 'OrderEnv'; IF ISCLEAR(XMLDocHeader) THEN BEGIN CREATE(XMLDocHeader); XMLDocHeader.async := FALSE; END; Ch10 := 10; Ch13 := 13; Ch9 := 9; Separator := FORMAT(Ch13) + FORMAT(Ch10) + FORMAT(Ch9); //Cancel validation because loadXML will try to send to parser and it will fail because of external DTD XMLDocHeader.validateOnParse(FALSE); //Insert the header you want/need to use. It seems you must have root or something like it. //You can add a boolean in front of this command to verify that it loaded. XMLDocHeader.loadXML( '<?xml version="1.0" encoding="UTF-8" ?>' + Separator + '<!DOCTYPE OrderEnv SYSTEM "http://integratex.quality.techdata.de:8080/ix/dtd/ixOrder4.dtd">' + Separator + '<'+ NodeNameGlobal +'></'+ NodeNameGlobal +'>'); XMLDomHeaderRootNode := XMLDocHeader.selectSingleNode(NodeNameGlobal); MESSAGE(FORMAT(XMLDomHeaderRootNode.nodeName)); } END. } }
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions