Re: How to correctly position breaks in mixed content?

"Wendell Piez [email protected]" <[email protected]> Wed, 14 Apr 2021 12:34:09 -0000
Newsgroups gmane.text.xml.xsl.general.mulberrytech
Message-ID <[email protected]>
--0000000000005b83fa05bfedf50c
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

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 [email protected] <
[email protected]> wrote:

> Hi Trevor,
>
> One option would be to replace the mixed content elements by empty elemen=
ts
> <var>n<superscript>th</superscript></var>
> to become
> <var type=3D"s" id=3D"ID01"/>n<superscript  type=3D"s" id=3D"ID02"/>th<su=
perscript
>   type=3D"e" id=3D"ID02"><var  type=3D"r" id=3D"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
> [email protected] <[email protected]>:
>
> 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=3D"wordwrap">
>
>   <xsl:param name=3D"input" select=3D"." />
>
>   <xsl:param name=3D"linelen" select=3D"64" />
>
> =E2=80=A6
>
> </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
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/554170> (by
> email)
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/174322> (by
> email <>)
>


--=20
...Wendell Piez... ...wendell -at- nist -dot- gov...
...wendellpiez.com... ...pellucidliterature.org... ...pausepress.org...
...github.com/wendellpiez... ...gitlab.coko.foundation/wendell...
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/3329386
or by email: [email protected]
--~--

--0000000000005b83fa05bfedf50c
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi,<div><br></div><div>Yep, this is essentially an overlap=
=C2=A0problem.</div><div><br></div><div>What a wonderful thing, that we hav=
e workable solutions. :-&gt;</div><div><br></div><div>Cheers, Wendell</div>=
<div><br></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=
=3D"gmail_attr">On Wed, Apr 14, 2021 at 5:55 AM Geert Bormans <a href=3D"ma=
ilto:[email protected]">[email protected]</a> &lt;<a href=
=3D"mailto:[email protected]">xsl-list-service@lists.=
mulberrytech.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" =
style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);pa=
dding-left:1ex"><div><div style=3D"font-family:Arial;font-size:10pt;color:r=
gb(0,0,0)"><div>Hi Trevor,</div><div><br></div><div>One option would be to =
replace the mixed content elements by empty elements</div><div><span style=
=3D"color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px;fon=
t-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-=
weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-tran=
sform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255=
,255);text-decoration-style:initial;text-decoration-color:initial;float:non=
e;display:inline">&lt;var&gt;n&lt;superscript&gt;th&lt;/superscript&gt;&lt;=
/var&gt;</span><div style=3D"clear:both">to become</div><div style=3D"clear=
:both"><span style=3D"color:rgb(0,0,0);font-family:Calibri,sans-serif;font-=
size:14.6667px;font-style:normal;font-variant-ligatures:normal;font-variant=
-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-in=
dent:0px;text-transform:none;white-space:normal;word-spacing:0px;background=
-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color=
:initial;float:none;display:inline"><span style=3D"color:rgb(0,0,0);font-fa=
mily:Calibri,sans-serif;font-size:14.6667px;font-style:normal;font-variant-=
ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:no=
rmal;text-align:start;text-indent:0px;text-transform:none;white-space:norma=
l;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:=
initial;text-decoration-color:initial;float:none;display:inline"><span styl=
e=3D"color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px;fo=
nt-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font=
-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-tra=
nsform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,25=
5,255);text-decoration-style:initial;text-decoration-color:initial;float:no=
ne;display:inline">&lt;var type=3D&quot;s&quot; id=3D&quot;ID01&quot;/&gt;n=
&lt;superscript <span>=C2=A0</span>type=3D&quot;s&quot; id=3D&quot;ID02&quo=
t;/</span></span></span><span style=3D"color:rgb(0,0,0);font-family:Calibri=
,sans-serif;font-size:14.6667px;font-style:normal;font-variant-ligatures:no=
rmal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-al=
ign:start;text-indent:0px;text-transform:none;white-space:normal;word-spaci=
ng:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text=
-decoration-color:initial;float:none;display:inline"><span style=3D"color:r=
gb(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px;font-style:nor=
mal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;=
letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;=
white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-=
decoration-style:initial;text-decoration-color:initial;float:none;display:i=
nline"><span style=3D"color:rgb(0,0,0);font-family:Calibri,sans-serif;font-=
size:14.6667px;font-style:normal;font-variant-ligatures:normal;font-variant=
-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-in=
dent:0px;text-transform:none;white-space:normal;word-spacing:0px;background=
-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color=
:initial;float:none;display:inline">&gt;th&lt;superscript<span>=C2=A0</span=
><span style=3D"color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:1=
4.6667px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:=
normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0=
px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-=
style:initial;text-decoration-color:initial">=C2=A0</span>type=3D&quot;e&qu=
ot; id=3D&quot;ID02&quot;</span></span></span><span style=3D"color:rgb(0,0,=
0);font-family:Calibri,sans-serif;font-size:14.6667px;font-style:normal;fon=
t-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-=
spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-s=
pace:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decorat=
ion-style:initial;text-decoration-color:initial;float:none;display:inline">=
<span style=3D"color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14=
.6667px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:n=
ormal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0p=
x;text-transform:none;white-space:normal;word-spacing:0px;background-color:=
rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initia=
l;float:none;display:inline">&gt;&lt;var=C2=A0<span>=C2=A0</span>type=3D&qu=
ot;r&quot; id=3D&quot;ID01&quot;/&gt;</span></span><span style=3D"color:rgb=
(0,0,0);font-family:Calibri,sans-serif;font-size:14.6667px;font-style:norma=
l;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;le=
tter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;wh=
ite-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-de=
coration-style:initial;text-decoration-color:initial;float:none;display:inl=
ine"></span><div style=3D"clear:both"><br></div><div style=3D"clear:both">i=
f so all your characters are siblings, so can do a line breaking algorithm,=
 preserving the empty elements</div><div style=3D"clear:both">after that yo=
