Project

dx_sliml

0.0
No commit activity in last 3 years
No release in over 3 years
Uses a Sliml like format to transform a Dynarex document to HTML.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 1.7.28, ~> 1.7
 Project Readme

Transforming a Dynarex document to HTML using the DxSliml gem

require 'dx_sliml'


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

  dt to:
  dd $to

  dt subject:
  dd $subject
EOF

s2 =<<EOF
<?dynarex schema='email[title]/messages(from, to, subject)' delimiter='#'?>
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


d = DxSliml.new s, Dynarex.new.import(s2)
puts d.to_xslt
puts d.to_html

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='email'>
    <html>
      <head>
        <title>Email for James</title>
      </head>
      <body>
        <header>
          <xsl:apply-templates select='summary'/>
        </header>
        <main>
          <xsl:apply-templates select='records/messages'/>
        </main>
      </body>
    </html>
  </xsl:template>
  <xsl:template match='email/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='records/messages'>
    <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>

HTML output:

<?xml version="1.0"?>
<html>
  <head>
    <title>Email for James</title>
  </head>
  <body>
    <header>
      <dl>
        <dt>title</dt>
        <dd>Email for James</dd>
        <dt>recordx_type</dt>
        <dd>dynarex</dd>
        <dt>format_mask</dt>
        <dd>[!from] [!to] [!subject]</dd>
        <dt>schema</dt>
        <dd>email[title]/messages(from, to, subject)</dd>
        <dt>default_key</dt>
        <dd>from</dd>
      </dl>
    </header>
    <main>
      <dl>
        <dt>from:</dt>
        <dd>abc@ruby132.org</dd>
        <dt>to:</dt>
        <dd>james@jamesrobertson.eu test 123</dd>
        <dt>subject:</dt>
        <dd/>
      </dl>
      <dl>
        <dt>from:</dt>
        <dd>info@gtdtoday.co.uk</dd>
        <dt>to:</dt>
        <dd>james@jamesrobertson.eu</dd>
        <dt>subject:</dt>
        <dd>How to plan ahead (newsletter)</dd>
      </dl>
      <dl>
        <dt>from:</dt>
        <dd>a123456@aol.com</dd>
        <dt>to:</dt>
        <dd>info@jamesrobertson.eu</dd>
        <dt>subject:</dt>
        <dd>hello</dd>
      </dl>
    </main>
  </body>
</html>

Resources

dxsliml dynarex html xslt