Created
January 29, 2015 15:57
-
-
Save maizy/aae9424cb881274126ae to your computer and use it in GitHub Desktop.
xsl:param with nodeset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<doc> | |
<var>world</var> | |
</doc> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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