<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TechBlog &#187; XML</title>
	<atom:link href="http://techblog.byllemos.com/category/xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://techblog.byllemos.com</link>
	<description>Accelerating into the Future with Wisdom about Technology! Ingrid Byllemos</description>
	<lastBuildDate>Tue, 05 Jan 2010 00:04:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>XMLports &#8211; What are they and how to use them</title>
		<link>http://techblog.byllemos.com/2009/06/xmlports-what-are-they-and-how-to-use-them/</link>
		<comments>http://techblog.byllemos.com/2009/06/xmlports-what-are-they-and-how-to-use-them/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 17:31:25 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[Navision]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XMLport]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=259</guid>
		<description><![CDATA[<p>XMLports was introduced with Navision 4.0 &#8211; they act like dataports, with a small difference. They can only be used for XML-formatted data and they must by executed from some other routine.</p>
<p>In the XMLport designer &#8211; you set up&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>XMLports was introduced with Navision 4.0 &#8211; they act like dataports, with a small difference. They can only be used for XML-formatted data and they must by executed from some other routine.</p>
<p>In the XMLport designer &#8211; you set up a defined format. Just think of it, as a kind of schema (xsd). You can add Elements and Attributes and in the Properties you can setup the Encoding and the DefaultNamespace.<span id="more-259"></span></p>
<p><img src="http://techblog.byllemos.com/wp-content/xmlport_designer.png" alt="xmlport_designer" title="xmlport_designer" width="542" height="296" class="alignnone size-full wp-image-263" /></p>
<p>Now that the XMLport has been designed, it is time to use it.</p>
<p>An XMLport, can as already mentioned, not be executed by itself. You have to call it from another routine. Such as a codeunit, forms etc.</p>
<p>To export XMLs do the following:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="cside"><div class="devcodeoverflow">First create an Out File - this are what you xml will be called:

      outFile.CREATE('c:\outxml.xml');

Next prepare for streaming the data to XML. In Designer example we used 
Sales Header. So the out stream is called SH_outStream:

      outFile.CREATEOUTSTREAM(SH_outStream);

Now that we have the out File and the out stream ready it is time to execute
the XMLport. This is done by calling the export:

      XMLPORT.EXPORT(50000, SH_outStream);

And then finally end by closing the file.

      outFile.CLOSE;</div></pre><!--END_DEVFMTCODE--></p>
<p>The exported XML file will look like this:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title=""><div class="devcodeoverflow">
&lt;?xml version=&quot;<span style="">1.0</span>&quot; encoding=&quot;UTF-<span style="">16</span>&quot; standalone=&quot;no&quot;?&gt;
&lt;invoice&gt;
    &lt;sales_header&gt;
        &lt;document_no&gt;<span style="">2001</span>&lt;/document_no&gt;
        &lt;sell-to_customer&gt;<span style="">10000</span>&lt;/sell-to_customer&gt;
        &lt;sales_lines&gt;
            &lt;sales_line&gt;
                &lt;itemno quantity=&quot;<span style="">4</span>&quot; price=&quot;<span style="">0</span>&quot;&gt;ITEM-No-<span style="">10</span>&lt;/itemno&gt;
                &lt;description&gt;This is a item description&lt;/description&gt;
            &lt;/sales_line&gt;
        &lt;/sales_lines&gt;
    &lt;/sales_header&gt;
&lt;/invoice&gt;</div></pre><!--END_DEVFMTCODE--></p>
<p>Importing XML files is similar to the Export:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="cside"><div class="devcodeoverflow">
First open the file:

      inFile.OPEN('c:\inxml.xml');

Next create an in stream:

      inFile.CREATEINSTREAM(SH_inStream);

And then execute the XMLport to importing the xml:

      XMLPORT.IMPORT(50000, SH_inStream);

And then finally end by closing the file:

      inFile.CLOSE;
</div></pre><!--END_DEVFMTCODE--></p>
<p>That&#8217;s all &#8211; now you can export and import xml files using an XMLport.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2009/06/xmlports-what-are-they-and-how-to-use-them/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML &#8211; SetAttribute can cause Navision to crash</title>
		<link>http://techblog.byllemos.com/2008/04/xml-setattribute-can-cause-navision-to-crash/</link>
		<comments>http://techblog.byllemos.com/2008/04/xml-setattribute-can-cause-navision-to-crash/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 21:34:45 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[Automations]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Navision]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=62</guid>
		<description><![CDATA[<p>There is an error in the XML DOM automation which can cause Navision to crash. This looks like a kind of memory leak and will therefore often occur in automated/scheduled jobs.</p>
<p>The error occurs when using setAttribute directly on the&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>There is an error in the XML DOM automation which can cause Navision to crash. This looks like a kind of memory leak and will therefore often occur in automated/scheduled jobs.</p>
<p>The error occurs when using setAttribute directly on the XML Dom Element. To prevent a crash, use a function to set the Attribute.<br />
<span id="more-62"></span><br />
The function could look like this:</p>
<blockquote><p>IF ISCLEAR(XMLDoc) THEN<br />
<blankspace>&#8230;..</blankspace>CREATE(XMLDoc);</p>
<p>XMLAttribute := XMLDoc.createAttribute(AttributeName);<br />
XMLAttribute.value(Value);<br />
XMLElement.setAttributeNode(XMLAttribute);<br />
CLEAR(XMLAttribute);</p>
<p>where the local variables are:</p>
<ul>
<li> XMLDoc is Microsoft XML, v4.0&#8242;.DOMDocument</li>
<li> XMLAttribute is Microsoft XML, v4.0&#8242;.IXMLDOMAttribute</li>
</ul>
<p>and the function parameters are:</p>
<ul>
<li> Value is Text 1024</li>
<li> AttributeName is Text 1024</li>
<li> XMLElement is var and a Automation &#8220;&#8216;Microsoft XML, v4.0&#8242;.IXMLDOMElement&#8221;</li>
</ul>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2008/04/xml-setattribute-can-cause-navision-to-crash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Problems when loading XML</title>
		<link>http://techblog.byllemos.com/2007/10/problems-when-loading-xml/</link>
		<comments>http://techblog.byllemos.com/2007/10/problems-when-loading-xml/#comments</comments>
		<pubDate>Tue, 16 Oct 2007 19:39:30 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[Automations]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Navision]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=33</guid>
		<description><![CDATA[<p>A load will not work if the document contains a DTD / Schema definition where the validation file cannot be found!</p>
<p>Ex. a XML containing the following will not be able to be loaded because the DTD does not use&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>A load will not work if the document contains a DTD / Schema definition where the validation file cannot be found!</p>
<p>Ex. a XML containing the following will not be able to be loaded because the DTD does not use a URI path.<br />
<span id="more-33"></span></p>
<blockquote><p>&lt;!DOCTYPE TXP SYSTEM &#8220;example.dtd&#8221;&gt;</p></blockquote>
<blockquote><p>Uniform Ressource Identifier (URI) Ex. &#8220;http://mysite.com/ex.dtd&#8221;</p></blockquote>
<p>A load can be done any way by ignoring parsing errors <img src='http://techblog.byllemos.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<blockquote><p> XMLDoc.validateOnParse := FALSE;<br />
XMLDoc.resolveExternals := FALSE;</p></blockquote>
<p>Loading a XML document with a DTD / Schema is possible if the DTD / XSD file is placed in the same directory as the XML file.</p>
<p>Luckily load errors can be captured!</p>
<p>validateOnParse and resolveExternals must be enabled when loading the document (they are by default true)</p>
<blockquote><p> XMLDoc.validateOnParse := TRUE;<br />
XMLDoc.resolveExternals := TRUE;<br />
XMLDoc.load(FileName);</p></blockquote>
<p>Parse Errors can be saved in a variable (Microsoft XML IXMLDOMParseError)</p>
<blockquote><p> XMLErr := XMLDoc.parseError;</p></blockquote>
<p>XMLErr can return a error code and a reason description</p>
<blockquote><p> Message(<code>'</code>Error: %1 %2<code>'</code>,XMLErr.errorCode,XMLErr.reason);</p>
<p>Error: -1072898028<br />
Element content is invalid according to the DTD/Schema</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2007/10/problems-when-loading-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML in Navision</title>
		<link>http://techblog.byllemos.com/2007/10/xml-in-navision/</link>
		<comments>http://techblog.byllemos.com/2007/10/xml-in-navision/#comments</comments>
		<pubDate>Fri, 12 Oct 2007 19:01:19 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[Automations]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Navision]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=32</guid>
		<description><![CDATA[<p>In Navision there are 2 ways to handle XMLs. In all versions it is possible to use the automation Microsoft XML and from Navision 4 it is possible to use XML ports.</p>
<p>XML ports are thought not my preferred object,&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>In Navision there are 2 ways to handle XMLs. In all versions it is possible to use the automation Microsoft XML and from Navision 4 it is possible to use XML ports.</p>
<p>XML ports are thought not my preferred object, because they are limited. They work in the same way as a dataport. Therefore in the following we will concentrate us on the use of the automation Microsoft XML.</p>
<p>Before we are able to load/read an XML document, we must define a variable, which will provide us with a container for the document.<br />
<span id="more-32"></span></p>
<blockquote><p>Define the variable XMLDom as Microsoft XML – DomDocument</p></blockquote>
<p>Because we are using automations, we have to create the instant at first:</p>
<blockquote><p>CREATE(XMLDom);</p></blockquote>
<p>Now we are ready to load a XML document into the container. There are 2 ways:</p>
<p>1.    Loading from a text variable<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="cside"><div class="devcodeoverflow">XMLText := '<"1.0" encoding="ISO-8859-1"?>';
XMLText += 'SystemStatus';
XMLDom.loadXML(XMLText);</div></pre><!--END_DEVFMTCODE--></p>
<p>2.    Loading from a file<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="cside"><div class="devcodeoverflow">XMLFile := 'c:\text.xml';
XMLDom.load(XMLFile);</div></pre><!--END_DEVFMTCODE--><br />
By the way, the XML file could also be at text stream.</p>
<p>As soon the XML Document has been loaded, we are ready to add tags and read tags.</p>
<p>There are 2 ways to read XMLs. You can parse the XML Document as Nodes or as Elements. Nodes are though often Elements with sub elements. Elements do not contain sub elements.</p>
<blockquote><p>Tags a common referee to Nodes and Elements</p></blockquote>
<p>1. Reading as Nodes:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="cside"><div class="devcodeoverflow">XMLNodeList := XMLDoc.getElementsByTagName(Tag);
Node := XMLNodeList.item(0);
IF NOT ISCLEAR(Node) THEN
    ReturnValue := Node.text;</div></pre><!--END_DEVFMTCODE--><br />
Where XMLNodeList is Microsoft XML IXMLDOMNodeList and Node is Microsoft XML IXMLDOMNode</p>
<p>2. Reading as Elements:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="cside"><div class="devcodeoverflow">Element := XMLDoc.selectSingleNode(TagName);
IF NOT ISCLEAR(Element) THEN BEGIN
    ReturnValue := Element.text;</div></pre><!--END_DEVFMTCODE--><br />
Where Element is Microsoft XML IXMLDOMElement</p>
<p>If you instead of reading wants to build a XML Document you can also do this in 2 ways.</p>
<p>1.    Create a XML from a text variable:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="cside"><div class="devcodeoverflow">Building the XML

    XMLText := '<"1.0" encoding="ISO-8859-1"?>';
    XMLText += '<order><type>SystemStatus</type></order>';
    XMLDom.loadXML(XMLText);

Saving the XML:

    XMLDom.save(xmlfile);

XML:
    <"1.0" encoding="ISO-8859-1"?>
    <order>
        <type>SystemStatus</type>
    </order>
</div></pre><!--END_DEVFMTCODE--></p>
<p>2. Creating an Init XML and then adding elements /nodes:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="cside"><div class="devcodeoverflow">Build initial XML:

    InitXML := '<"1.0" encoding="ISO-8859-1"?>'+
               '<order />';

    XMLDom.load(InitXML);

Add Element:

    Root := XMLdoc.documentElement;
    NewTag := XMLDom.createElement('Type');
    NewTag.text := 'SystemStatus';
    Root.appendChild(NewTag);

XML:
    <"1.0" encoding="ISO-8859-1"?>
    <order>
          <type>SystemStatus</type>
    </order>
</div></pre><!--END_DEVFMTCODE--></p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2007/10/xml-in-navision/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>XML Schemas &amp; DTDs</title>
		<link>http://techblog.byllemos.com/2007/10/xml-schemas-dtds/</link>
		<comments>http://techblog.byllemos.com/2007/10/xml-schemas-dtds/#comments</comments>
		<pubDate>Thu, 11 Oct 2007 21:26:32 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=20</guid>
		<description><![CDATA[<p>XML are validated with a DTD or with an XML Schema.</p>
<p>Document Type Definition (DTD) defines the legal elements of an XML Document.</p>
<blockquote><p>&#60;!DOCTYPE note SYSTEM &#8220;external.dtd&#8221;&#62;<br />
&#60;root&#62;</p></blockquote>
<p>XML Schema is an XML-based alternativ to DTD.<br />
<span id="more-20"></span>&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>XML are validated with a DTD or with an XML Schema.</p>
<p>Document Type Definition (DTD) defines the legal elements of an XML Document.</p>
<blockquote><p>&lt;!DOCTYPE note SYSTEM &#8220;external.dtd&#8221;&gt;<br />
&lt;root&gt;</p></blockquote>
<p>XML Schema is an XML-based alternativ to DTD.<br />
<span id="more-20"></span></p>
<blockquote><p>&lt;root<br />
xmlns=http://mysite<br />
xmlns:xsi=&#8221;http://www.w3.org/2001/XMLSchema-instance&#8221;<br />
xsi:schemaLocation=&#8221;http://mysite/schema.xsd&#8221;&gt;</p></blockquote>
<p>Schemas will in the near future replace DTDs.</p>
<p>DTD Example &#8211; External DTD file</p>
<blockquote><p>&lt;?xml version=&#8221;1.0&#8243;?&gt;<br />
&lt;!ELEMENT root (child)&gt;<br />
&lt;!ELEMENT child (#PCDATA)&gt;</p></blockquote>
<p>DTD Example &#8211; Using DTD in a XML</p>
<blockquote><p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243; ?&gt;<br />
&lt;!DOCTYPE note SYSTEM &#8220;external.dtd&#8221;&gt;<br />
&lt;root&gt;<br />
<blankspace>&#8230;..</blankspace>&lt;child&gt;123456&lt;/child&gt;<br />
&lt;/root&gt;</p></blockquote>
<p>Schema Example</p>
<blockquote><p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
&lt;xs:schema xmlns:xs=&#8221;http://www.w3.org/2001/XMLSchema&#8221;<br />
xmlns=&#8221;www.mysite.dk&#8221;<br />
xmlns:wmh=&#8221;"<br />
elementFormDefault=&#8221;qualified&#8221;<br />
targetNamespace=&#8221;www.mysite.dk&#8221;&gt;<br />
&lt;xs:element name=&#8221;root&#8221;&gt;<br />
<blankspace>&#8230;..</blankspace>&lt;xs:complexType&gt;<br />
<blankspace>&#8230;&#8230;&#8230;.</blankspace>&lt;xs:sequence&gt;<br />
<blankspace>&#8230;&#8230;&#8230;&#8230;&#8230;</blankspace>&lt;xs:element ref=&#8221;child&#8221;/&gt;<br />
<blankspace>&#8230;&#8230;&#8230;.</blankspace>&lt;/xs:sequence&gt;<br />
<blankspace>&#8230;..</blankspace>&lt;/xs:complexType&gt;<br />
&lt;/xs:element&gt;<br />
&lt;xs:element name=&#8221;child&#8221; type=&#8221;xs:string&#8221;/&gt;<br />
&lt;/xs:schema&gt;</p></blockquote>
<p>Schema Example &#8211; Using Schema in a XML</p>
<blockquote><p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt;<br />
&lt;root xmlns=&#8221;www.mysite.dk&#8221;<br />
xmlns:xsi=&#8221;http://www.w3.org/2001/XMLSchema-instance&#8221;<br />
xsi:schemaLocation=&#8221;www.mysite.dk ex.xsd&#8221;&gt;<br />
<blankspace>&#8230;..</blankspace>&lt;child/&gt;<br />
&lt;/root&gt;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2007/10/xml-schemas-dtds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML Rules</title>
		<link>http://techblog.byllemos.com/2007/10/xml-rules/</link>
		<comments>http://techblog.byllemos.com/2007/10/xml-rules/#comments</comments>
		<pubDate>Wed, 10 Oct 2007 21:06:35 +0000</pubDate>
		<dc:creator>iby</dc:creator>
				<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://techblog.byllemos.com/?p=17</guid>
		<description><![CDATA[<p>Following rules must be applied when working with XML:</p>
<ul>
<li>Single, unique root element</li>
<li>Matching open/close tags</li>
<li>Consistent capitalisation</li>
<li>Correctly nested elements (no overlapping elements)</li>
<li>Attribute values enclosed in quotes</li>
<li>No repeating attributes in an element</li>
</ul>
<p><span id="more-17"></span></p>
<table width="90%"></table><p>&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Following rules must be applied when working with XML:</p>
<ul>
<li>Single, unique root element</li>
<li>Matching open/close tags</li>
<li>Consistent capitalisation</li>
<li>Correctly nested elements (no overlapping elements)</li>
<li>Attribute values enclosed in quotes</li>
<li>No repeating attributes in an element</li>
</ul>
<p><span id="more-17"></span></p>
<table width="90%">
<tr>
<td>
<img src="http://techblog.byllemos.com/wp-content/xmlrules.gif" alt="XML Rules" />
</td>
</tr>
</table>
<p>If a document conforms to the rules then it is well formed.</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.byllemos.com/2007/10/xml-rules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

