[Xml-compile] queryXPath() ... related

Nikos Skalis garde.avant.be at gmail.com
Mon May 23 14:14:43 GMT 2011


Hello all,

I decided to use eXist as a database for an application that I am writing in Perl and 
I am experimenting with it. The problem is that I have stored a .xml document with the following structure

<foo-bar00>
    <perfdata datum="GigabitEthernet3_0_18">
        <cli cmd="whatsup" detail="GigabitEthernet3/0/18" find="" given="">
            <input_rate>3</input_rate>
            <output_rate>3</output_rate>
        </cli>
    </perfdata>
    <timeline>2011-5-23T11:15:33</timeline>
</foo-bar00>

and it is located in the "/db/LAB/foo-bar00/2011/5/23/11_15_33.xml" collection.

I can successfully query it, like
my $xquery = 'doc("/db/LAB/foo-bar00/2011/5/23/11_15_33.xml")' ;
or $xquery can be equal to
= doc("/db/LAB/foo-bar00/2011/5/23/11_15_33.xml")/foo-bar00/perfdata/cli/data(output_rate)
= doc("/db/LAB/foo-bar00/2011/5/23/11_15_33.xml")/foo-bar00/data(timeline)

my ($rc1, $set) = $eXist->executeQuery($xquery) ;
my ($rc2, $count) = $eXist->numberOfResults($set) ;
my ($rc3, @data) = $eXist->retrieveResults($set) ;
$eXist->releaseResultSet($set) ;
print Dumper(@data) ;

And the result is :
$VAR1 = {
  'hitCount' => 1,
  'foo-bar00' => {
    'perfdata' => {
      'cli' => {
        'given' => '',
        'detail' => 'GigabitEthernet3/0/18',
        'input_rate' => '3',
        'cmd' => 'whatsup',
        'output_rate' => '3',
        'find' => ''
      },
      'datum' => 'GigabitEthernet3_0_18'
    },
    'timeline' => '2011-5-23T11:15:33'
  }
};

---> Given that I know the xml document that I want to retrieve info from.
---> Given that I want to retrieve the timeline information.

When I am writing :
my $db_xml_doc = "/db/LAB/foo-bar00/2011/5/23/11_15_33.xml" ;
my ($db_rc, $db_datum) = $eXist->queryXPath("/foo-bar00/timeline", $db_xml_doc, "") ;
print Dumper($db_datum) ;
The result is :
$VAR1 = {
  'hash' => 1717362942,
  'id' => 3,
  'results' => [
    {
      'node_id' => '1.2',
      'document' => '/db/LAB/foo-bar00/2011/5/23/11_15_33.xml'
    }
  ]
};

********** The question is : How can I retrieve the "timeline" info ? 
Seems that the "node_id" variable (=1.2) can points to the "timeline" info, but how can I use it ?

Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/xml-compile/attachments/20110523/399e071c/attachment.htm


More information about the Xml-compile mailing list