Xstream is a new streaming XML API for Navision I’ve been working on. It actually makes writing XML in Navision quite elegant.

To create this fragment

   <person id=”BRA”>

This code will do

      “>”(‘person’); “@”(‘ID’,’BRA’);

There are a basic set of operators that are used for node construction

The “>” operator creates a new element, puts it into the context element and sets the new element as the context element.

The “<” operator sets the parent of the context element as the new context element.

The “=” operator creates a new element, adds a text node to it and adds the the new element to the context node.

The “@” operator creates an attribute node, assigns a value for it and adds the attribute node to the context element.

Now let’s look at the function definitions

“>”(k : Text[50])
   tmp := doc.createElement(k);
   ctx := ctx.appendChild(tmp);

   ctx := ctx.parentNode;

“=”(k : Text[30], v : Variant) : Boolean
   IF NOT ref.XmlSchemaFormat(v,s) THEN
   tmp := doc.createElement(k);
   tmp.text := s;

“@”(k : Text[30], v : Text[1024]) : Boolean
   IF NOT ref.XmlSchemaFormat(v,s) THEN
   attr := ctx.ownerDocument.createAttribute(k);
   attr.nodeValue := s;

That’s it.


About xosfaere

Software Developer
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s