Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - XSL: automatically wrapping text in [Thread Next] Re: XSL: automatically wrapping text inTo: NULL Date: 7/1/2004 5:31:00 PM Sam Quigley wrote: > I want to use XSL to wrap paragraphs of text in <p> tags > automatically, basically using the heuristic that two chunks of text > separated by 2 consecutive newlines are to be treated as two <p>s... > I do this right now by putting the input xml (the text to be wrapped) > in a <paraset> tag, and using the following XSL: > > <xsl:template match="paraset"> > <xsl:call-template name="wrapinp"> > <xsl:with-param name="input"> > <xsl:value-of select="."/> Here you pass in the value of a <paraset> element to the named template wrapinp meaning here you throw out all structure the <paraset> content might have and reduce it to its string value. If you want to process <emph> elements for instance you need to make sure you do process text nodes and element nodes in <paraset> recursively with e.g. <xsl:apply-templates />. Of course you want to split text by newlines however that is hard with XSLT if you have child elements as well, if possible try to fix the original markup to use elements to indicate the paragraph structure and not newlines. I realize I have only explained what goes wrong in your current solution without providing a better approach with XSLT, I would start looking at http://www.dpawson.co.uk/xsl/sect2/sect21.html for a solution. -- Martin Honnen http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
