[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Data Integration at runtime using XSL


Subject: Re: [xsl] Data Integration at runtime using XSL
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 7 Sep 2006 13:42:40 +0100

Or, in XSLT2:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
  <xsl:output indent="yes"/>
  <xsl:strip-space elements="*"/>
  <xsl:variable name="str" select="'abc|def'"/>
  <xsl:variable name="seq" select="tokenize($str,'\|')"/>

  <xsl:template match="x">
    <x>
      <xsl:apply-templates select="main-element"/>
    </x>
  </xsl:template>
  
 <xsl:template match="main-element">
   <xsl:variable name="p" select="position()"/>
     <header>
     <xsl:value-of select="$seq[min(($p,last()))]"/>
   </header>
   <xsl:copy-of select="."/>
  </xsl:template>


</xsl:stylesheet>



$ saxon8 sigh.xml sigh2.xsl
<?xml version="1.0" encoding="UTF-8"?>
<x>
   <header>abc</header>
   <main-element>
      <fid id="DATA_STATUS">0</fid>
   </main-element>
   <header>def</header>
   <main-element>
      <fid id="DATA_STATUS">1</fid>
   </main-element>
   <header>def</header>
   <main-element>
      <fid id="DATA_STATUS">2</fid>
   </main-element>
</x>


Current Thread