Work with multiple XSD

I have xsd that has 3 imports in another xsd, 8 complex types and 3 simple types.

Now I have to work with only one type of compex, which in turn inherits many other XSDs - basically 3 imports that have the current xsd.

I get an XML file containing data only according to the complex type alone that I mentioned.

Now I'm trying to generate a sample XML file that contains data according to one complex type and trying to validate it, but when I try to do it using XMLSpy or OxygenXML, it says that the root node is not defined.

Now, when I try to determine the root nodes, this does not allow me to do this, and if I try to create another xsd only for this complex type, than this will also give me some errors like the inherited xsd that this complex type indicates the initial xsd is not works in the new one, I tried to inherit 3 xsd, to which a complex type points to the initial xsd in the new xsd, but still it does not work.

Also my other question: can we check the XML file for some part of the XSD compared to the full XSD, because the XML, that turns out, corresponds to 1 complex element type in the XSD?

Initial XSD format:

 <?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:schema location targetNamespace=targetnamespace elementFormDefault="qualified" attributeFormDefault="unqualified" version="0.652">
    <xs:import namespace=first xsd which is imported>
    <xs:import namespace=second xsd which is imported>
    <xs:import namespace=third xsd which is imported>
    <xs:complexType name="firstcomplextype" abstract="false">
        <xs:sequence>
            <xs:element name="some value" type="xs:string" minOccurs="0"/>
            <xs:element name="some value" type="some value"/>
            <xs:element name="some value" type="xs:string" minOccurs="0"/>
        </xs:sequence>
        <xs:attribute name="some value" type="xs:int" use="required"/>
        <xs:attribute name="some value" type="xs:value" use="required"/>
        <xs:attribute name="some value" type="xs:int" use="required"/>
    </xs:complexType>
    <xs:complexType name="second complex type" abstract="false">
        <xs:sequence>
            <xs:element name="some value" type="xs:some value" minOccurs="0"/>
            <xs:element name="some value" type="xs:some value" minOccurs="0"/>
            <xs:element name="some value" type="some value"/>
            <xs:element name="some value" type="some value"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="third complex type**I need to work with only this complex type and xml file will contain data according to this complex type only and I need to validate incoming XML against only this complex type**" abstract="false">
        <xs:sequence>
            <xs:element name="some value" minOccurs="0">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="some value" type="some value" minOccurs="0" maxOccurs="unbounded"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="some value" type="some value"/>
            <xs:element name="some value" minOccurs="0">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="some value" type="some value" minOccurs="0" maxOccurs="unbounded"/>---**Here this particular element points to another XSD, one of the imported XSD's**
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:sequence minOccurs="0">
                <xs:element name="some value" type="xs:some value" minOccurs="0" maxOccurs="unbounded"/>
                <xs:element name="some value" minOccurs="0">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="some value" type="some value" minOccurs="0" maxOccurs="unbounded"/>---**Here this particular element points to another XSD, one of the imported XSD's**
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
            <xs:sequence minOccurs="0">
                <xs:element name="some value" type="xs:some value" minOccurs="0" maxOccurs="unbounded"/>
                <xs:element name="some value" minOccurs="0">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="some value" type="some value" minOccurs="0" maxOccurs="unbounded"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="4th complex type" abstract="false">
        <xs:sequence>
            <xs:element name="elements">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="some value" type="some value" maxOccurs="unbounded"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

and xsd goes on as it has many more complex types and simple types. Any guidance would be greatly appreciated.

+1
source share
2

complexType. XML-, element , . ( ) , , XML, .

"" . element XML, XML- ( DTD RELAX NG, ).

XML-, xsi:type , complexType, . , -

xsi:type="firstcomplextype" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

XML-.

+1

, , . :

:

   <xs:element name="newElement" type="thirdComplexType"/>

(, ), , .

XML "thirdComplexType", "newElement" . , XML XSD.

XML- :

0

Source: https://habr.com/ru/post/1720737/


All Articles