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 praktikant <pr...@feltengmbh.de> on 2002/09/11 14:43:02 UTC

xpath question

Hi,
I try to make a list of all hyperlinks in my collection. Each link is stored
in an other resource.
Can you help me?

this is my Collection:

<?xml version="1.0" encoding="UTF-8" ?> 
<collection:collections resources="6" collections="0"
xmlns:collection="http://apache.org/cocoon/xmldb/1.0
<http://apache.org/cocoon/xmldb/1.0> "> 
<collection:resource name="hans.xml" /> 
<collection:resource name="joachim.xml" /> 
<collection:resource name="joerg.xml" /> 
<collection:resource name="martin.xml" /> 
<collection:resource name="ruediger.xml" /> 
<collection:resource name="stefan.xml" /> 
</collection:collections>

each Resource looks like this:

<?xml version="1.0"?>
 <person>
  <name>Holsten</name>
  <vorname>Hans</vorname>
  <hlink>hansh</hlink>
 </person>

if I now use "http://localhost:8080/cocoon/xmldb/mitarbeiter/?xpath=//hlink"
I get:

<?xml version="1.0" encoding="UTF-8" ?> 
<collection:results query="//hlink" resources="6" 
xmlns:collection="http://apache.org/cocoon/xmldb/1.0
<http://apache.org/cocoon/xmldb/1.0> "> 
<collection:result docid="hans.xml"> 
<hlink xmlns:src="http://xml.apache.org/xindice/Query
<http://xml.apache.org/xindice/Query> " src:col="/db/mitarbeiter"
src:key="hans.xml">hansh</hlink> 
</collection:result> 
<collection:result docid="joachim.xml"> 
<hlink xmlns:src="http://xml.apache.org/xindice/Query
<http://xml.apache.org/xindice/Query> " src:col="/db/mitarbeiter"
src:key="joachim.xml">joachimh</hlink> 
</collection:result> 
<collection:result docid="joerg.xml"> 
<hlink xmlns:src="http://xml.apache.org/xindice/Query
<http://xml.apache.org/xindice/Query> " src:col="/db/mitarbeiter"
src:key="joerg.xml">joergh</hlink> 
</collection:result> 
<collection:result docid="martin.xml"> 
<hlink xmlns:src="http://xml.apache.org/xindice/Query
<http://xml.apache.org/xindice/Query> " src:col="/db/mitarbeiter"
src:key="martin.xml">martinh</hlink> 
</collection:result> 
<collection:result docid="ruediger.xml"> 
<hlink xmlns:src="http://xml.apache.org/xindice/Query
<http://xml.apache.org/xindice/Query> " src:col="/db/mitarbeiter"
src:key="ruediger.xml">ruedigerh</hlink> 
</collection:result> 
<collection:result docid="stefan.xml"> 
<hlink xmlns:src="http://xml.apache.org/xindice/Query
<http://xml.apache.org/xindice/Query> " src:col="/db/mitarbeiter"
src:key="stefan.xml">stefanh</hlink> 
</collection:result> 
</collection:results>

What I want to have is an output look mostly like that:

<hlink>hansh</hlink> 
<hlink>joachimh</hlink> 
<hlink>joergh</hlink> 
<hlink>martinh</hlink> 
<hlink>ruedigerh</hlink> 
<hlink>stefanh</hlink> 

Is it possible to do so?
I use Xindice 1.0.

Thanks and regards
Hans

Re: xpath question

Posted by KOZLOV Roman <r-...@opencascade.com>.
Hi,

It's possible by means of additional transformation of the Xindice's response by
a client. I think this is the only way for the moment. By the way, don't use
"//" in queries, for example in your case use "/person/hlink", because it's much
less time consuming.

Best regards,
    Roman

praktikant wrote:

> Hi,
> I try to make a list of all hyperlinks in my collection. Each link is stored
> in an other resource.
> Can you help me?
>
> this is my Collection:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <collection:collections resources="6" collections="0"
> xmlns:collection="http://apache.org/cocoon/xmldb/1.0
> <http://apache.org/cocoon/xmldb/1.0> ">
> <collection:resource name="hans.xml" />
> <collection:resource name="joachim.xml" />
> <collection:resource name="joerg.xml" />
> <collection:resource name="martin.xml" />
> <collection:resource name="ruediger.xml" />
> <collection:resource name="stefan.xml" />
> </collection:collections>
>
> each Resource looks like this:
>
> <?xml version="1.0"?>
>  <person>
>   <name>Holsten</name>
>   <vorname>Hans</vorname>
>   <hlink>hansh</hlink>
>  </person>
>
> if I now use "http://localhost:8080/cocoon/xmldb/mitarbeiter/?xpath=//hlink"
> I get:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <collection:results query="//hlink" resources="6"
> xmlns:collection="http://apache.org/cocoon/xmldb/1.0
> <http://apache.org/cocoon/xmldb/1.0> ">
> <collection:result docid="hans.xml">
> <hlink xmlns:src="http://xml.apache.org/xindice/Query
> <http://xml.apache.org/xindice/Query> " src:col="/db/mitarbeiter"
> src:key="hans.xml">hansh</hlink>
> </collection:result>
> <collection:result docid="joachim.xml">
> <hlink xmlns:src="http://xml.apache.org/xindice/Query
> <http://xml.apache.org/xindice/Query> " src:col="/db/mitarbeiter"
> src:key="joachim.xml">joachimh</hlink>
> </collection:result>
> <collection:result docid="joerg.xml">
> <hlink xmlns:src="http://xml.apache.org/xindice/Query
> <http://xml.apache.org/xindice/Query> " src:col="/db/mitarbeiter"
> src:key="joerg.xml">joergh</hlink>
> </collection:result>
> <collection:result docid="martin.xml">
> <hlink xmlns:src="http://xml.apache.org/xindice/Query
> <http://xml.apache.org/xindice/Query> " src:col="/db/mitarbeiter"
> src:key="martin.xml">martinh</hlink>
> </collection:result>
> <collection:result docid="ruediger.xml">
> <hlink xmlns:src="http://xml.apache.org/xindice/Query
> <http://xml.apache.org/xindice/Query> " src:col="/db/mitarbeiter"
> src:key="ruediger.xml">ruedigerh</hlink>
> </collection:result>
> <collection:result docid="stefan.xml">
> <hlink xmlns:src="http://xml.apache.org/xindice/Query
> <http://xml.apache.org/xindice/Query> " src:col="/db/mitarbeiter"
> src:key="stefan.xml">stefanh</hlink>
> </collection:result>
> </collection:results>
>
> What I want to have is an output look mostly like that:
>
> <hlink>hansh</hlink>
> <hlink>joachimh</hlink>
> <hlink>joergh</hlink>
> <hlink>martinh</hlink>
> <hlink>ruedigerh</hlink>
> <hlink>stefanh</hlink>
>
> Is it possible to do so?
> I use Xindice 1.0.
>
> Thanks and regards
> Hans