By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,107 Members | 1,484 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,107 IT Pros & Developers. It's quick & easy.

XmlSchema include question.

P: n/a
Hello,

I have 2 schema, for argument sake let's call them child.xsd and parent.xsd.
I define all my types in parent.xsd and the child.xsd include the parent.xsd
using the following tag:

<xs:include schemaLocation="http://localhost/xsds/parent.xsd"/>

Now when I create an XmlSchema object on the child.xsd I couldn't get the
type that I define in the parent.xsd. How do I get this? Do I need to create
an XmlSchema on the parent.xsd itself? Why doesn't the xs:include includes
the parent.xsd?

I tried to loop through the .Include property, I have 1 element there -
which is right - but then the SourceUri is empty ...

Thanks,

Nathan
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Please post the two XSD files and the code you are using.

Thanks.

"Nathan Wallace" <sy***@nospam.nospam> wrote in message
news:28**********************************@microsof t.com...
Hello,

I have 2 schema, for argument sake let's call them child.xsd and parent.xsd. I define all my types in parent.xsd and the child.xsd include the parent.xsd using the following tag:

<xs:include schemaLocation="http://localhost/xsds/parent.xsd"/>

Now when I create an XmlSchema object on the child.xsd I couldn't get the
type that I define in the parent.xsd. How do I get this? Do I need to create an XmlSchema on the parent.xsd itself? Why doesn't the xs:include includes
the parent.xsd?

I tried to loop through the .Include property, I have 1 element there -
which is right - but then the SourceUri is empty ...

Thanks,

Nathan

Nov 12 '05 #2

P: n/a
Well it's simple:

File 1:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:sauce="http://www.synop.com/sauce/1.0" elementFormDefault="qualified"
attributeFormDefault="qualified">
<xs:include schemaLocation="http://victor/sauce.xsd"/>
<xs:element name="topic">
<xs:annotation>
<xs:documentation>Defines a topic.</xs:documentation>
<xs:appinfo>
<sauce:name>Topic
</sauce:name>
</xs:appinfo>
</xs:annotation>
<xs:complexType mixed="false">
<xs:sequence>
<xs:element name="title"/>
<xs:element name="body"/>
</xs:sequence>
<xs:anyAttribute namespace="##any"/>
</xs:complexType>
</xs:element>
</xs:schema>

While the second file (sauce.xsd) is:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:sauce="http://www.synop.com/sauce/1.0" elementFormDefault="qualified">
<xs:simpleType name="mediumString">
<xs:annotation>
<xs:documentation>A string</xs:documentation>
</xs:annotation>
<xs:restriction>
<xs:minLength value="1"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
"Zafar Abbas [MSFT]" wrote:
Please post the two XSD files and the code you are using.

Thanks.

"Nathan Wallace" <sy***@nospam.nospam> wrote in message
news:28**********************************@microsof t.com...
Hello,

I have 2 schema, for argument sake let's call them child.xsd and

parent.xsd.
I define all my types in parent.xsd and the child.xsd include the

parent.xsd
using the following tag:

<xs:include schemaLocation="http://localhost/xsds/parent.xsd"/>

Now when I create an XmlSchema object on the child.xsd I couldn't get the
type that I define in the parent.xsd. How do I get this? Do I need to

create
an XmlSchema on the parent.xsd itself? Why doesn't the xs:include includes
the parent.xsd?

I tried to loop through the .Include property, I have 1 element there -
which is right - but then the SourceUri is empty ...

Thanks,

Nathan


Nov 12 '05 #3

P: n/a
Your second schema, sauce.xsd is invalid. Did you load file1 into an
XmlSchema and called Compile(). It should have reported an error.
The corrected sauce.xsd is:

<xs:simpleType name="mediumString">
<xs:annotation>
<xs:documentation>A string</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
"Victor Hadianto" <sy***@nospam.nospam> wrote in message
news:A7**********************************@microsof t.com...
Well it's simple:

File 1:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:sauce="http://www.synop.com/sauce/1.0" elementFormDefault="qualified" attributeFormDefault="qualified">
<xs:include schemaLocation="http://victor/sauce.xsd"/>
<xs:element name="topic">
<xs:annotation>
<xs:documentation>Defines a topic.</xs:documentation>
<xs:appinfo>
<sauce:name>Topic
</sauce:name>
</xs:appinfo>
</xs:annotation>
<xs:complexType mixed="false">
<xs:sequence>
<xs:element name="title"/>
<xs:element name="body"/>
</xs:sequence>
<xs:anyAttribute namespace="##any"/>
</xs:complexType>
</xs:element>
</xs:schema>

While the second file (sauce.xsd) is:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:sauce="http://www.synop.com/sauce/1.0" elementFormDefault="qualified"> <xs:simpleType name="mediumString">
<xs:annotation>
<xs:documentation>A string</xs:documentation>
</xs:annotation>
<xs:restriction>
<xs:minLength value="1"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
"Zafar Abbas [MSFT]" wrote:
Please post the two XSD files and the code you are using.

Thanks.

"Nathan Wallace" <sy***@nospam.nospam> wrote in message
news:28**********************************@microsof t.com...
Hello,

I have 2 schema, for argument sake let's call them child.xsd and

parent.xsd.
I define all my types in parent.xsd and the child.xsd include the

parent.xsd
using the following tag:

<xs:include schemaLocation="http://localhost/xsds/parent.xsd"/>

Now when I create an XmlSchema object on the child.xsd I couldn't get the type that I define in the parent.xsd. How do I get this? Do I need to

create
an XmlSchema on the parent.xsd itself? Why doesn't the xs:include includes the parent.xsd?

I tried to loop through the .Include property, I have 1 element there - which is right - but then the SourceUri is empty ...

Thanks,

Nathan


Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.