You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by Erick Brie`re <er...@afp.com> on 2002/07/05 14:47:09 UTC

Retieving parts of documents using XPath on a collection

(Perhaps my question concerns more Xpath than Xindice itself... ?)

Is there a way to get only nodes without their descendant(s) ?

I test with these two documents:

$ cat doc1.xml
<?xml version="1.0"?>
<AAA>
  <BBB/>
  <CCC value="doc1">
    <DDD/>
    <EEE/>
  </CCC>
  <FFF/>
</AAA> 
$ 
$ cat doc2.xml
<?xml version="1.0"?>
<AAA>
  <BBB/>
  <CCC value="doc2">
    <DDD/>
    <EEE/>
  </CCC>
  <FFF/>
</AAA> 

I'd like to get the list of "CCC values", without having the "DDD" and 
"EEE" nodes:

$ xindice xpath -c /db/test -q '/AAA/CCC'
<?xml version="1.0"?>
<CCC value="doc1" xmlns:src="http://xml.apache.org/xindice/Query" src:col="/db/test" src:key="338c319e664de474000000eedabd3e89">
    <DDD />
    <EEE />
</CCC>
<?xml version="1.0"?>
<CCC value="doc2" xmlns:src="http://xml.apache.org/xindice/Query" src:col="/db/test" src:key="338c319e664de474000000eedabd99ef">
    <DDD />
    <EEE />
</CCC>

What should be the QUERY for having this:

$ xindice xpath -c /db/test -q QUERY
<?xml version="1.0"?>
<CCC value="doc1" xmlns:src="http://xml.apache.org/xindice/Query" src:col="/db/test" src:key="338c319e664de474000000eedabd3e89">
</CCC>
<?xml version="1.0"?>
<CCC value="doc2" xmlns:src="http://xml.apache.org/xindice/Query" src:col="/db/test" src:key="338c319e664de474000000eedabd99ef">
</CCC>


NB: probably i didn't anderstand wel the tutorial 
http://www.zvon.org/xxl/XPathTutorial/General/examples.html ...

Thanks,
Erick.




Re: Retieving parts of documents using XPath on a collection

Posted by Ciprian Popovici <ci...@sap.ro>.
Monday, July 08, 2002, 16:03:18, Erick Brière <er...@afp.com> wrote:
> The problem is (for me) Java: does some body has a simple example for
> doing that ? ("that" = get result of an xpath query, keep only required nodes,
> dropping children).

Not the full example, but the Xindice documentation has an XML Objects
example which can get you started:
http://xml.apache.org/xindice/DevelopersGuide.html#N2C8

You can change the "result" variable somewhere between the node list
creation and its transformation into a document:

NodeList result = XPathAPI.selectNodeList(target, xpath);
<insert your code here>
Document doc = new DocumentImpl();

--Ciprian Popovici


Re: Retieving parts of documents using XPath on a collection

Posted by Carsten Ziegert <ca...@ik.fh-hannover.de>.
Erick,
here is a Java example:

XPathQueryService service = ...;
String xpath = ...;
ResourceSet resultSet = service.query(xpath);
ResourceIterator results = resultSet.getIterator();
while (results.hasMoreResources()) {
    Resource res = results.nextResource();
    String resu = (String) res.getContent();
    // use String methods
}


Am 08.07.2002 15:03 Uhr schrieb "Erick Brière" unter <er...@afp.com>:

> Using XMLObjects seems to be the best, at least for performance point of vue.
> 
> The problem is (for me) Java: does some body has a simple example for doing
> that ?
> ("that" = get result of an xpath query, keep only required nodes, dropping
> children).
> 
> Thanks,
> Erick.
> 
> 
> Ciprian Popovici wrote:
>> Friday, July 05, 2002, 15:47:09, Erick Brie`re <er...@afp.com>
>> <ma...@afp.com>  wrote:
>>   
>>> (Perhaps my question concerns more Xpath than Xindice itself... ?)
>>> Is there a way to get only nodes without their descendant(s) ?
>>>     
>> 
>> I've asked the same recently. One answer seems to be to use XMLObjects
>> and alter the returned dataset at special requests. I'm working on it
>> but haven't advanced lately. Let me know if you get anywhere with it.
>> 
>> --Ciprian Popovici
>> 
>> 
>>   
> 
> 



--

Medizinische Hochschule Hannover                    Fachhochschule Hannover
Abt. Hämatologie und Onkologie     FB Informations- und Kommunikationswesen
Carl-Neuberg-Straße 1                               Ricklinger Stadtweg 120
30625 Hannover                                               30459 Hannover

                           ++49-511-9296-1650
                    http://summit-bmt.fh-hannover.de





Re: Retieving parts of documents using XPath on a collection

Posted by Erick Brière <er...@afp.com>.
Using XMLObjects seems to be the best, at least for performance point of 
vue.

The problem is (for me) Java: does some body has a simple example for 
doing that ?
("that" = get result of an xpath query, keep only required nodes, 
dropping children).

Thanks,
Erick.


Ciprian Popovici wrote:

>Friday, July 05, 2002, 15:47:09, Erick Brie`re <er...@afp.com> wrote:
>  
>
>>(Perhaps my question concerns more Xpath than Xindice itself... ?)
>>Is there a way to get only nodes without their descendant(s) ?
>>    
>>
>
>I've asked the same recently. One answer seems to be to use XMLObjects
>and alter the returned dataset at special requests. I'm working on it
>but haven't advanced lately. Let me know if you get anywhere with it.
>
>--Ciprian Popovici
>
>
>  
>


Re: Retieving parts of documents using XPath on a collection

Posted by Ciprian Popovici <ci...@sap.ro>.
Friday, July 05, 2002, 15:47:09, Erick Brie`re <er...@afp.com> wrote:
> (Perhaps my question concerns more Xpath than Xindice itself... ?)
> Is there a way to get only nodes without their descendant(s) ?

