[英]convert XSLT 2.0 to 1.0
我在 XSLT 2.0 中有以下解决方案
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/rows">
<xsl:copy>
<xsl:for-each-group select="row" group-starting-with="row[item='****************']">
<xsl:variable name="title-item" select="preceding-sibling::row[1]/item" />
<xsl:for-each select="current-group()[starts-with(item[1], '#')]">
<row>
<xsl:copy-of select="$title-item, *"/>
</row>
</xsl:for-each>
</xsl:for-each-group>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
XSLT 1.0 不支持for-each-group
我想把它转换成XSLT 1.0版本。
声明例如
<xsl:key name="group" match="row[not(item = '****************')]" use="generate-id(preceding-sibling::row[item='****************'][1])"/>
作为顶级元素,然后代替<xsl:for-each-group select="row" group-starting-with="row[item='****************']">
试试
<xsl:for-each select="row[item='****************']">
<xsl:variable name="group" select="key('group', generate-id())"/>
<xsl:variable name="title-item" select="preceding-sibling::row[1]/item" />
<xsl:for-each select="$group[starts-with(item[1], '#')]">
<row>
<xsl:copy-of select="$title-item | *"/>
</row>
</xsl:for-each>
</xsl:for-each>
但是我们确实需要查看一些输入样本结构以及想要的结果。 尽管我尝试编写 XSLT 1,但我可能会忽略一些 XSLT/XPath 2 唯一的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.