2013-08-01 85 views
1

例如,有一個XML:如何通過xsl中的條件獲得下一個節點?

<?xml version="1.0" encoding="utf-8"?> 
<root> 
    <row> 
     <Type>1</Type> 
     <WeaNr_ArtNr>100027</WeaNr_ArtNr> 
     <UID>101114557945</UID> 
    </row> 
    <row> 
     <Type>2</Type> 
     <WeaNr_ArtNr>2000311</WeaNr_ArtNr> 
     <UID>101114557945</UID> 
     <UnitQuantity>10</UnitQuantity> 
    </row> 
    <row> 
     <Type>1</Type> 
     <WeaNr_ArtNr>100027</WeaNr_ArtNr> 
     <UID>101114557946</UID> 
    </row> 
<row> 
    <Type>2</Type> 
    <WeaNr_ArtNr>2000312</WeaNr_ArtNr> 
    <UID>101114557946</UID> 
    <UnitQuantity>10</UnitQuantity> 
</row> 
    <row> 
     <Type>1</Type> 
     <WeaNr_ArtNr>55555</WeaNr_ArtNr> 
     <UID>101114558000</UID> 
    </row> 
    <row> 
     <Type>2</Type> 
     <WeaNr_ArtNr>200053155555</WeaNr_ArtNr> 
     <UID>101114558000</UID> 
     <UnitQuantity>1</UnitQuantity> 
    </row> 
    <row> 
     <Type>1</Type> 
     <WeaNr_ArtNr>55555</WeaNr_ArtNr> 
     <UID>101114558001</UID> 
    </row> 
    <row> 
     <Type>2</Type> 
     <WeaNr_ArtNr>200053255555</WeaNr_ArtNr> 
     <UID>101114558001</UID> 
     <UnitQuantity>1</UnitQuantity> 
    </row> 
     <row> 
     <Type>1</Type> 
     <WeaNr_ArtNr>100023</WeaNr_ArtNr> 
     <UID>101114557989</UID> 
    </row> 
    <row> 
     <Type>2</Type> 
     <WeaNr_ArtNr>2000274</WeaNr_ArtNr> 
     <UID>101114557989</UID> 
     <UnitQuantity>14</UnitQuantity> 
    </row> 
    <row> 
     <Type>1</Type> 
     <WeaNr_ArtNr>100023</WeaNr_ArtNr> 
     <UID>101114557990</UID> 
    </row> 
    <row> 
     <Type>2</Type> 
     <WeaNr_ArtNr>2000275</WeaNr_ArtNr> 
     <UID>101114557990</UID> 
     <UnitQuantity>23</UnitQuantity> 
    </row> 
</root> 

通過了解WeaNr_ArtNr值情況下Type='1'我想回到下一個節點

例如,對於WeaNr_ArtNr='100027「我想獲得這些節點:

<row> 
    <Type>2</Type> 
    <WeaNr_ArtNr>2000311</WeaNr_ArtNr> 
    <UID>101114557945</UID> 
    <UnitQuantity>10</UnitQuantity> 
</row> 
<row> 
    <Type>2</Type> 
    <WeaNr_ArtNr>2000312</WeaNr_ArtNr> 
    <UID>101114557946</UID> 
    <UnitQuantity>10</UnitQuantity> 
</row> 

因爲這些節點正在追加節點時WeaNr_ArtNr='100027'

我已經試過這樣的事情

/root/row[WeaNr_ArtNr='100023']/preceding::row[WeaNr_ArtNr!='100023'] 

,但它不工作...

回答

1

所以,你要的行立即有WeaNr_ArtNr='100027'每一行以下?那麼怎麼樣

/root/row[WeaNr_ArtNr='100027']/following-sibling::row[1]