I have two xml files and I need to create one xsd for both. This is the first time I am dealing with xml files. How can I create one xsd for both xml files and validate that they are correct?
My first xml file:
<?xml version="1.0" encoding="UTF-8"?>
<specification xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DATA>
<Id>S2</Id>
<Name>sai</Name>
<Service>manufaturer</Service>
<ref_complete_customer path="/work/bsr.xml"/>
<ref_complete_customer path="/work/srr.xml"/>
<Service_Customers>
<Customer Id="bs"/>
</Service_Customers>
<Service_Suppliers>
<Supplier Id="r"/>
<Supplier Id="b"/>
<Supplier Id="L"/>
</Service_Suppliers>
</DATA>
</specification>
My second xml file:
<?xml version="1.0" encoding="UTF-8"?>
<universitylist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<university>
<refstr>bdvl_te_skrm_stc</refstr>
<ref_complete_customer path="/work/bsr.xml"/>
<Code>A0f11478</Code>
<Area>sku</Area>
<started>1987</started>
<branch>
<electronics>
<students Nr="120" ece="ab">
<student Name="svr" year="2010" rank="3"/>
<student Name="bvr" year="2010" rank="1"/>
</students>
</electronics>
</branch>
<semister>
<semister num="3"/>
</semister>
<address>
1.address of student
<extrainfo>
</extrainfo>
</address>
</university>
</universitylist>
This is my approch
specification.xsd for frist file.
universitylist.xsd for second file.
combined xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="specification.xsd" />
<xs:include schemaLocation="universitylist.xsd" />
</xs:schema>
I’m not sure why you would want a single schema that describes both document instances, since they seem completely unrelated. But the fact that they are unrelated makes it trivial – you just combine the two XSDs. For example, if you currently have a.xsd and b.xsd, then you can create a new c.xsd that simply does an xs:include on both of these.