[Mono-list] XSD indirect importing problem with XsdSchemaSet

魏玮 shazhouke at gmail.com
Wed Oct 14 02:32:07 EDT 2009


Hi, guys,

I ran into this problem when working with the XsdSchemaSet:

Take an example:

There are 3 schemas, say a.xsd, b.xsd, c.xsd
a.xsd imports b.xsd, b.xsd imports c.xsd
a.xsd and c.xsd have the SAME target namespace

a.xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://nsA" xmlns:xs="
http://www.w3.org/2001/XMLSchema">
  <xs:import targetNamespace=http://nsB" target="b.xsd"/>
  <xs:element name="a">
  </xs:element>
</xs:schema>

b.xsd:
 <?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://nsB" xmlns:xs="
http://www.w3.org/2001/XMLSchema">
  <xs:import targetNamespace=http://nsA" target="c.xsd"/>
  <xs:element name="b">
  </xs:element>
</xs:schema>

c.xsd
 <?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://nsA" xmlns:xs="
http://www.w3.org/2001/XMLSchema">
  <xs:element name="c">
  </xs:element>
</xs:schema>

An error saying "Target namespace must be different from that of included
schema", when I was running the following program

using System;
using System.Xml;
using System.Xml.Schema;

namespace testSchema
{
    class Program
    {
        static void Main(string[] args)
        {
            XmlSchemaSet xss = new XmlSchemaSet();
            xss.Add(null, "a.xsd")
            xss.Compile();
        }
    }
}

I have tried:
1. Run the program with Mono 2.4.2.3 , got the error "Target namespace must
be different from that of included schema",
2. Run the program with Visiual Studio 2008, no error.
3. Include c.xsd in a.xsd, before importing,
     <?xml version="1.0" encoding="utf-8"?>
    <xs:schema targetNamespace="http://nsA" xmlns:xs="
http://www.w3.org/2001/XMLSchema">
      <xs:include schemaLocation="c.xsd"/>
      <xs:import targetNamespace=http://nsB" schemaLocation="b.xsd"/>
      <xs:element name="a">
      </xs:element>
    </xs:schema>
    run with Mono 2.4.2.3, no error.

I want to know:

Is there any method to resolve this error except adding includes (If no, I
have to modify a lot schema files)


--
Thank you and best regards :)
Wei Wei
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20091014/9682a5eb/attachment-0001.html 


More information about the Mono-list mailing list