xsl-list
[Top] [All Lists]

Re: [xsl] Q: XSLT 1.0 output of namespace

2010-08-17 07:56:20

In getting to the solution below I found that
   ". = ../namespace::*[name()]"
as "is-namespace()" test is even simpler than Michael's
   "count(. | ../@*) != count(../@*)".

Similarly ". = ../attribute::*[name()]" can be used as "is-attribute()".


It might be simpler, but it's wrong. Firstly, the expression attribute::*[name()] is rather pointless: it selects all attribute that have a name, and all of them do. While namespace::*[name()] selects all namespaces except the default namespace, so your test will fail for that one.

Secondly, it's quite possible to have an attribute and a namespace with the same string-value, for example

<xs:schema xmlns:a="http://my.namespace/"; targetNamespace="http://my.namespace/";>

and in this case your test for a namespace and your test for an attribute will both return true.

Michael Kay
Saxonica

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>