u simply reconstruct the elements</div></div></div><div><br></div><div><div=
>Met vriendelijke groeten,<br>Best regards,<br><br>Geert Bormans<br></div><=
/div><div><br><span id=3D"gmail-m_6819433899129429828zwchr">----- Op 14 apr=
 2021 om 11:46 schreef Trevor Nicholls <a href=3D"mailto:trevor@castingthev=
oid.com" target=3D"_blank">[email protected]</a> &lt;<a href=3D"mai=
lto:[email protected]" target=3D"_blank">xsl-list-ser=
[email protected]</a>&gt;:<br></span><br></div><div><div><p class=
=3D"MsoNormal">NB currently XSL 2.0</p><p class=3D"MsoNormal">=C2=A0</p><p =
class=3D"MsoNormal">I&#39;m struggling with what I thought would be a simpl=
e enough problem:</p><p class=3D"MsoNormal">=C2=A0</p><p class=3D"MsoNormal=
">given content like this</p><p class=3D"MsoNormal">=C2=A0</p><p class=3D"M=
soNormal">&quot;&lt;code&gt;Mixed content, mainly text but with some text s=
uch as &lt;var&gt;variable names&lt;/var&gt; wrapped in elements, sometimes=
 nested like a reference to the &lt;var&gt;n&lt;superscript&gt;th&lt;/super=
script&gt;&lt;/var&gt; occurrence.&lt;/code&gt;&quot;</p><p class=3D"MsoNor=
mal">=C2=A0</p><p class=3D"MsoNormal">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 &lt;code&gt; element and transform it into its word-wrappe=
d equivalent.</p><p class=3D"MsoNormal">=C2=A0</p><p class=3D"MsoNormal">I =
don&#39;t need to concern myself with character sizes or styles; the output=
 of this transformation will always be rendered in a fixed-width font.</p><=
