Results 1 to 5 of 5

Thread: Parsing XSD to generate xml instances

  1. #1
    Join Date
    May 2008
    Posts
    2,680

    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!

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    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.

  3. #3
    Join Date
    May 2008
    Posts
    2,680

    Re: Parsing XSD to generate xml instances

    Can u please lend me a sample code of what u have explained ?
    thanks.

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    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.

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    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>

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,864,955.75988 seconds with 17 queries