Subject: Re: Re: using OR in a group-ending-with test
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Tue, 16 Aug 2011 11:00:53 +0100
|
On 16 August 2011 10:43, Jeff Wilson <jeffrey@xxxxxxxxxxxxxxxxxxxx> wrote:
> 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>
^^^ what is that ? ^^^^^^
It's not xml... its rubbish in so many ways. How hard is it to put
together a small complete sample... if anyone wanted to use that
sample they would need to spend 5 mins correcting it first, then more
time wading through the redundant namespaces and nesting for this
problem. You could just use:
<root>
<foo val="para"/>
<foo val="feature"/>
<foo val="feature/>
<foo val="feature"/>
</root>
> 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>
You just need a for-each-group selecting the elements you want to
group, using group-adjacent to select the common thing to group on:
<xsl:for-each-group select="w:p"
group-adjacent="w:pPr/w:pStyle/@w:val/starts-with(., 'Feature')">
--
Andrew Welch
http://andrewjwelch.com
|