XML : XSLT Template Match 'middle' child

I am new to XSLT and was wandering how to match the 'middle' child/sibling nodes? (so basically all those which are not first or last)

For example, say i have the following xml....

  <FRUITS>    <FRUIT>Apple</FRUIT>    <FRUIT>Pear</FRUIT>     <!--I want to match this in a template-->    <FRUIT>Banana</FRUIT>   <!--I want to match this in a template-->    <FRUIT>..........</FRUIT>  </FRUITS>     

The example above is just a very short example of the xml i am working on. However in the real xml i will never know how many fruit siblings there are. So in other words i am looking to construct a statement that will identify if a node has following-siblings and preceding-siblings together. I have looked at the following but no joy as the syntax is not correct.....

  <xsl:template match="FRUIT[preceding-sibling::FRUIT*]/[following-sibling::FRUIT*]" />    

And also....

  <xsl:template match="FRUIT[preceding-sibling::FRUIT*] and [following-sibling::FRUIT*]" />    

This is using XSLT 1.0

Any help would be most appreciated

No comments:

Post a Comment