home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 October / INTERNET108.ISO / pc / software / windows / building / xmlspy / xmlspyentcomplete5.exe / Data1.cab / _EEC29B420E2146C0BCDB53ACC66D82D7 < prev    next >
Encoding:
Extensible Markup Language  |  2002-09-20  |  2.1 KB  |  49 lines

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2.  
  3. <!--  specialize.xsl 1.0; 14 June 2001
  4.  | Convert "generalized" DITA topics back into specialized form
  5.  |
  6.  | Copyright IBM Corporation, 2001
  7.  | This file is part of the DITA package on IBM's developerWorks site.
  8.  | See license.txt for disclaimers.
  9.  +======================================
  10.  | 2002/05/09 - modified the stylesheet for new class attribute separation token - es
  11.  *-->
  12.  
  13. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  14.      <xsl:output method="xml" indent="no"/>
  15.      <!--Find the class attribute within the XML instance document. -->
  16.      <xsl:template match="*[@class]">
  17.           <xsl:call-template name="specialize">
  18.                <xsl:with-param name="class" select="@class"/>
  19.           </xsl:call-template>
  20.      </xsl:template>
  21.      <!--Look for the last class definition, i.e, task/steps. Replace existing generalized element name
  22.       with specialized element name -->
  23.      <xsl:template name="specialize">
  24.           <xsl:param name="class"/>
  25.           <xsl:choose>
  26.                <xsl:when test="contains(normalize-space($class),' ')">
  27.                     <xsl:call-template name="specialize">
  28.                          <xsl:with-param name="class" select="substring-after($class,' ')"/>
  29.                     </xsl:call-template>
  30.                </xsl:when>
  31.                <xsl:otherwise>
  32.                     <xsl:variable name="element_name" select="substring-after(normalize-space($class),'/')" />
  33.                          <xsl:element name="{$element_name}">
  34.                                    <xsl:copy-of select="@*[local-name() != 'class']"/>
  35.                               <xsl:apply-templates/>
  36.                          </xsl:element>
  37.                </xsl:otherwise>
  38.           </xsl:choose>
  39.      </xsl:template>
  40.     <!--pick up everything from the element -->
  41.      <xsl:template match="*|@*|comment()|processing-instruction()|text()">
  42.        <xsl:copy>
  43.          <xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()"/>
  44.        </xsl:copy>
  45.      </xsl:template>
  46.  
  47. </xsl:stylesheet>
  48.  
  49.