xsl-list
[Top] [All Lists]

Re: [xsl] Is it possible to access a tag after using apply-templates?

2008-07-04 07:47:21
Martin,

Thank you for your solutions! I forgot to mention I am using XSLT 1.0
with Xalan 1.9, as this is the XSLT engine that comes with
Intersystems Cache which is the environment I am working with. Your
solution works as described, I am not quite sure I 'get it' at this
point but I'm sure that will happen.

Edwin

On Fri, Jul 4, 2008 at 4:28 PM, Martin Honnen 
<Martin(_dot_)Honnen(_at_)gmx(_dot_)de> wrote:
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/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





-- 
Edwin
PoeticTerror.Com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--