xsl-list
[Top] [All Lists]

RE: Matching similar rows in a table

2004-07-15 07:57:13
Hi Aadjan,

Apart from the direct solution that Jarno gave you you may notice that your
XML is not well-formed - you need to add an all-encompassing element to make
it well-formed.

Cheers,
<prs/>

-----Original Message-----
From: Aadjan van der Helm 
[mailto:A(_dot_)vanderHelm(_at_)io(_dot_)tudelft(_dot_)nl] 
Sent: Thursday, July 15, 2004 3:21 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Matching similar rows in a table

Question:

I want to transform the below source xml to the destination xml with a XSLT
script. I run into problems trying to generate the <chapter></chapter> tags
because there is no structural textual "signal" in the source XML to match
the start/end of a chapter.

The source XML is the export from a DB in the form of a table. Each page is
in a row, only the first page has the chapter title, in the other page that
column contains no data.

The XSLT script has to pick up the special first row, create the chapter and
name tags and insert the pages for the chapter until another special first
row is detected.

Alternatively I could generate XML which has the chapter name in each first
column in the page row. Then the XSLT script will has to detect a change in
the content of the first column and start a new chapter.

How can I do this in XSLT?

Groeten,
--Aadjan

Source XML
<row><col>Chapter 1</col><col>page 1</col><col>picture1</col></row>
<row><col></col><col>page 2</col><col>picture2</col></row>
<row><col></col><col>page 3</col><col>picture3</col></row> <row><col>Chapter
2</col><col>page 1</col><col>picture4</col></row> <row><col></col><col>page
2</col><col>picture5</col></row> <row><col></col><col>page
3</col><col>picture6</col></row>

Destination XML
<chapter>
<name>Chapter 1</name>
<page><content>picture1</content></page>
<page><content>picture2</content></page>
<page><content>picture3</content></page>
</chapter>
<chapter>
<name>Chapter 2</name>
<page><content>picture4</content></page>
<page><content>picture5</content></page>
<page><content>picture6</content></page>
</chapter>

--+------------------------------------------------------------------
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>