0
比方說,我們有這個源XML:XSLT修改屬性值
<?xml version="1.0" encoding="UTF-8"?>
<SyncSupplierPartyMaster xmlns="http://schema.infor.com/InforOAGIS/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schema.infor.com/InforOAGIS/2 http://schema.infor.com/2.10.x/InforOAGIS/BODs/Developer/SyncSupplierPartyMaster.xsd" releaseID="9.2" versionID="2.10.x">
<DataArea>
<SupplierPartyMaster>
<Classification>
<Codes>
<Code listID="CLASS" sequence="1">3</Code>
<Code listID="CURRENCY" sequence="2">EUR</Code>
<Code listID="KVK" sequence="3">-</Code>
</Codes>
</Classification>
</SupplierPartyMaster>
</DataArea>
</SyncSupplierPartyMaster>
我需要改變類MROClass。我有這個XSL,哪個不起作用,有人能告訴我什麼是錯的?轉換也可以在:http://xsltransform.net/gWEamL8/1
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="http://schema.infor.com/InforOAGIS/2">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- Rename attribute Class to MROClass -->
<xsl:template match="@ListID[.='CLASS']">
<xsl:attribute name="ListID">
<xsl:value-of select="'MROClass'"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>