2016-03-25 8 views
0

XSDの同じレベルにある複数の入力をカンマ区切り値としてターゲット要素にマップしようとしています。エラーコードのような他の要素を、ERRORTYPEは同じままにしてください..私はそれらを使用しています - これは出力コンマで区切られた単一の出力レスポンス要素に複数の入力要素をマップします

<output>error1,error2,error3,error4</output> 

ますのでご注意ください

<Errors> <error> <errorcode>code</errorcode> <errortype>type</errortype> <paramater1>error1</paramater1> <paramater2>error2</paramater2> <paramater3/>error3</paramater3> <paramater4/>error4</paramater4> <error> <Errors> 

入力構造

XSLT 1.0でなんとかですすることができます他のマッピングでは

答えて

0

あなたはこれらのテンプレートを使用して試すことができます:

<xsl:template match="error"> 
    <xsl:copy> 
     <!-- apply identity transform for child elements which name doesn't start with 'parameter' --> 
     <xsl:apply-templates select="*[not(starts-with(name(), 'paramater'))]"/> 

     <!-- output comma-separated value from child elements which name start with 'parameter' --> 
     <output> 
      <xsl:for-each select="*[starts-with(name(), 'paramater')]"> 
       <xsl:value-of select="."/> 
       <xsl:if test="position() &lt; last()"> 
        <xsl:text>,</xsl:text> 
       </xsl:if> 
      </xsl:for-each> 
     </output> 
    </xsl:copy> 
</xsl:template> 

<!-- identity template --> 
<xsl:template match="@*|node()"> 
    <xsl:copy> 
     <xsl:apply-templates select="@*|node()"/> 
    </xsl:copy> 
</xsl:template> 
関連する問題