Is there any language that compiles in xslt and simplifies its use and support

XSLT is a very powerful tool, but using it can be painful ... even with zencoding .

Roughly I need 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 

at

<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...

+5
source share
1 answer

You can check the XMLStarlet .

It can help you generate XSL templates.

For instance:

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>
+1
source

All Articles