Ecco un 8 anni FXSL 1.x (un XSLT 1.0 soluzione di libray scritta completamente in XSLT 1.0):
test-strSplit-to-Words 10.xsl:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ext="http://exslt.org/common"
>
<xsl:import href="strSplitWordDel.xsl"/>
<!-- To be applied on: test-strSplit-to-Words10.xml -->
<xsl:output indent="yes" omit-xml-declaration="yes"/>
<xsl:variable name="vLower"
select="'abcdefgijklmnopqrstuvwxyz'"/>
<xsl:variable name="vUpper"
select="'ABCDEFGIJKLMNOPQRSTUVWXYZ'"/>
<xsl:template match="/">
<xsl:variable name="vwordNodes">
<xsl:call-template name="str-split-word-del">
<xsl:with-param name="pStr" select="/"/>
<xsl:with-param name="pDelimiters"
select="', .(	 '"/>
</xsl:call-template>
</xsl:variable>
<xsl:apply-templates select="ext:node-set($vwordNodes)/*"/>
</xsl:template>
<xsl:template match="word">
<xsl:choose>
<xsl:when test="not(position() = last())">
<xsl:value-of
select="translate(substring(.,1,1),$vLower,$vUpper)"/>
<xsl:value-of select="substring(.,2)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="delim">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
Quando questa trasformazione viene applicata sul seguente documento XML (test-strSplit-to-Words10.xml):
<t>004.lightning crashes (live).mp3</t>
il risultato è:
004.Lightning Crashes (Live).mp3
Quando applicata a questo documento XML (il campione in dotazione):
dInEsh sAchdeV kApil Muk
il risultato è :
DInEsh SAchdeV KApil Muk
Con un po Tweek, otteniamo questo codice:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ext="http://exslt.org/common"
>
<xsl:import href="strSplitWordDel.xsl"/>
<!-- To be applied on: test-strSplit-to-Words10.xml -->
<xsl:output indent="yes" omit-xml-declaration="yes"/>
<xsl:variable name="vLower"
select="'abcdefgijklmnopqrstuvwxyz'"/>
<xsl:variable name="vUpper"
select="'ABCDEFGIJKLMNOPQRSTUVWXYZ'"/>
<xsl:template match="/">
<xsl:variable name="vwordNodes">
<xsl:call-template name="str-split-word-del">
<xsl:with-param name="pStr" select="/"/>
<xsl:with-param name="pDelimiters"
select="', .(	 '"/>
</xsl:call-template>
</xsl:variable>
<xsl:apply-templates select="ext:node-set($vwordNodes)/*"/>
</xsl:template>
<xsl:template match="word">
<xsl:value-of
select="translate(substring(.,1,1),$vLower,$vUpper)"/>
<xsl:value-of select="translate(substring(.,2), $vUpper, $vLower)"/>
</xsl:template>
<xsl:template match="delim">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
che ora produce il risultato voluto:
Dinesh Sachdev Kapil Muk
Spiegazione:
Il str-split-word-del
modello di FXSL può essere utilizzato per la tokenizzazione con (possibilmente più di uno) delimitatori specificati come parametro stringa.
fonte
2012-10-29 22:52:58
OP ha il tag 'xslt-1.0' ...' inferiore case' e 'maiuscole 'non è disponibile in 1.0 – freefaller
@freefaller Ooh, mancato quello. Cambiare risposta per riflettere questo per riferimento futuro. Grazie! – Kris