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

Re: Use of DOMXPathEvaluator




Hi Richard,

    Thanks for the example and the quick response. Your explanation 
makes sense. I was confused since I was accessing the DOMXPathEvaluator 
though the DOMDocument class, I though that it was implementing the 
xpath evaluations.

    We should discuss this at our next software meeting (date and time 
as yet not determined). In an attempt to get something working, I had 
implemented an extremely simple parser. It works on only a very small 
subset of the xpath syntax, but is capable of at least understanding 
strings like the one you gave in your example. It would certainly be 
desirable to have a fully XPath 1.0 compliant parser instead. However, 
as you know, I am very cautious when it comes to package creep. Also, if 
we are going to bring in a whole other package in order to gain XPath 
compliance, then should we consider bringing in something to do XQuery 
instead (i.e. XQilla)? Xalan, of course, has the advantage that we 
already have some software in our repository that uses it. How much 
power will we need here?

Regards,
-David

Richard Jones wrote:
> 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
>>
>

-- 

------------------------------------------------------------------------
  David Lawrence Ph.D.
  Staff Scientist                 Office: (757)269-5567   [[[  [   [ [       
  Jefferson Lab                   Pager:  (757)584-5567   [  [ [ [ [ [   
  http://www.jlab.org/~davidl     davidl@jlab.org         [[[  [[ [[ [[[
------------------------------------------------------------------------