This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: plain txt output tips


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@nag.co.uk> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]