Skip to content

Instantly share code, notes, and snippets.

@maizy
Created January 29, 2015 15:57
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 maizy/aae9424cb881274126ae to your computer and use it in GitHub Desktop.
Save maizy/aae9424cb881274126ae to your computer and use it in GitHub Desktop.
xsl:param with nodeset
<html><body>
<h1>call 1</h1>
<div class="param1_content"><p><a href="http://example.com/">hello</a></p></div>
<h1>call 2 with param</h1>
<div class="param1_content">
oh no!
</div>
<h1>call 3 with param and value-of and apply-template</h1>
<div class="param1_content">
<b>Hello</b><b>world</b>
apply:
var: world</div>
</body></html>
<?xml version="1.0" encoding="utf-8"?>
<doc>
<var>world</var>
</doc>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="uni-name">
<xsl:param name="param1">
<p><a href="http://example.com/">hello</a></p>
</xsl:param>
<div class="param1_content">
<xsl:copy-of select="$param1"/>
</div>
</xsl:template>
<xsl:template match="doc">
<html>
<body>
<h1>call 1</h1>
<xsl:call-template name="uni-name"/>
<h1>call 2 with param</h1>
<xsl:call-template name="uni-name">
<xsl:with-param name="param1">
oh no!
</xsl:with-param>
</xsl:call-template>
<h1>call 3 with param and value-of and apply-template</h1>
<xsl:call-template name="uni-name">
<xsl:with-param name="param1">
<b>Hello</b>
<b><xsl:value-of select="var"/></b>
apply: <xsl:apply-templates select="." mode="inline"/>
</xsl:with-param>
</xsl:call-template>
</body>
</html>
</xsl:template>
<xsl:template match="doc" mode="inline">
var: <xsl:value-of select="var"/>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment