0

I need to create an XML file from an XSD file, but its schema is present in multiple XSDs. I have tried to create using Eclipse IDE.

To generate XML for CREATEE_ABC_REQ, two other schemas are present in ABC-Messaging.xsd and EX-Bulk-Types.xsd.

Below is the CREATEE_ABC_REQ.XSD which is the root XSD.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"  xmlns="http://abc.def.com/service/SOMEService" targetNamespace="http://abc.def.com/service/SOMEService" elementFormDefault="qualified">
   <xs:include schemaLocation="ABC-Messaging.xsd"/>
   <xs:include schemaLocation="EX-Bulk-Types.xsd"/>
   <xs:element name="CREATEE_ABC_REQ">
      <xs:complexType>
         <xs:sequence>
            <xs:element name="HEADER" type="HEADERType"/>
            <xs:element name="BODY">
               <xs:complexType>
                  <xs:sequence>
                     <xs:element name="ABC-Master-Full" type="abcblk-Full-Type"/>
                  </xs:sequence>
               </xs:complexType>
            </xs:element>
         </xs:sequence>
      </xs:complexType>
   </xs:element>
</xs:schema>

Below is ABC-Messaging.xsd

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:complexType name="HEADERType">
        <xs:sequence>
            <xs:element name="SOURCE" type="SOURCEType" />
            <xs:element name="OPERATION" type="OperationType" />
        </xs:sequence>
    </xs:complexType>
    <xs:simpleType name="SOURCEType">
        <xs:restriction base="xs:string">
            <xs:pattern value="[a-zA-Z_0-9]*" />
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="OperationType">
        <xs:restriction base="xs:string">
            <xs:pattern value="[a-zA-Z_0-9]*" />
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

Below is EX-Bulk-Types.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
   <xs:annotation>
      <xs:documentation xml:lang="en">
      </xs:documentation>
   </xs:annotation>

   <xs:complexType name="abcblk-Full-Type">
      <xs:sequence>
         <xs:element name="SAMPLE" minOccurs="0">
            <xs:simpleType>
               <xs:restriction base="xs:string">
                  <xs:maxLength value="35"/>
               </xs:restriction>
            </xs:simpleType>
         </xs:element>
         <xs:element name="SAMPLE2" minOccurs="0">
            <xs:simpleType>
               <xs:restriction base="xs:string">
                  <xs:maxLength value="35"/>
               </xs:restriction>
            </xs:simpleType>
         </xs:element>
      </xs:sequence>
   </xs:complexType>
</xs:schema>

How do I generate XML for this?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Kamalraj
  • 17
  • 5
  • What have you tried, and what are you stuck on? Given the root XSD uses `include`, it should work just as if the content of the other two XSDs are in the root XSD (i.e. as if there is only one XSD). – Mark Rotteveel Apr 27 '23 at 12:48
  • @MarkRotteveel , I Have tried to Generate XML using Eclipse for above XSD. But while Generating, It Does not Create For two XSD which is in the root XSD. – Kamalraj Apr 27 '23 at 13:11
  • 1
    Then you need to edit your question and provide a [mre] that describes exactly what you do, what the results were and what you expected. Also, please don't randomly capitalize words. In English, you only capitalize the first letter of a sentence, 'I' (first person singular), and the first letter of given names (including languages, names of months and days, etc). All other words should be lowercase. – Mark Rotteveel Apr 27 '23 at 13:17
  • Are you constrained to use Eclipse? There are many other tools that attempt to generate XML from XSD. – Michael Kay Apr 27 '23 at 13:34
  • Generate an XML instance with XMLBeans: https://stackoverflow.com/questions/50106696/create-xml-file-according-to-xsd-schema/50106837#50106837 – LMC Apr 27 '23 at 15:55
  • The includes in the schema should allow multiple schemas to be combined. An well formed Xml has only one root element. If you have two different xml you need to have another schema which has two possible child items. – jdweng Apr 27 '23 at 16:35
  • @MichaelKay could you please suggest me some other tool for this – Kamalraj Apr 27 '23 at 17:58
  • I've come across several (e.g. the one in Oxygen), but I don't know whether they provide the feature you require. – Michael Kay Apr 27 '23 at 19:37

0 Answers0