You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by sc...@us.ibm.com on 2002/05/23 16:51:04 UTC

Re: XPaths and Apostrophes

This is a well known problem.  XPath 2.0 will have a proper escaping
mechanism for quotes. Meanwhile, can you try:

<xsl:value-of select='Parent[Child="Child&apos;s Text"]'/>

(The reason the apos didn't work in your example is that the entity ref is
resolved before the XPath parse takes place, so the nesting in that case is
still a problem).

-scott




                                                                                                                      
                      "Isaac Hands"                                                                                   
                      <ih...@msn.com>         To:       xalan-j-users@xml.apache.org                                 
                                               cc:       (bcc: Scott Boag/Cambridge/IBM)                              
                      05/23/2002 10:55         Subject:  XPaths and Apostrophes                                       
                      AM                                                                                              
                                                                                                                      
                                                                                                                      




I am having trouble with the xalan-J processor when I try to specify an
XPath that includes an apostrophe in a conditional statement as follows:

     Parent[Child='Child's Text']

I need to use this xpath in an <xsl:value-of> element to select this node
as
follows:

<xsl:value-of select="Parent[Child='Child's Text']"/>

So, naturally I thought that I could use the escaping characters for my
embedded apostrophes like this:

<xsl:value-of select="Parent[Child='Child&apos;s Text']"/>

But, no, I get this error from the xalan-j processor:

javax.xml.transform.TransformerConfigurationException:
javax.xml.transform.TransformerException:
javax.xml.transform.TransformerException: Expected ], but found: s
             at
org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:995)

             at
org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:799)


Apparently, the xalan processor is assuming that my escaped apostrophe is
the end of the text string inside the conditional, which is obviously
wrong.
Can someone please shed some light on this problem ?

Thanks


_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx