Title: auto generate xsl based on 2 different xml schema files?

  If I only have one target schema, I could use java. In my case, there might be multiple target schemas. It would be more convenient for me to translate the source xml files to target xml files if I could get the xsl generated automatically out off the schema files. I guess the worst scenario is that I have to write xsl files from the scratch based off the schema files.

 

Steve Lu

 


From: Steven Traut [mailto:[EMAIL PROTECTED]
Sent: Friday, June 24, 2005 1:11 PM
To: [email protected]
Subject: RE: auto generate xsl based on 2 different xml schema files?

 

Steve,

 

This kind of conversion is the sort of thing that XSL is often used for, so that's certainly an option. Seems to me the kind of tool you're describing would need to provide a UI through which you can "map" aspects of one XML shape (schema) to the other. I don't know of such a tool, although I know that XMLSpy offers an XSL design environment.

 

Since you have schema for both XML shapes, there's a non-XSL option that that involves Java and XMLBeans. You could compile both of your schemas using scomp, then write Java code that copies values from an instance of one schema into a new instance of the other schema. So if schema A has a Foo element of type xs:string, and schema B has a Bar element of type xs:string (with parent Baz), you could do something like this:

 

    newBaz.setBar(incomingFoo.getStringValue());

 

I think you'd need to convert non-string values to strings where necessary. You could also use XPath to get values from the incoming schema (which is what XSL does anyway).

 

I don't know how efficient this is, and it feels like a wacky use of schema, but it's an idea for someone unfamiliar with XSL, but comfortable with Java.

 

Steve

-----Original Message-----
From: Lu, Shengkai [mailto:[EMAIL PROTECTED]
Sent: Friday, June 24, 2005 8:58 AM
To: '[email protected]'
Subject: auto generate xsl based on 2 different xml schema files?

  I need to convert xml files that conform to one xml schema to another schema instance xml files. What would be the best approach? I'm thinking xslt might be a good choice. I would expect to have a tool that reads 2 xml schema files and spits out a xsl file, I can then use any transformer program to convert one xml file into other format with the xsl file.  Is there such tool exist? Thanks in advance.

Steve Lu

Reply via email to