Re: preceding-sibling in a group

"[email protected]" <[email protected]> Thu, 20 May 2021 20:20:12 -0000
Newsgroups gmane.text.xml.xsl.general.mulberrytech
Message-ID <[email protected]>
This is a multipart message in MIME format.

------=_NextPart_000_044E_01D74D93.F2E40500
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

Here is my sample input:

 

<?xml version="1.0" encoding="UTF-8"?>

<dataroot>

    <DH675AU>

        <FIG_NO>99999</FIG_NO>

        <PART_DES>DIPSTICK</PART_DES>

    </DH675AU>

    <DH675AU>

        <FIG_NO>99999</FIG_NO>

        <PART_DES>O-RING</PART_DES>

    </DH675AU>

    <DH675AU>

        <FIG_NO>99999</FIG_NO>

        <PART_DES>SCREW, SELF-TAPPING</PART_DES>

    </DH675AU>

    <DH675AU>

        <FIG_NO>99999</FIG_NO>

        <PART_DES>NOTE: (1) NOT SERVICED SEPARATELY. INCLUDED IN</PART_DES>

    </DH675AU>

    <DH675AU>

        <FIG_NO>99999</FIG_NO>

        <PART_DES>58F-98-40740 SEAL KIT.</PART_DES>

    </DH675AU>

    <DH675AU>

        <FIG_NO>69500</FIG_NO>

        <PART_DES>DIPSTICK</PART_DES>

    </DH675AU>

    <DH675AU>

        <FIG_NO>69500</FIG_NO>

        <PART_DES>O-RING</PART_DES>

    </DH675AU>

    <DH675AU>

        <FIG_NO>69500</FIG_NO>

        <PART_DES>SCREW, SELF-TAPPING</PART_DES>

    </DH675AU>

</dataroot>

 

Here is my desired output:

 

<?xml version="1.0" encoding="UTF-8"?>

<root>

   <entry>

      <figure>99999</figure>

      <description>DIPSTICK</description>

      <description>O-RING</description>

      <description>SCREW, SELF-TAPPING</description>

      <note>NOTE: (1) NOT SERVICED SEPARATELY. INCLUDED IN</note>

      <note>58F-98-40740 SEAL KIT.</note>

   </entry>

   <entry>

      <figure>69500</figure>

      <description>DIPSTICK</description>

      <description>O-RING</description>

      <description>SCREW, SELF-TAPPING</description>

   </entry>

</root>

 

Here is my stylesheet:

 

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

    xmlns:xs="http://www.w3.org/2001/XMLSchema"

    xmlns:math="http://www.w3.org/2005/xpath-functions/math"

    exclude-result-prefixes="xs math"

    version="3.0" expand-text="true">

    

    <xsl:output method="xml" indent="yes"/>

    

    <xsl:template match="/dataroot">

        <root>

            <xsl:call-template name="make-components"/>

        </root>

    </xsl:template>

    

    <xsl:template name="make-components">

        <xsl:for-each-group select="*" group-by="child::FIG_NO">

            <xsl:call-template name="make-entries"/>

        </xsl:for-each-group>

    </xsl:template>

    

    <xsl:template name="make-entries">

        <entry>

            <figure><xsl:apply-templates
select="current-group()[1]/FIG_NO"/></figure>

            <xsl:for-each select="current-group()">

                <xsl:choose>

                    <xsl:when test="PART_DES[matches(.,'NOTE')] or
preceding::PART_DES[matches(.,'NOTE')]">

                        <note>

                            <xsl:apply-templates select="PART_DES"/>

                        </note>

                    </xsl:when>

                    <xsl:otherwise>

                        <description>

                            <xsl:apply-templates select="PART_DES"/>

                        </description>

                    </xsl:otherwise>

                </xsl:choose>

            </xsl:for-each>

        </entry>

    </xsl:template>

     

</xsl:stylesheet>

 

Here is what I am getting:

 

