Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Question on the xmlns attribute of qualified elements [Thread Next] Re: Question on the xmlns attribute of qualified elementsTo: 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();
> }
>
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
