Tuesday, 31 January 2012

XSLT compatibility problem between XLAN and SAXON

When I'm implementing an XSLT to transform IRIS data dictionary items value (numbers, e.g. 02 08 etc) to descriptive texts for preview page, I found an incompatibility problem between XLAN and SAXON XSLT processor. It's mainly caused by the usage of tokenize funciton. The solution I found is:


<xsl:stylesheet version="1.0" 
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                  xmlns:iris="http://iris-database.org/iris"
                  xmlns:str="http://exslt.org/strings"
                  exclude-result-prefixes="xsl str">
......

      <xsl:choose>
        <!-- For XLAN -->
        <xsl:when test="function-available('str:tokenize')">
          <xsl:for-each select="str:tokenize(.,' ')">
            <xsl:variable name="currentType" select="."/>
            <xsl:if test=".!='999'">
              <iris:instrumentType><xsl:value-of select="$ddDoc/IRIS_Data_Dict/instrument/typeOfInstruments//type/@label[../@value=$currentType]"/></iris:instrumentType>
            </xsl:if>
            <xsl:if test=".='999'">
              <iris:instrumentType><xsl:value-of select="$newType"/></iris:instrumentType>
            </xsl:if>
          </xsl:for-each>
        </xsl:when>

        <!-- For SAXON -->
        <xsl:otherwise>  
          <xsl:for-each select="tokenize(.,' ')">
            <xsl:variable name="currentType" select="."/>
            <xsl:if test=".!='999'">
              <iris:instrumentType><xsl:value-of select="$ddDoc/IRIS_Data_Dict/instrument/typeOfInstruments//type/@label[../@value=$currentType]"/></iris:instrumentType>
            </xsl:if>
            <xsl:if test=".='999'">
              <iris:instrumentType><xsl:value-of select="$newType"/></iris:instrumentType>
            </xsl:if>
          </xsl:for-each>
        </xsl:otherwise>
      </xsl:choose>        



No comments:

Post a Comment