[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
hello
i've a flat xml-doc that i want to structure with the for-each-group function. everything ist working fine, but i cant deselect the first group (wgicg i dont need). i've experimented with several ideas but i can't find the solution.
any help would be great!
thank you
gregor
-- My XSLT -------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2004/07/xpath-functions" xmlns:xdt="http://www.w3.org/2004/07/xpath-datatypes">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="ehapa">
<ehapa>
<xsl:for-each-group select="*" group-starting-with="kapitel-container">
<xsl:element name="kapitel" >
<xsl:attribute name="abschnittsmarke" select="@abschnittsmarke"/>
<xsl:attribute name="nav-titel" select="@nav-titel"/>
<xsl:for-each-group select="current-group()" group-starting-with="headline-container">
<xsl:element name="artikel" >
<xsl:attribute name="nav-titel" select="@nav-titel"/>
<xsl:for-each select="current-group()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:for-each>
</xsl:element>
</xsl:for-each-group>
</xsl:element>
</xsl:for-each-group>
</ehapa>
</xsl:template>
</xsl:stylesheet>
-- What I get ... using built in XMLSPY 2005 Home Processor ---
<?xml version="1.0" encoding="UTF-8"?>
<ehapa>
<kapitel abschnittsmarke="Einleitung" nav-titel="e00">
<artikel nav-titel="e00">
<kapitel-container abschnittsmarke="Einleitung" art="kapitel-start" nav-titel="e00">
[..]
</kapitel-container>
</artikel>
<artikel nav-titel="e00_ein01">
<headline-container art="headline" nav-titel="e00_ein01">
[...]
</headline-container>
</artikel>
[...]
</kapitel>
[...]
</ehapa>
--- My Source ist ---------
<ehapa>
<kapitel-container abschnittsmarke="Einleitung" art="kapitel-start" nav-titel="e00">[...]</kapitel-container>
<headline-container art="headline" nav-titel="e00_ein01">[...]</headline-container>
<artikel-container art="textbox" nav-titel="e00_ein01">[...]>/artikel-container>
<artikel-container art="textbox" nav-titel="e00_ein01">[...]>/artikel-container>
<artikel-container art="textbox" nav-titel="e00_ein01">[...]>/artikel-container>
<headline-container art="headline" nav-titel="e00_ein01">[...]</headline-container>
[...]
[xsl] for-each-group but not the first?
Subject: [xsl] for-each-group but not the first? From: "gregor FELLENZ" <gf_public@xxxxxxx> Date: Tue, 15 Feb 2005 18:17:28 +0100 |
hello
i've a flat xml-doc that i want to structure with the for-each-group function. everything ist working fine, but i cant deselect the first group (wgicg i dont need). i've experimented with several ideas but i can't find the solution.
any help would be great!
thank you
gregor
-- My XSLT -------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2004/07/xpath-functions" xmlns:xdt="http://www.w3.org/2004/07/xpath-datatypes">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@*|node()" priority="-1"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template>
<xsl:template match="ehapa">
<ehapa>
<xsl:for-each-group select="*" group-starting-with="kapitel-container">
<xsl:element name="kapitel" >
<xsl:attribute name="abschnittsmarke" select="@abschnittsmarke"/>
<xsl:attribute name="nav-titel" select="@nav-titel"/>
<xsl:for-each-group select="current-group()" group-starting-with="headline-container">
<xsl:element name="artikel" >
<xsl:attribute name="nav-titel" select="@nav-titel"/>
<xsl:for-each select="current-group()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:for-each>
</xsl:element>
</xsl:for-each-group>
</xsl:element>
</xsl:for-each-group>
</ehapa>
</xsl:template>
</xsl:stylesheet>
-- What I get ... using built in XMLSPY 2005 Home Processor ---
<?xml version="1.0" encoding="UTF-8"?>
<ehapa>
<kapitel abschnittsmarke="Einleitung" nav-titel="e00">
<artikel nav-titel="e00">
<kapitel-container abschnittsmarke="Einleitung" art="kapitel-start" nav-titel="e00">
[..]
</kapitel-container>
</artikel>
<artikel nav-titel="e00_ein01">
<headline-container art="headline" nav-titel="e00_ein01">
[...]
</headline-container>
</artikel>
[...]
</kapitel>
[...]
</ehapa>
-- What I need - The same without the first group ---- <?xml version="1.0" encoding="UTF-8"?> <ehapa> <kapitel abschnittsmarke="Einleitung" nav-titel="e00"> <artikel nav-titel="e00_ein01"> <headline-container art="headline" nav-titel="e00_ein01"> [...] </headline-container> </artikel> [...] </kapitel> [...] </ehapa>
--- My Source ist ---------
<ehapa>
<kapitel-container abschnittsmarke="Einleitung" art="kapitel-start" nav-titel="e00">[...]</kapitel-container>
<headline-container art="headline" nav-titel="e00_ein01">[...]</headline-container>
<artikel-container art="textbox" nav-titel="e00_ein01">[...]>/artikel-container>
<artikel-container art="textbox" nav-titel="e00_ein01">[...]>/artikel-container>
<artikel-container art="textbox" nav-titel="e00_ein01">[...]>/artikel-container>
<headline-container art="headline" nav-titel="e00_ein01">[...]</headline-container>
[...]
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Saxon: java extension fun, Richard Lewis | Thread | Re: [xsl] for-each-group but not th, David Carlisle |
RE: [xsl] Performance problem, Michael Kay | Date | Re: [xsl] Replacing character entit, Wagstaff, Jason |
Month |
Keywords