Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
NfXML
Message
From
10/07/2016 14:31:55
 
 
To
10/07/2016 02:38:03
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Title:
Re: NfXML
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01638182
Message ID:
01638193
Views:
147
I was wondering about the decision of instantiate "Microsoft.XMLDOM" (which limits to versions of the Microsoft parser below 3) instead of cascading from DOMDocument.6.0 to bottom, and so I decided to check on the presence of different namespaces and how they could affect the serialization (namespaces handling is one of the key aspects that differentiate later and former versions of the XML parser).

So, I tried this little beast under nfxmlRead() to help me understand better the inner works of nfxml and how namespace handling is actually performed.
<?xml version="1.0" encoding="UTF-8"?>
<nfXML xmlns:n1="info:namespace1" xmlns:n2="info:namespace2">
  <n1:element>element of namespace 1</n1:element>
  <n2:element>element of namespace 2</n2:element>
  <element>element of default namespace</element>
</nfXML>
With MSXML2.DOMDocument, the parser can not select namespaced nodes unless namespaces are previously set, so fails to read the XML document.

With Microsoft.XMLDOM, the namespace prefix is attached to the element naming, in its VFP declaration. So, "element" of namespace "info:namespace1" turns into "n1_58_element". We can say that at least the document is serialized as a VFP object, but the structural meaning gets lost in the way: the prefix is just a local convenience, and namespace reference can be really nasty, as in the example below:
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:a="http://myserver.com" xmlns:b="http://yourserver.com">
  <branch>branch</branch>
  <root xmlns="http://myserver.com">
    <a:branch>a-branch</a:branch>
    <branch xmlns="http://yourserver.com">
      b-branch
      <deep xmlns:a="http://yourserver.com" xmlns:b="http://myserver.com">
        <a:x b:attrib="o" />
      </deep>
    </branch>
  </root>
</root>
So, back to wondering: what if for each element that goes to the VFP the correct namespace, disregarding of any prefix, is attached as a property, and so instead of creating "Empty" objects, for each element is instantiated a simple class that holds the element value and its namespace.

Does this make sense? If so, I foresee that this could also aid to typify values, instead of just storing them as strings...
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform