"Re: [xslt] name() = localname() ?"


on 3/26/2004 7:45 PM Mark_Vakoc@peoplesoft.com wrote:
>>I have a problem to get the namespace prefix of a node.
>>name() and local-name() always give the same result but
>>I want to get the node name with namespace prefix.
>>Maybe somebody can help me how to do that.
> I'm not positive but if the QName of an element without a prefix
> declaration is the same as the localname.  Changing the source document to:
> <test:test xmlns:test="http://test.com"/>
> should get the desired result, if that is acceptable.

Just to give five cents more on this issue: the function "name()" acts 
equivalent to the DOM methods Element.tagName or Attr.name; it works on 
the processed XML file, so the prefix for this particular namespace 
binding won't be the one you declared in the stylesheet, but the one in 
the processed XML file. If it happens to be bound to a default 
namespace, you get the local name only.

By the way, the tranformation result of your test has both, DOM level 1 
nodes (not bound to a namespace) and DOM level 2 nodes (bound to a 
namespace); using a DOM level 3 parser this could result in an error 
during serialization (look at the namespace normalization functions [1]).




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]