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

Re: General algorithm for finding nodes between PIs

Subject: Re: General algorithm for finding nodes between PIs
From: "Rick Quatro rick@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 27 Jan 2017 19:19:44 -0000
Re:  General algorithm for finding nodes between PIs
Yes, I think that is it. Thanks for the pointer.

-----Original Message-----
From: David Carlisle d.p.carlisle@xxxxxxxxx
[mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx]
Sent: Friday, January 27, 2017 1:52 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  General algorithm for finding nodes between PIs

white space after the PI?

On 27 January 2017 at 18:50, Rick Quatro rick@xxxxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> OK, I understand. It didn't work with the self::* test on it so let me see
if I can figure out why. Thank you very much.
>
> -----Original Message-----
> From: David Carlisle d.p.carlisle@xxxxxxxxx
> [mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx]
> Sent: Friday, January 27, 2017 1:36 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  General algorithm for finding nodes between PIs
>
> On 27 January 2017 at 18:21, Rick Quatro rick@xxxxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>> Hi David,
>>
>> That works well, except I had to change this:
>>
>> <xsl:when test="following-sibling::node()[1]/self::* and
>> starts-with(.,'Condstart ')">
>>
>> to this:
>>
>> <xsl:when test="following-sibling::node()[1] and
>> starts-with(.,'Condstart ')">
>>
>> Thank you all for the help.
>>
>> Rick
>
> well...
>
> following-sibling::node()[1]/self::*
>
> tests that the node immediately following the Pi is an element.
>
> and
>
> following-sibling::node()[1]
>
> is the same as
>
> following-sibling::node()
>
> in a boolean context and tests that the PI has any following sibling.
>
> So I think my code is closer to what you said your requirements are,
> but whatever works:-)
>
> David
>
>
> the second
>>
>> -----Original Message-----
>> From: David Carlisle d.p.carlisle@xxxxxxxxx
>> [mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx]
>> Sent: Friday, January 27, 2017 11:51 AM
>> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>> Subject: Re:  General algorithm for finding nodes between PIs
>>
>> or sometimes it's easier with xslt- style sibling recursion rather
>> then using for-each-group
>>
>> Not sure I have all the cases but
>>
>> <x>
>>  <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>
>>
>>  <p><?Fm Condstart USB?><span>If you need</span>  <span>this, do
>> that.</span><?Fm Condend USB?>text<?Fm  Condstart foo?>Some text<?Fm
>> Condend foo?><span>another text</span></p> </x>
>>
>>
>> comes out as
>>
>> <?xml version="1.0" encoding="UTF-8"?><x>  <p platform="USB">If you
>> need this, do that.textSome textanother text</p>
>>
>>  <p><span platform="USB">If you need</span>  <span
>> platform="USB">this, do that.</span>textSome text<span>another
>> text</span></p> </x>
>>
>>
>> using
>>
>>
>> <xsl:stylesheet version="2.0"
>>         xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>>
>>
>>
>>  <xsl:template match="node()">
>>   <xsl:param name="att"/>
>>   <xsl:copy>
>>    <xsl:copy-of select="$att"/>
>>    <xsl:apply-templates select="child::node()[1]"/>
>>   </xsl:copy>
>>   <xsl:apply-templates select="following-sibling::node()[1]">
>>    <xsl:with-param name="att" select="$att"/>
>>   </xsl:apply-templates>
>>  </xsl:template>
>>
>>  <xsl:template match="processing-instruction(Fm)">
>>   <xsl:param name="att"/>
>>   <xsl:choose>
>>    <xsl:when test="following-sibling::node()[1]/self::text() and
>>            not(preceding-sibling::node()) and
>>            starts-with(.,'Condstart ')">
>>     <xsl:attribute name="platform" select="substring-after(.,'Condstart
')"/>
>>       <xsl:apply-templates select="following-sibling::node()[1]"/>
>>    </xsl:when>
>>    <xsl:when test="following-sibling::node()[1]/self::*
>>            and starts-with(.,'Condstart ')">
>>     <xsl:apply-templates select="following-sibling::node()[1]">
>>      <xsl:with-param name="att" as="attribute()">
>>       <xsl:attribute name="platform" select="substring-after(.,'Condstart
')"/>
>>      </xsl:with-param>
>>     </xsl:apply-templates>
>>    </xsl:when>
>>    <xsl:when test="substring-after(.,'Condend ')=$att">
>>     <xsl:apply-templates select="following-sibling::node()[1]"/>
>>    </xsl:when>
>>    <xsl:otherwise>
>>     <xsl:apply-templates select="following-sibling::node()[1]">
>>      <xsl:with-param name="att" select="$att"/>
>>     </xsl:apply-templates>
>>    </xsl:otherwise>
>>   </xsl:choose>
>>  </xsl:template>
>>
>> </xsl:stylesheet>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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