Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 25-10-2008
Member
 
Join Date: May 2008
Posts: 2,676
Parsing XSD to generate xml instances

Hello...

Is it possible to parse (or rather read) an xsd file and depending on the constraints in the xsd...develop a java code to generate xml instances confirming to the xsd ?

I am working on something called "template based code generation" where in my template is an xsd file which i have to read and create xml instances confirming to the xsd . After that these xml instances would be used as data inputs to another code which will be used to generating test cases.

please help!
Reply With Quote
  #2  
Old 25-10-2008
Member
 
Join Date: May 2008
Posts: 2,293
Re: Parsing XSD to generate xml instances

I think it is always possible, given a valid XSD, to generate an XML that conforms to that XSD, and I think it may even be feasible (perhaps even trivial?) to implement a program to do this for you. However, I'm not sure why this would be useful. E.g. my implementation would always generate the minimum XML possible. If the empty document is legal, that's what it will generate.
Reply With Quote
  #3  
Old 25-10-2008
Member
 
Join Date: May 2008
Posts: 2,676
Re: Parsing XSD to generate xml instances

Can u please lend me a sample code of what u have explained ?
thanks.
Reply With Quote
  #4  
Old 25-10-2008
Member
 
Join Date: Jan 2008
Posts: 1,515
Re: Parsing XSD to generate xml instances

XMLSpy does a pretty good job of this. It even gives you a decent amount of control over the specimen document that it produces. It can certainly be useful to be able to generate document from schema, although, the range of values that you need for testing is generally more than you get from this.
Reply With Quote
  #5  
Old 25-10-2008
Member
 
Join Date: May 2008
Posts: 2,293
Re: Parsing XSD to generate xml instances

Er... well, I could give you pseudocode... Anything more than that, and
you'd have to pay me.

Code:
<pseudocode>
generateBasicNode(someNode) {
emit "<";
emit someNode.name;
/*handle the attributes in the obvious way*/
emit ">";
for each child in someNode.children {
generateNode(child)
}
emit "</";
emit someNode.name;
emit ">";

}

generateOptionalNode(someNode) {
/*Don't emit optional nodes, 'cause they're optional*/
}

generateNodeSequence(someSequence) {
for each node in someSequence {
generateNode(node);
}
}

//etc.
</pseudocode>
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Parsing XSD to generate xml instances"
Thread Thread Starter Forum Replies Last Post
How to use XML Parsing using PHP LasitMalinga Software Development 4 05-10-2011 02:33 PM
How to kill multiple instances of a command EricTheRed Tips & Tweaks 1 03-06-2011 08:05 AM
Multiple instances of Outlook Zeeman28a Windows Software 3 29-07-2010 06:56 PM
Multiple ActiveX instances Wagstafari Operating Systems 2 23-11-2009 05:04 AM
Running multiple instances of an application DocAtom Vista Help 7 14-02-2008 08:52 PM


All times are GMT +5.5. The time now is 10:29 PM.