Project

rx_sliml

0.0
Low commit activity in last 3 years
No release in over a year
Generates an XML stylesheet or HTML string from a RecordX object.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.0, >= 1.0.1
~> 1.11, >= 1.11.1
 Project Readme

Using the Rx_sliml gem to create an XML stylesheet from a RecordX object

require 'rx_sliml'
require 'dynarex'

s = <<EOF
dl
  dt from:
  dd $from

  dt to:
  dd $to

  dt subject:
  dd $subject
EOF


s2 =<<EOF
&lt;?dynarex schema='email[title]/messages(from, to, subject)' delimiter='#'?&gt;
title: Email for James
-----------------------

abc@ruby132.org     # james@jamesrobertson.eu # test 123
info@gtdtoday.co.uk # james@jamesrobertson.eu # How to plan ahead (newsletter)
a123456@aol.com     # info@jamesrobertson.eu  # hello

EOF


dx = Dynarex.new.import(s2)

r = RxSliml.new(s, dx.all[2]).to_xslt

Output:

<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
  <xsl:output method='xml' indent='yes' omit-xml-declaration='yes'/>
  <xsl:template match='kvx'>
    <html>
      <head>
        <title>
          <xsl:value-of select='summary/title'/>
        </title>
      </head>
      <body>
        <header>
          <xsl:apply-templates select='summary'/>
        </header>
        <main>
          <xsl:apply-templates select='body'/>
        </main>
      </body>
    </html>
  </xsl:template>
  <xsl:template match='kvx/summary'>
    <dl>
      <xsl:for-each select='*'>
        <dt>
          <xsl:value-of select='name()'/>
        </dt>
        <dd>
          <xsl:value-of select='.'/>
        </dd>
      </xsl:for-each>
    </dl>
  </xsl:template>
  <xsl:template match='body'>
    <dl>
  <dt>from:</dt>
  <dd><xsl:value-of select="from"/></dd>
  <dt>to:</dt>
  <dd><xsl:value-of select="to"/></dd>
  <dt>subject:</dt>
  <dd><xsl:value-of select="subject"/></dd>
</dl>
  </xsl:template>
</xsl:stylesheet>

Resources

rx_sliml kvx recordx xslt