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

Re: Use of DOMXPathEvaluator



Dave,

You may have noticed in the xerces API documentation that references to 
XPath objects do not have explicit types (void *).  This is because 
xerces has hooks for xpath extensions but no support in the built-in 
classes.  The evaluate method of the DOMXPathEvaluator is pure virtual, 
you may have noticed.

The apache project that implements a full userspace xpath library is 
called xalan.  Like xerces it comes in c++ and java implementations, and 
xalan is implemented on top of xerces.  The download binary tarballs and 
installation instructions are very similar to xerces, and found on the 
web site http://xalan.apache.org.  I installed xalan-c a long time ago 
at the same time as I installed xerces because it has a full XSLT 
translation engine in it.  You may have it as well.  The two versions 
(xerces and xalan) should be kept in sync.

In the xalan distribution there are several sample programs to show how 
the xpath API works.  I took one of them, SimpleXPathAPI.cpp, and 
tweaked it to work with the hdds geometry document tree.  You can find 
it in subversion within the hdds package called xpath-example.cpp.  
Makefile knows how to build it, provided that your setup script defines 
the environment variable XALANCROOT.

For example, to extract the atomic number of Antimony from the materials 
db, go into the hdds directory, make xpath-example, and try the 
following command.

$  ./xpath-example main_HDDS.xml / '//hdds:element[@name="Antimony"]/@a'
The string value of the result is:
121.75



David Lawrence wrote:
>
> Hi Richard,
>
>    I am currently working on the API through which JANA will read in 
> geometry information. My plan is to have it read in from the hdds file 
> using xerces. After doing a little web research, I have come upon 
> something you mentioned some time ago, xpath. It seems this is the 
> appropriate way to specify a node for which one needs the value of a 
> specific attribute. (Unless you have a better suggestion).
>
>    I have been trying to use it with the evaluate method of a 
> DOMDocument object which looks like it inherits from 
> DOMXPathEvaluator. I have not had much luck getting it to work yet and 
> can't seem to find any examples on the Web. Have you used this before? 
> Any insights would be great.
>
> Regards,
> -David
>

S/MIME Cryptographic Signature