p class=3D"MsoNormal">=C2=A0</p><p class=3D"MsoNormal">I can write somethin=
g which works fine if a &lt;code&gt; element is simple text - but the requi=
rement 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 &lt;var&gt;.</p><p class=3D"Ms=
oNormal">=C2=A0</p><p class=3D"MsoNormal">Assuming that the &lt;code&gt; ex=
ample above is the current element, what I am trying to write is a template=
</p><p class=3D"MsoNormal">=C2=A0</p><p class=3D"MsoNormal">&lt;xsl:templat=
e name=3D&quot;wordwrap&quot;&gt;</p><p class=3D"MsoNormal">=C2=A0 &lt;xsl:=
param name=3D&quot;input&quot; select=3D&quot;.&quot; /&gt;</p><p class=3D"=
MsoNormal">=C2=A0 &lt;xsl:param name=3D&quot;linelen&quot; select=3D&quot;6=
4&quot; /&gt;</p><p class=3D"MsoNormal">=E2=80=A6</p><p class=3D"MsoNormal"=
>&lt;/xsl:template&gt;</p><p class=3D"MsoNormal">=C2=A0</p><p class=3D"MsoN=
ormal">that will output</p><p class=3D"MsoNormal">=C2=A0</p><p class=3D"Mso=
Normal">&quot;Mixed content, mainly text but with some text such as &lt;var=
&gt;variable&lt;/var&gt;&lt;wordwrap/&gt;</p><p class=3D"MsoNormal">&lt;var=
&gt;names&lt;/var&gt; wrapped in elements, sometimes nexted like a referenc=
e to&lt;wordwrap/&gt;</p><p class=3D"MsoNormal">the &lt;var&gt;n&lt;supersc=
ript&gt;th&lt;/superscript&gt;&lt;/var&gt; occurrence.&quot;</p><p class=3D=
"MsoNormal">=C2=A0</p><p class=3D"MsoNormal">Can anyone offer me some point=
ers as to how I should implement this?</p><p class=3D"MsoNormal">=C2=A0</p>=
<p class=3D"MsoNormal">Cheers</p><p class=3D"MsoNormal">T</p></div>
<div>
<div style=3D"border-top:1px solid black;background-color:rgb(221,221,221);=
color:rgb(136,136,136);font-size:smaller;padding:5px;text-align:center;font=
-family:arial,verdana,arial,sans-serif;margin:auto">
<a href=3D"http://www.mulberrytech.com/xsl/xsl-list" rel=3D"nofollow noopen=
er noreferrer" target=3D"_blank">
XSL-List info and archive</a>
<div style=3D"text-align:center">
<a style=3D"color:blue" href=3D"http://lists.mulberrytech.com/unsub/xsl-lis=
t/554170" rel=3D"nofollow noopener noreferrer" target=3D"_blank">EasyUnsubs=
cribe</a>
(<a style=3D"color:blue" rel=3D"nofollow noopener noreferrer">by email</a>)
</div>
</div>
</div><br></div></div></div>
<div>
<div style=3D"border-top:1px solid black;background-color:rgb(221,221,221);=
color:rgb(136,136,136);font-size:smaller;padding:5px;text-align:center;font=
-family:arial,verdana,arial,sans-serif;clear:both;margin:auto">
<a href=3D"http://www.mulberrytech.com/xsl/xsl-list" target=3D"_blank">
XSL-List info and archive</a>
<div style=3D"text-align:center">
<a style=3D"color:blue" href=3D"http://lists.mulberrytech.com/unsub/xsl-lis=
t/174322" target=3D"_blank">EasyUnsubscribe</a>
(<a style=3D"color:blue" href=3D"" target=3D"_blank">by email</a>)
</div>
</div>
</div>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
 class=3D"gmail_signature">...Wendell Piez... ...wendell -at- nist -dot- go=
v...<br>...wendellpiez.com... ...pellucidliterature.org... ...pausepress.or=
g...<br>...<a href=3D"http://github.com/wendellpiez." target=3D"_blank">git=
hub.com/wendellpiez.</a>.. ...gitlab.coko.foundation/wendell... </div>
<div><!-- begin bl.html.trailer -->
<div style=3D"border-top:1px solid black; background-color: #dddddd;
color: #888888; font-size: smaller; padding: 5px; text-align: center;
font-family: arial,verdana,arial,sans-serif; margin-top:1em; clear:
both; margin: auto">
<a href=3D"http://www.mulberrytech.com/xsl/xsl-list">
XSL-List info and archive</a>
<div style=3D"text-align:center;">
<a style=3D"color: blue;"
  href=3D"http://lists.mulberrytech.com/unsub/xsl-list/3329386"
>EasyUnsubscribe</a>
(<a style=3D"color: blue;"
href=3D"mailto:[email protected]?subject=3Dremove"
>by email</a>)
</div>
</div>
<!-- end bl.html.trailer --></div>

--0000000000005b83fa05bfedf50c--