This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
XPATH as parameter
- From: Corneanu Dan <cdan at savatech dot ro>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Thu, 13 Jun 2002 13:07:18 +0300
- Subject: [xsl] XPATH as parameter
- References: <GAEEKOFFIGMPDJOEFBIIEECGCAAA.paulb@dev.mms.sonybpe.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
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