I complete disagree and believe that there a big misinterpretations here 
leading to poor implementation and massive confusion.

The misinterpretation that I've seen stated in many places and by 
Richard Eckart earlier in this thread is:

XPath statement operates on the default namespace (xmlns="")


 From the XML 1.0 spec, I find this statement to be completely wrong.  
There is no such thing as "The default namespace" in a global sense.  
Default namespace as a term, is clearly a matter of inheritance, and I 
don't see how anyone could argue otherwise after reading the bit about 
default namespace from the XML 1.0 spec.( 
http://www.w3.org/TR/REC-xml-names/#defaulting )  The simplest support 
of my interpretation is the statement in the spec: "The attribute value 
in a default namespace declaration /MAY/ be empty. This has the same 
effect, within the scope of the declaration, of there being no default 
namespace."

I believe the implementation error is that elements that are using a 
default namespace are being assigned a namespace rather than being setup 
to inherit them.  From the spec, the example for setting the empty 
namespace as the default namespace is:

<?xml version='1.0'?>
<Beers>
  <!-- the default namespace inside tables is that of HTML -->
  <table xmlns='http://www.w3.org/1999/xhtml'>
   <th><td>Name</td><td>Origin</td><td>Description</td></th>
   <tr> 
     <!-- no default namespace inside table cells -->
     <td><brandName xmlns="">Huntsman</brandName></td>
     <td><origin xmlns="">Bath, UK</origin></td>
     <td>
       <details xmlns=""><class>Bitter</class><hop>Fuggles</hop>
         <pro>Wonderful hop, light alcohol, good summer beer</pro>
         <con>Fragile; excessive variance pub to pub</con>
         </details>
        </td>
      </tr>
    </table>
  </Beers>

So, logically <details xmlns="" is applying the default namespace for 
its children.  Therefore, its children should be dependent on it 
supplying this default namespace.  If it were to no longer supply this 
default namespace, then the children would logically default to the 
xhtml namespace.  Also, if you were to take this XML document and change 
<details xmlns=""> to <details xmlns="urn:blah.com:blah"> and reparse 
the document then of course the children are now in the new default 
namespace.  I am of the opinion that if you were to programatically 
change the namespace on this nodes, that it's completely logical that 
you'd have the same end result and that the descendant nodes would 
inherit the new namespace.

I also believe that the Jaxen has made the same misinterpretation which 
led to the implementation assuming the empty namespace when no namespace 
is specified.  As much as I wish the XPath docs stated what the default 
namespace for XPath processing should be, I haven't found anything.  I 
still believe, however, that there is more merit and logic in using the 
context node's namespace rather than the empty namespace, and that there 
is no specification backing for using the empty namespace as the default 
namespace.

In regard to me disagreeing with Edwin's statement that attributes must 
be specifically declared in a namespace.  I'd quote the XML spec in 
saying, "Default namespace declarations do not apply directly to 
attribute names; the interpretation of unprefixed attributes is 
determined by the element on which they appear."  My interpretation of 
this is that default namespaces don't apply DIRECTLY to, but they can 
apply indirectly to attributes.  The attribute has the same namespace as 
the element unless specified otherwise, and there's no reason that the 
element couldn't be using the default namespace in scope.  In regard to 
the quote, I believe that "The namespace name for an unprefixed 
attribute name always has no value."  does not imply that the attribute 
has no namespace, but that it has no "namespace name" which I believe 
must have different meaning.

--Evan



Edwin Dankert wrote:
> Attributes always need to be specifically declared in a namespace.
>
> "If there is a default namespace declaration in scope, the expanded
> name corresponding to an unprefixed element name has the URI of the
> default namespace as its namespace name. If there is no default
> namespace declaration in scope, the namespace name has no value. The
> namespace name for an unprefixed attribute name always has no value.
> In all cases, the local name is local part (which is of course the
> same as the unprefixed name itself)."
>
> http://www.w3.org/TR/REC-xml-names/#defaulting
>
> Regards,
> Edwin
>   


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to