2017-04-08 12 views
1

を使用してXMLを変換:私は以下のようなXMLを持って

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<properties> 
<entry key="user">1234</entry> 
<entry key="name">sam</entry> 
</properties> 

私はキー値(キー=「CM:ユーザー」への鍵=「ユーザー」)を変換するXSLTを使用して、新しいXMLファイルに012:私はそれを実行すると

<xsl:stylesheet version="2.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:result-document href="foo.xml" method="xml"> 
    <xsl:copy> 
    <xsl:apply-templates select="@*|node()"/> 
    </xsl:copy> 
</xsl:result-document> 
</xsl:template> 

<xsl:template match="@key[.='user']"> 
<xsl:attribute name="key"> 
     <xsl:value-of select="'cm:user'"/> 
    </xsl:attribute> 
</xsl:template> 
</xsl:stylesheet> 

私は以下のエラーを取得しています:、出力XMLは、私は以下のXSLTとサクソンジャーを使用しています。この

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<properties> 
<entry key="cm:user">1234</entry> 
<entry key="name">sam</entry> 
</properties> 

ようにする必要があります
XTDE1490:同じURIに複数の結果文書書き込むことができません:あなたは結果を定義する場合
を誰かがこれで私を助けてもらえ..

答えて

3

をあなたは、単に

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> 

<xsl:template match="@key[.='user']"> 
<xsl:attribute name="key"> 
     <xsl:value-of select="'cm:user'"/> 
    </xsl:attribute> 
</xsl:template> 

    <xsl:template match="@*|node()"> 
     <xsl:copy> 
      <xsl:apply-templates select="@*|node()"/> 
     </xsl:copy> 
    </xsl:template> 
</xsl:transform> 

が必要ファイル名をxsl:result-documentを使用して入力してください。

<xsl:template match="/"> 
    <xsl:result-document href="foo.xml"> 
    <xsl:apply-templates/> 
    </xsl:result-document> 
</xsl:template> 
+0

素晴らしいです。マーティンホーネンに感謝します。 –

関連する問題