Skip to Content

How to add namespace to xsd ?

i have Structure in Wsdl like:

<ns0:Root>

<header>

</A>

</header>

<Body>

</B>

</Body>

<ns0:/Root>

How to generate xsd with namespace.

Regards,

Aditya

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Mar 06, 2017 at 10:00 AM

    Hello Aditya,

    You have to set below two parameters in your XSD which will make your XSD fully qualified.

    attributeFormDefault="qualified" elementFormDefault="qualified"

    XML:

    <ns0:Root xmlns:ns0="http://test.com">
        <ns0:Header>
            <ns0:H1>Hii</ns0:H1>
        </ns0:Header>
        <ns0:Record>
            <ns0:R1>Hello</ns0:R1>
        </ns0:Record>
    </ns0:Root>

    XSD:

    <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://test.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:element name="Root">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="Header">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element type="xs:string" name="H1"/>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                    <xs:element name="Record">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element type="xs:string" name="R1"/>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
    </xs:schema>

    Regards,

    Sriprasad Shivaram Bhat

    Add comment
    10|10000 characters needed characters exceeded