I've asked the same recently. One answer seems to be to use XMLObjects
and alter the returned dataset at special requests. I'm working on it
but haven't advanced lately. Let me know if you get anywhere with it.

--Ciprian Popovici


Re: Retieving parts of documents using XPath on a collection

Posted by Ciprian Popovici <ci...@sap.ro>.
Tuesday, July 09, 2002, 11:47:52, Erhan Baz <er...@yahoo.com> wrote:
> 1- Creating new document by getting small XML branches via XPathAPI.
> 2- Firstly getting all document at once and eliminating unwanted
> branches.
> I don't know which could be the perfect solution...

It depends on what you want: if the "trimming" is meant to provide
a performance boost you'll need #1. If you simply need the result in
the shortened format you can go either way (and #2 may be easier and
more flexible).

Speaking of "performance boost", I haven't got around to doing any
serious testing yet, so it may not be such a big boost at all.

--Ciprian Popovici


Re: Retieving parts of documents using XPath on a collection

Posted by Erhan Baz <er...@yahoo.com>.
Yes I know that. Elimination of branches in server
side by XMLObjects would be the best but I couldn't
run any XMLObject example. So I had to implement my
application in client side. But there are two
situations in here:

1- Creating new document by getting small XML branches
via XPathAPI.

2- Firstly getting all document at once and
eliminating unwanted branches.

I don't know which could be the perfect solution... 

--- Ciprian Popovici <ci...@sap.ro> wrote:
> Saturday, July 06, 2002, 11:38:30, Erhan Baz
> <er...@yahoo.com> wrote:
> > faced with the same problem and wrote an
> application which takes the
> > all document as DOM and eliminates unwanted
> branches.
> 
> The trouble with these solutions is that Xindice
> still does the same
> amount of work. Performance-wise you're back at the
> starting point. Do
> XML Objects affect the query <before> or <after> it
> goes out of
> Xindice?
> 
> --Ciprian Popovici
> 


__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com

Re: Retieving parts of documents using XPath on a collection

Posted by Ciprian Popovici <ci...@sap.ro>.
Saturday, July 06, 2002, 11:38:30, Erhan Baz <er...@yahoo.com> wrote:
> faced with the same problem and wrote an application which takes the
> all document as DOM and eliminates unwanted branches.

The trouble with these solutions is that Xindice still does the same
amount of work. Performance-wise you're back at the starting point. Do
XML Objects affect the query <before> or <after> it goes out of
Xindice?

--Ciprian Popovici


Re: Retieving parts of documents using XPath on a collection

Posted by Jeff Greif <jg...@alumni.princeton.edu>.
Just speculating, but I believe that XPointer has a notion of ranges of
XPaths.  You might be able to find an XPointer implementation somewhere that
would carry out the extraction and glue it into your Xindice client (or even
as an XMLObject in the server).

Jeff
----- Original Message -----
From: "Rizwan Virk" <rb...@msn.com>
To: <xi...@xml.apache.org>
Sent: Saturday, July 06, 2002 4:31 AM
Subject: RE: Retieving parts of documents using XPath on a collection


