XSL Split

<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" encoding="gb2312" indent="yes" method="xml"/>
<xsl:template match="/">
   <select id ="test1">
    <xsl:call-template name="split">
         <xsl:with-param name="strng" select="//string"/>
         <xsl:with-param name="p">,</xsl:with-param>
    </xsl:call-template>
    </select>
</xsl:template>

<xsl:template name="split">
   <xsl:param name="strng"/>
   <xsl:param name="p"/>
   <option><xsl:value-of select="substring-before($strng,$p)"/></option>

   <xsl:choose>
    <xsl:when test="contains(substring-after($strng,$p),$p)">
        <xsl:call-template name="split">
             <xsl:with-param name="strng" select="substring-after($strng,$p)"/>
             <xsl:with-param name="p" select="$p"/>
        </xsl:call-template>
    </xsl:when>
     <xsl:otherwise> <option><xsl:value-of select='substring-after($strng,$p)'/> </option></xsl:otherwise>
   </xsl:choose>
 
</xsl:template>
</xsl:stylesheet>

你可能感兴趣的:(xml,XSL)