The markup in the document following the root element must be well-formed.While extracting XSD from WSDL

StackOverflow https://stackoverflow.com/questions/22830601

Вопрос

I am trying to read a WSDL, extract the schemas imported/inline and put all these things into a single schema file.(extracting the string between the tags)

While doing so, I am getting the following error:

[Fatal Error] :1:416: The markup in the document following the root element must be well-formed.

Это было полезно?

Решение

Your XML is not well-formed because you need to have a single root element. Your document has two! If you place them under a single root, you will obtain a well-formed XML (but not necessarily a valid one, since that depends on how you are going to use it):

<root>
    <xsd:schema ...> ... </xsd:schema>
    <xsd:schema ...> ... </xsd:schema>
</root>

A valid way to combine the definitions in two schemas would be to include their contents in one schema, having <xsd:schema> as the root element:

<xsd:schema ...>
    <xsd:complexType ...> ... </xsd:complexType>
    <xsd:element ...> ... </xsd:element>
</xsd:schema>

But if it will work or not depends on your namespace definitions. If you had the same target namespaces for both schemas, you could keep them in different files and include one in the other using <xsd:include>. With different namespaces, as it seems to be your case, you can use <xsd:import> to import the qualified elements from your second schema to your first one :

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:import namespace="services/data/common" schemaLocation="your-second-schema.xsd"/>
    <xsd:complexType name="NoNamespaceType">...</xsd:complexType>
    ...
</xsd:schema>

That will allow you to use it to validate instances which use elements from your second schema, as long as they are qualified with a namespace:

<d:request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="your-first-schema.xsd" xmlns:d="services/data/common">
    <d:header></d:header>
    <d:body></d:body>
</d:request>

as well as unqualified elements that use the no-namespace schema:

<noNamespace xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="your-first-schema.xsd">
    <firstElement></firstElement>
    <secondElement></secondElement>
</noNamespace>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top