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 Martin Polley <ma...@shaar-hagolan.co.il> on 2005/04/19 08:25:37 UTC

Apostrophe in XUpdate select string

I have a JSP page that takes a request and constructs an XUpdate query 
from it. The problem is that the selector string can include 
apostrophes. When such a string is incorporated into the XUpdate 
expression it causes an error (misquoted literal... expected single 
quote!).

The offending XUpdate query looks something like this:

<xu:modifications version="1.0" 
xmlns:xu="http://www.xmldb.org/xupdate"><xu:update 
select="//*[@name='Don't try this at 
home']/@description">Test</xu:update></xu:modifications>

No surprise that it doesn't work...

How can I get around this?

I have tried replacing the apostrophe with &apos; (by using the 
replaceAll() function), but the result is exactly the same. In the 
XUpdate query (which the page writes to the log), it appears as 
"Don&apos;t", but submitting this query results in the same error.

Any ideas?

TIA,
-- 
*Martin Polley
*+972 (52) 3864280
Homepage <http://212.179.45.118:8080/cocoon/writestuff/index.html>


-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.2.4 (MingW32)

mQGiBEECX6QRBADLc8aOn4ZYYceFXPahxpDjd9qHNxMd/OnpLI/7v5o0ORz914vC
35Aqs3yITM2Bg7976IEVYHMa8+asJuPSdw8VZKulbtZRJOrxAR47GVei9ogSzsDq
bMFduuCO8ObddV1C4huUdC1KedcXQm4kvP75HX1UdeYYJLFPYHw9K4JmCwCglEeP
II3D4AC7CMn4BR3uwbEcANEEAMbjpQAvfJ7/P+nJglw0joUJnmIOaAN7DpEgK4fs
IbDlVECJkqM+ucFyzu+TV7mzgU21AHOgdaJQX3Ys7dCQHEsxqyQzkiLwsdqb8Ti6
sPJue+W0anjsXd56WqwZdno4PJfS75JJ2MQKRJECe2xrn9SByhwro53mCImjus2/
9PCDBACerr+2CgscX5z0zCOD6ov+woSoft95suoyvIjazSYY0mkNCNVUEb5iTGSt
jCl/LNYLkPcqTVCXcSWofQUW5gkp2GZH99KiNiS7U1TUMDO5SpMn8IgqkfxdzT8V
Yc7QSpqGPe7A5td0Qk4G51c4ajRJDrG1B7rToZYd3YYGI9+I+rQuTWFydGluIFBv
bGxleSAoSG9tZSkgPG1hcnRpbi5wb2xsZXlAZ21haWwuY29tPoheBBMRAgAeBQJB
Al+kAhsDBgsJCAcDAgMVAgMDFgIBAh4BAheAAAoJEDPX1JyF4zeSt6IAn1Hccnof
RHA+pnHu5b11cp+b2dBaAJsHhYhog3h0qjLjTlHfov4gepDVYLkBDQRBAl+mEAQA
gcpbUCEhWosGpDbT5SW6YRXDHTlGpo+Jd+Z1ATxvSqMLj7t80XyTmADHhLWZesm2
BEZ+LuYxO3PZWqVPXizXyIxwVvbkq4PsFncA+kDQL8DJ57c6Am35sY5xzQSpPtg6
Esak2UF5A627dHfpXiqFoGBRf+edMnmjnOstxLnCmAcABAsD/jQ5tDTXHJkHMKPv
yAy1pSVoPecL6w604aTiwR6qzB39I2IN3aBtVVUbZdQyXEj6DU4WPaboEXG5CM0g
3jmOjtgKd4YV83f/1H5t2tdYtfw4lKPdgoIBxKuwXrUZ0Hsbjkj0eiC/d18rOFgU
3lcbuDb8p4clrTUkfYuL/JEMqFQniEkEGBECAAkFAkECX6YCGwwACgkQM9fUnIXj
N5IZuACggG5ZfRtfBBMHIiOVFmQJvYj0e6gAn3XGPRgmRURmUrY9Qoxr091jnMqZ
=R8rS
-----END PGP PUBLIC KEY BLOCK-----



---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0516-0, 04/18/2005
Tested on: 4/19/2005 9:25:38 AM
avast! - copyright (c) 2000-2004 ALWIL Software.
http://www.avast.com




Re: Apostrophe in XUpdate select string

Posted by Martin Polley <ma...@shaar-hagolan.co.il>.
Hi Yan,

Thanks for the suggestion, but it didn't help. I just get a different 
error now:

2005-04-20 21:55:27,211 [http-8080-Processor21] INFO  
org.apache.commons.httpclient.HttpMethodBase - Recoverable exception 
caught when processing request
2005-04-20 21:55:27,251 [http-8080-Processor21] WARN  
org.apache.commons.httpclient.HttpMethodBase - Recoverable exception 
caught but MethodRetryHandler.retryMethod() returned false, rethrowing 
exception

Thanks anyway!
-- 
*Martin Polley
*+972 (52) 3864280
Homepage <http://212.179.45.118:8080/cocoon/writestuff/index.html>


-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.2.4 (MingW32)

