Skip to content

Instantly share code, notes, and snippets.

@166MMX
Created May 13, 2014 17:28
Show Gist options
  • Save 166MMX/1d2246ebb670710c5bd5 to your computer and use it in GitHub Desktop.
Save 166MMX/1d2246ebb670710c5bd5 to your computer and use it in GitHub Desktop.
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:f="http://test.example"
exclude-result-prefixes="xsl xs fn f">
<xsl:variable name="in">
<node1>
<node2>
<node3>
<node4/>
</node3>
</node2>
</node1>
</xsl:variable>
<xsl:template match="/">
<out1>
<out2>
<xsl:apply-templates select="/" mode="m1"/>
</out2>
</out1>
</xsl:template>
<xsl:template match="/" mode="m1">
<out3>
<xsl:apply-templates select="$in/node1" mode="m2"/>
</out3>
</xsl:template>
<xsl:template match="node1" mode="m2">
<out4>
<xsl:apply-templates select="node2" mode="m2"/>
</out4>
</xsl:template>
<xsl:template match="node2" mode="m2">
<out5>
<xsl:apply-templates select="node3" mode="m2"/>
</out5>
</xsl:template>
<xsl:template match="node3" mode="m2">
<out6>
<out7>
<out8>
<out9>
<out10>
<out11>
<xsl:apply-templates select="node4" mode="m3"/>
</out11>
</out10>
</out9>
</out8>
</out7>
</out6>
</xsl:template>
<xsl:template match="node4" mode="m3">
<xsl:variable name="var1" select="f:fn1('')"/>
<xsl:value-of select="$var1"/>
</xsl:template>
<xsl:function name="f:fn1">
<xsl:param name="p1"/>
<xsl:variable name="var1" select="''"/>
<xsl:variable name="var2" select="f:fn2($p1)"/>
<xsl:sequence select="string-join(($var1, $var2), '')"/>
</xsl:function>
<xsl:function name="f:fn2">
<xsl:param name="p1"/>
<xsl:variable name="var1" select="''"/>
<xsl:variable name="var2" select="f:fn3($var1, '')"/>
<xsl:sequence select="$var2"/>
</xsl:function>
<xsl:function name="f:fn3">
<xsl:param name="p1"/>
<xsl:param name="p2"/>
<xsl:sequence select="f:fn3($p1, $p2, '')"/>
</xsl:function>
<xsl:function name="f:fn3">
<xsl:param name="p1"/>
<xsl:param name="p2"/>
<xsl:param name="p3"/>
<xsl:message terminate="yes">
<xsl:text>Happy needle hunting</xsl:text>
</xsl:message>
</xsl:function>
</xsl:stylesheet>
#!/bin/sh
if ! which brew > /dev/null
then
echo "ERROR: Missing homebrew" > /dev/stderr
fi
if ! which saxon > /dev/null
then
brew install saxon
fi
#/usr/local/bin/saxon
#/usr/local/opt/saxon/bin/saxon
saxon -xsl:missingCallStackFrame.xsl -s:missingCallStackFrame.xsl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment