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

Re: data translation => descendants appear side by sid

Subject: Re: data translation => descendants appear side by side inHTML-table
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Sat, 04 May 2002 14:30:24 +0200
sid translation to name
If you don't copy the description-elements to the variables (creating an RTF), you won't need the extension-function and you will get a general solution:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


<xsl:output method="html"/>

  <xsl:variable name="desc1" select="/root/base[1]//description"/>
  <xsl:variable name="desc2" select="/root/base[2]//description"/>

<xsl:template match="/">
<html>
<head><title>Descriptions</title></head>
<body>
<table border="1">
<xsl:variable name="count1" select="count($desc1)"/>
<xsl:variable name="count2" select="count($desc2)"/>
<xsl:variable name="count">
<xsl:choose>
<xsl:when test="$count1 &gt;= $count2"><xsl:value-of select="$count1"/></xsl:when>
<xsl:otherwise><xsl:value-of select="$count2"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>


          <xsl:call-template name="description-row">
            <xsl:with-param name="count" select="$count"/>
          </xsl:call-template>

        </table>
      </body>
    </html>
  </xsl:template>

  <xsl:template name="description-row">
    <xsl:param name="index" select="1"/>
    <xsl:param name="count" />
    <tr>
      <td><xsl:value-of select="$desc1[$index]"/></td>
      <td><xsl:value-of select="$desc2[$index]"/></td>
    </tr>

    <xsl:if test="$index &lt; $count">
      <xsl:call-template name="description-row">
        <xsl:with-param name="index" select="$index + 1"/>
        <xsl:with-param name="count" select="$count"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>

</xsl:stylesheet>

Regards,

Joerg

Stuart Celarier schrieb:
----- Answer -----
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt">

  <!--
    Variables containing description elements in each base element.
    Use top-level variables for efficiency, so they don't have to be
passed into templates
  -->
  <xsl:variable name="desc1">
    <xsl:apply-templates select="/root/base[1]"/>
  </xsl:variable>
  <xsl:variable name="desc2">
    <xsl:apply-templates select="/root/base[2]"/>
  </xsl:variable>
>
  <!-- make copy of all description elements within base -->
  <xsl:template match="base">
    <xsl:copy-of select=".//description"/>
  </xsl:template>


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


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.