G
Glen Millard
Okay, I have an XML file that I get from a provider:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="basic.xsl"?>
<content>
<status>ok</status>
<faxes>
<faxid>21404974</faxid>
<date>2012-01-05 07:34:10</date>
<source>5194852368</source>
<destination>8885216725</destination>
<status>read</status>
<faxid>23223059</faxid>
<date>2012-03-01 07:27:52</date>
<source>5194211862</source>
<destination>8885216725</destination>
<status>new</status>
<faxid>23223164</faxid>
<date>2012-03-01 07:29:45</date>
<source>5194211862</source>
<destination>8885210692</destination>
<status>new</status>
<faxid>23224287</faxid>
<date>2012-03-01 07:51:07</date>
<source>8885216725</source>
<destination>8885210692</destination>
<status>new</status>
</faxes></content>
I want to be able to import/parse this into a MySQL database. However, I need to reformat it so that it is 'database-centric'. I was going to use a simple script to use find/replace with a sed and regular expressions - which works.
However, I am going to need to do this multiple times per day and figured that an xslt processor would be more efficient.
So, can someone get me started? I think that the root element being <database></database> would be a start.
I am just kind of clueless on this - I am not looking for someone to do it for me, just a little hand-holding on how to create an xsl stylesheet to rename the elements.
This is the type of format that I want to achieve:
<database>
<status>ok</status>
<faxes>
<row>
<faxid>21404974</faxid>
<date>2012-01-05 07:34:10</date>
<source>5194852368</source>
<destination>8885216725</destination>
<status>read</status>
</row>
<row>
<faxid>23223059</faxid>
<date>2012-03-01 07:27:52</date>
<source>5194211862</source>
<destination>8885216725</destination>
<status>new</status>
</row>
<row>
<faxid>23223164</faxid>
<date>2012-03-01 07:29:45</date>
<source>5194211862</source>
<destination>8885210692</destination>
<status>new</status>
</row>
<row>
<faxid>23224287</faxid>
<date>2012-03-01 07:51:07</date>
<source>8885216725</source>
<destination>8885210692</destination>
<status>new</status>
</row>
</faxes>
</database>
This way, I can use a parser XML
arser in Perl to bring it into a MySQL database.
So, I guess substituting/replacing tags is what I need to do.
I guess I just don't understand the syntax of xsl stylesheets.
Thanks - Glen
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="basic.xsl"?>
<content>
<status>ok</status>
<faxes>
<faxid>21404974</faxid>
<date>2012-01-05 07:34:10</date>
<source>5194852368</source>
<destination>8885216725</destination>
<status>read</status>
<faxid>23223059</faxid>
<date>2012-03-01 07:27:52</date>
<source>5194211862</source>
<destination>8885216725</destination>
<status>new</status>
<faxid>23223164</faxid>
<date>2012-03-01 07:29:45</date>
<source>5194211862</source>
<destination>8885210692</destination>
<status>new</status>
<faxid>23224287</faxid>
<date>2012-03-01 07:51:07</date>
<source>8885216725</source>
<destination>8885210692</destination>
<status>new</status>
</faxes></content>
I want to be able to import/parse this into a MySQL database. However, I need to reformat it so that it is 'database-centric'. I was going to use a simple script to use find/replace with a sed and regular expressions - which works.
However, I am going to need to do this multiple times per day and figured that an xslt processor would be more efficient.
So, can someone get me started? I think that the root element being <database></database> would be a start.
I am just kind of clueless on this - I am not looking for someone to do it for me, just a little hand-holding on how to create an xsl stylesheet to rename the elements.
This is the type of format that I want to achieve:
<database>
<status>ok</status>
<faxes>
<row>
<faxid>21404974</faxid>
<date>2012-01-05 07:34:10</date>
<source>5194852368</source>
<destination>8885216725</destination>
<status>read</status>
</row>
<row>
<faxid>23223059</faxid>
<date>2012-03-01 07:27:52</date>
<source>5194211862</source>
<destination>8885216725</destination>
<status>new</status>
</row>
<row>
<faxid>23223164</faxid>
<date>2012-03-01 07:29:45</date>
<source>5194211862</source>
<destination>8885210692</destination>
<status>new</status>
</row>
<row>
<faxid>23224287</faxid>
<date>2012-03-01 07:51:07</date>
<source>8885216725</source>
<destination>8885210692</destination>
<status>new</status>
</row>
</faxes>
</database>
This way, I can use a parser XML
So, I guess substituting/replacing tags is what I need to do.
I guess I just don't understand the syntax of xsl stylesheets.
Thanks - Glen