Subject: Re: [xsl] using for-each-group to wrap an element From: Brandon Ibach <brandon.ibach@xxxxxxxxxxxxxxxxxxx> Date: Tue, 23 Aug 2011 05:20:15 -0400 |
You're grouping the child *nodes* of <root>, rather than just the elements. Since your input appears to have whitespace between elements, the <FeatureType> and <FeaturePara> are not adjacent. -Brandon :) On Tue, Aug 23, 2011 at 5:08 AM, Jeff Wilson <jeffrey@xxxxxxxxxxxxxxxxxxxx> wrote: > Good morning, > > I'm still working with for-each-group in order to wrap an element around > adjacent siblings. I decided to use a 2nd transformation to take care of > the grouping. I'm getting closer, but I don't know what I've done wrong > here. > > Again, thank you for your help. > > Input: > <root> > <ChapterTitle>...</ChapterTitle> > <H1>...</H1> > <Para>...</Para> > <Para>...</Para> > <AnchoredGraphic><img src="..."/></AnchoredGraphic> > <H1>...</H1> > <Para>...</Para> > <H2>...</H2> > <Para>...</Para> > <FeatureType>...</FeatureType> > <FeaturePara>...</FeaturePara> > <ListNumbered>...</ListNumbered> > <ListNumbered>...</ListNumbered> > <ListPara>...</ListPara> > <ListNumbered>...</ListNumbered> > </root> > > Desired Output: > <root> > <ChapterTitle>...</ChapterTitle> > <H1>...</H1> > <Para>...</Para> > <Para>...</Para> > <AnchoredGraphic><img src="..."/></AnchoredGraphic> > <H1>...</H1> > <Para>...</Para> > <H2>...</H2> > <Para>...</Para> > <AnchoredFeature> > <FeatureType>...</FeatureType> > <FeaturePara>...</FeaturePara> > </AnchoredFeature > <ListNumbered>...</ListNumbered> > <ListNumbered>...</ListNumbered> > <ListPara>...</ListPara> > <ListNumbered>...</ListNumbered> > </root> > > Current output: > <root> > <ChapterTitle>...</ChapterTitle> > <H1>...</H1> > <Para>...</Para> > <Para>...</Para> > <AnchoredGraphic><img src=".."/></AnchoredGraphic> > <H1>...</H1> > <Para>...</Para> > <H2>...</H2> > <Para>...</Para> > <AnchoredFeature><FeatureType>...</FeatureType></AnchoredFeature> > <AnchoredFeature><FeaturePara>...</FeaturePara></AnchoredFeature> > <ListNumbered>...</ListNumbered> > <ListNumbered>...</ListNumbered> > <ListPara>...</ListPara> > <ListNumbered>...</ListNumbered> > </root> > > XSL: > <?xml version="1.0" encoding="UTF-8"?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="2.0"> > <xsl:template match="root"> > <xsl:element name="root"> > <xsl:for-each-group select="child::node()" > group-adjacent="starts-with(name(),'Feature')"> > <xsl:choose> > <xsl:when test="current-grouping-key()"> > <xsl:element name="AnchoredFeature"> > <xsl:copy-of select="current-group()"/> > </xsl:element> > </xsl:when> > <xsl:otherwise> > <xsl:copy-of select="current-group()"/> > </xsl:otherwise> > </xsl:choose> > </xsl:for-each-group> > </xsl:element> > </xsl:template> > </xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] using for-each-group to wrap , Jeff Wilson | Thread | [xsl] strange error message parsing, Matthieu Ricaud-Duss |
[xsl] using for-each-group to wrap , Jeff Wilson | Date | Re: [xsl] XSL stylesheet embedding , Hermann Stamm-Wilbra |
Month |