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 Paul Caton <pa...@mama.stg.brown.edu> on 2002/03/26 19:01:35 UTC

Must escape (Unix geeks pls ignore)

I'm running Xindice 1.0 on a Red Hat Linux box, using a Bash
shell. This is just a note that might help folks with a similar setup
avoid wasting time trying to discover why some commandline XPath
queries don't work. When you give a query like this:

     xindice xpath -c /db/pebbles -q /rock[@type="hard"]

which is almost identical to Example 5.1 in the commandline tools
reference doc, you might find Xindice returns nothing at all. This is
because you need to escape the quote marks, like so:

     xindice xpath -c /db/pebbles -q /rock[@type=\"hard\"]

Similarly, if your XPath includes a function you must escape the
parentheses, eg:

     xindice xpath -c /db/pebbles -q /rock[position\(\)=1]

I appreciate this is basic Unix stuff, but when you're focusing on
Xindice it's easy to forget, and the documentation doesn't remind you,
and neither the server nor the shell will return an error message in
response to the command. I wasted a good while before smacking myself
upside the head when I realised what was wrong ;-)

Paul.

-- 
Paul Caton
Electronic Publications Editor
Women Writers Project

 e-mail: paul@mail.stg.brown.edu
    tel: (401) 863-3619
address: Box 1841, Brown University, Providence RI 02912

	


Re: Must escape (Unix geeks pls ignore)

Posted by Carsten Ziegert <ca...@ik.fh-hannover.de>.
Am 26.03.2002 19:01 Uhr schrieb "Paul Caton" unter
<pa...@mama.stg.brown.edu>:

> I'm running Xindice 1.0 on a Red Hat Linux box, using a Bash
> shell. This is just a note that might help folks with a similar setup
> avoid wasting time trying to discover why some commandline XPath
> queries don't work. When you give a query like this:
> 
>    xindice xpath -c /db/pebbles -q /rock[@type="hard"]
> 
> which is almost identical to Example 5.1 in the commandline tools
> reference doc, you might find Xindice returns nothing at all. This is
> because you need to escape the quote marks, like so:
> 
>    xindice xpath -c /db/pebbles -q /rock[@type=\"hard\"]
> 
> Similarly, if your XPath includes a function you must escape the
> parentheses, eg:
> 
>    xindice xpath -c /db/pebbles -q /rock[position\(\)=1]
> 
> I appreciate this is basic Unix stuff, but when you're focusing on
> Xindice it's easy to forget, and the documentation doesn't remind you,
> and neither the server nor the shell will return an error message in
> response to the command. I wasted a good while before smacking myself
> upside the head when I realised what was wrong ;-)
> 
> Paul.


I use a bash shell under Solaris and have no problems at all.
But I also use single quotes around the query itself, e.g.

xindice xpath -c /db/pebbles -q '/rock[@type="hard"]'

I think this syntax is mentioned in the documentation.

Carsten

--

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