<?xml version="1.0" encoding="UTF-8"?>

<root>

   <entry>

      <figure>99999</figure>

      <description>DIPSTICK</description>

      <description>O-RING</description>

      <description>SCREW, SELF-TAPPING</description>

      <note>NOTE: (1) NOT SERVICED SEPARATELY. INCLUDED IN</note>

      <note>58F-98-40740 SEAL KIT.</note>

   </entry>

   <entry>

      <figure>69500</figure>

      <note>DIPSTICK</note>

      <note>O-RING</note>

      <note>SCREW, SELF-TAPPING</note>

   </entry>

</root>

 

The idea is that when I see a "NOTE" string, I want that entry and all
following within the same group to be <note> elements. So I am look for
preceding-sibling or self that contains "NOTE" but restricted to the same
group. I am using XSLT 3. Thank you very much.

 

Rick

 

Rick Quatro

Carmen Publishing Inc.

585-729-6746

[email protected] <mailto:[email protected]> 

http://www.frameexpert.com/store

 

 

XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>  

 <http://lists.mulberrytech.com/unsub/xsl-list/612310> EasyUnsubscribe (
<> by email) 
--~----------------------------------------------------------------
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]
--~--

------=_NextPart_000_044E_01D74D93.F2E40500
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:o=3D"urn:schemas-microsoft-com:office:office" xmlns:w=3D"urn:sc=
hemas-microsoft-com:office:word" xmlns:m=3D"http://schemas.microsoft.com/of=
fice/2004/12/omml" xmlns=3D"http://www.w3.org/TR/REC-html40"><head><meta ht=
tp-equiv=3DContent-Type content=3D"text/html; charset=3Dus-ascii"><meta nam=
e=3DGenerator content=3D"Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:#0563C1;
	text-decoration:underline;}
