home movie radio music chord lyrics book game Dictionary clip
HOME HAND MADE RADIO SHOP CHORD LYRICS BOOKS GAME Dictionary Clip
[ Team LiB ] Previous Section Next Section

9.6 The from Attribute

The from attribute was shown earlier in data.xsl. This attribute tells the XSLT processor the node where you want the counting to start from. Example 9-26, the stylesheet from.xsl, uses the from attribute.

Example 9-26. A stylesheet using from
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
   
<xsl:template match="outline">
 <xsl:for-each select="section|//item">
  <xsl:number from="section" level="multiple" count="section | item" format=" a "/>
  <xsl:value-of select="@title | text(  )"/>
  <xsl:text>&#10;</xsl:text>
 </xsl:for-each>
 <xsl:text>&#10; see http://www.usmint.gov and http://www.bep.treas.gov&#10;</xsl:text>
</xsl:template>
   
</xsl:stylesheet>

When you count using from="section", the processor counts the nodes after the section nodes in the source tree, that is, all the item nodes. The result of this is that item nodes are counted, but the section nodes are not, as Example 9-27 shows.

Example 9-27. A stylesheet for counting from section elements
US coin denominations
 a cent
 b nickel
 c dime
 d quarter
 e half dollar
 f dollar
Persons on US coins
 a Abraham Lincoln (cent)
 b Thomas Jefferson (nickel)
 c Franklin Roosevelt (dime)
 d George Washington (quarter)
 e John Kennedy (half dollar)
 f Sacagawea (dollar)
US currency in bills
 a $1 dollar bill
 b $2 dollar bill
 c $5 dollar bill
 d $10 dollar bill
 e $20 dollar bill
 f $50 dollar bill
 g $100 dollar bill
Persons on US bills
 a George Washington ($1)
 b Thomas Jefferson ($2)
 c Abraham Lincoln ($5)
 d Alexander Hamilton $10
 e Andrew Jackson ($20)
 f Ulysses Grant ($50)
 g Benjamin Franklin ($100)
   
 see http://www.usmint.gov and http://www.bep.treas.gov

Notice that no number precedes the section text (U.S. coin denominations and so forth). Now that you've seen several examples of multilevel numbering, I hope you can find at least one of them that meets your needs.

    [ Team LiB ] Previous Section Next Section