Why namespaces?

Mark Birbeck Mark.Birbeck at iedigital.net
Sat Sep 4 17:54:07 BST 1999


James Clark wrote:
> Mark Birbeck wrote:
> 
> > A template of 'P' would match all elements that have a local
> > name 'P', regardless of the namespace they came from,
> 
> Not true.  It matches a P whose expanded-name has a local 
> name of P and a null namespace URI.

Many, many, apologies. I was looking at Section 5.5 of XSLT which
discusses the pecking order in which patterns would be matched. I
understood it to mean that if I had:

    <xsl:template match="x:para">
        ...
    </xsl:template>

it would score higher than:

    <xsl:template match="para">
        ...
    </xsl:template>

when processing the first 'para' node in the tree:

    <doc xmlns="z">
        <para xmlns="x" />
        <para xmlns="y" />
    </doc>

but lower (actually, not at all) when processing the second 'para'
element.

Although this scoring mechanism is right, the mistake I made was
thinking that the template rules were expanded in the context of the
node that was being processed - i.e., that:

    match="para"

would be:

    match="x:para"

in one situation and:

    match="y:para"

in another. However, looking at XPath again (Section 2.3), I realise
that the node context is from the element that contains the XPath
expression (in this case the template), and not the source document. And
this is obviously why as a rule XPath doesn't provide the default
namespace as one of the namespaces provided in the node context -
because it would be the wrong default (from XSLT, in this case, not the
source).

So, as you say, the definition of the pattern 'para' would be just that
... 'para' (or <NULL>:para as an expanded name). And, patterns with a
NULL namespace will only match elements from the default namespace in
the source document.

Sorry if I caused any confusion.

Best regards,

Mark

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)





More information about the Xml-dev mailing list