Subject: Re: [xsl] Is it possible to access a tag after using apply-templates? From: Michael Ludwig <mlu@xxxxxxxxxxxxx> Date: Fri, 04 Jul 2008 16:45:31 +0200 |
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?
in addition to what Martin has already supplied, you may want to try the following XSL 1.0 solution, which produces the desired output. Note the identity template with parameter at the end tries to emulate tunnel parameters.
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:param name="data-file" select="'XemonerdX-2008-07-04.xml'"/> <xsl:variable name="root" select="/"/> <xsl:variable name="data-doc" select="document( $data-file )"/>
<xsl:template match="layout | layout-main"><!-- pass through --> <xsl:apply-templates select="*"/> </xsl:template> <xsl:template match="layout-cell"/><!-- do not go down here -->
<xsl:template match="title"> <xsl:copy-of select="$data-doc/top/data/title"/> </xsl:template>
<xsl:template match="insert-name"> <xsl:value-of select="$data-doc/top/data/name"/> </xsl:template>
<xsl:template match="insert-cells"> <xsl:for-each select="$data-doc/top/cells/cell"> <xsl:variable name="current-cell" select="."/> <xsl:apply-templates select="$root/layout/layout-cell/*" mode="cell"> <xsl:with-param name="current-cell" select="$current-cell"/> </xsl:apply-templates> </xsl:for-each> </xsl:template>
<xsl:template match="insert-cell-name"> <xsl:apply-templates select="/layout/layout-cell/*"/> </xsl:template>
<xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template>
<!-- identity template with parameter --> <xsl:template match="@*|node()" mode="cell"> <xsl:param name="current-cell"/> <xsl:copy> <xsl:apply-templates select="@*|node()" mode="cell"> <xsl:with-param name="current-cell" select="$current-cell"/> </xsl:apply-templates> </xsl:copy> </xsl:template> <!-- placeholder to be filled in --> <xsl:template match="insert-cell-name" mode="cell"> <xsl:param name="current-cell"/> <xsl:value-of select="$current-cell/name"/> </xsl:template> <!-- another placeholder --> <xsl:template match="insert-cell-value" mode="cell"> <xsl:param name="current-cell"/> <xsl:value-of select="$current-cell/value"/> </xsl:template> </xsl:transform>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Is it possible to access , XemonerdX | Thread | [xsl] Grouping problem. 2.0, Dave Pawson |
RE: [xsl] Is it possible to access , Michael Kay | Date | Re: [xsl] Is it possible to access , XemonerdX |
Month |