【发布时间】:2014-04-24 10:23:38
【问题描述】:
我有一个简单的 XML 文件,我需要为它更新一个属性值(应该足够简单)。尽管复制了其他有效的示例,但我收到错误消息“无法在包含元素的子元素之后创建属性节点 (LastUpdateDate)”。谁能发现我做错了什么或提出替代方法?
我的 XML 是:
<Root>
<Datasource Name="SCV">
<Datafeed FeedMask="yyyyMMdd_Individual" LastUpdateDate="20140401"/>
<Datafeed FeedMask="yyyyMMdd_MarketingPreferences" LastUpdateDate="20140401"/>
</Datasource>
</Root>
我的 XSL 是:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/Root/Datasource[@Name='SCV']/Datafeed[@FeedMask='yyyyMMdd_Individual']">
<xsl:attribute name="LastUpdateDate"><xsl:value-of select="20140402"/> </xsl:attribute>
</xsl:template>
</xsl:transform>
感谢您的帮助,
史蒂夫
【问题讨论】:
标签: xslt