[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xsl-list
Subject:    Re: [xsl] XML to text - converting DITA to asciidoc
From:       "dvint dvint () dvint ! com" <xsl-list-service () lists ! mulberrytech ! com>
Date:       2023-12-09 19:51:17
Message-ID: 20231209145043.f5b1451d () lists ! mulberrytech ! com
[Download RAW message or body]

Thanks, the <xml:strip-space> did the trickSent from my Verizon, Samsung Galaxy \
                smartphone
-------- Original message --------From: "Martin Honnen martin.honnen@gmx.de" \
<xsl-list-service@lists.mulberrytech.com> Date: 12/9/23  10:45 AM  (GMT-08:00) To: \
xsl-list@lists.mulberrytech.com Subject: Re: [xsl] XML to text - converting DITA to \
asciidoc On 09/12/2023 19:04, dvint@dvint.com wrote:> I'm trying to process complex \
inline DITA content to text and at the> same time both process inline markup and \
strip excess whitespace that> comes from having the content in a pretty printed \
format.>> I suppose a quick fix might be to go through and un=pretty the XML in> a \
pre-pass. Anyone got something that does that?>> Currently, I'm trying to process \
these files as they are in XML and> make nice text blocks in the converted content. I \
know that> normalize-space() will strip the space from text, but it doesn't allow> \
processing of the markup at the same time.>> So if I have a call like>> \
<xsl:apply-templates/>>> I get this when processing an <li>>> ======> * \
link:lnu1689300505181.dita[Step>                                        3]>> * \
link:txr1689300527868.dita[Step>                                                4]>> \
* Complete!>>>>>> * link:fkt1688690571816.dita[Show me the primary landing>           \
page]>> * link:fto1689306405929.dita[Show me>                                         \
tiles without descriptions]>>>>>>>> * link:https://example.com[Sample app]>>>>> *>    \
link:https://example.com[Security Key]>> ======>> If I change that call to>> \
<xsl:apply-templates select="normalize-space(.)"/>>> I get clean text, but now I'm \
missing the processing of the inline> elements like these <xref>s>>Either strip space \
from the input during input tree building with e.g.    <xsl:strip-space \
elements="*"/>or, if you want to normalize space in text nodes, use e.g.    \
<xsl:template match="text()">        <xsl:value-of select="normalize-space()"/>    \
</xsl:template>That way your xsl:apply-templates will process any inline elements \
                withmatching templates and the encountered text nodes with above \
                template.
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/651070
or by email: xsl-list-unsub@lists.mulberrytech.com
--~--


[Attachment #3 (text/html)]

<html><head><meta http-equiv="Content-Type" content="text/html; \
charset=UTF-8"></head><body dir="auto"><div dir="auto">Thanks, the \
&lt;xml:strip-space&gt; did the trick</div><div dir="auto"><br></div><div \
dir="auto"><br></div><div dir="auto"><br></div><div id="composer_signature" \
dir="auto"><div style="font-size:12px;color:#575757" dir="auto">Sent from my Verizon, \
Samsung Galaxy smartphone</div></div><div dir="auto"><br></div><div><br></div><div \
align="left" dir="auto" style="font-size:100%;color:#000000"><div>-------- Original \
message --------</div><div>From: "Martin Honnen martin.honnen@gmx.de" \
&lt;xsl-list-service@lists.mulberrytech.com&gt; </div><div>Date: 12/9/23  10:45 AM  \
(GMT-08:00) </div><div>To: xsl-list@lists.mulberrytech.com </div><div>Subject: Re: \
[xsl] XML to text - converting DITA to asciidoc </div><div><br></div></div><br>On \
09/12/2023 19:04, dvint@dvint.com wrote:<br>&gt; I'm trying to process complex inline \
DITA content to text and at the<br>&gt; same time both process inline markup and \
strip excess whitespace that<br>&gt; comes from having the content in a pretty \
printed format.<br>&gt;<br>&gt; I suppose a quick fix might be to go through and \
un=pretty the XML in<br>&gt; a pre-pass. Anyone got something that does \
that?<br>&gt;<br>&gt; Currently, I'm trying to process these files as they are in XML \
and<br>&gt; make nice text blocks in the converted content. I know that<br>&gt; \
normalize-space() will strip the space from text, but it doesn't allow<br>&gt; \
processing of the markup at the same time.<br>&gt;<br>&gt; So if I have a call \
like<br>&gt;<br>&gt; &lt;xsl:apply-templates/&gt;<br>&gt;<br>&gt; I get this when \
processing an &lt;li&gt;<br>&gt;<br>&gt; ======<br>&gt; * \
link:lnu1689300505181.dita[Step<br>&gt; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
3]<br>&gt;<br>&gt; * link:txr1689300527868.dita[Step<br>&gt; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
4]<br>&gt;<br>&gt; * Complete!<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; * \
link:fkt1688690571816.dita[Show me the primary landing<br>&gt; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
page]<br>&gt;<br>&gt; * link:fto1689306405929.dita[Show me<br>&gt; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
tiles without descriptions]<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; \
* link:https://example.com[Sample app]<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; \
*<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
link:https://example.com[Security Key]<br>&gt;<br>&gt; ======<br>&gt;<br>&gt; If I \
change that call to<br>&gt;<br>&gt; &lt;xsl:apply-templates \
select="normalize-space(.)"/&gt;<br>&gt;<br>&gt; I get clean text, but now I'm \
missing the processing of the inline<br>&gt; elements like these \
&lt;xref&gt;s<br>&gt;<br>&gt;<br><br>Either strip space from the input during input \
tree building with e.g.<br><br> &nbsp; &lt;xsl:strip-space \
elements="*"/&gt;<br><br>or, if you want to normalize space in text nodes, use \
e.g.<br><br> &nbsp; &lt;xsl:template match="text()"&gt;<br><br> &nbsp;&nbsp;&nbsp; \
&lt;xsl:value-of select="normalize-space()"/&gt;<br><br> &nbsp; \
&lt;/xsl:template&gt;<br><br><br>That way your xsl:apply-templates will process any \
inline elements with<br>matching templates and the encountered text nodes with above \
template.<br><br><br></body></html> <div><!-- begin bl.html.trailer -->
<div style="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="http://www.mulberrytech.com/xsl/xsl-list">
XSL-List info and archive</a>
<div style="text-align:center;">
<a style="color: blue;"
  href="http://lists.mulberrytech.com/unsub/xsl-list/651070"
> EasyUnsubscribe</a>
(<a style="color: blue;"
href="mailto:xsl-list-unsub@lists.mulberrytech.com?subject=remove"
> by email</a>)
</div>
</div>
<!-- end bl.html.trailer --></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic