Skip to content

Instantly share code, notes, and snippets.

@georgebashi
Created September 5, 2012 08:57
Show Gist options
  • Save georgebashi/3633638 to your computer and use it in GitHub Desktop.
Save georgebashi/3633638 to your computer and use it in GitHub Desktop.
XQuery and XSLT intro
<hello>
<person name="edd" />
<person name="chrisp" />
</hello>
<html>
<p>hello, these are my friends:</p>
<ul>{
for $person in //person
let $name := $person/@name
return <li>{string($name)}</li>
}</ul>
</html>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="person">
<li>
<xsl:value-of select="@name"/>
</li>
</xsl:template>
<xsl:template match="hello">
<ul>
<xsl:apply-templates/>
</ul>
</xsl:template>
<xsl:template match="/">
<html>
<p>
<xsl:text>hello, these are my friends:</xsl:text>
</p>
<xsl:apply-templates/>
</html>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment