[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] XPATH as parameter


Subject: [xsl] XPATH as parameter
From: Corneanu Dan <cdan@xxxxxxxxxxx>
Date: Thu, 13 Jun 2002 13:07:18 +0300

Hi,

I have a collection of xmls with the following structure:

<?xml version="1.0" encoding="UTF-8"?>
<record>
   <name>Dan</name>
   <city>TM</city>
</record>

and a index.xml file with the URIs of all the record files in my collection:

<?xml version="1.0" encoding="UTF-8"?>
<index>
   <record ref="r1.xml"/>
   <record ref="r2.xml"/>
   <record ref="r3.xml"/>
</index>

I want to make a search on my collection of documents based on an
xpath. The xpath should be a parameter passed to a search.xsl file. The problem is
that I don't know how to apply an xpath stored as a parameter variable. I have tried like this


<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:param name="xpath">/record/name[contains(../city, 'TM')]</xsl:param>
<xsl:template match="/index">
<resultset>
<xsl:apply-templates select="record"/>
</resultset>
</xsl:template>
<xsl:template match="record"> <xsl:for-each select="document(@ref)">
<result>
<xsl:value-of select="$xpath"/>
</result>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>


but of course it's not working. Any idea how this can be done?


Thanks.



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




Current Thread
Keywords