Re: [xml] Xpath and default attribute value



On Fri, Jun 06, 2003 at 12:10:38PM -0700, Jean Senellart wrote:
my reformulation of this is: with a validating XML processor, we could assume the tree contains default 
attribute value and therefore should not "/test_unit[ st=0]" match in my example?

thank you for any answer on this point

  in libxml2 validating does not do defaulting at the tree level,
attribute defaulting is a separate operation:

paphio:~/XML -> xmllint --valid --shell tst.xml
/ > xpath /test_unit[ st=0]
Object is a Node Set :
Set contains 0 nodes:
/ > paphio:~/XML ->
paphio:~/XML -> xmllint --dtdattr --shell tst.xml
/ > xpath /test_unit[ st=0]
Object is a Node Set :
Set contains 1 nodes:
1  ELEMENT test_unit
    ATTRIBUTE st
      TEXT
        content=0
/ > paphio:~/XML ->

Instead of asking for default validation just ask for DTD loading and
attribute completion:

xmlLoadExtDtdDefaultValue |= XML_DETECT_IDS | XML_COMPLETE_ATTRS;

this should work.

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]