RE: XPath question

Hi Gregor,

Short answer:

The attached documents should help demonstrate the point.  They were
produced via the following call:

saxon -o testNS.txt testNS.xml testNS.xsl

Long answer:

Actually, you aren't citing the whole paragraph but just the dependent
clause beginning with the word 'except'.  This dependent clause qualifies
the first part of the paragraph.  The complete paragraph is:

"A QName in the node test is expanded into an expanded-name using the
namespace declarations from the expression context. This is the same way
expansion is done for element type names in start and end-tags except that
the default namespace declared with xmlns is not used: if the QName does not
have a prefix, then the namespace URI is null (this is the same way
attribute names are expanded). It is an error if the QName has a prefix for
which there is no namespace declaration in the expression context." [1]

[1] http://www.w3.org/TR/xpath#node-tests

Thus, it is the QName in the node-test that is expanded without the benefit
of the default namespace URI, should it be defined for the evaluation
context of the XPath expression.

However, the namespace URI of an element in the input document is available
for comparison whether it was specified by explicit or default namespace
qualification.

The attached documents include testNS.xml and testNS.xsl.

The xml file contains a root document element named Test that has three
children with the same local name 'e'.  The first is unqualified, the second
is qualified by default, and the third is qualified by explicit declaration
of the prefix 'NS'.

The xsl file contains three templates.  The first simply latches onto the
root element Test, and applies all templates to its child elements.  The
second template is designed to match elements with local name 'e' and no
namespace URI.  The third template matches elements 'e' that have a
namespace URI of testNS (which is the declared value of the NS prefix).

The result of the transformation appears in testNS.txt.  The exception in
the paragraph of XPath cited above is demonstrated by the fact that the
second template only matches the unqualified element 'e' despite the
declaration within the second template of 'testNS' as the default namespace
URI.  The fact that the third template (bearing the match expression "NS:e")
matches both the second and third elements 'e' demonstrates that input
elements retain their namespace URI if it was derived by default and that
namespace qualified input elements are matched by namespace URI and local
name, regardless of how they obtained their namespace URI.

Thanks,
John Boyer
Development Team Leader,
Distributed Processing and XML
PureEdge Solutions Inc.
Creating Binding E-Commerce
v: 250-479-8334, ext. 143  f: 250-479-3772
1-888-517-2675   http://www.PureEdge.com <http://www.pureedge.com/>



-----Original Message-----
From: Gregor Karlinger [mailto:gregor.karlinger@iaik.at]
Sent: Thursday, September 07, 2000 11:09 PM
To: John Boyer; XMLSigWG
Subject: AW: XPath question


Hi John,

> In the first code example, the Signature is in the default namespace of
> &dsig;.  However, the XPath expression has the dsig prefix
> declared, and the
> match to the Signature is done using dsig:Signature.  Thus, matching
> elements in the default namespace can be done by setting up a prefix with
> the same URI as the default namespace.

What is your source for that information? I think the paragraph I have
cited in my first message, reads quite clear, that the default namespace
is not used in XPath:

  "...except that the default namespace declared with xmlns is not used:
   if the QName does not have a prefix, then the namespace URI is null
   (this is the same way attribute names are expanded). "

I have posted my concerns also in the developer newsgroup of the Apache
Xalan project. The response I got from Joseph Kesselman, one of the
developers, is:

  "XPath does not use the default namespace declaration. If you don't
specify
  a prefix, the name is assumed to be in _no_ namespace (the original
  default, not the changed default). If you want to access a namespaced
node,
  you must use an explicit prefix which maps to that namespace.

  See the XPath spec, section 2.3 (Node Tests), third paragraph or
  thereabouts."

Maybe we should ask the editors of XPath of the intended meaning of the
sentence above.

Regards, Gregor
---------------------------------------------------------------
Gregor Karlinger
mailto://gregor.karlinger@iaik.at
http://www.iaik.at
Phone +43 316 873 5541
Institute for Applied Information Processing and Communications
Austria
---------------------------------------------------------------

Received on Friday, 8 September 2000 13:44:24 UTC