[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Is it possible to access a tag after using apply-

Subject: Re: 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
Re:  Is it possible to access a tag after using  apply-
XemonerdX schrieb:
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?

Hi Edwin,


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>

Michael Ludwig

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.