The problem is that the ' are being expanded to a single quote, which is interpreted the exact same as the other single quotes that are deliminating the string. The ' only escapes the single quote inside of the select="..." attribute -- it does not perform any escaping on the XPath string literal that is inside of the attribute. The error message you are getting is simply saying that it since the ' actually functions like a normal single quote in this case, the string literal is being ended early and you actually end up with several string literals (aka tokens), which it doesn't know how to handle.
There are a couple ways you can get around this: <xsl:variable name="exper">//Category[attribute::name='Cat2']</xsl:variable> (avoid the whole problem all together) <xsl:variable name="exper" select=""//Category[attribute::name='Cat2']""/> (use double quotes to deliminate the XPath string literal, and single quotes inside) <xsl:variable name="exper" select='"//Category[attribute::name='Cat2']"'/> (the single quote is on the outside, and the double quote is on the inside) Let me know if any of those didn't work (I haven't tested, but it looks like they should unless there is a bug somewhere). Note also that if you use methods 2 or 3 from above, you don't even need the variable: <xsl:copy-of select="xalan:evaluate("//Category[attribute::name='Cat2']")"/> but then again I guess that removes the whole purpose of evaluating it dynamically in the first place, doesn't it :) Atul Patel wrote: > I have the following stylesheet: > > <?xml version="1.0"?> > > <xsl:stylesheet xmlns:xsl=" http://www.w3.org/1999/XSL/Transform" > xmlns:xalan="http://xml.apache.org/xalan " > version="1.0"> > > <xsl:template match="/"> > <!-- <xsl:variable name="exper" > select="'//Category[attribute::name='Cat2']'"/> --> > <xsl:variable name="exper" select="'//Category'"/> > <xsl:copy-of select="xalan:evaluate($exper)"/> > </xsl:template> > > </xsl:stylesheet> > > > Where I am using xalan:evaluate extension function. > > // Works Fine Starts > >-------------------------------------------------------------------------------------------------------------------------- > > // If I use the simple xpath it works fine. > > <xsl:variable name="exper" select="'//Category'"/> > <xsl:copy-of select="xalan:evaluate($exper)"/> > > // Works Fine Ends > >-------------------------------------------------------------------------------------------------------------------------- > > > // Problem Starts > >-------------------------------------------------------------------------------------------------------------------------- > > // But if I use the conditional xpath it does not work See below > > <xsl:variable name="exper" > select="'//Category[attribute::name='Cat2']'"/> > <xsl:copy-of select="xalan:evaluate($exper)"/> > > It gives me Exception Message: > javax.xml.transform.TransformerException: Extra illegal tokens: > 'Cat2', '']'' > > // Problem Ends > >-------------------------------------------------------------------------------------------------------------------------- > > > > Is there a restriction on the XPath being used as an argument to > xalan:evaluate()? > or > Am I doing something wrong? > > Thanks in advance. > > > Regards, > > Atul Patel > 17 Skyline Drive, J2-A29, > Hawthorne, NY, 10532. > EXT: (914) 784 - 5120 > TL: 863- 5120 > -- Furthermore, I believe bacon prevents hair loss. Peter Davis Developer, Speaklink Inc. [EMAIL PROTECTED]
