What is the spec for whitespace in an XSL document?  sabcmd prints my
fields all squished together, so I tried adding a   and a funny
character (�) appears.

Here are some snippets:

---XML---
<?xml version="1.0" encoding="UTF-8"?>

<schema table="blackbook">
        <field name="ID" type="int(10) unsigned" default="0" null="no"
auto_increment="yes"/>
        <field name="fname" type="varchar(30)" default="" null="no"/>
        <field name="lname" type="varchar(30)" default="" null="no"/>
        <field name="phone" type="varchar(20)"/>
        <field name="email" type="varchar(30)"/>
        <key field="ID" type="primary key"/>
</schema>

---XSL snippet---
        <xsl:template match="field">
                <xsl:value-of select="@name"/> <xsl:value-of select="@type"/>
                <xsl:if test="@default"> DEFAULT '<xsl:value-of select="@default"/>'
</xsl:if>
                <xsl:if test="@null = 'no'"> NOT NULL </xsl:if> ,
        </xsl:template>

---sabcmd output snippet---
IDint(10) unsigned DEFAULT '0'  NOT NULL  ,

Notice how "ID" and "int(10)" have no whitespace.  Here the output when
I use &nbsp;:

ID int(10) unsigned DEFAULT '0'  NOT NULL  ,

Any suggestions on how I put whitespace in there?  I've attached the
files for your perusal.

Just for comparison, Xalan doesn't honor the whitespace, but does output
the &nbsp; correctly.  And xslt-parser honors the whitespace and outputs
&nbsp; literally.

Thanks,
-- 
Trevor Leffler, Software Developer
PETTT / Ed-Tech Development Group
University of Washington
(206) 616-3406 / OUGL 230, Box 353080
<?xml version="1.0" encoding="UTF-8"?>

<schema table="blackbook">
        <field name="ID" type="int(10) unsigned" default="0" null="no" 
auto_increment="yes"/>
        <field name="fname" type="varchar(30)" default="" null="no"/>
        <field name="lname" type="varchar(30)" default="" null="no"/>
        <field name="phone" type="varchar(20)"/>
        <field name="email" type="varchar(30)"/>
        <key field="ID" type="primary key"/>
</schema>
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE xsl:stylesheet [
        <!ENTITY nbsp "&#160;">
]>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
        <xsl:output method="text" omit-xml-declaration="yes"/>

        <xsl:template match="schema">
                create table <xsl:value-of select="@table"/> {
                        <xsl:apply-templates/>
                };
        </xsl:template>

        <xsl:template match="field">
                <xsl:value-of select="@name"/>&nbsp;<xsl:value-of select="@type"/>
                <xsl:if test="@default"> DEFAULT '<xsl:value-of select="@default"/>' 
</xsl:if>
                <xsl:if test="@null = 'no'"> NOT NULL </xsl:if> ,
        </xsl:template>

        <xsl:template match="key">
                <xsl:value-of select="@type"/> (<xsl:value-of select="@field"/>),
        </xsl:template>
</xsl:stylesheet>

Reply via email to