Generate Sample DOM tree for an XSD

N

Nettar

Hi,

Is it possible to generate a sample DOM tree for a given XSD
programatically using Java?

I know that some tools can generate a sample XML for the given XSD. I
want to do this programatically.

Can anyone suggest any approach for achieving this?

Thanks,
Jayarama Nettar.
 
J

Joe Kesselman

Nettar said:
Can anyone suggest any approach for achieving this?

Read the schema. Start from the top-level element description and
examine what its possible contents are. Generate something at random
that meets those constraints. Recurse downward until all branches of the
DOM tree have reached nodes which do not have further content.

That will produce a document which matches the schema. It may not be a
document which makes any sense in application terms, depending on just
how many of the application constraints have been encoded into the schema.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,167
Latest member
SusanaSwan
Top