2016-10-22 7 views
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> 

答えて

1

XSLTは大文字と小文字を区別します。あなたのXML属性はlistIDですが、XSLTはListID(大文字のL)を探しています。

<xsl:template match="@listID[.='CLASS']"> 
    <xsl:attribute name="listID"> 
     <xsl:text>MROClass</xsl:text> 
    </xsl:attribute> 
</xsl:template> 

あるいは単に、この...あなたは本当にxsl:value-ofで出力テキストにする必要はありません

<xsl:template match="@listID[.='CLASS']"> 
    <xsl:attribute name="listID"> 
     <xsl:value-of select="'MROClass'"/> 
    </xsl:attribute> 
</xsl:template> 

、あなたがこれを行うことができます:

これにテンプレートを変更してみてください
<xsl:template match="@listID[.='CLASS']"> 
    <xsl:attribute name="listID">MROClass</xsl:attribute> 
</xsl:template> 
関連する問題