如何为每个属性应用xslt?
我的XML文档如下所示-如何为每个属性应用xslt?,xslt,saxon,Xslt,Saxon,我的XML文档如下所示- <doc> <system_data> <registry_item id="1"> <hive>HKEY_LOCAL_MACHINE</hive> </registry_item> <file_item id="2"> <filepath>C:\Windows\System32\msasn1.dll</filepa
<doc>
<system_data>
<registry_item id="1">
<hive>HKEY_LOCAL_MACHINE</hive>
</registry_item>
<file_item id="2">
<filepath>C:\Windows\System32\msasn1.dll</filepath>
</file_item>
</system_data>
</doc>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Whenever you match any node or any attribute -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
尝试将
match=“//system\u data/*”
的模板更改为:
<xsl:template match="@id">
<xsl:attribute name="id">
<xsl:value-of select="number($newID)+count(preceding::*/@id)"/>
</xsl:attribute>
</xsl:template>
您是否能够帮助解决类似问题您好,您是否能够帮助解决类似问题
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Whenever you match any node or any attribute -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
An attribute node (id) cannot be created after the children of the containing element
<xsl:template match="@id">
<xsl:attribute name="id">
<xsl:value-of select="number($newID)+count(preceding::*/@id)"/>
</xsl:attribute>
</xsl:template>