transforming xml to tables

Subject: transforming xml to tables
From: "Pedro Castro" <pfc@xxxxxxxxxx>
Date: Mon, 14 Jun 2004 17:41:01 +0100
Hi, all. I'm a beginner in this xsl world and I'm trying to learn.
I could do the work I have to do in a different way but I'm trying to see
the advantages of xsl (which are convincing me). But I was stopped in the
process because of a problem which I (try to) describe next:

I have the following xml:

<aaa name="t1">
	<bbb name="t1_ID" type="n"/>
	<bbb name="c1" type="t2"/>
	<bbb name="c2"/>
	<bbb name="c3" type="n"/>
</aaa>

And I want to transform this (part) into a script for create a relational
table structure (for later processing):

(A table has always an id that is conventioned to be the table name followed
by "_ID" word)

<table name="t1">
	<column name="t1_ID" primaryKey="true"/>
	<column name="c1"/>
	<column name="c2"/>
	<column name="c3"/>
</table>

<table name="t1_t2_nxn">
	<column name="t1_ID" primaryKey="true"/>
	<column name="t2_ID" primaryKey="true"/>
	<foreign-key foreignTable="t1">
		<reference local="t1_ID" foreign="t1_ID"/>
	</foreign-key>	
	<foreign-key foreignTable="t2">
		<reference local="t2_ID" foreign="t2_ID"/>
	</foreign-key>
</table>
	

The rules for transformation are simple: if an inner element for the <aaa>
element has a type other than none or "n" (like the type="t2" case) than i
need to create the second table which is an n x n table between t1 and (an
already existent) t2 table.

Is this possible to do in xsl?
I'm sorry for the long question, and I hope that anybody can understand and
help :) 

Thanks in advance!!


Pedro Castro.
Portugal.



Current Thread