Skip to content

Instantly share code, notes, and snippets.

@ethangardner
Created June 28, 2011 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ethangardner/1052532 to your computer and use it in GitHub Desktop.
Save ethangardner/1052532 to your computer and use it in GitHub Desktop.
XSL Restaurant Menu 3
<xsl:template name="section" match="menu/section">
<!-- This begins a new template called "section." Providing a name
attribute for a template helps with code organization and also
allows the template to be explicitly called by another template.
Remember our XML structure. The match statement will apply the
template to the all of the section tags which are children of the
menu tag.
-->
<h2><xsl:value-of select="@name" /></h2>
<!-- The :value-of function will output a value based on the select
statement. The "@name" selects the name attribute of the matched
tag, in this case the section tag from our XML file.
-->
<p><xsl:value-of select="summary" /></p>
<!-- This will apply the template to the summary tag. Since this
statement occurs inside of a template matched to menu/section,
the select statement is looking for summary tags that is a child
of section and a grandchild of menu.
-->
<dl>
<xsl:apply-templates select="item" />
<!-- This will apply the template to the item tag. -->
</dl>
</xsl:template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment