Creating an XSLT stylesheet for a Polyrex document

require 'polyrex'

polyrex = Polyrex.new 'month[name]/week[no]/day[x,wday]'
xslt = polyrex.xslt_schema('table[caption:name]/tr/td[div:x,div,div:event]').to_xslt

The Polyrex#to_xslt method accepts an XSLT Polyrex schema toprimarily create an XSLT template to generate an HTML document.

xslt output: ...

<xsl:template match='month'>
  <table>
    <xsl:apply-templates select='summary'/>
  <\table>
</xsl:template>  


<xsl:template match='month/summary'>
    <caption><xsl:value-of select='name'/></caption>
</xsl:template>


<xsl:template match='records/week'>
  <tr>
    <xsl:apply-templates select='summary'/>
    <xsl:apply-templates select='records'/>
  <\tr>
</xsl:template>


<xsl:template match='week/summary'>
</xsl:template>


<xsl:template match='records/day'>
  <td>
    <xsl:apply-templates select='summary'/>
  <\td>
</xsl:template>  


<xsl:template match='day/summary'>
    <div><xsl:value-of select='x'/></div>
    <div><xsl:value-of select='div'/></div>
    <div><xsl:value-of select='event'/></div>
</xsl:template>  


 </xsl:stylesheet>

Hopefully it makes it more convenient to create XSLT templateson-the-fly.

Tags:
Source:
1913hrs.txt
Published:
08-06-2014 19:13