繼樣式表有一個名爲令牌化模板,標記化基礎上通過分離器和每一個令牌字符串創建郵編元素:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template name="tokenize">
<xsl:param name="text"/>
<xsl:param name="separator" />
<xsl:choose>
<xsl:when test="not(contains($text, $separator))">
<Postalcode>
<xsl:value-of select="$text"/>
</Postalcode>
</xsl:when>
<xsl:otherwise>
<Postalcode>
<xsl:value-of select="normalize-space(substring-before($text, $separator))"/>
</Postalcode>
<xsl:call-template name="tokenize">
<xsl:with-param name="text" select="substring-after($text, $separator)"/>
<xsl:with-param name="separator" select="$separator"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="/Code">
<xsl:copy>
<xsl:variable name="tokenize">
<xsl:call-template name="tokenize">
<xsl:with-param name="text" select="."/>
<xsl:with-param name="separator" select="'|'"/>
</xsl:call-template>
</xsl:variable>
<xsl:copy-of select="$tokenize"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Lingamurthy嗨,你的代碼工程奇蹟: )。它給出了我正在尋找的確切輸出。萬分感謝!!! – user3478371