[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xsl-grouping two different elements together

Subject: Re: xsl-grouping two different elements together
From: gregor FELLENZ <gregor@xxxxxxxxxxxx>
Date: Tue, 16 Mar 2010 16:14:43 +0100
Re:  xsl-grouping two different elements together
hey david,

tanks for the quick reply!

On 16.03.2010 16:09, David Carlisle wrote:
> It's hard sometimes to infer a general rule from a single example, but
> perhaps something like this, assuming that abs is usable as a group
> separator:

unfortunately i can't use <abs> as separator... there are around 10 other block level elements on the same level. the target structure is similar to html (<einschub typ="1"> behaves like a <div class="1"> [a german one :-/ ] ) in the source a <kapitel> is a chapter with block-level children (lists, table, ... ). therefore the group-adjacent="local-name()" is also used for grouping lists ... [fyi the whole template:

<xsl:template match="kapitel">
<xsl:element name="kapitel">
<xsl:copy-of select="@sprungziel"/>
<xsl:copy-of select="@DOI"/>
<xsl:copy-of select="@typ"/>
<xsl:copy-of select="@leseprobe"/>
<xsl:for-each-group select="*" group-adjacent="local-name()" >
<xsl:choose>
<xsl:when test="starts-with(current-grouping-key(),'einschub')">
<xsl:choose>
<xsl:when test="starts-with(local-name(following-sibling::*[1]), 'u') and not (starts-with(local-name(following-sibling::*[1]), 'u-zwischen'))">
<xsl:element name="einschub_vor">
<xsl:attribute name="typ" select='replace(local-name(), "[^\d]+", "")'/>
<xsl:apply-templates select="current-group()"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="einschub">
<xsl:attribute name="typ" select='replace(local-name(), "[^\d]+", "")'/>
<xsl:apply-templates select="current-group()"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="starts-with(current-grouping-key(),'liste_ungeordnet')">
<xsl:element name="liste_ungeordnet">
<xsl:attribute name="typ" select='replace(local-name(), "[^\d]+", "")'/>
<xsl:attribute name="zaehlertyp" select="@zaehlertyp"></xsl:attribute>
<xsl:apply-templates select="current-group()"/>
</xsl:element>
</xsl:when>
<xsl:when test="starts-with(current-grouping-key(),'liste_geordnet')">
<xsl:element name="liste_geordnet">
<xsl:attribute name="typ" select='replace(local-name(), "[^\d]+", "")'/>
<xsl:attribute name="zaehlertyp" select="@zaehlertyp"></xsl:attribute>
<xsl:apply-templates select="current-group()"/>
</xsl:element>
</xsl:when>


                    <xsl:otherwise>
                        <xsl:apply-templates select="current-group()"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:for-each-group>
        </xsl:element>
    </xsl:template>

]

regards,
gregor

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.