簡體   English   中英

將 XSLT 2.0 轉換為 1.0

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM