|
Subject: [xsl] processing following-siblings to a point From: charlieo0@xxxxxxxxxxx Date: Thu, 9 Jul 2009 18:59:02 +0000 (UTC) |
Hello all,
I've run into a structure that I must transform that I just haven't found a solution for. XSL 1.0 only. (I just don't have the proficiency for 2.0 yet).
I'm transforming what was a rather flat SGML structure to an XML structure. Here's the input structure:
<gen>
<title>TITLE_1</title>
<subtitle>SUBTITLE_1</subtitle>
<para>Text.</para>
<para>Text.</para>
<para>Text.</para>
<title>TITLE_2</title>
<subtitle>SUBTITLE_2</subtitle>
<para>Text.</para>
<para>Text.</para>
<para>Text.</para>
<para>Text.</para>
<title>TITLE_2</title>
<subtitle>SUBTITLE_2</subtitle>
<para>Text.</para>
<para>Text.</para>
<para>Text.</para>
<para>Text.</para>
</gen>
Resulting structure tree:
<para0>
<title>TITLE_1</title>
<subpara1>
<title>SUBTITLE_1</title>
<para>Text.</para>
<para>Text.</para>
<para>Text.</para>
</subpara1>
</para0>
<para0>
<title>TITLE_2</title>
<subpara1>
<title>SUBTITLE_2</title>
<para>Text.</para>
<para>Text.</para>
<para>Text.</para>
<para>Text.</para>
</subpara1>
</para0>
<para0>
<title>TITLE_3</title>
<subpara1>
<title>SUBTITLE_3</title>
<para>Text.</para>
<para>Text.</para>
<para>Text.</para>
<para>Text.</para>
<para>Text.</para>
</subpara1>
</para0>
My template (or at least the important part).
<xsl:template match="gen/title" mode="move">
<para0>
<title>
<xsl:value-of select="."/>
</title>
<subpara1>
<title><xsl:value-of select="following-sibling::subtitle[1]"/></title>
<xsl:apply-templates select="following-sibling::para"/>
</subpara1>
</para0>
My problem is with the <xsl:apply-templates select="following-sibling::para"/> line. Of course, all of the para elements are following siblings of all the gen/title elements. How can I express the <apply-templates> to process only the para element siblings BEFORE the next following title sibling. (This is difficult because EVERYTHING is a sibling of everything else).
Charles Flanders
IETM Developer
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Forcing a blank page, Brandon Ibach | Thread | Re: [xsl] processing following-sibl, G. Ken Holman |
| Re: [xsl] Forcing a blank page, G. Ken Holman | Date | Re: [xsl] processing following-sibl, G. Ken Holman |
| Month |