XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] Quiz: how many namespaces are in scope?

It's an odd definition, but correct according to XPath. I agree that there are better ways it could have been modeled which still abstract away from particular aspects of the instance, e.g., "one namespace node per each non-redundant namespace declaration." Instead, the way it was originally defined in XPath seems to have been: "one namespace node for every possible legal namespace declaration, redundant or not."

You can legally include all 21 namespace declarations without changing the data as far as the XPath data model is concerned:
<N1:NumberList xmlns:N1="http://www.example1.org"
               xmlns:N2="http://www.example2.org"
               xmlns:xml="http://www.w3.org/XML/1998/namespace">
        <Number xmlns:N1="http://www.example1.org"
                xmlns:N2="http://www.example2.org"
               xmlns:xml="http://www.w3.org/XML/1998/namespace"
>23</Number>
        <Number xmlns:N1="http://www.example1.org"
                xmlns:N2="http://www.example2.org"
               xmlns:xml="http://www.w3.org/XML/1998/namespace"
>41</Number>
        <Number xmlns:N1="http://www.example1.org"
                xmlns:N2="http://www.example2.org"
               xmlns:xml="http://www.w3.org/XML/1998/namespace"
>70</Number>
        <Number xmlns:N1="http://www.example1.org"
                xmlns:N2="http://www.example2.org"
               xmlns:xml="http://www.w3.org/XML/1998/namespace"
>103</Number>
        <Number xmlns:N1="http://www.example1.org"
                xmlns:N2="http://www.example2.org"
               xmlns:xml="http://www.w3.org/XML/1998/namespace"
>99</Number>
        <Number xmlns:N1="http://www.example1.org"
                xmlns:N2="http://www.example2.org"
               xmlns:xml="http://www.w3.org/XML/1998/namespace"
>6</Number>
</N1:NumberList>

See? There are 21 of them. ;-)

And while the namespace axis is "deprecated" in XPath 2.0, this isn't purely an academic exercise as it directly impacts the result of the following expression (and any other expression that uses the namespace axis):

count(//namespace::*) => 21
> If namespaces-in-scope manifest as "nodes," do other scoped 
> abstractions (like xml:lang) do the same?
No. The only other node types are root/document node, element, attribute, text, comment, and processing instruction.

--
Evan Lenz
Lenz Consulting Group, Inc.
http://lenzconsulting.com
+1 (360) 297-0087



Amelia A Lewis wrote:
20100830152041888531.1c594bf9@talsever.com" type="cite">
On Mon, 30 Aug 2010 11:39:46 -0700, Evan Lenz wrote:
  
In my XPath/XSLT training classes, I like to ask this quiz question: 
How many namespace nodes are in this document? People are usually 
surprised when they hear the answer is (for this case) 21.
    

You mean for the document that Roger posted?

  
<?xml version="1.0"?>
<N1:NumberList xmlns:N1="http://www.example1.org"
               xmlns:N2=" http://www.example2.org ">
        <Number>23</Number>
        <Number>41</Number>
        <Number>70</Number>
        <Number>103</Number>
        <Number>99</Number>
        <Number>6</Number>
</N1:NumberList>
      

That's an odd definition of "namespace node," to my mind.  You're 
asserting that each element node has three namespace "nodes" associated 
with it?  I would have thought that the only "nodes" were the 
declarations.  So I could see arguments for two, three, or nine such 
nodes (variation depending upon how one handled the implicit xml 
namespace declaration).

If namespaces-in-scope manifest as "nodes," do other scoped 
abstractions (like xml:lang) do the same?

Amy!
  




[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS