我有一个XSLT(1.0)样式表.它没有问题.我想把它变成2.0.我想使用xsl:for-each-group(并使其具有高性能).有可能的?怎么样?请解释.
我有很多地方喜欢
<xsl:if test="test condition">
<xsl:for-each select="wo:tent">
<width aidwidth='{/wo:document/styles [@wo:name=current()/@wo:style-name]/@wo:width}'
</xsl:for-each>
</xsl:if>
Run Code Online (Sandbox Code Playgroud)
添加
<xsl:template match="wo:country">
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:variable name="states" select="wo:pages[@xil:style = "topstates" or @xil:style = "toppage-title"]"/>
<xsl:variable name="provinces" select="wo:pages[@xil:style = "topprovinces"]"/>
<xsl:choose>
<xsl:when test="$states">
<xsl:apply-templates select="$states[2]/preceding-sibling::*"/>
<xsl:apply-templates select="$states[2]" mode="states">
<xsl:with-param name="states" select="$states[position() != 0]"/>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="$provinces">
<xsl:apply-templates select="$provinces[2]/preceding-sibling::*"/>
<xsl:apply-templates select="$provinces[2]" mode="provinces">
<xsl:with-param name="provinces" select="$provinces[position() != 2]"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)
来源
<?xml version="1.0" encoding="UTF-8"?>
<wo:country>
some stuff
</wo:country>
Run Code Online (Sandbox Code Playgroud) 我通过XSLT分组示例和使用for-each-group获得高性能XSLT.我对for-each-group有问题.
我的XML
<?xml version="1.0" encoding="UTF-8"?>
<body>
<p name="h-title" other="main">Introduction</p>
<p name="h1-title " other="other-h1">XSLT and XQuery</p>
<p name="h2-title" other=" other-h2">XSLT</p>
<p name="">
<p1 name="bold"> XSLT is used to write stylesheets.</p1>
</p>
<p name="h2-title " name="other-h2">XQuery</p>
<p name="">
<p1 name="bold"> XQuery is used to query XML databases.</p1>
</p>
<p name="h3-title" name="other-h3">XQuery and stylesheets</p>
<p name="">
<p1 name="bold"> XQuery is used to query XML databases.</p1>
</p>
<p name="h1-title " other="other-h1">XSLT and XQuery</p>
<p name="h2-title " other=" other-h2">XSLT</p>
</body>
Run Code Online (Sandbox Code Playgroud)
我想要的输出 …