Re: [xml] xmllint --shell : xpath is not working? (libxml2-2.6.4)



Hi,

can anyone confirm and/or explain that?

xmllint --shell giml/gitkTemplate_message.xml
/ > cat
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE giml SYSTEM "http://gitk.sourceforge.net/giml.dtd";>
<giml xmlns="http://gitk.sourceforge.net/";

Here you define the default namespace as "http://gitk.sourceforge.net/";

xmlns:dc="http://purl.org/dc/elements/1.1/";
xmlns:i18n="http://apache.org/cocoon/i18n/2.0";>
  <dialog focus="ctrl">
    <meta>
      <dc:title><i18n:text>message</i18n:text></dc:title>
    </meta>
  <dialogwidgets>
     <dialogwidget id="Okay"/>
  </dialogwidgets>
    <widgetgroup>
      <widget id="Message" type="label"/>
    </widgetgroup>
  </dialog>
</giml>

Therefore, element "widget" belong to namespace "http://gitk.sourceforge.net/";

/ > xpath //widget

And here you are asking for elements with localname "widget" and WITHOUT namespace (I think that XPath 
doesn't have the concept of default namespace, you always need to specify a prefix like "mynsprefix:widget")

Object is a Node Set :
Set contains 0 nodes:

And xmllint gives you the right answer.

I don't know how to use the shell xpath command in documents with declared default namespaces, since the 
shell utility doesn't have a command to register namespaces and prefixes (something like xmlXPathRegisterNs).

Manuel





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