Re: [xsl] Creating Nested Structure Based on Attributes

Subject: Re: [xsl] Creating Nested Structure Based on Attributes
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 19 Mar 2007 09:41:52 GMT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

  <xsl:output indent="yes"/>
  
  <xsl:template match="inline">
    <inline>
      <xsl:apply-templates select="." mode="fs"/>
    </inline>
  </xsl:template>

  <xsl:template match="inline" mode="fs">
    <xsl:apply-templates select="." mode="fv"/>
  </xsl:template>

  <xsl:template match="inline[@font-style]" mode="fs">
    <emphasis format="{@font-style}">
      <xsl:apply-templates select="." mode="fv"/>
    </emphasis>
  </xsl:template>

  <xsl:template match="inline" mode="fv">
    <xsl:apply-templates select="." mode="fw"/>
  </xsl:template>

  <xsl:template match="inline[@font-variant]" mode="fv">
    <emphasis format="{@font-variant}">
      <xsl:apply-templates select="." mode="fw"/>
    </emphasis>
  </xsl:template>

  <xsl:template match="inline" mode="fw">
    <xsl:apply-templates select="." mode="tu"/>
  </xsl:template>

  <xsl:template match="inline[@font-weight]" mode="fw">
    <emphasis format="{@font-weight}">
      <xsl:apply-templates select="." mode="tu"/>
    </emphasis>
  </xsl:template>


  <xsl:template match="inline" mode="tu">
    <xsl:apply-templates select="." mode="va"/>
  </xsl:template>

  <xsl:template match="inline[@text-underline-style]" mode="tu">
    <emphasis format="{@text-underline-style}">
      <xsl:apply-templates select="." mode="va"/>
    </emphasis>
  </xsl:template>


  <xsl:template match="inline" mode="va">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="inline[@vertical-alignment]" mode="va">
    <xsl:element name="{@vertical-alignment}">
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>




</xsl:stylesheet>



$ saxon inline.xml inline.xsl
<?xml version="1.0" encoding="utf-8"?>
<inline>
   <emphasis format="italic">
      <emphasis format="small-caps">
         <emphasis format="bold">
            <superscript>text</superscript>
         </emphasis>
      </emphasis>
   </emphasis>
</inline>

Current Thread