Home » Developer & Programmer » JDeveloper, Java & XML » Generating XMLfrom XSD at runtime (Solaris and Linux)
Generating XMLfrom XSD at runtime [message #563376] Mon, 13 August 2012 06:25 Go to next message
tigsav
Messages: 49
Registered: April 2012
Member
Hello All,

I Have got a requirement where we have to generate an xml conforming to a particular XSD.
What i will be having already in place is an XSD document.
We are thinking of making a procedure which will be recieving the set of inputs required for creating that xml.(Data content of that XML.)We would have to make the XML according to that XSD.

Everytime Parsing the XSD is not feasible.
We are looking at a solution which would be easy to make the xml from xsd at runtime.
These values (DATA) will be available at run time.

Thanks in Advance!!!!
Re: Generating XMLfrom XSD at runtime [message #565635 is a reply to message #563376] Wed, 05 September 2012 12:37 Go to previous messageGo to next message
tigsav
Messages: 49
Registered: April 2012
Member
Hello friends,

Did anyone manage to get anything on this.Even any references would do.I am still struggling to find a way out.
Re: Generating XMLfrom XSD at runtime [message #566523 is a reply to message #563376] Mon, 17 September 2012 00:24 Go to previous messageGo to next message
tigsav
Messages: 49
Registered: April 2012
Member
Hello friends ,

I am strugling to to find a way ouy.Anyone got any clue?
Re: Generating XMLfrom XSD at runtime [message #566601 is a reply to message #566523] Mon, 17 September 2012 18:54 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9077
Registered: November 2002
Location: California, USA
Senior Member
I am thinking that maybe you are looking for something with dbms_xmlschema that generates the tables. To clarify your problem, can you post a simple test case that produces something like what you have and also provide an example of what you want based on that?
Re: Generating XMLfrom XSD at runtime [message #566767 is a reply to message #563376] Wed, 19 September 2012 07:18 Go to previous messageGo to next message
tigsav
Messages: 49
Registered: April 2012
Member
hi,
Consider an example :

Suppose the XSD is :
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="[url]http://www.w3.org/2001/XMLSchema[/url]">

<xs:element name="shiporder">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="orderperson" type="xs:string"/>
      <xs:element name="shipto">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="name" type="xs:string"/>
            <xs:element name="address" type="xs:string"/>
            <xs:element name="city" type="xs:string"/>
            <xs:element name="country" type="xs:string"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="item" maxOccurs="unbounded">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="title" type="xs:string"/>
            <xs:element name="note" type="xs:string" minOccurs="0"/>
            <xs:element name="quantity" type="xs:positiveInteger"/>
            <xs:element name="price" type="xs:decimal"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="orderid" type="xs:string" use="required"/>
  </xs:complexType>
</xs:element>

</xs:schema>


The values for name ,address,and all elements will be known at run time .Now we need to have a code which will generate an xml based on that values.
I know only the structure of xsd.

Also the code needs to be generic handling all possible types of XSD's i.e If any future any new XSD comes then my code should not change.


[mod-edit: code tags added by bb; next time please add them yourself]

[Updated on: Wed, 19 September 2012 12:26] by Moderator

Report message to a moderator

Re: Generating XMLfrom XSD at runtime [message #566819 is a reply to message #566767] Wed, 19 September 2012 22:23 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9077
Registered: November 2002
Location: California, USA
Senior Member
Please provide an example of the xml that you want based on the xsd provided, as previously requested.
Re: Generating XMLfrom XSD at runtime [message #566824 is a reply to message #563376] Thu, 20 September 2012 00:07 Go to previous messageGo to next message
tigsav
Messages: 49
Registered: April 2012
Member
Sorry for not providing that earlier,

<?xml version="1.0" encoding="ISO-8859-1"?>

<shiporder orderid="889923"
xmlns:xsi="[url]http://www.w3.org/2001/XMLSchema-instance[/url]"
xsi:noNamespaceSchemaLocation="shiporder.xsd">
  <orderperson>John Smith</orderperson>
  <shipto>
    <name>Ola Nordmann</name>
    <address>Langgt 23</address>
    <city>4000 Stavanger</city>
    <country>Norway</country>
  </shipto>
  <item>
    <title>Empire Burlesque</title>
    <note>Special Edition</note>
    <quantity>1</quantity>
    <price>10.90</price>
  </item>
  <item>
    <title>Hide your heart</title>
    <quantity>1</quantity>
    <price>9.90</price>
  </item>
</shiporder> 



[mod-edit: code tags added by bb again]

[Updated on: Thu, 20 September 2012 11:16] by Moderator

Report message to a moderator

Re: Generating XMLfrom XSD at runtime [message #566909 is a reply to message #566824] Thu, 20 September 2012 18:30 Go to previous message
Barbara Boehmer
Messages: 9077
Registered: November 2002
Location: California, USA
Senior Member
Sorry, but it looks like what I was thinking isn't going to work. Hopefully, someone else will have an idea.
Previous Topic: Problem with XML
Next Topic: XMLPARSER.ParseClob
Goto Forum:
  


Current Time: Fri Mar 29 04:25:50 CDT 2024