XSLT to format XML for Filemaker or mySQL Import

Here should go questions about transforming XML with XSLT and FOP.
undrmoons
Posts: 11

XSLT to format XML for Filemaker or mySQL Import

Wed Jan 10, 2007 5:37 pm

I have a library of XML files which I'd ideally like to put into a database. These XML files contain data about various different products with different specs, details, etc. As a result XML files may contain several variables.

The constants, are <Product_Group>, <Product_Name> and <Table>. Only one of each always exists.

The variables would be the number of <Bullet> tags, the number of columns (total <TD> tags per row) and the number of rows themselves (<TR>). The sample below only shows a table with two rows (one being the header row). These XML files could contain as many as 20-50 additional rows beneath the header row, each representing a new product with a different SKU falling within the catagory indicated in the <Product_Group> (in this case "Euro Boards").

Firstly, I'm not sure where to begin writing an XSLT that would format my XML for import into a database, Filemaker or mySQL.

Secondly, I'm just not sure how to begin writing an XSLT which would work with so many variables.

Do you have any input which would help?
I've included sample code below:


******************************************************************************************
******************************************************************************************

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Product_Group>
<Product_Name>Euro Boards</Product_Name>
<Bullet>• Bullet copy 1</Bullet>
<Bullet>• Bullet copy 2</Bullet>
<Bullet>• Bullet copy 3</Bullet>
<TABLE>
<THR>
<TD>
<Chart_Header_Red>SKU</Chart_Header_Red>
</TD>
<TD>
<Chart_Header>Mfr. No. </Chart_Header>
</TD>
<TD>
<Chart_Header>Frame</Chart_Header>
</TD>
<TD>
<Chart_Header>Size (W x H)</Chart_Header>
</TD>
<TD>
<Chart_Header>Qty. </Chart_Header>
</TD>
<TD>
<Chart_Header>Sale Price</Chart_Header>
</TD>
<THR>
<TR>
<TD>
<SKU>46217034 </SKU>
</TD>
<TD>
<Chart_Copy>QRP564T </Chart_Copy>
</TD>
<TD>
<Chart_Copy>Titanium Finish</Chart_Copy>
</TD>
<TD>
<Chart_Copy>4 x 3 </Chart_Copy>
</TD>
<TD>
<Chart_Copy>EA </Chart_Copy>
</TD>
<TD>
<Price>$39.95</Price>
</TD>
</TR>
</TABLE>
</Product_Group>

******************************************************************************************
******************************************************************************************

I'm just not at all certain where to even start.

Thank you in advance for any help you can offer.

-lmm
george
Site Admin
Posts: 2100

Thu Jan 18, 2007 5:09 pm

Hi,

You can write a stylesheet that can generate an SQL insert or a sequence of SQL insert statements based on your XML file.

Best Regards,
George
George Cristian Bina

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 0 guests