| You could probably do this using XSL (though I haven't actually done it) -
| the way to do it would be to use XPATH to find the nodes you're interested
| in - and then instead of copying the node from the input to the output,
just
| output the current node name and its attributes without copying it's
| children.  (Using xsl:element and the nodename variable....
|
| Of course, at this point, you're writing code so you just might want to go
| ahead and do it with DOM (which is relatively straightforward using Java,


AW: XPATH usage

Posted by "Dr. Klemens Waldhör" <Wa...@t-online.de>.
Hi,

Nope. Same result if I use:

c:\Programme\xml-xindice-1.0>xindice xpath_query -c /db/klemens -q
/product[@product_id='120320']
c:\Programme\xml-xindice-1.0>

And as far as I know XML and SGML it does not matter if you use " or '.

Klemens

-----Ursprüngliche Nachricht-----
Von: Erhan Baz [mailto:erhanbaz@yahoo.com] 
Gesendet: Samstag, 6. Juli 2002 17:05
An: xindice-users@xml.apache.org
Betreff: Re: XPATH usage


Use this;

c:\projects\perl\tm>xindice xpath_query -c /db/klemens
-q /product[@product_id='120320']

Single quato. I guess

Bye..
--- "Dr._Klemens_Waldhör" <Wa...@t-online.de>
wrote:
> Hi,
> 
> I tried several times to run the XPATH example given
> in the user manual.
> It does not seem to work.
> 
> I imported several files. Also one with given in the
> manual. My
> collectionn is called db/klemens.
> 
> <?xml version="1.0"?>
> <product product_id="120320">
>    <description>Glazed Ham</description>
> </product>
>          
> Now when I search using
> 
> c:\projects\perl\tm>xindice xpath_query -c
> /db/klemens -q
> /product[@product_id="120320"]
> 
> ====> No result !
> 
> If I use the following simple XPATH query instead:
> 
> c:\projects\perl\tm>xindice xpath_query -c
> /db/klemens -q /product
> 
> I get:
> 
> 
> <?xml version="1.0"?> <product product_id="120320" 
> xmlns:src="http://xml.apache.org/xindice/Query"
> sr:col="/db/klemens"
> src:key="test3">
>    <description>Glazed Ham</description>
> </product>
> c:\projects\perl\tm>
> 
> It works ! Now what's wrong with the first query ?
> Do I have to create
> an index ? I am really wondering.
> 
> With regard to the article mentioned at XINDICE
> realm it should work too
> (Apache's Xindice Organizes XML Data Without
> Schema). The example there
> is as follows (although one has to adapt it because
> this is not a valid
> XML document and XINDICE recognises this bug)
> 
> "     <?xml version="1.0"?>
>      <product product_id="1" type="widget">
>           <description>foo</description>
>      </product>
>      <product product_id="2" type="widget">
>           <description>bar</description>
>      </product>
>      <product product_id="3" type="widget">
>           <description>foobar</description>
>      </product>
> 
> And the author states: If I wanted to write an XPath
> query to select the
> second product, I could use the following query
> string: 
>      /product[@product_id="2"]
> "
> 
> So theoretically my statement is correct.
> 
> Thanks for your help !
> 
> I also used the query in some of the browsers
> avalable for XINDICE and
> it does not work either. Curiously other queries
> sometimes work,
> sometimes not. And it hard to see why one query
> works and the other not.
> 
> Another question: Is there an easy way to check if
> XINDICE is running or
> not ? Idea is to check through the web if the server
> is running or not
> on a specific machine.
> 
> BTW: XINDICE is a cool tool.
> 
> Klemens
> 


__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free http://sbc.yahoo.com


Re: XPATH usage

Posted by Erhan Baz <er...@yahoo.com>.
Use this;

c:\projects\perl\tm>xindice xpath_query -c /db/klemens
-q /product[@product_id='120320']

Single quato. I guess

Bye..
--- "Dr._Klemens_Waldh�r" <Wa...@t-online.de>
wrote:
> Hi,
> 
> I tried several times to run the XPATH example given
> in the user manual.
> It does not seem to work.
> 
> I imported several files. Also one with given in the
> manual. My
> collectionn is called db/klemens.
> 
> <?xml version="1.0"?>
> <product product_id="120320">
>    <description>Glazed Ham</description>
> </product>
>          
> Now when I search using
> 
> c:\projects\perl\tm>xindice xpath_query -c
> /db/klemens -q
> /product[@product_id="120320"]
> 
> ====> No result !
> 
> If I use the following simple XPATH query instead:
> 
> c:\projects\perl\tm>xindice xpath_query -c
> /db/klemens -q /product
> 
> I get:
> 
> 
> <?xml version="1.0"?> <product product_id="120320"
> xmlns:src="http://xml.apache.org/xindice/Query"
> sr:col="/db/klemens"
> src:key="test3">
>    <description>Glazed Ham</description>
> </product>
> c:\projects\perl\tm>
> 
> It works ! Now what's wrong with the first query ?
> Do I have to create
> an index ? I am really wondering.
> 
> With regard to the article mentioned at XINDICE
> realm it should work too
> (Apache's Xindice Organizes XML Data Without
> Schema). The example there
> is as follows (although one has to adapt it because
> this is not a valid
> XML document and XINDICE recognises this bug)
> 
> "     <?xml version="1.0"?>
>      <product product_id="1" type="widget">
>           <description>foo</description>
>      </product>
>      <product product_id="2" type="widget">
>           <description>bar</description>
>      </product>
>      <product product_id="3" type="widget">
>           <description>foobar</description>
>      </product>
> 
> And the author states: If I wanted to write an XPath
> query to select the
> second product, I could use the following query
> string: 
>      /product[@product_id="2"]
> "
> 
> So theoretically my statement is correct.
> 
> Thanks for your help !
> 
> I also used the query in some of the browsers
> avalable for XINDICE and
> it does not work either. Curiously other queries
> sometimes work,
> sometimes not. And it hard to see why one query
> works and the other not.
> 
> Another question: Is there an easy way to check if
> XINDICE is running or
> not ? Idea is to check through the web if the server
> is running or not
> on a specific machine.
> 
> BTW: XINDICE is a cool tool.
> 
> Klemens
> 


__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com

AW: AW: XPATH usage

Posted by "Dr. Klemens Waldhör" <Wa...@t-online.de>.
Hi,

This does not work either. The really curious thing is that sometimes
other queries work.

I tried the query also in some XINDICE browser and there it does not
work too. Thus I think this has nothing to do with the way how Windows
(XP) treats command lines.

Klemens

-----Ursprüngliche Nachricht-----
Von: Mark J. Stang [mailto:markstang@earthlink.net] 
Gesendet: Montag, 8. Juli 2002 15:06
An: xindice-users@xml.apache.org
Betreff: Re: AW: XPATH usage


Shouldn't it be:

xindice xpath -c /db/klemens -q "/product[@product_id='120320']"

xpath not xpath_query...

Mark

"Dr. Klemens Waldhör" wrote:

> I tried this too. The answer I get is:
>
> c:\Programme\xml-xindice-1.0>xindice xpath_query -c /db/klemens -q 
> "/product[@product_id='120320']" Results in:
>
> "='120320']""==""" ist syntaktisch an dieser Stelle nicht 
> verarbeitbar.
>
> Which literally translated means: "='120320']""==""" cannot be treated
> (?) syntactically at this point.
>
> Klemens
>
> -----Ursprüngliche Nachricht-----
> Von: Mark J. Stang [mailto:markstang@earthlink.net]
> Gesendet: Samstag, 6. Juli 2002 21:52
> An: xindice-users@xml.apache.org
> Betreff: Re: XPATH usage
>
> This is necessary on Windows.   Otherwise, the command-line parser in
> windows gets screwed up.   It is a platform thing...
>
> Mark
>
> "Richard R. Liu" wrote:
>
> > Try
> >
> > xindice xpath_query -c /db/klemens -q 
> > "/product[@product_id='120320']"
> >
> > i.e., double quotes around the query and single quotes within it.
> >
> > > -----Original Message-----
> > > From: Rizwan Virk [mailto:rbrain@msn.com]
> > > Sent: Saturday, July 06, 2002 17:07
> > > To: xindice-users@xml.apache.org
> > > Subject: RE: XPATH usage
> > >
> > >
> > > hi,
> > >
> > > try it with single quotes ... this makes a difference sometimes 
> > > ... /product[@product_id='120320']
> > >
> > > Thanks
> > > Riz
> > >
> > > ------------------------------
> > > Riz Virk, (617) 905-3518
> > > riz@xyztechnologies.com, riz@alum.mit.edu 
> > > http://www.xyztechnologies.com
> > >
> > >
> > > -----Original Message-----
> > > From: Dr. Klemens Waldhör [mailto:Waldhoer@t-online.de]
> > > Sent: Saturday, July 06, 2002 10:54 AM
> > > To: xindice-users@xml.apache.org
> > > Subject: XPATH usage
> > >
> > >
> > > Hi,
> > >
> > > I tried several times to run the XPATH example given in the user 
> > > manual. It does not seem to work.
> > >
> > > I imported several files. Also one with given in the manual. My 
> > > collectionn is called db/klemens.
> > >
> > > <?xml version="1.0"?>
> > > <product product_id="120320">
> > >    <description>Glazed Ham</description>
> > > </product>
> > >
> > > Now when I search using
> > >
> > > c:\projects\perl\tm>xindice xpath_query -c /db/klemens -q 
> > > /product[@product_id="120320"]
> > >
> > > ====> No result !
> > >
> > > If I use the following simple XPATH query instead:
> > >
> > > c:\projects\perl\tm>xindice xpath_query -c /db/klemens -q /product
> > >
> > > I get:
> > >
> > >
> > > <?xml version="1.0"?> <product product_id="120320" 
> > > xmlns:src="http://xml.apache.org/xindice/Query" 
> > > sr:col="/db/klemens"
>
> > > src:key="test3">
> > >    <description>Glazed Ham</description>
> > > </product>
> > > c:\projects\perl\tm>
> > >
> > > It works ! Now what's wrong with the first query ? Do I have to 
> > > create an index ? I am really wondering.
> > >
> > > With regard to the article mentioned at XINDICE realm it should 
> > > work
>
> > > too (Apache's Xindice Organizes XML Data Without Schema). The 
> > > example there is as follows (although one has to adapt it because 
> > > this is not a valid
> > > XML document and XINDICE recognises this bug)
> > >
> > > "     <?xml version="1.0"?>
> > >      <product product_id="1" type="widget">
> > >           <description>foo</description>
> > >      </product>
> > >      <product product_id="2" type="widget">
> > >           <description>bar</description>
> > >      </product>
> > >      <product product_id="3" type="widget">
> > >           <description>foobar</description>
> > >      </product>
> > >
> > > And the author states: If I wanted to write an XPath query to 
> > > select
>
> > > the second product, I could use the following query string:
> > >      /product[@product_id="2"]
> > > "
> > >
> > > So theoretically my statement is correct.
> > >
> > > Thanks for your help !
> > >
> > > I also used the query in some of the browsers avalable for XINDICE

> > > and it does not work either. Curiously other queries sometimes 
> > > work,
>
> > > sometimes not. And it hard to see why one query works and the 
> > > other not.
> > >
> > > Another question: Is there an easy way to check if XINDICE is 
> > > running or not ? Idea is to check through the web if the server is

> > > running or not on a specific machine.
> > >
> > > BTW: XINDICE is a cool tool.
> > >
> > > Klemens
> > >
> > >
>
> --
> Mark J Stang
> System Architect
> Cybershop Systems

--
Mark J Stang
System Architect
Cybershop Systems



Re: AW: XPATH usage

Posted by "Mark J. Stang" <ma...@earthlink.net>.
Shouldn't it be:

xindice xpath -c /db/klemens -q "/product[@product_id='120320']"

xpath not xpath_query...

Mark

"Dr. Klemens Waldhör" wrote:

> I tried this too. The answer I get is:
>
> c:\Programme\xml-xindice-1.0>xindice xpath_query -c /db/klemens -q
> "/product[@product_id='120320']"
> Results in:
>
> "='120320']""==""" ist syntaktisch an dieser Stelle nicht verarbeitbar.
>
> Which literally translated means: "='120320']""==""" cannot be treated
> (?) syntactically at this point.
>
> Klemens
>
> -----Ursprüngliche Nachricht-----
> Von: Mark J. Stang [mailto:markstang@earthlink.net]
> Gesendet: Samstag, 6. Juli 2002 21:52
> An: xindice-users@xml.apache.org
> Betreff: Re: XPATH usage
>
> This is necessary on Windows.   Otherwise, the command-line parser in
> windows gets screwed up.   It is a platform thing...
>
> Mark
>
> "Richard R. Liu" wrote:
>
> > Try
> >
> > xindice xpath_query -c /db/klemens -q
> > "/product[@product_id='120320']"
> >
> > i.e., double quotes around the query and single quotes within it.
> >
> > > -----Original Message-----
> > > From: Rizwan Virk [mailto:rbrain@msn.com]
> > > Sent: Saturday, July 06, 2002 17:07
> > > To: xindice-users@xml.apache.org
> > > Subject: RE: XPATH usage
> > >
> > >
> > > hi,
> > >
> > > try it with single quotes ... this makes a difference sometimes ...
> > > /product[@product_id='120320']
> > >
> > > Thanks
> > > Riz
> > >
> > > ------------------------------
> > > Riz Virk, (617) 905-3518
> > > riz@xyztechnologies.com, riz@alum.mit.edu
> > > http://www.xyztechnologies.com
> > >
> > >
> > > -----Original Message-----
> > > From: Dr. Klemens Waldhör [mailto:Waldhoer@t-online.de]
> > > Sent: Saturday, July 06, 2002 10:54 AM
> > > To: xindice-users@xml.apache.org
> > > Subject: XPATH usage
> > >
> > >
> > > Hi,
> > >
> > > I tried several times to run the XPATH example given in the user
> > > manual. It does not seem to work.
> > >
> > > I imported several files. Also one with given in the manual. My
> > > collectionn is called db/klemens.
> > >
> > > <?xml version="1.0"?>
> > > <product product_id="120320">
> > >    <description>Glazed Ham</description>
> > > </product>
> > >
> > > Now when I search using
> > >
> > > c:\projects\perl\tm>xindice xpath_query -c /db/klemens -q
> > > /product[@product_id="120320"]
> > >
> > > ====> No result !
> > >
> > > If I use the following simple XPATH query instead:
> > >
> > > c:\projects\perl\tm>xindice xpath_query -c /db/klemens -q /product
> > >
> > > I get:
> > >
> > >
> > > <?xml version="1.0"?> <product product_id="120320"
> > > xmlns:src="http://xml.apache.org/xindice/Query" sr:col="/db/klemens"
>
> > > src:key="test3">
> > >    <description>Glazed Ham</description>
> > > </product>
> > > c:\projects\perl\tm>
> > >
> > > It works ! Now what's wrong with the first query ? Do I have to
> > > create an index ? I am really wondering.
> > >
> > > With regard to the article mentioned at XINDICE realm it should work
>
> > > too (Apache's Xindice Organizes XML Data Without Schema). The
> > > example there
> > > is as follows (although one has to adapt it because this is
> > > not a valid
> > > XML document and XINDICE recognises this bug)
> > >
> > > "     <?xml version="1.0"?>
> > >      <product product_id="1" type="widget">
> > >           <description>foo</description>
> > >      </product>
> > >      <product product_id="2" type="widget">
> > >           <description>bar</description>
> > >      </product>
> > >      <product product_id="3" type="widget">
> > >           <description>foobar</description>
> > >      </product>
> > >
> > > And the author states: If I wanted to write an XPath query to select
>
> > > the second product, I could use the following query string:
> > >      /product[@product_id="2"]
> > > "
> > >
> > > So theoretically my statement is correct.
> > >
> > > Thanks for your help !
> > >
> > > I also used the query in some of the browsers avalable for XINDICE
> > > and it does not work either. Curiously other queries sometimes work,
>
> > > sometimes not. And it hard to see why one query works and the other
> > > not.
> > >
> > > Another question: Is there an easy way to check if XINDICE is
> > > running or not ? Idea is to check through the web if the server is
> > > running or not on a specific machine.
> > >
> > > BTW: XINDICE is a cool tool.
> > >
> > > Klemens
> > >
> > >
>
> --
> Mark J Stang
> System Architect
> Cybershop Systems

--
Mark J Stang
System Architect
Cybershop Systems


AW: XPATH usage

Posted by "Dr. Klemens Waldhör" <Wa...@t-online.de>.
I tried this too. The answer I get is:

c:\Programme\xml-xindice-1.0>xindice xpath_query -c /db/klemens -q
"/product[@product_id='120320']"
Results in:

"='120320']""==""" ist syntaktisch an dieser Stelle nicht verarbeitbar.

Which literally translated means: "='120320']""==""" cannot be treated
(?) syntactically at this point.

Klemens

-----Ursprüngliche Nachricht-----
Von: Mark J. Stang [mailto:markstang@earthlink.net] 
Gesendet: Samstag, 6. Juli 2002 21:52
An: xindice-users@xml.apache.org
Betreff: Re: XPATH usage


This is necessary on Windows.   Otherwise, the command-line parser in
windows gets screwed up.   It is a platform thing...

Mark

"Richard R. Liu" wrote:

> Try
>
> xindice xpath_query -c /db/klemens -q  
> "/product[@product_id='120320']"
>
> i.e., double quotes around the query and single quotes within it.
>
> > -----Original Message-----
> > From: Rizwan Virk [mailto:rbrain@msn.com]
> > Sent: Saturday, July 06, 2002 17:07
> > To: xindice-users@xml.apache.org
> > Subject: RE: XPATH usage
> >
> >
> > hi,
> >
> > try it with single quotes ... this makes a difference sometimes ... 
> > /product[@product_id='120320']
> >
> > Thanks
> > Riz
> >
> > ------------------------------
> > Riz Virk, (617) 905-3518
> > riz@xyztechnologies.com, riz@alum.mit.edu 
> > http://www.xyztechnologies.com
> >
> >
> > -----Original Message-----
> > From: Dr. Klemens Waldhör [mailto:Waldhoer@t-online.de]
> > Sent: Saturday, July 06, 2002 10:54 AM
> > To: xindice-users@xml.apache.org
> > Subject: XPATH usage
> >
> >
> > Hi,
> >
> > I tried several times to run the XPATH example given in the user 
> > manual. It does not seem to work.
> >
> > I imported several files. Also one with given in the manual. My 
> > collectionn is called db/klemens.
> >
> > <?xml version="1.0"?>
> > <product product_id="120320">
> >    <description>Glazed Ham</description>
> > </product>
> >
> > Now when I search using
> >
> > c:\projects\perl\tm>xindice xpath_query -c /db/klemens -q 
> > /product[@product_id="120320"]
> >
> > ====> No result !
> >
> > If I use the following simple XPATH query instead:
> >
> > c:\projects\perl\tm>xindice xpath_query -c /db/klemens -q /product
> >
> > I get:
> >
> >
> > <?xml version="1.0"?> <product product_id="120320" 
> > xmlns:src="http://xml.apache.org/xindice/Query" sr:col="/db/klemens"

> > src:key="test3">
> >    <description>Glazed Ham</description>
> > </product>
> > c:\projects\perl\tm>
> >
> > It works ! Now what's wrong with the first query ? Do I have to 
> > create an index ? I am really wondering.
> >
> > With regard to the article mentioned at XINDICE realm it should work

> > too (Apache's Xindice Organizes XML Data Without Schema). The
> > example there
> > is as follows (although one has to adapt it because this is
> > not a valid
> > XML document and XINDICE recognises this bug)
> >
> > "     <?xml version="1.0"?>
> >      <product product_id="1" type="widget">
> >           <description>foo</description>
> >      </product>
> >      <product product_id="2" type="widget">
> >           <description>bar</description>
> >      </product>
> >      <product product_id="3" type="widget">
> >           <description>foobar</description>
> >      </product>
> >
> > And the author states: If I wanted to write an XPath query to select

> > the second product, I could use the following query string:
> >      /product[@product_id="2"]
> > "
> >
> > So theoretically my statement is correct.
> >
> > Thanks for your help !
> >
> > I also used the query in some of the browsers avalable for XINDICE 
> > and it does not work either. Curiously other queries sometimes work,

> > sometimes not. And it hard to see why one query works and the other 
> > not.
> >
> > Another question: Is there an easy way to check if XINDICE is 
> > running or not ? Idea is to check through the web if the server is 
> > running or not on a specific machine.
> >
> > BTW: XINDICE is a cool tool.
> >
> > Klemens
> >
> >

--
Mark J Stang
System Architect
Cybershop Systems



Re: XPATH usage

Posted by "Mark J. Stang" <ma...@earthlink.net>.
This is necessary on Windows.   Otherwise, the command-line parser in
windows gets screwed up.   It is a platform thing...

Mark

"Richard R. Liu" wrote:

> Try
>
> xindice xpath_query -c /db/klemens -q  "/product[@product_id='120320']"
>
> i.e., double quotes around the query and single quotes within it.
>
> > -----Original Message-----
> > From: Rizwan Virk [mailto:rbrain@msn.com]
> > Sent: Saturday, July 06, 2002 17:07
> > To: xindice-users@xml.apache.org
> > Subject: RE: XPATH usage
> >
> >
> > hi,
> >
> > try it with single quotes ... this makes a difference sometimes ...
> > /product[@product_id='120320']
> >
> > Thanks
> > Riz
> >
> > ------------------------------
> > Riz Virk, (617) 905-3518
> > riz@xyztechnologies.com, riz@alum.mit.edu
> > http://www.xyztechnologies.com
> >
> >
> > -----Original Message-----
> > From: Dr. Klemens Waldhör [mailto:Waldhoer@t-online.de]
> > Sent: Saturday, July 06, 2002 10:54 AM
> > To: xindice-users@xml.apache.org
> > Subject: XPATH usage
> >
> >
> > Hi,
> >
> > I tried several times to run the XPATH example given in the
> > user manual.
> > It does not seem to work.
> >
> > I imported several files. Also one with given in the manual. My
> > collectionn is called db/klemens.
> >
> > <?xml version="1.0"?>
> > <product product_id="120320">
> >    <description>Glazed Ham</description>
> > </product>
> >
> > Now when I search using
> >
> > c:\projects\perl\tm>xindice xpath_query -c /db/klemens -q
> > /product[@product_id="120320"]
> >
> > ====> No result !
> >
> > If I use the following simple XPATH query instead:
> >
> > c:\projects\perl\tm>xindice xpath_query -c /db/klemens -q /product
> >
> > I get:
> >
> >
> > <?xml version="1.0"?> <product product_id="120320"
> > xmlns:src="http://xml.apache.org/xindice/Query" sr:col="/db/klemens"
> > src:key="test3">
> >    <description>Glazed Ham</description>
> > </product>
> > c:\projects\perl\tm>
> >
> > It works ! Now what's wrong with the first query ? Do I have to create
> > an index ? I am really wondering.
> >
> > With regard to the article mentioned at XINDICE realm it
> > should work too
> > (Apache's Xindice Organizes XML Data Without Schema). The
> > example there
> > is as follows (although one has to adapt it because this is
> > not a valid
> > XML document and XINDICE recognises this bug)
> >
> > "     <?xml version="1.0"?>
> >      <product product_id="1" type="widget">
> >           <description>foo</description>
> >      </product>
> >      <product product_id="2" type="widget">
> >           <description>bar</description>
> >      </product>
> >      <product product_id="3" type="widget">
> >           <description>foobar</description>
> >      </product>
> >
> > And the author states: If I wanted to write an XPath query to
> > select the
> > second product, I could use the following query string:
> >      /product[@product_id="2"]
> > "
> >
> > So theoretically my statement is correct.
> >
> > Thanks for your help !
> >
> > I also used the query in some of the browsers avalable for XINDICE and
> > it does not work either. Curiously other queries sometimes work,
> > sometimes not. And it hard to see why one query works and the
> > other not.
> >
> > Another question: Is there an easy way to check if XINDICE is
> > running or
> > not ? Idea is to check through the web if the server is running or not
> > on a specific machine.
> >
> > BTW: XINDICE is a cool tool.
> >
> > Klemens
> >
> >

--
Mark J Stang
System Architect
Cybershop Systems


RE: XPATH usage

Posted by "Richard R. Liu" <ri...@tiscalinet.ch>.
Try

xindice xpath_query -c /db/klemens -q  "/product[@product_id='120320']"

i.e., double quotes around the query and single quotes within it.

> -----Original Message-----
> From: Rizwan Virk [mailto:rbrain@msn.com]
> Sent: Saturday, July 06, 2002 17:07
> To: xindice-users@xml.apache.org
> Subject: RE: XPATH usage
>
>
> hi,
>
> try it with single quotes ... this makes a difference sometimes ...
> /product[@product_id='120320']
>
> Thanks
> Riz
>
> ------------------------------
> Riz Virk, (617) 905-3518
> riz@xyztechnologies.com, riz@alum.mit.edu
> http://www.xyztechnologies.com
>
>
> -----Original Message-----
> From: Dr. Klemens Waldhör [mailto:Waldhoer@t-online.de]
> Sent: Saturday, July 06, 2002 10:54 AM
> To: xindice-users@xml.apache.org
> Subject: XPATH usage
>
>
> Hi,
>
> I tried several times to run the XPATH example given in the
> user manual.
> It does not seem to work.
>
> I imported several files. Also one with given in the manual. My
> collectionn is called db/klemens.
>
> <?xml version="1.0"?>
> <product product_id="120320">
>    <description>Glazed Ham</description>
> </product>
>
> Now when I search using
>
> c:\projects\perl\tm>xindice xpath_query -c /db/klemens -q
> /product[@product_id="120320"]
>
> ====> No result !
>
> If I use the following simple XPATH query instead:
>
> c:\projects\perl\tm>xindice xpath_query -c /db/klemens -q /product
>
> I get:
>
>
> <?xml version="1.0"?> <product product_id="120320"
> xmlns:src="http://xml.apache.org/xindice/Query" sr:col="/db/klemens"
> src:key="test3">
>    <description>Glazed Ham</description>
> </product>
> c:\projects\perl\tm>
>
> It works ! Now what's wrong with the first query ? Do I have to create
> an index ? I am really wondering.
>
> With regard to the article mentioned at XINDICE realm it
> should work too
> (Apache's Xindice Organizes XML Data Without Schema). The
> example there
> is as follows (although one has to adapt it because this is
> not a valid
> XML document and XINDICE recognises this bug)
>
> "     <?xml version="1.0"?>
>      <product product_id="1" type="widget">
>           <description>foo</description>
>      </product>
>      <product product_id="2" type="widget">
>           <description>bar</description>
>      </product>
>      <product product_id="3" type="widget">
>           <description>foobar</description>
>      </product>
>
> And the author states: If I wanted to write an XPath query to
> select the
> second product, I could use the following query string:
>      /product[@product_id="2"]
> "
>
> So theoretically my statement is correct.
>
> Thanks for your help !
>
> I also used the query in some of the browsers avalable for XINDICE and
> it does not work either. Curiously other queries sometimes work,
> sometimes not. And it hard to see why one query works and the
> other not.
>
> Another question: Is there an easy way to check if XINDICE is
> running or
> not ? Idea is to check through the web if the server is running or not
> on a specific machine.
>
> BTW: XINDICE is a cool tool.
>
> Klemens
>
>



RE: XPATH usage

Posted by Rizwan Virk <rb...@msn.com>.
hi,

try it with single quotes ... this makes a difference sometimes ...
/product[@product_id='120320']

Thanks
Riz

------------------------------
Riz Virk, (617) 905-3518
riz@xyztechnologies.com, riz@alum.mit.edu
http://www.xyztechnologies.com


-----Original Message-----
From: Dr. Klemens Waldhör [mailto:Waldhoer@t-online.de]
Sent: Saturday, July 06, 2002 10:54 AM
To: xindice-users@xml.apache.org
Subject: XPATH usage


Hi,

I tried several times to run the XPATH example given in the user manual.
It does not seem to work.

I imported several files. Also one with given in the manual. My
collectionn is called db/klemens.

<?xml version="1.0"?>
<product product_id="120320">
   <description>Glazed Ham</description>
</product>

Now when I search using

c:\projects\perl\tm>xindice xpath_query -c /db/klemens -q
/product[@product_id="120320"]

====> No result !

If I use the following simple XPATH query instead:

c:\projects\perl\tm>xindice xpath_query -c /db/klemens -q /product

I get:


<?xml version="1.0"?> <product product_id="120320"
xmlns:src="http://xml.apache.org/xindice/Query" sr:col="/db/klemens"
src:key="test3">
   <description>Glazed Ham</description>
</product>
c:\projects\perl\tm>

It works ! Now what's wrong with the first query ? Do I have to create
an index ? I am really wondering.

With regard to the article mentioned at XINDICE realm it should work too
(Apache's Xindice Organizes XML Data Without Schema). The example there
is as follows (although one has to adapt it because this is not a valid
XML document and XINDICE recognises this bug)

"     <?xml version="1.0"?>
     <product product_id="1" type="widget">
          <description>foo</description>
     </product>
     <product product_id="2" type="widget">
          <description>bar</description>
     </product>
     <product product_id="3" type="widget">
          <description>foobar</description>
     </product>

And the author states: If I wanted to write an XPath query to select the
second product, I could use the following query string:
     /product[@product_id="2"]
"

So theoretically my statement is correct.

Thanks for your help !

I also used the query in some of the browsers avalable for XINDICE and
it does not work either. Curiously other queries sometimes work,
sometimes not. And it hard to see why one query works and the other not.

Another question: Is there an easy way to check if XINDICE is running or
not ? Idea is to check through the web if the server is running or not
on a specific machine.

BTW: XINDICE is a cool tool.

Klemens



XPATH usage

Posted by "Dr. Klemens Waldhör" <Wa...@t-online.de>.
Hi,

I tried several times to run the XPATH example given in the user manual.
It does not seem to work.

I imported several files. Also one with given in the manual. My
collectionn is called db/klemens.

<?xml version="1.0"?>
<product product_id="120320">
   <description>Glazed Ham</description>
</product>
         
Now when I search using

c:\projects\perl\tm>xindice xpath_query -c /db/klemens -q
/product[@product_id="120320"]

====> No result !

If I use the following simple XPATH query instead:

c:\projects\perl\tm>xindice xpath_query -c /db/klemens -q /product

I get:


<?xml version="1.0"?> <product product_id="120320"
xmlns:src="http://xml.apache.org/xindice/Query" sr:col="/db/klemens"
src:key="test3">
   <description>Glazed Ham</description>
</product>
c:\projects\perl\tm>

It works ! Now what's wrong with the first query ? Do I have to create
an index ? I am really wondering.

With regard to the article mentioned at XINDICE realm it should work too
(Apache's Xindice Organizes XML Data Without Schema). The example there
is as follows (although one has to adapt it because this is not a valid
XML document and XINDICE recognises this bug)

"     <?xml version="1.0"?>
     <product product_id="1" type="widget">
          <description>foo</description>
     </product>
     <product product_id="2" type="widget">
          <description>bar</description>
     </product>
     <product product_id="3" type="widget">
          <description>foobar</description>
     </product>

And the author states: If I wanted to write an XPath query to select the
second product, I could use the following query string: 
     /product[@product_id="2"]
"

So theoretically my statement is correct.

Thanks for your help !

I also used the query in some of the browsers avalable for XINDICE and
it does not work either. Curiously other queries sometimes work,
sometimes not. And it hard to see why one query works and the other not.

Another question: Is there an easy way to check if XINDICE is running or
not ? Idea is to check through the web if the server is running or not
on a specific machine.

BTW: XINDICE is a cool tool.

Klemens


RE: Retieving parts of documents using XPath on a collection

Posted by Rizwan Virk <rb...@msn.com>.
You could probably do this using XSL (though I haven't actually done it) -
the way to do it would be to use XPATH to find the nodes you're interested
in - and then instead of copying the node from the input to the output, just
output the current node name and its attributes without copying it's
children.  (Using xsl:element and the nodename variable....

Of course, at this point, you're writing code so you just might want to go
ahead and do it with DOM (which is relatively straightforward using Java,
etc.).
Thanks
Riz


------------------------------
Riz Virk, (617) 905-3518
riz@xyztechnologies.com, riz@alum.mit.edu
http://www.xyztechnologies.com


-----Original Message-----
From: Erhan Baz [mailto:erhanbaz@yahoo.com]
Sent: Saturday, July 06, 2002 4:39 AM
To: xindice-users@xml.apache.org
Subject: Re: Retieving parts of documents using XPath on a collection


Hi,

	You can't get this type of result with only Xpath. We
faced with the same problem and wrote an application
which takes the all document as DOM and eliminates
unwanted branches.
	You must look for this type of solution.
Bye..

--- Erick_Brie`re <er...@afp.com> wrote:
> (Perhaps my question concerns more Xpath than
> Xindice itself... ?)
>
> Is there a way to get only nodes without their
> descendant(s) ?
>
> I test with these two documents:
>
> $ cat doc1.xml
> <?xml version="1.0"?>
> <AAA>
>   <BBB/>
>   <CCC value="doc1">
>     <DDD/>
>     <EEE/>
>   </CCC>
>   <FFF/>
> </AAA>
> $
> $ cat doc2.xml
> <?xml version="1.0"?>
> <AAA>
>   <BBB/>
>   <CCC value="doc2">
>     <DDD/>
>     <EEE/>
>   </CCC>
>   <FFF/>
> </AAA>
>
> I'd like to get the list of "CCC values", without
> having the "DDD" and
> "EEE" nodes:
>
> $ xindice xpath -c /db/test -q '/AAA/CCC'
> <?xml version="1.0"?>
> <CCC value="doc1"
> xmlns:src="http://xml.apache.org/xindice/Query"
> src:col="/db/test"
> src:key="338c319e664de474000000eedabd3e89">
>     <DDD />
>     <EEE />
> </CCC>
> <?xml version="1.0"?>
> <CCC value="doc2"
> xmlns:src="http://xml.apache.org/xindice/Query"
> src:col="/db/test"
> src:key="338c319e664de474000000eedabd99ef">
>     <DDD />
>     <EEE />
> </CCC>
>
> What should be the QUERY for having this:
>
> $ xindice xpath -c /db/test -q QUERY
> <?xml version="1.0"?>
> <CCC value="doc1"
> xmlns:src="http://xml.apache.org/xindice/Query"
> src:col="/db/test"
> src:key="338c319e664de474000000eedabd3e89">
> </CCC>
> <?xml version="1.0"?>
> <CCC value="doc2"
> xmlns:src="http://xml.apache.org/xindice/Query"
> src:col="/db/test"
> src:key="338c319e664de474000000eedabd99ef">
> </CCC>
>
>
> NB: probably i didn't anderstand wel the tutorial
>
http://www.zvon.org/xxl/XPathTutorial/General/examples.html
> ...
>
> Thanks,
> Erick.
>
>
>

__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com


Re: Retieving parts of documents using XPath on a collection

Posted by Erhan Baz <er...@yahoo.com>.
Hi,

	You can't get this type of result with only Xpath. We
faced with the same problem and wrote an application
which takes the all document as DOM and eliminates
unwanted branches.
	You must look for this type of solution.
Bye..

--- Erick_Brie`re <er...@afp.com> wrote:
> (Perhaps my question concerns more Xpath than
> Xindice itself... ?)
> 
> Is there a way to get only nodes without their
> descendant(s) ?
> 
> I test with these two documents:
> 
> $ cat doc1.xml
> <?xml version="1.0"?>
> <AAA>
>   <BBB/>
>   <CCC value="doc1">
>     <DDD/>
>     <EEE/>
>   </CCC>
>   <FFF/>
> </AAA> 
> $ 
> $ cat doc2.xml
> <?xml version="1.0"?>
> <AAA>
>   <BBB/>
>   <CCC value="doc2">
>     <DDD/>
>     <EEE/>
>   </CCC>
>   <FFF/>
> </AAA> 
> 
> I'd like to get the list of "CCC values", without
> having the "DDD" and 
> "EEE" nodes:
> 
> $ xindice xpath -c /db/test -q '/AAA/CCC'
> <?xml version="1.0"?>
> <CCC value="doc1"
> xmlns:src="http://xml.apache.org/xindice/Query"
> src:col="/db/test"
> src:key="338c319e664de474000000eedabd3e89">
>     <DDD />
>     <EEE />
> </CCC>
> <?xml version="1.0"?>
> <CCC value="doc2"
> xmlns:src="http://xml.apache.org/xindice/Query"
> src:col="/db/test"
> src:key="338c319e664de474000000eedabd99ef">
>     <DDD />
>     <EEE />
> </CCC>
> 
> What should be the QUERY for having this:
> 
> $ xindice xpath -c /db/test -q QUERY
> <?xml version="1.0"?>
> <CCC value="doc1"
> xmlns:src="http://xml.apache.org/xindice/Query"
> src:col="/db/test"
> src:key="338c319e664de474000000eedabd3e89">
> </CCC>
> <?xml version="1.0"?>
> <CCC value="doc2"
> xmlns:src="http://xml.apache.org/xindice/Query"
> src:col="/db/test"
> src:key="338c319e664de474000000eedabd99ef">
> </CCC>
> 
> 
> NB: probably i didn't anderstand wel the tutorial 
>
http://www.zvon.org/xxl/XPathTutorial/General/examples.html
> ...
> 
> Thanks,
> Erick.
> 
> 
> 

__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com