[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Martin Honnen wrote:
If you need/want to use XSLT 1.0 then you need to make sure you pass parameters explicitly on in all templates that are used, in particular that identity transformation template:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:variable name="data" select="/"/>
<xsl:variable name="layout"
select="document('test2008070402.xml')"/>
<xsl:template match="/">
<xsl:apply-templates select="$layout/layout/layout-main/*"/>
</xsl:template>
<!-- transformations -->
<xsl:template match="insert-name">
<xsl:value-of select="$data/top/data/name"/>
</xsl:template>
<xsl:template match="insert-title">
<xsl:value-of select="$data/top/data/title"/>
</xsl:template>
<xsl:template match="insert-cells">
<xsl:for-each select="$data/top/cells/cell">
<xsl:variable name="name" select="name"/>
<xsl:variable name="value" select="value"/>
<xsl:apply-templates select="$layout/layout/layout-cell/tr">
<xsl:with-param name="name" select="$name"/>
<xsl:with-param name="value" select="$value"/>
</xsl:apply-templates>
</xsl:for-each>
</xsl:template>
<xsl:template match="insert-cell-name">
<xsl:param name="name"/>
<xsl:value-of select="$name"/>
</xsl:template>
<xsl:template match="insert-cell-value">
<xsl:param name="value"/>
<xsl:value-of select="$value"/>
</xsl:template>
<!-- Identity transformation -->
<xsl:template match="@*|node()">
<xsl:param name="name"/>
<xsl:param name="value"/>
<xsl:copy>
<xsl:apply-templates select="@*|node()">
<xsl:with-param name="name" select="$name"/>
<xsl:with-param name="value" select="$value"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
--
Re: [xsl] Is it possible to access a tag after using apply-templates?
Subject: Re: [xsl] Is it possible to access a tag after using apply-templates? From: Martin Honnen <Martin.Honnen@xxxxxx> Date: Fri, 04 Jul 2008 16:28:03 +0200 |
Martin Honnen wrote:
XemonerdX wrote:
Unfortunately that's not quite the result. I can't seem to be able to replace the 'insert-cell-name' and 'insert-cell-value' tags with the corresponding 'name' and 'value' tag values. Is this possible?
Here is an XSLT 2.0 stylesheet making use of tunnel parameters.
If you need/want to use XSLT 1.0 then you need to make sure you pass parameters explicitly on in all templates that are used, in particular that identity transformation template:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:variable name="data" select="/"/>
<xsl:variable name="layout"
select="document('test2008070402.xml')"/>
<xsl:template match="/">
<xsl:apply-templates select="$layout/layout/layout-main/*"/>
</xsl:template>
<!-- transformations -->
<xsl:template match="insert-name">
<xsl:value-of select="$data/top/data/name"/>
</xsl:template>
<xsl:template match="insert-title">
<xsl:value-of select="$data/top/data/title"/>
</xsl:template>
<xsl:template match="insert-cells">
<xsl:for-each select="$data/top/cells/cell">
<xsl:variable name="name" select="name"/>
<xsl:variable name="value" select="value"/>
<xsl:apply-templates select="$layout/layout/layout-cell/tr">
<xsl:with-param name="name" select="$name"/>
<xsl:with-param name="value" select="$value"/>
</xsl:apply-templates>
</xsl:for-each>
</xsl:template>
<xsl:template match="insert-cell-name">
<xsl:param name="name"/>
<xsl:value-of select="$name"/>
</xsl:template>
<xsl:template match="insert-cell-value">
<xsl:param name="value"/>
<xsl:value-of select="$value"/>
</xsl:template>
<!-- Identity transformation -->
<xsl:template match="@*|node()">
<xsl:param name="name"/>
<xsl:param name="value"/>
<xsl:copy>
<xsl:apply-templates select="@*|node()">
<xsl:with-param name="name" select="$name"/>
<xsl:with-param name="value" select="$value"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
--
Martin Honnen http://JavaScript.FAQTs.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Is it possible to access , Martin Honnen | Thread | Re: [xsl] Is it possible to access , XemonerdX |
Re: [xsl] Is it possible to access , Martin Honnen | Date | Re: [xsl] Empty input in analyze-st, Mathieu Malaterre |
Month |
Keywords