XML Tutorial/XSLT stylesheet/substring after — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 11:26, 26 мая 2010
Changing case of a text: substring-after() substring-before() translate()
<source lang="xml">
File: Data.xml <?xml version="1.0" encoding="utf-8"?> <citylist>
<distance city="A">1 HOURS</distance> <distance city="B">2 HOURS</distance> <distance city="C">30 MINUTES</distance> <distance city="D">HOURS HOURS</distance> <distance city="E">MINUTES MINUTES</distance>
</citylist> File: Transform.xslt <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet
version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="citylist">
<xsl:value-of select="@city"/> <xsl:text>=</xsl:text> <xsl:value-of select="substring-before(.," ")"/> <xsl:text/> <xsl:value-of select="translate(substring-after(.," "),"OURSINTE","oursinte")"/> |
</xsl:template>
</xsl:stylesheet> Output:
<?xml version="1.0" encoding="UTF-8"?>A=1Hours |
B=2Hours |
C=30Minutes |
D=HOURSHours |
E=MINUTESMinutes |