Re: cannot find the namespace declarations from an extension function

Adrian Herscu <[email protected]>
Newsgroups gmane.text.xml.xalan.java.user
Message-ID <[email protected]>

Michael Ludwig wrote:
> Adrian Herscu schrieb:
>> Michael Ludwig wrote:
>>>> Hmmm... It appears that the parser completely ignores all 'xmlns'
>>>> attributes. The interesting thing is that it reads attributes from
>>>> other non-null namespaces.
>>>
>>> The xmlns may look like an attribute, but it really isn't. It's a
>>> namespace declaration, which happens to use attribute syntax.
> 
>> http://www.w3.org/TR/xml-names/#ns-decl
>>
>> [Definition: A namespace (or more precisely, a namespace binding) is
>> declared using a family of reserved attributes. Such an attribute's
>> name must either be xmlns or begin xmlns:. ...]
>>
>> Hence a namespace declaration is an attribute with special meaning,
>> but still just an attribute.
> 
> Well, I'd say, both are right, depending on which view you take :-)
> 
> But on this list the view should probably be Xalan, hence XSLT and the
> XPath Data Model. A namespace declaration attribute isn't an attribute
> in XDM, because it's not on the attribute axis. The fact that namespace
> declaration serialization happens to take attribute form doesn't matter.
> 
>>> That's why it doesn't show up among the attributes, neither in DOM
>>> nor in XDM (XPath Data Model).

Seems like XDM is related to XPath 2.0.
The data model in XPath 1.0 is described at 
http://www.w3.org/TR/xpath#data-model

According to http://www.w3.org/TR/xpath#namespace-nodes

This means that an element will have a namespace node:
     * for every attribute on the element whose name starts with xmlns:;
     * for every attribute on an ancestor element whose name starts 
xmlns: unless the element itself or a nearer ancestor redeclares the prefix;
     * for an xmlns attribute, if the element or some ancestor has an 
xmlns attribute, and the value of the xmlns attribute for the nearest 
such element is non-empty

They are called "attributes"!
Also in DOM2 Core there is nothing that suggests that "namespace 
attributes" are not just regular attributes.


>>
>> The Xerces DOM parser recognizes xmlns: prefixed attributes as
>> attributes. The problem was with the DTM parser used by Xalan.
> 
> Here's a small, standalone, and off-topic script in PHP using LibXML2,
> where the attributes don't show up. But you're right, using Xerces they
> do show up. So I guess DOM (which level?) requires them to show up. Does
> anyone know whether and, if so, where the correct behaviour is
> specified?
> 
> Michael Ludwig
> 
> milu@colinux:~/Werkstatt/php > expand -t2 ns-attr.php
> <?php
> $docstr = '<x:Urmel xmlns="urn:x-U" xmlns:x="urn:x-X" y="3" z="4"/>';
> $dom = new DOMDocument;
> $dom->loadXML( $docstr);
> $elm = $dom->documentElement;
> if ( $elm->hasAttributes() ) {
>   $attlist = $elm->attributes; # DOMNamedNodeMap
>   for ( $i = 0; $node = $attlist->item($i); $i++ ) {
>     echo $node->name, "\n";
>   }
> }
> 
> milu@colinux:~/Werkstatt/php > php ns-attr.php
> y
> z
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.