[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: plain txt output tips

Subject: Re: plain txt output tips
From: Nathan Shaw <n8_shaw@xxxxxxxxx>
Date: Tue, 16 Apr 2002 09:00:30 -0700 (PDT)
xsl output plain text emails
Thanks David.

I think I see what you are saying, but I am having a
little bit of trouble seeing how to implement it.

I am not storing all of my output in a variable called
content.

<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text" encoding="iso-8859-1"
media-type="text/plain" indent="no" />
<xsl:strip-space elements="*" />

<xsl:template match="/">
<xsl:variable name="content">
<!--contact info -->
<xsl:value-of
select="PressRelease/MetaData/InstitutionalPAO/FName"
/><xsl:text> </xsl:text><xsl:value-of
select="PressRelease/MetaData/InstitutionalPAO/LName"
/>
<xsl:text>&#xA;</xsl:text>
<xsl:value-of
select="PressRelease/MetaData/InstitutionalPAO/JobTitle"
/>
<xsl:value-of
select="PressRelease/MetaData/InstitutionalPAO/OrgName"
/>
<xsl:value-of
select="PressRelease/MetaData/InstitutionalPAO/Address"
/>
<xsl:value-of
select="PressRelease/MetaData/InstitutionalPAO/SubAddress"
/>
Phone: <xsl:value-of
select="PressRelease/MetaData/InstitutionalPAO/Phone"
/>
Fax: <xsl:value-of
select="PressRelease/MetaData/InstitutionalPAO/Fax" />
Email: <xsl:value-of
select="PressRelease/MetaData/InstitutionalPAO/Email"
/>
<xsl:text>&#xA;</xsl:text>
RELEASE: <xsl:value-of
select="PressRelease/@ReleaseNum"
/><xsl:text>&#xA;&#xA;</xsl:text>
<xsl:value-of select="PressRelease/MetaData/Headline"
/><xsl:text>&#xA;</xsl:text>
<!-- content -->
<xsl:apply-templates select="PressRelease/Body" />
<!-- end content -->
<!-- related links -->
<xsl:text>&#xA;</xsl:text>
<xsl:text>-----------------------------RELATED
LINKS-----------------------------</xsl:text>
<xsl:apply-templates
select="PressRelease/RelatedLinks" />
<xsl:text>-----------------------------------------------------------------------</xsl:text>
<!-- end related links -->
<!-- footer -->
<xsl:text>&#xA;&#xA;</xsl:text><xsl:text>             
                   </xsl:text>-end-
</xsl:variable>
<xsl:value-of select="$content" />
</xsl:template>

But, I am not sure exactly how to send that variable
into another named recursive template and spit out
lines no greater than 72 characters long.

Could you perhaps help get me started here? I would
appreciate it.

--Nate


--- David Carlisle <davidc@xxxxxxxxx> wrote:
> 
> > 1) What is the best way to force line breaks?
> Right
> > now, I am using <xsl:text>
</xsl:text> to do
> it.
> 
> yes
> 
> 
> > 2) How can I limit the line length? I have run
> across
> > several templates that break your lines at xx num
> of
> > characters, but none of them a) consider breaking
> > right in the middle of words nor b) how you handle
> > breaking in a mixed content model, which is what I
> am
> > working with.
> 
> If you're generating plain text then you can run all
> your templates
> into the content of a variable, then you have the
> output as a string
> which you can try to break.
> 
> Basically you want to tokenise on word boundaries
> (using a tokenise
> extension, or one of Dimitre's functions, or a
> simple recusuive template
> looking for substring-before(.,' '), then you want a
> recusive template
> that runs over the list of tokens keeping a running
> total of the length
> of the current line and adding a line break where
> needed.
> 
> That's the general case, in simple cases I've done
> something simpler:
> if you know the words are basically rather short and
> you don't need to
> get the "best possible" line breaking, then you can
> (assuming you are
> aiming to break in column 80, for exampple
> use substring($string,1,70)  to get most of the line
> then
> substring-before(substring($string,71),' ') to get
> th erest of the final
> word then recurse on the rest of the string which is
> substring-after(substring($string,71),' ')
> 
> David
> 
>
_____________________________________________________________________
> This message has been checked for all known viruses
> by Star Internet
> delivered through the MessageLabs Virus Scanning
> Service. For further
> information visit http://www.star.net.uk/stats.asp
> or alternatively call
> Star Internet for details on the Virus Scanning
> Service.
> 
>  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.