Re: [xml] Canonical XML



On Thu, Feb 28, 2002 at 10:47:13AM -0800, Aleksey Sanin wrote:
Please, find examples bellow. The brief description is that AFAIK
if we evaluate XPath expression against document then the document
should be modified at least as follows:
    1) default attributes added to element nodes
  
  Done at parse time in xsltproc.c with
    xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
    you also need
    xmlSubstituteEntitiesDefault(1)
  just do the same to the parser context when parsing a document for
processing XPath

    2) namespaces from ancesstors are propagated to the node
These new added nodes could be included in the resulted XPath nodes set for
further processing.

   Namespaces are propagated to children. But namespace nodes have
no parent in libxml2 XPath implementation. This property is actually
expected to be removed in XPath 2.0 I was told.

   1) "parent::ietf:e1" does not include any e1 namespaces

Give an example, sounds strange.

Example:
------------
## xml doc:
<doc xmlns="http://www.ietf.org"; xmlns:w3c="http://www.w3.org";>
   <e1 a=b>
           ^This is not XML ! I assume it is actually a="b"

      <e2 xmlns="" />
   </e1>
</doc>

## xpath expr:
(//. | //@* | //namespace::*)
[
   self::ietf:e1 or (parent::ietf:e1 and not self::e2)
]

  To compile such an expression you must provide a mapping for 
the ietf namespace prefix. What is its namespace name ? How did you pass
it to the XPath evalution ? I assume you did this.

Running the beginning of the XPath query on the corrected document brings:
orchis:~/XML -> xmllint --shell tst.xml
/ > ls (//. | //@* | //namespace::*)
--n        3 doc
t--        4     
-a-        3 e1
t--        1  
t--        4     
t--        7        
--n        0 e2
t--        4     
t--        1 b
t--        7        
--n        0 e2
t--        4     
t--        1  
n        1 default -> http://www.ietf.org
n        1 w3c -> http://www.w3.org
n        1 xml -> http://www.w3.org/XML/1998/namespace
n        1 default -> 
/ > 

  So the namespace nodes inherited are found, but the test "parent::ietf:e1"
on the namespaces nodes returned will not work as expected using the XPath-1.0
semantic.

## CVS version of file xpath.c, function xmlXPathNextParent() :
   
    case XML_NAMESPACE_DECL:   
                                 /*  
                                  * TODO !!! may require extending 
struct _xmlNs with           
                                  * parent field
                                  * C.f. Infoset 
case...                                   
                                   */                                
                                   return(NULL);

  A libxml2 XML_NAMESPACE_DECL node is NOT an XPath namespace node. It
is a node defining the namespace, not reflecting that the 

   2) namespaces from the parent element are not included
   in the child's namespaces axis


   Hum, strange. I'm pretty sure it works well, I even have some XSLT test
cases for those.

See the example above.

  That's not a good caracterization of the problem.

   3) default attributes from inner DTD are not included
   in the result nodes set

  xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
          you also need
  xmlSubstituteEntitiesDefault(1)

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]