2017-03-02 4 views
1

ファイル私たちはそう上記の取り込みノードが

<charac> 
    <charactername> 
    <charactervalue> 
    </charac> 

のようにセグメントの下になっている入力ペイロードで

以下のように入力values.the要件に基づいて一つのセグメントを移入する必要がありますセグメントは複数回来るかもしれませんが、いくつかの値に基づいて、たとえばセグメントを設定するだけで済みます。

 <charac> 
    <charactername>print</charactername> 
    <charactervalue>123</charactervalue> 
    </charac> 

    <charac> 
    <charactername>comp</charactername> 
    <charactervalue>1234</charactervalue> 
    </charac> 

    <charac> 
    <charactername>pal</charactername> 
    <charactervalue>1235</charactervalue> 
    </charac> 

したがって、ここでは、私は

のみプリント又はCOMPに等しい受信機構造セグメントは

<e1edl1> 
    <at> 
    <rt> 
    </e1edl1> 

あるので、出力は

<e1edl1> 
    <at>print</at> 
    <rt>123</rt> 
    </e1edl1> 

    <e1edl1> 
    <at>comp</at> 
    <rt>1234</rt> 
    </e1edl1> 

ようにする必要があり、私は以下のコードで

を試し
<ns0:if test="count(./charac)!=0"> 
<ns0:for-each select="./charac"> 
<e1edl1 SEGMENT="1"> 
<at> 
    <ns0:value-of select="charactername" /> 
    </at> 
    <rt> 
    <ns0:value-of select="charactervalue" /> 
    </rt> 
    </e1edl1> 
    </ns0:for-each> 
</ns0:if> 

でこれを助けてくれますか?

よろしく、 Janardhan

+0

はあなたが現在試みているすべてのXSLTを表示するには、あなたの質問を編集してくださいことはできますか?ありがとうございました! –

+0

申し訳ありませんTim、私はこのxsltコードを初めて使っていますが、正しい構文を試しましたが、私は得ることができません。私はあなたの助けが必要です。 –

+0

私はいくつかのコードを追加しましたが、条件に基づいて移入することができません。 –

答えて

0
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:strip-space elements="*"/> 
<xsl:output omit-xml-declaration="yes" indent="yes"/> 


<xsl:template match="/"> 
<xsl:apply-templates select="//charac[charactername='print' or charactername='comp']" /> 
</xsl:template> 


<xsl:template match="charac"> 
    <e1edl1> 
     <at><xsl:value-of select="charactername" /></at> 
     <rt><xsl:value-of select="charactervalue" /></rt> 
    </e1edl1> 
</xsl:template> 


</xsl:stylesheet>