xsl-list
[Top] [All Lists]

Re: [xsl] How to correctly position breaks in mixed content?

2021-04-14 07:47:16
then a typo occurred to me... 

<var type="s" id="ID01"/>n<superscript type="s" id="ID02"/ >th<superscript 
type="e" id="ID02" ><var type=" r " id="ID01"/> 
should read 
<var type="s" id="ID01"/>n<superscript type="s" id="ID02"/ >th<superscript 
type="e" id="ID02" ><var type=" e " id="ID01"/> 


Met vriendelijke groeten, 
Best regards, 

Geert Bormans 

----- Op 14 apr 2021 om 14:40 schreef Wendell Piez 
wapiez(_at_)wendellpiez(_dot_)com 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>: 

Hi, 
Yep, this is essentially an overlap problem. 

What a wonderful thing, that we have workable solutions. :-> 

Cheers, Wendell 


On Wed, Apr 14, 2021 at 5:55 AM Geert Bormans [ 
mailto:geert(_at_)gbormans(_dot_)telenet(_dot_)be | 
geert(_at_)gbormans(_dot_)telenet(_dot_)be ] < [ 
mailto:xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com | 
xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com ] > wrote: 



Hi Trevor, 

One option would be to replace the mixed content elements by empty elements 
<var>n<superscript>th</superscript></var> 
to become 
<var type="s" id="ID01"/>n<superscript type="s" id="ID02"/ >th<superscript 
type="e" id="ID02" ><var type="r" id="ID01"/> 
if so all your characters are siblings, so can do a line breaking algorithm, 
preserving the empty elements 
after that you simply reconstruct the elements 

Met vriendelijke groeten, 
Best regards, 

Geert Bormans 

----- Op 14 apr 2021 om 11:46 schreef Trevor Nicholls [ 
mailto:trevor(_at_)castingthevoid(_dot_)com | 
trevor(_at_)castingthevoid(_dot_)com ] < [ 
mailto:xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com | 
xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com ] >: 



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

… 

</xsl:template> 



that will output 



"Mixed content, mainly text but with some text such as 
<var>variable</var><wordwrap/> 

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

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



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



Cheers 

T 
[ http://www.mulberrytech.com/xsl/xsl-list | 
XSL-List info and archive ] 
[ http://lists.mulberrytech.com/unsub/xsl-list/554170 | EasyUnsubscribe ] ( by 
email ) 

[ http://www.mulberrytech.com/xsl/xsl-list | 
XSL-List info and archive ] 
[ http://lists.mulberrytech.com/unsub/xsl-list/174322 | EasyUnsubscribe ] ( [ 
https://mail.telenet.be/zimbra/mail?client=advanced | by email ] ) 





-- 
...Wendell Piez... ...wendell -at- nist -dot- gov... 
...wendellpiez.com... ...pellucidliterature.org... ...pausepress.org... 
... [ http://github.com/wendellpiez. | github.com/wendellpiez. ] .. 
...gitlab.coko.foundation/wendell... 
[ http://www.mulberrytech.com/xsl/xsl-list | 
XSL-List info and archive ] 
[ http://lists.mulberrytech.com/unsub/xsl-list/554170 | EasyUnsubscribe ] ( [  
| by email ] ) 
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>