<amendment/>
要素の場合は、<sectionid/>
,<amendmenttext/>
および<sponsor/>
という要素がある場合はそれを取得する必要があります。ここXSLTで前の兄弟のグループを取得する
は一例であり:
から:
<root>
<amendment>
<id>1</id>
<text>some text</text>
</amendment>
<sectionid>A</sectionid>
<sponsor>jon</sponsor>
<sponsor>peter</sponsor>
<amendment>
<id>8</id>
<text>some text</text>
</amendment>
<sectionid>B</sectionid>
<sponsor>matt</sponsor>
<sponsor>ben</sponsor>
<amendmenttext>some intro text</amendmenttext>
<amendment>
<id>5</id>
<text>some text</text>
</amendment>
<amendment>
<id>4</id>
<text>some text</text>
</amendment>
<sponsor>max</sponsor>
<amendment>
<id>6</id>
<text>some text</text>
</amendment>
<amendment>
<id>7</id>
<text>some text</text>
</amendment>
</root>
に:
<root>
<amendment>
<id>1</id>
<text>some text</text>
</amendment>
<amendment>
<sectionid>A</sectionid>
<sponsor>jon</sponsor>
<sponsor>peter</sponsor>
<id>8</id>
<text>some text</text>
</amendment>
<amendment>
<sectionid>B</sectionid>
<sponsor>matt</sponsor>
<sponsor>ben</sponsor>
<amendmenttext>some intro</amendmenttext>
<id>5</id>
<text>some text</text>
</amendment>
<amendment>
<sectionid>B</sectionid>
<sponsor>matt</sponsor>
<sponsor>ben</sponsor>
<id>4</id>
<text>some text</text>
</amendment>
<amendment>
<sectionid>B</sectionid>
<sponsor>max</sponsor>
<id>6</id>
<text>some text</text>
</amendment>
<amendment>
<sectionid>B</sectionid>
<sponsor>max</sponsor>
<id>7</id>
<text>some text</text>
</amendment>
</root>
注1:<sectionid/>
要素は次<sectionid/>
前に、すべての<amendments/>
に適用します注2:<sponsor/>
要素は、次の<sponsor/>
リストの前のすべての<amendments/>
に適用されます。
注3://amendment/id
の値は連続していません。
注4:<amendment/>
は、前の兄弟として<sponsor/>
または<sectionid/>
を持つことができませんでした。
注5:<amendmenttext>
のみに適用され、以下、この変換は、XSLT 1.0で行うことができますどのように<amendment/>
。
前の質問からの変更http://stackoverflow.com/questions/4096481/refactor-xml-with-xslはマイナーです。私はそれが新しい質問に値するとは思わない。 –
沖。解決策が似ていることを知らない。元の回答者が回答した後に質問の文脈を変更することは公正ではないと思った。しかし、要点。 –