XSLT is a very powerful tool, but using it can be painful... even with zencoding.
Roughly I want a coffeescript for xslt, something that will compile for example
template test
params = {:foo => 'foo', :bar => 1}
<p>$foo, $bar</p>
end
call test :foo => 'oof', :bar => 2
into
<xsl:call-template name="test">
<xsl:with-param select="'oof'" name="foo"></xsl:with-param>
<xsl:with-param select="2" name="bar"></xsl:with-param>
</xsl:call-template>
<xsl:template name="test">
<xsl:param select="'foo'" name="foo" />
<xsl:param select="1" name="bar" />
<p><xsl:value-of select="$foo" />, <xsl:value-of select="$bar" /></p>
</xsl:template>
or something...
You may check XMLStarlet.
It can help you to generate XSL templates.
For example:
xml sel -C -t -c "xpath0" -m "xpath1" -m "xpath2" -v "xpath3" -t -m "xpath4" -c "xpath5"
will generate
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output omit-xml-declaration="yes" indent="no"/>
<xsl:template match="/">
<xsl:call-template name="t1"/>
<xsl:call-template name="t2"/>
</xsl:template>
<xsl:template name="t1">
<xsl:copy-of select="xpath0"/>
<xsl:for-each select="xpath1">
<xsl:for-each select="xpath2">
<xsl:value-of select="xpath3"/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template name="t2">
<xsl:for-each select="xpath4">
<xsl:copy-of select="xpath5"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With