span.EmailStyle21
	{mso-style-type:personal-compose;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-size:10.0pt;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style></head><body lang=3DEN-US link=3D"#0563C1" vlink=3D"#954F72" sty=
le=3D'word-wrap:break-word'><div class=3DWordSection1><p class=3DMsoNormal>=
Here is my sample input:<o:p></o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:=
p></p><p class=3DMsoNormal>&lt;?xml version=3D&quot;1.0&quot; encoding=3D&q=
uot;UTF-8&quot;?&gt;<o:p></o:p></p><p class=3DMsoNormal>&lt;dataroot&gt;<o:=
p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp; &lt;DH675AU&gt;<o:p></o=
:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;=
FIG_NO&gt;99999&lt;/FIG_NO&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;PART_DES&gt;DIPSTICK&lt;/PART_DES&gt;=
<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp; &lt;/DH675AU&gt;<o:p=
></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp; &lt;DH675AU&gt;<o:p></o:=
p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;F=
IG_NO&gt;99999&lt;/FIG_NO&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;PART_DES&gt;O-RING&lt;/PART_DES&gt;<o:=
p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp; &lt;/DH675AU&gt;<o:p></=
o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp; &lt;DH675AU&gt;<o:p></o:p><=
/p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FIG_=
NO&gt;99999&lt;/FIG_NO&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;PART_DES&gt;SCREW, SELF-TAPPING&lt;/PART_=
DES&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp; &lt;/DH675AU&=
gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp; &lt;DH675AU&gt;<o=
:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
; &lt;FIG_NO&gt;99999&lt;/FIG_NO&gt;<o:p></o:p></p><p class=3DMsoNormal>&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;PART_DES&gt;NOTE: (1) NOT SERVI=
CED SEPARATELY. INCLUDED IN&lt;/PART_DES&gt;<o:p></o:p></p><p class=3DMsoNo=
rmal>&nbsp;&nbsp;&nbsp; &lt;/DH675AU&gt;<o:p></o:p></p><p class=3DMsoNormal=
>&nbsp;&nbsp;&nbsp; &lt;DH675AU&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FIG_NO&gt;99999&lt;/FIG_NO&gt;<o=
:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
; &lt;PART_DES&gt;58F-98-40740 SEAL KIT.&lt;/PART_DES&gt;<o:p></o:p></p><p =
class=3DMsoNormal>&nbsp;&nbsp;&nbsp; &lt;/DH675AU&gt;<o:p></o:p></p><p clas=
s=3DMsoNormal>&nbsp;&nbsp;&nbsp; &lt;DH675AU&gt;<o:p></o:p></p><p class=3DM=
soNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FIG_NO&gt;69500&lt;=
/FIG_NO&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp; &lt;PART_DES&gt;DIPSTICK&lt;/PART_DES&gt;<o:p></o:p></p><p c=
lass=3DMsoNormal>&nbsp;&nbsp;&nbsp; &lt;/DH675AU&gt;<o:p></o:p></p><p class=
=3DMsoNormal>&nbsp;&nbsp;&nbsp; &lt;DH675AU&gt;<o:p></o:p></p><p class=3DMs=
oNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FIG_NO&gt;69500&lt;/=
FIG_NO&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp; &lt;PART_DES&gt;O-RING&lt;/PART_DES&gt;<o:p></o:p></p><p clas=
s=3DMsoNormal>&nbsp;&nbsp;&nbsp; &lt;/DH675AU&gt;<o:p></o:p></p><p class=3D=
MsoNormal>&nbsp;&nbsp;&nbsp; &lt;DH675AU&gt;<o:p></o:p></p><p class=3DMsoNo=
rmal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FIG_NO&gt;69500&lt;/FIG=
_NO&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp; &lt;PART_DES&gt;SCREW, SELF-TAPPING&lt;/PART_DES&gt;<o:p></o:p><=
/p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp; &lt;/DH675AU&gt;<o:p></o:p></p><=
p class=3DMsoNormal>&lt;/dataroot&gt;<o:p></o:p></p><p class=3DMsoNormal><o=
:p>&nbsp;</o:p></p><p class=3DMsoNormal>Here is my desired output:<o:p></o:=
p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal>&lt;?x=
ml version=3D&quot;1.0&quot; encoding=3D&quot;UTF-8&quot;?&gt;<o:p></o:p></=
p><p class=3DMsoNormal>&lt;root&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbs=
p;&nbsp; &lt;entry&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp; &lt;figure&gt;99999&lt;/figure&gt;<o:p></o:p></p><p class=3DM=
soNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;description&gt;DIPSTICK&lt;/des=
cription&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp; &lt;description&gt;O-RING&lt;/description&gt;<o:p></o:p></p><p class=3D=
MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;description&gt;SCREW, SELF-TAP=
PING&lt;/description&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp; &lt;note&gt;NOTE: (1) NOT SERVICED SEPARATELY. INCLUDED IN&=
lt;/note&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp; &lt;note&gt;58F-98-40740 SEAL KIT.&lt;/note&gt;<o:p></o:p></p><p class=
=3DMsoNormal>&nbsp;&nbsp; &lt;/entry&gt;<o:p></o:p></p><p class=3DMsoNormal=
>&nbsp;&nbsp; &lt;entry&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp; &lt;figure&gt;69500&lt;/figure&gt;<o:p></o:p></p><p clas=
s=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;description&gt;DIPSTICK&lt=
;/description&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp; &lt;description&gt;O-RING&lt;/description&gt;<o:p></o:p></p><p cla=
ss=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;description&gt;SCREW, SEL=
F-TAPPING&lt;/description&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbs=
p; &lt;/entry&gt;<o:p></o:p></p><p class=3DMsoNormal>&lt;/root&gt;<o:p></o:=
p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal>Here i=
s my stylesheet:<o:p></o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p=
 class=3DMsoNormal>&lt;?xml version=3D&quot;1.0&quot; encoding=3D&quot;UTF-=
8&quot;?&gt;<o:p></o:p></p><p class=3DMsoNormal>&lt;xsl:stylesheet xmlns:xs=
l=3D&quot;http://www.w3.org/1999/XSL/Transform&quot;<o:p></o:p></p><p class=
=3DMsoNormal>&nbsp;&nbsp;&nbsp; xmlns:xs=3D&quot;http://www.w3.org/2001/XML=
Schema&quot;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp; xmlns:ma=
th=3D&quot;http://www.w3.org/2005/xpath-functions/math&quot;<o:p></o:p></p>=
<p class=3DMsoNormal>&nbsp;&nbsp;&nbsp; exclude-result-prefixes=3D&quot;xs =
math&quot;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp; version=3D=
&quot;3.0&quot; expand-text=3D&quot;true&quot;&gt;<o:p></o:p></p><p class=
=3DMsoNormal>&nbsp;&nbsp;&nbsp; <o:p></o:p></p><p class=3DMsoNormal>&nbsp;&=
nbsp;&nbsp;&nbsp;&lt;xsl:output method=3D&quot;xml&quot; indent=3D&quot;yes=
&quot;/&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp; <o:p></o:=
p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsl:template match=
=3D&quot;/dataroot&quot;&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;root&gt;<o:p></o:p></p><p class=3DMsoNo=
rmal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt=
;xsl:call-template name=3D&quot;make-components&quot;/&gt;<o:p></o:p></p><p=
 class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/root&gt;=
<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp; &lt;/xsl:template&gt=
;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp; <o:p></o:p></p><p c=
lass=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsl:template name=3D&quot;make=
-components&quot;&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsl:for-each-group select=3D&quot;*&quot; grou=
p-by=3D&quot;child::FIG_NO&quot;&gt;<o:p></o:p></p><p class=3DMsoNormal>&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsl:cal=
l-template name=3D&quot;make-entries&quot;/&gt;<o:p></o:p></p><p class=3DMs=
oNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xsl:for-each-group&=
gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp; &lt;/xsl:template=
&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp; <o:p></o:p></p><=
p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsl:template name=3D&quot;m=
ake-entries&quot;&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp; &lt;entry&gt;<o:p></o:p></p><p class=3DMsoNormal>&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;figur=
e&gt;&lt;xsl:apply-templates select=3D&quot;current-group()[1]/FIG_NO&quot;=
/&gt;&lt;/figure&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsl:for-each select=3D&=
quot;current-group()&quot;&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp; &lt;xsl:choose&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsl:when test=3D&quot;PART_DES[matches(.,'NOT=
E')] or preceding::PART_DES[matches(.,'NOTE')]&quot;&gt;<o:p></o:p></p><p c=
lass=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp; &lt;note&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsl:=
apply-templates select=3D&quot;PART_DES&quot;/&gt;<o:p></o:p></p><p class=
=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
; &lt;/note&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp; &lt;/xsl:when&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsl:otherwise&gt;<o:p></o:p></p><p cl=
ass=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp; &lt;description&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &l=
t;xsl:apply-templates select=3D&quot;PART_DES&quot;/&gt;<o:p></o:p></p><p c=
lass=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp; &lt;/description&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xsl:otherwise&gt;<o:p></o:p></p><p class=3D=
MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xsl:choose&gt;<o:p></o:p></p><p class=3DMsoN=
ormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &l=
t;/xsl:for-each&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp; &lt;/entry&gt;<o:p></o:p></p><p class=3DMsoNormal>&n=
bsp;&nbsp;&nbsp; &lt;/xsl:template&gt;<o:p></o:p></p><p class=3DMsoNormal>&=
nbsp;&nbsp;&nbsp;&nbsp; <o:p></o:p></p><p class=3DMsoNormal>&lt;/xsl:styles=
heet&gt;<o:p></o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=
=3DMsoNormal>Here is what I am getting:<o:p></o:p></p><p class=3DMsoNormal>=
<o:p>&nbsp;</o:p></p><p class=3DMsoNormal>&lt;?xml version=3D&quot;1.0&quot=
; encoding=3D&quot;UTF-8&quot;?&gt;<o:p></o:p></p><p class=3DMsoNormal>&lt;=
root&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp; &lt;entry&gt;<o:p>=
</o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;figure&gt=
;99999&lt;/figure&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp; &lt;description&gt;DIPSTICK&lt;/description&gt;<o:p></o:p></p>=
<p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;description&gt;O-RI=
NG&lt;/description&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp; &lt;description&gt;SCREW, SELF-TAPPING&lt;/description&gt;<o:=
p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;note&gt=
;NOTE: (1) NOT SERVICED SEPARATELY. INCLUDED IN&lt;/note&gt;<o:p></o:p></p>=
<p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;note&gt;58F-98-4074=
0 SEAL KIT.&lt;/note&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp; &l=
t;/entry&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp; &lt;entry&gt;<=
o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;figur=
e&gt;69500&lt;/figure&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp; &lt;note&gt;DIPSTICK&lt;/note&gt;<o:p></o:p></p><p class=
=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;note&gt;O-RING&lt;/note&gt;=
<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;note=
&gt;SCREW, SELF-TAPPING&lt;/note&gt;<o:p></o:p></p><p class=3DMsoNormal>&nb=
sp;&nbsp; &lt;/entry&gt;<o:p></o:p></p><p class=3DMsoNormal>&lt;/root&gt;<o=
:p></o:p></p><p class=3DMsoNormal><span lang=3Den-BB><o:p>&nbsp;</o:p></spa=
n></p><p class=3DMsoNormal>The idea is that when I see a &#8220;NOTE&#8221;=
 string, I want that entry and all following within the same group to be &l=
t;note&gt; elements. So I am look for preceding-sibling or self that contai=
ns &#8220;NOTE&#8221; but restricted to the same group. <span lang=3Den-BB>=
I am using XSLT 3. Thank you very much.<o:p></o:p></span></p><p class=3DMso=
Normal><span lang=3Den-BB><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal>=
<span lang=3Den-BB>Rick<o:p></o:p></span></p><p class=3DMsoNormal><o:p>&nbs=
p;</o:p></p><p class=3DMsoNormal>Rick Quatro<o:p></o:p></p><p class=3DMsoNo=
rmal>Carmen Publishing Inc.<o:p></o:p></p><p class=3DMsoNormal>585-729-6746=
<o:p></o:p></p><p class=3DMsoNormal><a href=3D"mailto:[email protected]"=
>[email protected]</a><o:p></o:p></p><p class=3DMsoNormal><a href=3D"htt=
p://www.frameexpert.com/store">http://www.frameexpert.com/store</a><o:p></o=
:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal><span=
 lang=3Den-BB><o:p>&nbsp;</o:p></span></p><div><div style=3D'border:none;bo=
rder-top:solid black 1.0pt;padding:4.0pt 0in 0in 0in;margin-top:5.0pt;margi=
n-bottom:5.0pt'><p class=3DMsoNormal align=3Dcenter style=3D'text-align:cen=
ter;background:#DDDDDD'><span style=3D'font-size:7.5pt;font-family:"Arial",=
sans-serif;color:#888888'><a href=3D"http://www.mulberrytech.com/xsl/xsl-li=
st">XSL-List info and archive</a> <o:p></o:p></span></p><p class=3DMsoNorma=
l align=3Dcenter style=3D'text-align:center;background:#DDDDDD'><span style=
=3D'font-size:7.5pt;font-family:"Arial",sans-serif;color:#888888'><a href=
=3D"http://lists.mulberrytech.com/unsub/xsl-list/612310"><span style=3D'col=
or:blue'>EasyUnsubscribe</span></a> (<a href=3D""><span style=3D'color:blue=
'>by email</span></a>) <o:p></o:p></span></p></div></div></div></body></htm=
l>
<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>

------=_NextPart_000_044E_01D74D93.F2E40500--