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

How to correctly position breaks in mixed content?

Subject: How to correctly position breaks in mixed content?
From: "Trevor Nicholls trevor@xxxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 14 Apr 2021 09:40:10 -0000
 How to correctly position breaks in mixed content?
NB currently XSL 2.0


I'm struggling with what I thought would be a simple enough problem:


given content like this


"<code>Mixed content, mainly text but with some text such as <var>variable
names</var> wrapped in elements, sometimes nested like a reference to the
<var>n<superscript>th</superscript></var> occurrence.</code>"


and a constraint that code should be rendered within a fixed width box, I
need to come up with a template which will process the <code> element and
transform it into its word-wrapped equivalent.


I don't need to concern myself with character sizes or styles; the output of
this transformation will always be rendered in a fixed-width font.


I can write something which works fine if a <code> element is simple text -
but the requirement is for this to work with mixed content too. In the above
example, if the constraint is that the line must wrap at or before 64
characters, the first break comes in the middle of the first <var>.


Assuming that the <code> example above is the current element, what I am
trying to write is a template


<xsl:template name="wordwrap">

  <xsl:param name="input" select="." />

  <xsl:param name="linelen" select="64" />




that will output


"Mixed content, mainly text but with some text such as

<var>names</var> wrapped in elements, sometimes nexted like a reference

the <var>n<superscript>th</superscript></var> occurrence."


Can anyone offer me some pointers as to how I should implement this?




Current Thread


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.
First Name
Last Name
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.