Topic
2 replies Latest Post - ‏2013-04-16T08:39:49Z by mones
Richy
Richy
2 Posts
ACCEPTED ANSWER

Pinned topic xml schema question

‏2012-10-09T13:28:47Z |
Hello
I am running into this problem with xml schema, here is my issue
I have 3 schema(s), each with different name space. One schema "A" has 2 elements, one is header and the other is "Data".
Data can be any of 2 schema(s) (one or the other) , since these schema(s) do not have the same name space , I used import, but still having problem
Here are sample of I am trying to do , any help will be appreciate it.
<?xml version="1.0" ?>
<xs:schema targetNamespace="http://testA.com/A.xsd"
xmlns:cmr="http://testA.com/A.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:itmB=http://testB.com/B.xsd
xmlns:itmC="http://testC.com/C.xsd"

attributeFormDefault="qualified" elementFormDefault="qualified">

<xs:import namespace="http://testB.com/B.xsd"
schemaLocation="B.xsd"/>
<xs:import namespace="http://testC.com/C.xsd"
schemaLocation="C.xsd"/>

<xs:element name="A">
<xs:complexType>
<xs:sequence>
<xs:element name="Header" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="message-class" form="unqualified" type="xs:string" />
<xs:attribute name="message-id" form="unqualified" type="xs:long" />
<xs:attribute name="message-date" form="unqualified" type="xs:dateTime" />
</xs:complexType>
</xs:element>
<xs:element name="Data" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:choice>
<xs:element name="B" type="itmB:B"/>
<xs:element name="C" type="itmC:C"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Also here is sample of the schema B

<xs:schema id="B"
targetNamespace="http://testB.com/B.xsd"
elementFormDefault="qualified" attributeFormDefault="qualified"
xmlns="http://testB.com/B.xsd"
xmlns:mstns="http://testB.com/B.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="B" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Title">
<xs:complexType>
<xs:sequence>
.
.
Updated on 2012-10-09T19:28:19Z at 2012-10-09T19:28:19Z by Richy
  • Richy
    Richy
    2 Posts
    ACCEPTED ANSWER

    Re: xml schema question

    ‏2012-10-09T19:28:19Z  in response to Richy
    any help on this
    • mones
      mones
      1 Post
      ACCEPTED ANSWER

      Re: xml schema question

      ‏2013-04-16T08:39:49Z  in response to Richy

      You didn't stated the problem you're facing, but there's at least a couple of errors on the stuff you pasted:

      • missing quotes on itmB namespace
      • you're trying to use an element as a type (<xs:element name="B" type="itmB:B"/>), better put the name="B" attribute in the complexType tag and remove the enclosing element tag on shema B.

      HTH