Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Question on the xmlns attribute of qualified elements

From: "Ciprian Ciubotariu" <cipi@----.-->
To: NULL
Date: 10/1/2004 5:40:00 PM
Hi again.

Following this argument: please note that the MSXML DOM cannot validate XMLs
created without the xmlns attribute, issuing a validation error such as "no
schema attached to document". Therefore I must ask you how one can
programatically create MSXML-valid namespace-aware documents with createNode
?



"Ciprian Ciubotariu" <cipi@h...> wrote in message
news:%237TovOwpEHA.3324@T......
> Hi.
>
> I was trying to implement an XML DOM comparison procedure by performing a
> recursive tree-check on the information items in a DOM document. The
> comparison was to be done between a programatically created DOM and
another,
> parsed from a string.
>
> However, the results were disappointing, because of the following: the
> parsed tree had more attributes than the one created programatically,
namely
> the "xmlns" attributes.
>
> Please advise me on the following:
>
> 1. Is there a standard procedure for comparing two XML DOM documents? i.e.
> not their string representation, which may differ for various reasons
> (encoding etc.) - or should strings be compared in your opinion?
> 2. Should the xmlns attribute be present at all in the DOM tree?
> 3. Is there a standard procedure for creating namespace-qualified elements
> in MSXML4? The lack of the W3C-specified createElementNS, as well as MSDN
> itself, pointed me to createNode, which on the other hand won't create the
> xmlns attribute, causing the tree comparison to fail. Note that the
> difference is observable.
>
> I attached here a small c++ test case for this issue; the #if switces
> between parsing and programatical creation of such a DOM.
>
> Best regards,
>
> Ciprian Ciubotariu
>
>
> #include <iostream>
> #import <msxml4.dll>
> int main()
> {
>   ::CoInitialize(NULL);
>   {
>     ::MSXML2::IXMLDOMDocument2Ptr spDOM;
>     spDOM.CreateInstance(__uuidof(::MSXML2::DOMDocument40));
> #if 0
>     spDOM->loadXML("<element xmlns='test'/>");
> #else
>     ::MSXML2::IXMLDOMElementPtr spElement =
spDOM->createNode(NODE_ELEMENT,
> "element", "test");
>     spDOM->documentElement = spElement;
> #endif
>     ::std::cout << "nsURI=" << spDOM->documentElement->namespaceURI <<
> ::std::endl;
>     ::MSXML2::IXMLDOMNamedNodeMapPtr spAttrs =
> spDOM->documentElement->attributes;
>     ::std::cout << "attribute count=" << spAttrs->length << ::std::endl;
>     if (spAttrs->length > 0)
>     {
>       ::std::cout << "attribute name=" << spAttrs->item[0]->baseName <<
> ::std::endl;
>     }
>   }
>   ::CoUninitialize();
> }
>
>




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