Subject: Re: White space control when formatting for ascii text From: Dan Vint <dvint@xxxxxxxx> Date: Tue, 17 Oct 2000 13:37:13 -0700 (PDT) |
Quick guess as you have covered the usual problem with spaces in the template by surrounding your live text with <xsl:text elements is that some problems may be generated by the white space in your source data. Use something like this to strip the text output: <xsl:template match="text()"> <xsl:value-of select="normalize-space(.)"/> </xsl:template> that should get rid of any extra spaces, CR's and tabs that would come from the formatting in the source data. ..dan > > I'm attempting to transform some xml into nicely formatted ascii style > text instead of to html. I've been using tabs to align my columns but > sometimes I get extra tabs. I don't know why. > > It seems to be very difficult to control the white space in the style > sheet. Is there a way to make the white space more visibile for better > debugging? > > I switched to using the unicode characters for return and tab. > return = 
 and tab = 	 so that I could know what tabs and line > breaks I was putting in. > > Maybe I've missed something. > > Style sheet output: > ------------------- > > <?xml version="1.0" encoding="utf-8"?> > This is a listing of fields by category > > Category: People > > PersonID Global unique identifier for a person. > SSN Social Security Number > Firstname First Name > Lastname Last Name > Middlename Middle Name > DOB Date of birth > Gender Gender of the person. > ^ > |--------no reason for tab here. > > Style sheet: > ------------ > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:strip-space elements="*"/> > > <xsl:template match="fieldlist"> > <xsl:text>This is a listing of fields by category
</xsl:text> > <xsl:apply-templates/> > </xsl:template> > > <xsl:template match="table"> > <xsl:text>
</xsl:text> > <xsl:text>Category: </xsl:text> > <xsl:apply-templates/> > </xsl:template> > > <xsl:template match="name"> > <xsl:apply-templates/> > <xsl:text>

</xsl:text> > </xsl:template> > > <xsl:template match="field"> > <xsl:value-of select="@name"/> > <xsl:text>	</xsl:text> > <xsl:apply-templates/> > </xsl:template> > > > <xsl:template match="desc"> > <xsl:apply-templates/> > </xsl:template> > > </xsl:stylesheet> > > Original xml: > ------------- > <?xml version="1.0" standalone="no"?> > <!DOCTYPE fieldlist SYSTEM "fieldlist.dtd"> > <fieldlist> > <table> > <name>People</name> > > <field name="PersonID" type="Number(10)" keytype="PRIMARY KEY"> > <desc>Global unique identifier for a person. > </desc> > </field> > > <field name="SSN" type="varchar2(9)" keytype="NOT NULL"> > <desc>Social Security Number > </desc> > </field> > > <field name="Firstname" type="varchar2(20)" keytype=""> > <desc>First Name > </desc> > </field> > > <field name="Lastname" type="varchar2(20)" keytype=""> > <desc>Last Name > </desc> > </field> > > <field name="Middlename" type="varchar2(20)" keytype=""> > <desc>Middle Name > </desc> > </field> > > <field name="DOB" type="Date" keytype=""> > <desc>Date of birth > </desc> > </field> > > <field name="Gender" type="char(1)" keytype=""> > <desc>Gender of the person. > </desc> > </field> > </table> > </fieldlist> > > ______________________________________________________ > Rick Anderson | rianders@xxxxxxxxxxxxxxx > ________________|_____________________________________ > Continuous Education & Outreach > Manager of Computer Systems, (732)932-5071 > ______________________________________________________ > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: White space control when format, David Carlisle | Thread | Re: White space control when format, Tony Graham |
Re: White space control when format, David Carlisle | Date | Re: Which engine? (RE: JavaScript a, Eric van der Vlist |
Month |