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

Re: trying to query based on attribute value



Hi Steve,

Fri, 05 May 2000 Steve Evans wrote:
>Please help.
>
>I am using a slightly enhanced version of /samples/XML/Query.java.
>
>A fragment of my XML looks like this:
>
><artistinfo>
>     <song id="595">
>         <s_title>Title 1</s_title>
>     </song>
>     <song id="596">
>         <s_title>Title 2</s_title>
>     </song>
></artistinfo>
>
> From the command line, if I do:
>java Query artist_info.xml /artistinfo/song
>
>This prints both song nodes and all elements & values before it.
>
>I want only the info from song with attribute id=595; how do I do this?
>
>I tried: java Query artist_info.xml /artistinfo/song:id=595

The query

   /artistinfo/song[@id="595"]

should do the trick if you don't want to use the id() method from XPath.
The id() method from Xalans XPath implementation needs an XML parser to
ask the parser about the used DTD and elements with an "id" attribute. This
usage is a little bit tricky.

>
>with output: Query-Result (Boolean): false
>
>Could somebody out there give me the correct syntax? I can't find it in any 
>docs anywhere.

This is the overall problem with ozone. ;-(

Regards,
Lars
--
________________________________________________________________
Lars Martin                         mailto:lars@softwarebuero.de
softwarebuero m&b (SMB)              http://www.softwarebuero.de