[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Darrell,
At 04:32 PM 8/27/2002, you wrote:
Yep. Actually, just this morning.
Check out the thread "[xsl] Constructing hierarchical XML from a flat XML-tag sequence using XSLT", which Mike Kay and Tom Schutzer answered.
It's also in the FAQ: check out http://www.dpawson.co.uk/xsl/sect2/flatfile.html.
Basically it's a grouping problem. Your choice is whether to select nodes based directly on their relative positions in the flat (non-)hierarchy, or whether to do effectively the same thing using keys (which is good if the case is complex, but it doesn't look as though yours is).
Adapting Mike's solution from earlier today to your case:
Make sense?
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Re: [xsl] creating nesting from flat xml
Subject: Re: [xsl] creating nesting from flat xml From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Tue, 27 Aug 2002 17:04:54 -0400 |
Darrell,
At 04:32 PM 8/27/2002, you wrote:
surely this list has seen this before?
Yep. Actually, just this morning.
Check out the thread "[xsl] Constructing hierarchical XML from a flat XML-tag sequence using XSLT", which Mike Kay and Tom Schutzer answered.
It's also in the FAQ: check out http://www.dpawson.co.uk/xsl/sect2/flatfile.html.
Basically it's a grouping problem. Your choice is whether to select nodes based directly on their relative positions in the flat (non-)hierarchy, or whether to do effectively the same thing using keys (which is good if the case is complex, but it doesn't look as though yours is).
Adapting Mike's solution from earlier today to your case:
<xsl:template match="a"> <div> <xsl:copy-of select="."/> <xsl:copy-of select="following-sibling::* [generate-id(preceding-sibling::a[1])=generate-id(current())]"> </div> </xsl:template>
Make sense?
Cheers, Wendell
hello xsl list,
this problem has me scratching my head, i do not require a total solution, but perhaps a hint. I have run into mismatched tags quite a bit, i am thinking i have to use position()?
a new <div> is required every time an <a> is encountered
surely this list has seen this before?
thank you in advance. darrell dupas
===================== <xmlfile type="before-transform" > <a>grp1 title</a> <b>grp1 member a </b> <b>grp1 member b </b> <a>grp2 title</a> <b>grp2 member a </b> <b>grp2 member b </b> <b>grp2 member c </b> <b>grp2 member d </b> <a>grp3 title </a> <b>grp3 member a</b> </xmlfile> ========================= <xmlfile type="desired-result" > <div> <a>grp1 title</a> <b>grp1 member a </b> <b>grp1 member b </b> </div> <div> <a>grp2 title</a> <b>grp2 member a </b> <b>grp2 member b </b> <b>grp2 member c </b> <b>grp2 member d </b> </div> <div> <a>grp3 title </a> <b>grp3 member a</b> </div> </xmlfile>
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] creating nesting from flat xm, darrell | Thread | RE: [xsl] creating nesting from fla, Michael Kay |
Re: [xsl] double quotes in attribut, Peter Davis | Date | Re: [xsl] double quotes in attribut, Chuck White |
Month |