Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: xmlns attribute woes

From: reaanb@-----.---
To: NULL
Date: 3/4/2009 2:42:00 AM
Ah, never mind, I found it.  Amazing what the right search phrase will
do... ;)

For reference for anyone else with the same problem, search this group
using the phrase "empty xmlns".  Also, using createElement and then
setting the attribute won't work (it just writes the same xmlns for
each element), instead use createNode(NODE_ELEMENT, "elementname",
parentelement.namespaceURI).

On Mar 4, 11:42=A0am, rea...@gmail.com wrote:
> I want to generate the following using VB6 / XML DOM:
>
> <person xmlns=3D"urn:person-schema">
> =A0 <personal>
> =A0 =A0 ...
> =A0 </personal>
> </person>
>
> Naively, I tried the following code:
>
> Dim x As DOMDocument40: Set x =3D New DOMDocument40
>
> Dim p As IXMLDOMElement: Set p =3D xmlFile.createElement("person")
> p.setAttribute "xmlns", "urn:person-schema"
> x.appendChild p
>
> Dim q As IXMLDOMElement: Set q =3D xmlFile.createElement("personal")
> p.appendChild q
>
> But x.xml returns:
>
> <person xmlns=3D"urn:person-schema">
> =A0 <personal xmlns=3D"">
> =A0 =A0 ...
> =A0 </personal>
> </person>
>
> The problem is the empty xmlns attribute on the personal element. =A0I
> tried q.removeAttribute "xmlns", but it doesn't remove it. =A0Based on
> some code samples I saw, I tried the following instead of
> setAttribute, but it doesn't generate the attribute I want.
>
> Dim xsd As DOMDocument40: Set xsd =3D New DOMDocument40
> xsd.async =3D False
> xsd.Load App.Path & "\xsd\person-schema.xsd"
>
> Dim cache As XMLSchemaCache40: Set cache =3D New XMLSchemaCache40
> cache.Add "urn:person-schema", xsd
>
> Set x.schemas =3D cache
>
> I haven't been able to find any relevant info via MSDN / Google. =A0Any
> ideas what I'm doing wrong?



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent