xsl-list
[Top] [All Lists]

[xsl] grouping problem

2010-04-05 06:42:43
Dear Patrick,
Here is a solution of the problem you posted:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:xs="http://www.w3.org/2001/XMLSchema"; exclude-result-prefixes="xs" version="2.0">

<!-- copying element names and the text inside them -->
<xsl:template match="rechtliche-begruendung|ueberschrift">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

<!-- wrapping randziffer around every rz-zaehlung tag -->
<xsl:template match="rz-zaehlung">
<randziffer>
<rz-zaehlung>
<xsl:apply-templates/>
</rz-zaehlung>
<!-- Pulling the next sibling provided its neither rz-zaehlung nor absatz with roman number as text --> <xsl:apply-templates select="following-sibling::*[1][not(self::rz-zaehlung)][not(self::absatz[matches(.,'(^[IVXL]*)([.]+$)')])]" mode="grouping"/>
</randziffer>
</xsl:template>

<xsl:template match="absatz" mode="grouping">
<absatz>
<xsl:apply-templates/>
</absatz>
<!-- Agin, pulling the next sibling provided its neither rz-zaehlung nor absatz with roman number as text --> <xsl:apply-templates select="following-sibling::*[1][not(self::rz-zaehlung)][not(self::absatz[matches(.,'(^[IVXL]*)([.]+$)')])]" mode="grouping"/>
</xsl:template>


<xsl:template match="absatz">
<xsl:choose>
<!-- If the text insde is a roman number, tag it -->
<xsl:when test="matches(.,'(^[IVXL]*)([.]+$)')">
<absatz>
<xsl:apply-templates/>
</absatz>
</xsl:when>
<!-- We don't need to do anything here because mode=grouping has taken care of this condition -->
<xsl:otherwise/>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>


Best,
Siddhi
----------------------------------------------------------------------
Date: Fri, 2 Apr 2010 11:50:48 +0200
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
From: "Szabo, Patrick \(LNG-VIE\)" 
<patrick(_dot_)szabo(_at_)lexisnexis(_dot_)at>
Subject: grouping problem
Message-ID: <AB4D914EE3A3254CA8F439925297E4C606F986CA(_at_)LNGVIEEXCP01VB(_dot_)legal(_dot_)regn(_dot_)net>

Hi,=20
=20
I'm using XSLT 2.0 and Saxon 9.=20
=20
I've got the following structure:
=20
<rechtliche-begruendung>
   <ueberschrift>Gr=C3=BCnde:</ueberschrift>
   <absatz>I.</absatz>
   <rz-zaehlung>1</rz-zaehlung>
   <absatz>blabla</absatz>
   <rz-zaehlung>2</rz-zaehlung>
   <absatz>blabla</absatz>
   <absatz>I.</absatz>
   <rz-zaehlung>3</rz-zaehlung>
   <absatz>blabla</absatz>
   <absatz>blabla</absatz>
   <rz-zaehlung>4</rz-zaehlung>
   <absatz>blabla</absatz>
   <absatz>II.</absatz>
   <rz-zaehlung>5</rz-zaehlung>
   <absatz>blabla</absatz>
</rechtliche-begruendung>

It should look like this after grouping:

<rechtliche-begruendung>
   <ueberschrift>Gr=C3=BCnde:</ueberschrift>
   <absatz>I.</absatz>
   <randziffer>
     <rz-zaehlung>1</rz-zaehlung>
 <absatz>blabla</absatz>
   </randziffer>   =20
   <randziffer>
     <rz-zaehlung>2</rz-zaehlung>
   <absatz>blabla</absatz>
   </randziffer>
   <absatz>I.</absatz>
   <randziffer>   =20
<rz-zaehlung>3</rz-zaehlung>
   <absatz>blabla</absatz>
     <absatz>blabla</absatz>
   </randziffer>
   <randziffer>   =20
<rz-zaehlung>4</rz-zaehlung>
     <absatz>blabla</absatz>
   </randziffer>
   <absatz>II.</absatz>
   <randziffer>   =20
<rz-zaehlung>5</rz-zaehlung>
     <absatz>blabla</absatz>
   </randziffer>
</rechtliche-begruendung>

So a group is starting with rz-zeahlung.
The problem is that i don't want to have those <absatz> elements in the =
groups that=20
contain roman numbers...

Can anybody help me ?!

best regards

Patrick Szabo
XSLT-Entwickler=20

Tel.: +43 (1) 534 52 - 1573=20
Fax: +43 (1) 534 52 - 146=20

Patrick(_dot_)Szabo(_at_)lexisnexis(_dot_)at

LexisNexis Verlag ARD Orac GmbH & Co KG
Marxergasse 25, 1030 Wien
FN 8333f, Handelsgericht Wien
http://www.lexisnexis.at/
=20

------------------------------


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>