Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » How to generate XSD from XML, by restricting all the values ?(How can i create XSD from XML, by restricting all the values in XSD to the ones in the XML?)
How to generate XSD from XML, by restricting all the values ? [message #903191] Wed, 22 August 2012 09:07 Go to next message
sagar y is currently offline sagar y
Messages: 4
Registered: August 2012
Junior Member
Say, My XML is,

     <ITRForm:IncomeFromSal>1500000</ITRForm>
<ITRForm:TotalIncomeOfHP>-10000</ITRForm:TotalIncomeOfHP>
    <ITRForm:IncomeOthSrc>15000</ITRForm:IncomeOthSrc>


i need to restrict IncomeFromSal to 1500000,

In XSD, I can give,
<xs:element name="IncomeFromSal" fixed="1500000">


I've some 500 elements in my XML. I need to make all elements in XSD as, 'fixed' to the values in XML.

like

<xs:element name="IncomeFromSal" fixed="1500000">
<xs:element name="TotalIncomeOfHP" fixed="-10000">
<xs:element name="IncomeOthSrc" fixed="15000">


How to do this? Can any one help me?

Re: How to generate XSD from XML, by restricting all the values ? [message #903224 is a reply to message #903191] Wed, 22 August 2012 10:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25918
Registered: July 2009
Senior Member
What have you tried so far?

On 22/08/2012 3:07 PM, sagar y wrote:
> Say, My XML is,
>
> <ITRForm:IncomeFromSal>1500000</ITRForm>
> <ITRForm:TotalIncomeOfHP>-10000</ITRForm:TotalIncomeOfHP>
> <ITRForm:IncomeOthSrc>15000</ITRForm:IncomeOthSrc>
>
> i need to restrict IncomeFromSal to 1500000,
>
> In XSD, I can give,
>
> <xs:element name="IncomeFromSal" fixed="1500000">
>
> I've some 500 elements in my XML. I need to make all elements in XSD
> as, 'fixed' to the values in XML.
>
> like
>
> <xs:element name="IncomeFromSal" fixed="1500000">
> <xs:element name="TotalIncomeOfHP" fixed="-10000">
> <xs:element name="IncomeOthSrc" fixed="15000">
>
> How to do this? Can any one help me?
>
>
Re: How to generate XSD from XML, by restricting all the values ? [message #903308 is a reply to message #903224] Thu, 23 August 2012 02:15 Go to previous messageGo to next message
sagar y is currently offline sagar y
Messages: 4
Registered: August 2012
Junior Member
Hi Ed Merks,

Since i can restrict values by enumeration too,
I tried using int2xsd by giving enumeration attribute ,

inst2xsd -enumerations 1

but it generates XSD with enumeration to elements which have more than 1 different(at min.)

I do not get enumeration for elements which take only one value.

say My XML is
          <ITRForm:Section80GGA>2500</ITRForm:Section80GGA>
               <ITRForm:Section80GGC>3500</ITRForm:Section80GGC>
               <ITRForm:Section80U>1500</ITRForm:Section80U>


 <ITRForm:DoneePAN>SomePan11111</ITRForm:DoneePAN>
                  <ITRForm:AddressDetail>
                       <ITRForm:AddrDetail>SomePlace1111</ITRForm:AddrDetail> 

<ITRForm:DoneePAN>SomePan22222</ITRForm:DoneePAN>
                  <ITRForm:AddressDetail>
                       <ITRForm:AddrDetail>SomePlace2222</ITRForm:AddrDetail> 


XSD is created as,


 <xs:element name="Section80GGA" type="xs:integer"/>
  <xs:element name="Section80GGC" type="xs:integer"/>
  <xs:element name="Section80U" type="xs:integer"/>

      <xs:element name="AddrDetail">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="SomePlace1111"/>
            <xs:enumeration value="SomePlace2222"/>
             </xs:restriction>
        </xs:simpleType>
      </xs:element>


I need enumeration for Section80GGA,Section80GGC,Section80U too.

Other option is generating fixed="" attribute for elements.

Re: How to generate XSD from XML, by restricting all the values ? [message #903311 is a reply to message #903308] Thu, 23 August 2012 02:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25918
Registered: July 2009
Senior Member
Sagar,

A -inst2xsd option isn't part of the XSD project. Is this something
provided by Web Tools ore something external to Eclipse? I imagine a
schema generator tool will try to create a general schema that allows
more than just the one specific instance...


On 23/08/2012 8:15 AM, sagar y wrote:
> Hi Ed Merks,
>
> Since i can restrict values by enumeration too,
> I tried using int2xsd by giving enumeration attribute ,
>
> inst2xsd -enumerations 1
>
> but it generates XSD with enumeration to elements which have more than
> 1 different(at min.)
> I do not get enumeration for elements which take only one value.
>
> say My XML is
>
> <ITRForm:Section80GGA>2500</ITRForm:Section80GGA>
> <ITRForm:Section80GGC>3500</ITRForm:Section80GGC>
> <ITRForm:Section80U>1500</ITRForm:Section80U>
>
>
> <ITRForm:DoneePAN>SomePan11111</ITRForm:DoneePAN>
> <ITRForm:AddressDetail>
> <ITRForm:AddrDetail>SomePlace1111</ITRForm:AddrDetail>
> <ITRForm:DoneePAN>SomePan22222</ITRForm:DoneePAN>
> <ITRForm:AddressDetail>
> <ITRForm:AddrDetail>SomePlace2222</ITRForm:AddrDetail>
> XSD is created as,
>
>
> <xs:element name="Section80GGA" type="xs:integer"/>
> <xs:element name="Section80GGC" type="xs:integer"/>
> <xs:element name="Section80U" type="xs:integer"/>
>
> <xs:element name="AddrDetail">
> <xs:simpleType>
> <xs:restriction base="xs:string">
> <xs:enumeration value="SomePlace1111"/>
> <xs:enumeration value="SomePlace2222"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:element>
>
> I need enumeration for Section80GGA,Section80GGC,Section80U too.
>
> Other option is generating fixed="" attribute for elements.
>
>
Re: How to generate XSD from XML, by restricting all the values ? [message #903313 is a reply to message #903311] Thu, 23 August 2012 02:54 Go to previous messageGo to next message
sagar y is currently offline sagar y
Messages: 4
Registered: August 2012
Junior Member
Ed Merks,

Yeh.. inst2xsd is external to Eclipse. I tried with oxygenXml eclipse plugin. With that we can create sample XML from XSD.
Is there a way to create XSDs from XML with oxygenXml plugin?
Re: How to generate XSD from XML, by restricting all the values ? [message #903322 is a reply to message #903313] Thu, 23 August 2012 03:33 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25918
Registered: July 2009
Senior Member
I don't know anything about OxygenXML. Best to find an appropriate forum
to ask about that.


On 23/08/2012 8:54 AM, sagar y wrote:
> Ed Merks,
>
> Yeh.. inst2xsd is external to Eclipse. I tried with oxygenXml eclipse
> plugin. With that we can create sample XML from XSD.
> Is there a way to create XSDs from XML with oxygenXml plugin?
Re: How to generate XSD from XML, by restricting all the values ? [message #903518 is a reply to message #903322] Fri, 24 August 2012 02:03 Go to previous message
sagar y is currently offline sagar y
Messages: 4
Registered: August 2012
Junior Member
Ed Merks,

ok.. Thanx for responding.
Previous Topic:Maven properties and XML in Eclipse
Next Topic:one XML element value as other xml element value
Goto Forum:
  


Current Time: Fri Jul 25 09:41:09 EDT 2014

Powered by FUDForum. Page generated in 0.03026 seconds