Hi Atul,

This is the result of a limitation of defining literals in XPath.  Using
entities such as ', won't change how a literal is interpreted, since
the XML parser resolves the entities before the XSLT processor sees the
attribute.  Thus, your expression looks like this to the XSLT processor:

   '//Category[attribute::name='Cat2']'

which is clearly an illegal expression, since the ' after attribute::name
terminates the literal.

The easiest way around this is to put the expression into the content of an
element (or an attribute value) in one of your source document.  There is
no need to use xalan:evalute() when the expression is a literal in the
stylesheet.

Dave



                                                                                       
        
                    "Atul Patel"                                                       
        
                    <[EMAIL PROTECTED]        To:     [EMAIL PROTECTED]              
        
                    .com>                cc:     (bcc: David N Bertoni/CAM/Lotus)      
        
                                         Subject:     xalan:evaluate( XPath - 
expression )     
                    11/12/2001           help needed......                             
        
                    03:29 PM                                                           
        
                    Please                                                             
        
                    respond to                                                         
        
                    xalan-dev                                                          
        
                                                                                       
        
                                                                                       
        



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
=&apos;Cat2&apos;]'"/> -->
<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
=&apos;Cat2&apos;]'"/>
<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



Reply via email to