[xsl] Re: using OR in a group-ending-with test

Subject: [xsl] Re: using OR in a group-ending-with test
From: Jeff Wilson <jeffrey@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 16 Aug 2011 02:43:05 -0700
Good morning,

It seems that xsl:for-each-group may not be the correct way to go about what I'm trying to do. All I need to do is nest adjacent paras styled with "Feature..." in a new element.

Would it be easier to test the following-sibling's value to determine when to end the nesting element? Or is grouping the correct logic?

Given (simplified):

<w:p><w:pPr><w:pStyle @w:val="Para"></w:pPr></w:p>
<w:p><w:pPr><w:pStyle @w:val="Para"></w:pPr></w:p>
<w:p><w:pPr><w:pStyle @w:val="FeatureType"></w:pPr></w:p>
<w:p><w:pPr><w:pStyle @w:val="FeatureTitle"></w:pPr></w:p>
<w:p><w:pPr><w:pStyle @w:val="FeaturePara"></w:pPr></w:p>
<w:p><w:pPr><w:pStyle @w:val="FeaturePara"></w:pPr></w:p>
<w:p><w:pPr><w:pStyle @w:val="FeatureSlug"></w:pPr></w:p>
<w:p><w:pPr><w:pStyle @w:val="FeatureList"></w:pPr></w:p>
<w:p><w:pPr><w:pStyle @w:val="FeatureList"></w:pPr></w:p>
<w:p><w:pPr><w:pStyle @w:val="FeatureList"></w:pPr></w:p>
<w:p><w:pPr><w:pStyle @w:val="FeaturePara"></w:pPr></w:p>
<w:p><w:pPr><w:pStyle @w:val="Para"></w:pPr></w:p>
<w:p><w:pPr><w:pStyle @w:val="H1"></w:pPr></w:p>

I would like to end up with (simplified):

<Para>...</Para>
<Para>...</Para>
<AnchoredFeature>
<FeatureTitle>...</FeatureTitle>
<FeaturePara>...</FeaturePara>
<FeaturePara>...</FeaturePara>
<img src="...">
<FeatureList>...</FeatureList>
<FeatureList>...</FeatureList>
<FeatureList>...</FeatureList>
<FeaturePara>...</FeaturePara>
</AnchoredFeature>
<Para>...</Para>
<H1>...</H1>

I've tried many permutations of the select and group-by, group- adjacent, group-starting-with and group-ending-with to varying degrees of success. But it seems to me after much trial and error, that I might just be barking up the wrong tree.

Thanks to all who've responded, you're kindness is deeply appreciated.

Jeff

On Aug 15, 2011, at 12:51 PM, Jeff Wilson wrote:

Good afternoon,

I'm trying to get a group to end with either of two conditions.

This is the current group test:

<xsl:for-each-group select="following-sibling::w:p/w:pPr/w:pStyle/ @w:val[starts-with(.,'Feature')]/ancestor::w:p" group-ending- with="w:p/w:pPr/w:pStyle/@w:val[not(starts-with(.,'Feature')) or 'FeatureType']">

The resulting xml runs includes every following-sibling in the document, so I assume (and may be incorrect) that the problem is with my ending-with test.

Current Thread