[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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>
</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>
</xsl:text> RELEASE: <xsl:value-of select="PressRelease/@ReleaseNum" /><xsl:text>

</xsl:text> <xsl:value-of select="PressRelease/MetaData/Headline" /><xsl:text>
</xsl:text> <!-- content --> <xsl:apply-templates select="PressRelease/Body" /> <!-- end content --> <!-- related links --> <xsl:text>
</xsl:text> <xsl:text>-----------------------------RELATED LINKS-----------------------------</xsl:text> <xsl:apply-templates select="PressRelease/RelatedLinks" /> <xsl:text>-----------------------------------------------------------------------</xsl:text> <!-- end related links --> <!-- footer --> <xsl:text>

</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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|