Re: [xsl] Problem with grouping sibling tags

Subject: Re: [xsl] Problem with grouping sibling tags
From: Casper Voortman <casper.voortman@xxxxxxxxxxxx>
Date: Tue, 23 Dec 2008 12:12:01 +0100
Thanks Micheal,

The second link post seems more in the direction of what i'm looking for, but unfortunately i'm not completely grasping the process. Will study it harder, but this is 'higher' xslt writing for me.

Regards,

Casper Voortman

Op 23 dec 2008, om 11:45 heeft Michael Kay het volgende geschreven:


Go to http://xsl.markmail.org/ and search for "group adjacent bullets".

And in particular Ken Holman's post at
http://markmail.org/message/teo6uftbxjvsa56c (dated 22 Oct 1999) which must
be the earliest exposition of the technique often called "sibling
recursion".


Michael Kay
http://www.saxonica.com/


-----Original Message-----
From: Casper Voortman [mailto:casper.voortman@xxxxxxxxxxxx]
Sent: 23 December 2008 10:25
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Problem with grouping sibling tags

Hey everyone,

I have a problem within an xslt i'm writing that i just
can't figure
out how to solve. I think i have to use either some kind of
grouping
or work with preceding-sibling or following-sibling, maybe
even both
combined together. It has to be done in xslt version 1.0
which (for as
much as i have read on it) seems to be more complicated on
itself as
far as groupings and such go.

Here is a small description together with some samples.

The XML follows a structure like the following ( i have
replaced the
original text for 'textcontent' and 'bullet'
otherwise it would get too long a mail):

<?xml version="1.0" encoding="UTF-8"?> <ArticleContent>
    <Frame Label="BroodTekst">
        <Paragraph Pstyle="Tussenkop">
            <Text Cstyle="[No character style]">textcontent</Text>
            <Text Cstyle="[No character style]"/>
        </Paragraph>
        <Paragraph Pstyle="PlattetekstInitiaal">
            <Text Cstyle="[No character style]">textcontent</Text>
        </Paragraph>
        <Paragraph Pstyle="PlattetekstBullet">
            <Text Cstyle="[No character style]">bullet1</Text>
        </Paragraph>
        <Paragraph Pstyle="PlattetekstBullet">
            <Text Cstyle="[No character style]">bullet2</Text>
        </Paragraph>
        <Paragraph Pstyle="Plattetekst">
            <Text Cstyle="[No character style]">textcontent</Text>
        </Paragraph>
        <Paragraph Pstyle="Plattetekst">
            <Text Cstyle="[No character style]">textcontent</Text>
        </Paragraph>
        <Paragraph Pstyle="PlattetekstBullet">
            <Text Cstyle="[No character style]">bullet3</Text>
        </Paragraph>
    </Frame>
</ArticleContent>

This needs to be converted to another XML file that has the
following
structure:

<?xml version="1.0" encoding="utf-8"?> <section role="broodtekst">
<title role="tussenkop">textcontent</title>
<para role="plattetekstinitiaal">textcontent</para>
<itemizedlist>
	<listitem>
	   <para role="plattetekstbullet">bullet1</para>
	</listitem>
	<listitem>
	   <para role="plattetekstbullet">bullet2</para>
	</listitem>
</itemizedlist>
<para role="plattetekst">textcontent</para>
<para role="plattetekst">textcontent</para>
<itemizedlist>
	<listitem>
	   <para role="plattetekstbullet">bullet3</para>
	</listitem>
</itemizedlist>
</frame>

Now my problem is with the original tags <Paragraph
Pstyle="PlattetekstBullet"> these need to be grouped
together in the
new tag <itemizedlist>, but the structure within the story needs to
stay intact. So when another <Paragraph Pstyle="PlattetekstBullet">
appears that is not preceded or followed by the same <Paragraph
Pstyle="PlattetekstBullet"> tag they need to be grouped as well
separately.

I can provide the XSLT i have sofar if needed, but it's a
fairly long
one and it might clutter the issue.

Any help would be greatly appreciated and would make my x-mas.

Regards,

Casper Voortman

Current Thread