Matching Children

Matching Children

You can use the / step operator to separate element names when you want to refer to a child of a particular node. For example, say that you want to create a rule that applies to only those < NAME > elements that are children of <PLANET> elements. In that case, you can match the expression "PLANET/NAME" . Heres a rule that surrounds the text of such elements in a <H3> HTML element:

 <xsl:template match="PLANET/NAME">      <H3>           <xsl:value-of select="."/>      </H3>  </xsl:template> 

You also can use the * character as a wildcard, standing for any element. (* can match only elements, although note that the pattern @* can match any attribute.) For example, the following rule applies to all <NAME> elements that are grandchildren of <PLANET> elements:

 <xsl:template match="PLANET/*/NAME">      <H3>          <xsl:value-of select="."/>      </H3>  </xsl:template> 


Inside XSLT
Inside Xslt
ISBN: B0031W8M4K
EAN: N/A
Year: 2005
Pages: 196

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net