How to create a .xsl (XML Style) file with Rebol and my ML dialect:

write %STAR.xsl ML [
    <?xml version="1.0"?>
    <!-- Created by %STAR.r -->
    <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
        xmlns:o="urn:schemas-microsoft-com:office:office"
        xmlns:x="urn:schemas-microsoft-com:office:excel"
        xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
        xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
        xmlns:html="http://www.w3.org/TR/REC-html40";
        > [
        <xsl:output method="xml" encoding="iso-8859-1" />
        <xsl:template match="ss:Workbook"> [
            <Rebol> [
                <xsl:text> "^/; Indirectly created by %STAR.r."
                <xsl:for-each select="ss:Worksheet/ss:Table"> [
                    <xsl:text> "^/[^/"
                    <xsl:for-each select="ss:Row"> [
                        <xsl:text> "^-["
                        <xsl:for-each select="ss:Cell"> [
                            <xsl:apply-templates />
                            <xsl:if test="not(position()=last())"> [
                                <xsl:text> " "
                                ]
                            ]
                        <xsl:text> "]^/"
                        ]
                    <xsl:text> "^-]^/"
                    ]
                ]
            ]
        <xsl:template
match="ss:Workbook/ss:Worksheet/ss:Table/ss:Row/ss:Cell/ss:Data"> [
            <xsl:if test="@ss:Type='String'"> [
                <xsl:text> {"} <xsl:apply-templates /> <xsl:text> {"}
                ]
            <xsl:if test="@ss:Type='Number'"> [
                <xsl:apply-templates />
                ]
            <xsl:if test="@ss:Type='DateTime'"> [
                <xsl:text> "#" <xsl:apply-templates />
                ]
            ]
        ]
    ]

Which ends up creating a Rebol data file from a MS Excel .XML spreadsheet
when run through my newly built C# XML Stylesheet processor!

/*
%"XML Transform.cs"
1/December/2003
*/
using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;

class XML_Transform {
    public static void Main (string[] args) {
        if (3 == args.Length) {
            XslTransform xt = new XslTransform ();
            xt.Load (args[1]);
            xt.Transform (args[2], args[0], null);
            }
        }
    }

/*
End.
*/

Now if only I had C# dialect for Rebol... :)

Andrew J Martin
Speaking in tongues and performing miracles.
ICQ: 26227169
http://www.rebol.it/Valley/
http://valley.orcon.net.nz/
http://Valley.150m.com/
-><-

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.

Reply via email to