mQGiBEECX6QRBADLc8aOn4ZYYceFXPahxpDjd9qHNxMd/OnpLI/7v5o0ORz914vC
35Aqs3yITM2Bg7976IEVYHMa8+asJuPSdw8VZKulbtZRJOrxAR47GVei9ogSzsDq
bMFduuCO8ObddV1C4huUdC1KedcXQm4kvP75HX1UdeYYJLFPYHw9K4JmCwCglEeP
II3D4AC7CMn4BR3uwbEcANEEAMbjpQAvfJ7/P+nJglw0joUJnmIOaAN7DpEgK4fs
IbDlVECJkqM+ucFyzu+TV7mzgU21AHOgdaJQX3Ys7dCQHEsxqyQzkiLwsdqb8Ti6
sPJue+W0anjsXd56WqwZdno4PJfS75JJ2MQKRJECe2xrn9SByhwro53mCImjus2/
9PCDBACerr+2CgscX5z0zCOD6ov+woSoft95suoyvIjazSYY0mkNCNVUEb5iTGSt
jCl/LNYLkPcqTVCXcSWofQUW5gkp2GZH99KiNiS7U1TUMDO5SpMn8IgqkfxdzT8V
Yc7QSpqGPe7A5td0Qk4G51c4ajRJDrG1B7rToZYd3YYGI9+I+rQuTWFydGluIFBv
bGxleSAoSG9tZSkgPG1hcnRpbi5wb2xsZXlAZ21haWwuY29tPoheBBMRAgAeBQJB
Al+kAhsDBgsJCAcDAgMVAgMDFgIBAh4BAheAAAoJEDPX1JyF4zeSt6IAn1Hccnof
RHA+pnHu5b11cp+b2dBaAJsHhYhog3h0qjLjTlHfov4gepDVYLkBDQRBAl+mEAQA
gcpbUCEhWosGpDbT5SW6YRXDHTlGpo+Jd+Z1ATxvSqMLj7t80XyTmADHhLWZesm2
BEZ+LuYxO3PZWqVPXizXyIxwVvbkq4PsFncA+kDQL8DJ57c6Am35sY5xzQSpPtg6
Esak2UF5A627dHfpXiqFoGBRf+edMnmjnOstxLnCmAcABAsD/jQ5tDTXHJkHMKPv
yAy1pSVoPecL6w604aTiwR6qzB39I2IN3aBtVVUbZdQyXEj6DU4WPaboEXG5CM0g
3jmOjtgKd4YV83f/1H5t2tdYtfw4lKPdgoIBxKuwXrUZ0Hsbjkj0eiC/d18rOFgU
3lcbuDb8p4clrTUkfYuL/JEMqFQniEkEGBECAAkFAkECX6YCGwwACgkQM9fUnIXj
N5IZuACggG5ZfRtfBBMHIiOVFmQJvYj0e6gAn3XGPRgmRURmUrY9Qoxr091jnMqZ
=R8rS
-----END PGP PUBLIC KEY BLOCK-----



Yan Langlois wrote:

> I am not sure it could help but did you try this character "\" as an 
> escape character ?
> For example: 'Don't try this at home' would be replace by 'Don\'t try 
> this at home'
>
> Yan.
>
>
> Martin Polley wrote:
>
>> I have a JSP page that takes a request and constructs an XUpdate 
>> query from it. The problem is that the selector string can include 
>> apostrophes. When such a string is incorporated into the XUpdate 
>> expression it causes an error (misquoted literal... expected single 
>> quote!).
>>
>> The offending XUpdate query looks something like this:
>>
>> <xu:modifications version="1.0" 
>> xmlns:xu="http://www.xmldb.org/xupdate"><xu:update 
>> select="//*[@name='Don't try this at 
>> home']/@description">Test</xu:update></xu:modifications>
>>
>> No surprise that it doesn't work...
>>
>> How can I get around this?
>>
>> I have tried replacing the apostrophe with &apos; (by using the 
>> replaceAll() function), but the result is exactly the same. In the 
>> XUpdate query (which the page writes to the log), it appears as 
>> "Don&apos;t", but submitting this query results in the same error.
>>
>> Any ideas?
>>
>> TIA,
>
>
>
>
>
> ************************************************************************************ 
>
> This footnote confirms that this email message has been scanned by
> PineApp Mail-SeCure for the presence of malicious code, vandals & 
> computer viruses.
> ************************************************************************************ 
>
>
>
>
> ---
> avast! Antivirus: Inbound message clean.
> Virus Database (VPS): 0516-3, 04/20/2005
> Tested on: 4/20/2005 9:00:27 PM
> avast! - copyright (c) 2000-2004 ALWIL Software.
> http://www.avast.com
>
>
>
>


---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0516-3, 04/20/2005
Tested on: 4/20/2005 9:57:32 PM
avast! - copyright (c) 2000-2004 ALWIL Software.
http://www.avast.com




Re: Apostrophe in XUpdate select string

Posted by Yan Langlois <ya...@eseo.fr>.
I am not sure it could help but did you try this character "\" as an 
escape character ?
For example: 'Don't try this at home' would be replace by 'Don\'t try 
this at home'

Yan.


Martin Polley wrote:

> I have a JSP page that takes a request and constructs an XUpdate query 
> from it. The problem is that the selector string can include 
> apostrophes. When such a string is incorporated into the XUpdate 
> expression it causes an error (misquoted literal... expected single 
> quote!).
>
> The offending XUpdate query looks something like this:
>
> <xu:modifications version="1.0" 
> xmlns:xu="http://www.xmldb.org/xupdate"><xu:update 
> select="//*[@name='Don't try this at 
> home']/@description">Test</xu:update></xu:modifications>
>
> No surprise that it doesn't work...
>
> How can I get around this?
>
> I have tried replacing the apostrophe with &apos; (by using the 
> replaceAll() function), but the result is exactly the same. In the 
> XUpdate query (which the page writes to the log), it appears as 
> "Don&apos;t", but submitting this query results in the same error.
>
> Any ideas?
>
> TIA,