|
Subject: Re: [xsl] sequential grouping question From: Paul <reganmian@xxxxxxxxx> Date: Sun, 17 Nov 2002 07:28:29 -0800 (PST) |
Thank you Joerg !
it's beautiful, I realizedthis it's 'Muench method'
thank you for the leads. although the grouping the
substring is poor, I can make a temp tree with these
strings.
regards.
Paul
--- Joerg Heinicke <joerg.heinicke@xxxxxx> wrote:
> Hello Paul,
>
> it's a really poor XML for grouping. You must group
> the <xs:element/> by
> their preceding- or
> following-sibling::xsl:element[not(starts-with(@ref,
>
> 'snoopy'))]. Grouping by a substring must be poor.
> Do you really have no
> influence on the input?
>
> <xsl:key name="elements" match="xs:element"
> use="generate-id((preceding-sibling::xs:element |
> self::xs:element)
> [not(starts-with(@ref, 'snoopy'))][last()])"/>
>
> <xsl:template match="xs:sequence">
> <xsl:apply-templates select="key('elements', '')"
> mode="start"/>
> <xsl:apply-templates select="key('elements', '')"
> mode="end"/>
> ---
> <xsl:apply-templates
> select="xs:element[not(starts-with(@ref,
> 'snoopy'))]" mode="group"/>
> </xsl:template>
>
> <xsl:template match="xs:element" mode="group">
> <xsl:apply-templates select="." mode="start"/>
> <xsl:apply-templates select="." mode="end"/>
> <xsl:apply-templates select="key('elements',
> generate-id())[generate-id() !=
> generate-id(current())]" mode="start"/>
> <xsl:apply-templates select="key('elements',
> generate-id())[generate-id() !=
> generate-id(current())]" mode="end"/>
> ---
> </xsl:template>
>
> <xsl:template match="xs:element" mode="start">
> <xsl:value-of select="@ref"/> starts
> </xsl:template>
>
> <xsl:template match="xs:element" mode="end">
> <xsl:value-of select="@ref"/> ends
> </xsl:template>
>
> Output:
>
> snoopy-a starts
> snoopy-b starts
> snoopy-c starts
> snoopy-a ends
> snoopy-b ends
> snoopy-c ends
> ---
> Harry-GROUP starts
> Harry-GROUP ends
> snoopy-d starts
> snoopy-e starts
> snoopy-d ends
> snoopy-e ends
> ---
> MickeyMouse-GROUP starts
> MickeyMouse-GROUP ends
> snoopy-f starts
> snoopy-f ends
> ---
>
> Regards,
>
> Joerg
>
>
> hb wrote:
> > Hi
> >
> > stuck by belowed grouping problem, Is it possible
> to
> > give any suggestion ?
> >
> > ++++++++++++ begin schema +++++++++++
> >
> > <xs:element name="LETTERMSG">
> > <xs:complexType>
> > <xs:sequence>
> > <xs:element ref="snoopy-a"/>
> > <xs:element ref="snoopy-b"/>
> > <xs:element ref="snoopy-c"/>
> > <xs:element ref="Harry-GROUP"/>
> > <xs:element ref="snoopy-d"/>
> > <xs:element ref="snoopy-e"/>
> > <xs:element ref="MickeyMouse-GROUP"/>
> > <xs:element ref="snoopy-f"/>
> > </xs:sequence>
> > </xs:complexType>
> > </xs:element>
> > </xs:schema>
> > ++++++++++++ end schema +++++++++++
> >
> > ++++++++++++ begin output +++++++++++
> > snoopy-a goto room(1)
> > snoopy-b goto room(2)
> > snoopy-c goto room(3)
> > snoopy-a back form room(1)
> > snoopy-b back form room(2)
> > snoopy-c back form room(3)
> >
> > Hacked Harry-GROUP, putinto safetybox(1)
> > get Harry-GROUP form safetybox(1)
> >
> > snoopy-d goto room(1)
> > snoopy-e goto room(2)
> > snoopy-d back form room(1)
> > snoopy-e back form room(2)
> >
> > Hacked MickeyMouse-GROUP, putinto safetybox(1)
> > get MickeyMouse-GROUP form safetybox(1)
> >
> > snoopy-f goto room(1)
> > snoopy-f back form room(1)
> > +++++++++++ end output +++++++++++
> >
> > the desired output need to be
> > 1) by SEQUENCE
> > 2) by different TYPE(group or simple element)
> >
> > (it's dynamic because, the style sheet have to
> apply
> > different schema of LETTERMSG)
> >
> > Is there any idea ?
> >
> > Many thanks
> > Paul
>
>
> XSL-List info and archive:
> http://www.mulberrytech.com/xsl/xsl-list
>
__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] sequential grouping quest, Joerg Heinicke | Thread | [xsl] XML from JSP, Gavin Myers |
| RE: [xsl] fo:table border, Satish Kumar.R- CTD, | Date | [xsl] how to delete an attribute af, Noel Golding |
| Month |