こんにちは私はxsltを書き込もうとしています。以下のような同様の入力が与えられた場合は、必要な出力を得る必要があります。あなたが見た場合、出力には、そのXML内の要素の出現に基づくIDがあります。これまでの私のxsltでは、私はその位置に基づいてそれをやっています。それは入力XMLからすべてをカウントし、カウントを再開します。これを達成できるか?入力の要素の出現に基づいて出力の要素値をインクリメント
更新:
入力にいくつかの詳細を追加します。ご覧のとおり、私はレベルの下に追加され、それは、それぞれのデータのすべて
入力XML
<lines>
<line>
<po-num>text1</ponum>
<accountings>
<accounting>
<account>
<seg1>value1</seg1>
</account>
</accounting>
<accounting>
<account>
<seg1>value2</seg1>
</account>
</accounting>
</accountings>
</line>
<line>
<po-num>text2</ponum>
<accountings>
<accounting>
<account>
<seg1>value3</seg1>
</account>
</accounting>
</accountings>
</line>
<line>
<po-num>text3</ponum>
<account>
<seg1>value4</seg1>
</account>
</line>
</lines>
所望の出力XML
<Item>
<id>1</id>
<po-num>text1</ponum>
<seg>value1</seg>
</Item>
<Item>
<id>2</id>
<po-num>text1</ponum>
<seg>value2</seg>
</Item>
<Item>
<id>3</id>
<po-num>text2</ponum>
<seg>value3</seg>
</Item>
<Item>
<id>4</id>
<po-num>text3</ponum>
<seg>value4</seg>
</Item>
に取り込まれるべきXSLT I Rupeshが提供するxsltを使用しています。
<?xml version="2.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"></xsl:output>
<xsl:template match = "/">
<xsl:for-each select="//account">
<item>
<id><xsl:value-of select="position()"/></id>
<po-num><xsl:value-of select="../../../*:po-num"/></po-num>
<seg><xsl:value-of select="./*:seg1"></xsl:value-of></seg>
</item>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
で変換を見ることができますか?申し訳ありませんが、StackOverflowは既存のプログラミングコードを修正する手助けをしています。チュートリアル、リサーチ、ツール、推奨事項、図書館、およびフリーコードのリクエストは、話題にはなりません。 *** ***を読んでください。https://stackoverflow.com/help/on-topic、https://stackoverflow.com/help/how-to-ask、https://stackoverflow.com/help/dont- https://stackoverflow.com/help/mcveに問い合わせて、ここにQを投稿する前に[ツアー](https://stackoverflow.com/tour)に行ってください。がんばろう。 – shellter
こんにちは、実際のコードを共有することはできません。上記のサンプル入力をサポートするサンプルXSLTコードを作成してみます。コードのほんの一部です。上記の状況はその中に小さなモジュールです。 –