Xslt 2.0 如何在xslt中拆分和打印值?
我想创建一个xslt(版本2),其中可以使用delimeter“:”分割值,只打印分割的第一部分,并将第二部分存储到变量中。这些值必须传递给“学生”标记。以下是从db获取的值 亚当:101 布拉德:110 乍得:111 预期产出: 亚当 布拉德 查德 值101、110和111必须存储到变量中Xslt 2.0 如何在xslt中拆分和打印值?,xslt-2.0,Xslt 2.0,我想创建一个xslt(版本2),其中可以使用delimeter“:”分割值,只打印分割的第一部分,并将第二部分存储到变量中。这些值必须传递给“学生”标记。以下是从db获取的值 亚当:101 布拉德:110 乍得:111 预期产出: 亚当 布拉德 查德 值101、110和111必须存储到变量中 还请提供详细的xslt2.0教程链接。只需使用fn:tokenize()即可实现以下输出: 假设输入: <student>Adam:101 Brad:110 Chad:111</stude
还请提供详细的xslt2.0教程链接。只需使用fn:tokenize()即可实现以下输出: 假设输入:
<student>Adam:101 Brad:110 Chad:111</student>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
version="2.0">
<xsl:output indent="yes"/>
<xsl:template match="/">
<students>
<xsl:apply-templates/>
</students>
</xsl:template>
<xsl:template match="student">
<xsl:for-each select="tokenize(., ' ')">
<student variable="{substring-after(., ':')}">
<xsl:value-of select="substring-before(., ':')"/>
</student>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Adam:101布拉德:110查德:111
XSLT:
<student>Adam:101 Brad:110 Chad:111</student>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
version="2.0">
<xsl:output indent="yes"/>
<xsl:template match="/">
<students>
<xsl:apply-templates/>
</students>
</xsl:template>
<xsl:template match="student">
<xsl:for-each select="tokenize(., ' ')">
<student variable="{substring-after(., ':')}">
<xsl:value-of select="substring-before(., ':')"/>
</student>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
输出:
<?xml version="1.0" encoding="UTF-8"?>
<students>
<student variable="101">Adam</student>
<student variable="110">Brad</student>
<student variable="111">Chad</student>
</students>
亚当
布拉德
查德
链接: