1<?xml version="1.0"?> 2 3<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 4 5<xsl:output encoding="utf-8"/> 6 7<xsl:template match="top"> 8 <TOP> 9 <xsl:apply-templates/> 10 </TOP> 11</xsl:template> 12 13<xsl:template match="bar[baz or following-sibling::*[1][self::nar]]"> 14 <BAR><xsl:value-of select="."/></BAR> 15</xsl:template> 16 17<xsl:template match="foo[following-sibling::*[position()<=2][self::barg] and 18 following-sibling::*[position()<=2][self::nar]]"> 19 <FOO><xsl:value-of select="."/></FOO> 20</xsl:template> 21</xsl:stylesheet> 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40