The requirement is that if the Condstart PI occurs before a text node, it
has to be the first in the parent element. And the corresponding Condend PI
has to be the last node in that element. So any of the middle PIs would be
ignored. So, in this case:
<p><?Fm Condstart USB?>If you need this, do that.<?Fm Condend USB?>text<?Fm
Condstart foo?>Some text<?Fm Condend foo?>another text</p>
the result would be
<p platform="USB>If you need this, do that. text Some text another text</p>
(spaces added for clarity).
There are two general cases:
1. The first following-sibling is an element. In that case, I want to apply
an attribute to each following-sibling element, up to the corresponding
Condend PI.
2> The first following-sibling is a text node and the PI is the first child
of its parent. In that case, I want to apply an attribute to the parent
element.
All other PIs can be ignored or passed through to the output.
Rick
-----Original Message-----
From: Martin Honnen martin(_dot_)honnen(_at_)gmx(_dot_)de
[mailto:xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com]
Sent: Friday, January 27, 2017 10:07 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] General algorithm for finding nodes between PIs
On 27.01.2017 15:57, Rick Quatro rick(_at_)rickquatro(_dot_)com wrote:
Thanks for the reply. What I really want is this:
Input:
<?xml version="1.0" encoding="UTF-8"?> <info>
<?Fm Condstart VbV-VCO?>
<p>For this, use <b>that </b>to do that.</p>
<p>Another paragraph</p>
<?Fm Condend VbV-VCO?>
<p><?Fm Condstart USB?>If you need this, do that.<?Fm Condend
USB?></p>
<p>Outside paragraph.</p>
</info>
Output:
<?xml version="1.0" encoding="UTF-8"?> <info>
<p platform="VbV-VCO">For this, use <b>that </b>to do that.</p>
<p platform="VbV-VCO">Another paragraph</p>
<p platform="USB">If you need this, do that.</p>
<p>Outside paragraph.</p>
</info>
The basic logic is this: given a "Condstart" processing instruction:
* If the first sibling is an element, then assign an attribute to all
following sibling elements up to the corresponding Condend processing
instruction.
* If the first sibling is a text node, then assign an attribute to the
parent of the Condstart processing instruction.
Pulling up the pi value to the parent requires a different approach, I
think. I wonder what happens if there is an element containing several pis,
let's say, there is
<p><?Fm Condstart USB?>If you need this, do that.<?Fm Condend USB?>text<?Fm
Condstart foo?>Some text<?Fm Condend foo?>another text</p>
which output do you want in that case?
--~----------------------------------------------------------------
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
--~--