如果从p元素处理指令节点开始,那么如何在p元素之前移动处理指令position1?- XSLT
输入
<root>
<p><?page 1?>aaaa bbbb <?page 2?>cccccc</p>
<p>aaaa <?page 3?>bbbb <?page 4?>ccccc</p>
</root>预期输出
<root>
<?page 1?><p>aaaa bbbb <?page 2?>cccccc</p>
<p>aaaa <?page 3?>bbbb <?page 4?>ccccc</p>
</root>XSLT
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="p[count(processing-instruction()) > 1]">
<xsl:apply-templates select="processing-instruction()[1]"/>
<xsl:copy>
<xsl:apply-templates select="node() except processing-instruction()[1]"/>
</xsl:copy>
</xsl:template>发布于 2020-10-23 08:42:35
解决了
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="p[count(processing-instruction()) > 1 and child::processing-instruction()[not(preceding-sibling::node())]]">
<xsl:apply-templates select="processing-instruction()[1]"/>
<xsl:copy>
<xsl:apply-templates select="node() except processing-instruction()[1]"/>
</xsl:copy>
</xsl:template>https://stackoverflow.com/questions/64496502
复制相似问题