[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] plain txt output tips

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

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

<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:text> </xsl:text><xsl:value-of
Phone: <xsl:value-of
Fax: <xsl:value-of
select="PressRelease/MetaData/InstitutionalPAO/Fax" />
Email: <xsl:value-of
RELEASE: <xsl:value-of
<xsl:value-of select="PressRelease/MetaData/Headline"
<!-- content -->
<xsl:apply-templates select="PressRelease/Body" />
<!-- end content -->
<!-- related links -->
select="PressRelease/RelatedLinks" />
<!-- end related links -->
<!-- footer -->
<xsl:value-of select="$content" />

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.


--- 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

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

Current Thread