[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] grabbing chunks of preceding-siblings between tables


Subject: [xsl] grabbing chunks of preceding-siblings between tables
From: "Spencer Tickner" <spencertickner@xxxxxxxxx>
Date: Thu, 4 Oct 2007 08:40:18 -0700

Hi List,

Thanks in advance for the help. I'm doing some pre-processing of a XML
Dump of tables. I'm trying to associate header information in the
table to the table itself. I'm having difficulty figuring out how to
do this.. Anyway, examples always seem to say it better (XSLT 2.0 is
fine):

XML

<?xml version="1.0"?>
<root>
	<title1>Title for Table 1</title1>
	<title2>sub-title for Table 1</title2>
	<caption>Caption for Table 1</caption>
	<para_norm>Any number of different paragraphs that belong with Table
1</para_norm>
	<table>
		<cell>Foo</cell>
		<cell>Bar</cell>
	</table>
	<title2>Table 2 only has subtitle</title2>
	<caption>Caption for Table 2</caption>
	<para_diff>Any number of different paragraphs that belong with Table
2</para_diff>
	<table>
		<cell>Foo</cell>
		<cell>Bar</cell>
	</table>
	<title1>Title for Table 3</title1>
	<title2>sub-title for Table 3</title2>
	<caption>Caption for Table 3</caption>
	<para_norm>Any number of different paragraphs that belong with Table
3</para_norm>
	<table>
		<cell>Foo</cell>
		<cell>Bar</cell>
	</table>
</root>

Desired XML Output:

<?xml version="1.0"?>
<root>
	<table>
		<title1>Title for Table 1</title1>
		<title2>sub-title for Table 1</title2>
		<caption>Caption for Table 1</caption>
		<para_norm>Any number of different paragraphs that belong with Table
1</para_norm>
		<cell>Foo</cell>
		<cell>Bar</cell>
	</table>
	<table>
		<title2>Table 2 only has subtitle</title2>
		<caption>Caption for Table 2</caption>
		<para_diff>Any number of different paragraphs that belong with Table
2</para_diff>
		<cell>Foo</cell>
		<cell>Bar</cell>
	</table>
	<table>
		<title1>Title for Table 3</title1>
		<title2>sub-title for Table 3</title2>
		<caption>Caption for Table 3</caption>
		<para_norm>Any number of different paragraphs that belong with Table
3</para_norm>
		<cell>Foo</cell>
		<cell>Bar</cell>
	</table>
</root>

I've tried a number of different things, but can't seem to translate
"Take all elements between <table> and add as child to following
<table>" into XSLT. Any help would be greatly appreciated.

Thanks,

Spencer


Current Thread
Keywords
xml