XML instance generation from XML schema (xsd) [closed]
Asked Answered
S

5

14

I was wondering if there's a way I can automate the generation of XML files from XSD schemas given that I have the data and the labels. I'd like to do this in python/java. It seems very possible, yet I can't find any library that allows me to do this. I'm looking for a fairly quick solution.. Any ideas?

See also: how-to-generate-sample-xml-documents-from-their-dtd-or-xsd

Sikorsky answered 21/11, 2008 at 2:11 Comment(0)
B
8

Look at pyXSD for Python tools that are similar to JAXB.

XSD's are used to create Python classes. Python objects are used to emit XML.

Blackguard answered 21/11, 2008 at 2:26 Comment(0)
F
3

I recommend two approaches:

  1. Xstream - it let's you generate XML files by defining a Java file and either putting Java annotations on the items or just defining aliases. It is very easy, but it is not fully automatic;

  2. XMLBeans - these tools let's you generate Java files from XML schema definitions (xsd) so that you can import, manipulate, create and export XML files using JavaBeans-like method calls.

Regards, Luis

Felucca answered 21/11, 2008 at 18:30 Comment(1)
The XMLBeans xsd2inst tool will generate an instance from a schema. xmlbeans.apache.org/docs/2.4.0/guide/tools.html#xsd2instJanellajanelle
M
3

Microsoft has published a "document generator" tool as a sample. This is an article that describes the architecture and operation of the sample app in some detail.

If you just want to use the document generation tool, click here and install the MSI. It requires no programming.

It's free. The source is available. Requires the .NET Framework to run. Works only with XSDs. (not Relax NG or DTD).

Monster answered 3/6, 2009 at 15:59 Comment(0)
R
1

JAXB works fantastic for generating classes from xsd.

Ibatis works fantastic for getting data into classes.

You can use Ibatis to feed data and automatically create classes, then use JAXB to marshal the classes into an XML file! Mind you, that's a lot of effort if you're not going to be doing it over and over again.

Rendition answered 21/11, 2008 at 2:15 Comment(0)
S
0

I use Exchanger XML Editor for this purpose. You can download it for free for multiple operating systems at: http://www.exchangerxml.com/

The option is in menu "Schema" -> "Schema instance generation".

Strickler answered 1/7, 2010 at 8:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.