0

Can we control the single element using two, three xsd.

<html>
  <head>
    <title> </title>
  </head>
  <body>
  </body>
</html>

I have an xsd to control the above structure.

<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="html" type="Root" />
<xs:complexType name="Root">
    <xs:sequence>
        <xs:element name="head"/>
        <xs:element name="body" type="xs:string" minOccurs="1"/>
    </xs:sequence>
</xs:complexType>

I can call this as base xsd. I am creating another two xsd to control body element attribute values and allow one project1 element in the body, and in another xsd I want to project2 new element within body using base included base.xsd. How this can be done? Is this achievable?

Alexis King
  • 43,109
  • 15
  • 131
  • 205
VSe
  • 919
  • 2
  • 13
  • 29

1 Answers1

1

It's unconventional, but there's nothing stopping you from validating an XML document once with one XSD and again with a different XSD. Note that @schemaLocation and @noNamespaceSchemaLocation won't be sufficient to associate the additional XSDs to be successively applied; you'd have to make the additional associations between the XML document and the XSDs externally.

More commonly, however, a single XSD will be used for validation. That XSD might itself consist of other included or imported XSDs. (See: What's the difference between xsd:include and xsd:import?) If you're new to XSD and are looking to modularize your XSD design, I suggest you pursue this more conventional approach to organizing and composing XSDs.

Community
  • 1
  • 1
kjhughes
  • 106,133
  • 27
  • 181
  • 240