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

[xsl] [ XSLT ] Dynamically Transform xml pages to database queries


Subject: [xsl] [ XSLT ] Dynamically Transform xml pages to database queries
From: Jyotsna B <jbendapu@xxxxxxxxx>
Date: Fri, 19 May 2006 17:03:39 -0700 (PDT)

Hi All,
 
I am NEWbie to XSLT and in process of learning.Any
code suggestions or direction is greatly appreciated
I have a list of XML files at certain location (ex:
D:\xmlfilesloc )
I need to write a program which checks the folder
automatically and if files exists -reads each xml file
at a time and transforms the xml file (using XSLT ) to
bunch of customized oracle database queries .
 
Questions :
1)How to read each xml file from a specified location
dynamically ?
2)How to use XSLT to transform a xml file
dynamically/automatically  to bunch of customized
database queries (elements to table name mapping ;
attributes to columns names ;...etc )? 
 
-------------------------------------------
Ex Output I am trying to acheive is queries :- 
-------------------------------------------
insert into server
('oracleAppVersion',java-version,java-vendor,
java-vm-version,java-vm-vendor,java-vm-name,os-arch,os-name,os-version
)
values('1.0','1.1.9.0','vendorcl','1.2','vendvmor','virtual','a','bb','ccc')
;

 
I tried using XMLSpy feature "Create DB structure from
XML Schema" 
but its not helping to customize the output  ..so I
want to code myself the XSLT transformation to get
desired output queries 
 
-------------------------------
Example of Input XML file :-
-----------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSpy v2006 sp1 U
(http://www.altova.com)-->
<config xmlns="http://xxx.y.com/c/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=http://xxx.y.com/c/ id="String">
<domain-name>oracle appserver</domain-name>
<timestamp>2001-12-17T09:30:47.0Z</timestamp>
<server is-admin-server="false" name="String">
<company>
<server-version>1.0</server-version>
</company>
<java>
<version>1.1.9.0</version>
<vendor>vendorcl</vendor>
<vm>
<version>1.2</version>
<vendor>vendvmor</vendor>
<name>virtual</name>
</vm>
</java>
<os>
<arch>a</arch>
<name>bb</name>
<version>ccc</version>
</os>
</server>
</config>
 
 
---------------------------
configdetail.xsd - XSD Schema that it macthes
------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://y.com" xmlns:inv="http://y.com/c"
targetNamespace="http://y.com/c"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
 <xs:import namespace="http://y.com/c"
schemaLocation="../../configmain.xsd"/>
<xs:complexType name="configdetailtype">
<xs:complexContent>
<xs:extension base="cfg:ConfigmainType">
<xs:sequence>
<xs:element name="server" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
 <xs:element name="oracleAppVersion"
type="xs:string"/>
 <xs:element name="java">
  <xs:complexType>
   <xs:sequence>
    <xs:element name="version" type="xs:string"/>
    <xs:element name="vendor" type="xs:string"/>
    <xs:element name="vm">
     <xs:complexType>
      <xs:sequence>
       <xs:element name="version" type="xs:string"/>
       <xs:element name="vendor" type="xs:string"/>
       <xs:element name="name" type="xs:string"/>
      </xs:sequence>
     </xs:complexType>
    </xs:element>
   </xs:sequence>
  </xs:complexType>
 </xs:element>
 <xs:element name="os">
  <xs:complexType>
   <xs:sequence>
    <xs:element name="arch" type="xs:string"/>
    <xs:element name="name" type="xs:string"/>
    <xs:element name="version" type="xs:string"/>
   </xs:sequence>
  </xs:complexType>
 </xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string"
use="required"/>
<xs:attribute name="adminServer" type="xs:boolean"
use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>

I can give me more explaination if needed.
Thanks a lot for your response
Jyotsna


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Current Thread
Keywords