xmlSchema - undesired namespace

I have a problem using xmlschema when it adds an undesired namespacexmlns:sql="urn:schemas-microsoft-com:mapping-schema"to my annotations.

My Schema is as follows:

<?xml version="1.0" encoding="utf-16"?>
<xsd:schema xmlns:ms="urn:schemas-microsoft-com:xml-data" xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
xmlns:dt="urn:schemas-microsoft-com:datatypes"
elementFormDefault="qualified" targetNamespace="myform" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:annotation>
<xsd:appinfo>
<sql:relationship name="Relationship1" parent="ParentTable" parent-key="id" child="ChildTable1" child-key="id" />
<sql:relationship name="Relationship2" parent="ParentTable" parent-key="id" child="ChildTable2" child-key="id" />
</xsd:appinfo>
</xsd:annotation>
.
.
.

After a xmlSchema.read, followed by a xmlSchema.write, the schema is changed to the following:

<?xml version="1.0" encoding="utf-16"?>
<xsd:schema xmlns:ms="urn:schemas-microsoft-com:xml-data" xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
xmlns:dt="urn:schemas-microsoft-com:datatypes"
elementFormDefault="qualified" targetNamespace="myform" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:annotation>
<xsd:appinfo>
<sql:relationship name="Relationship1" parent="ParentTable" parent-key="id" child="ChildTable1" child-key="id"xmlns:sql="urn:schemas-microsoft-com:mapping-schema"/>
<sql:relationship name="Relationship2" parent="ParentTable" parent-key="id" child="ChildTable2" child-key="id" />
</xsd:appinfo>
</xsd:annotation>

This only happens on the first line of the annotation. It causes an error later on in my program when usingSqlXmlCommand.ExecuteXmlReader with the error:
Schema: unknown attribute 'sql' on relationship tag.

[2286 byte] By [BobLusk] at [2008-1-21]
# 1
SQLXML is trying to validate that the only attributes on the sql:relationship element are valid sql:relationship attributes. It is being probably overly aggressive by flagging the namespace decl. The only work around would be to strip that namespace decl from the sql:relationship element.
<sql:relationship name="Relationship1" parent="ParentTable" parent-key="id" child="ChildTable1" child-key="id" xmlns:sql="urn:schemas-microsoft-com:mapping-schema"/>

Hope this helps,
Todd

ToddPfleiger at 2007-9-9 > top of Msdn Tech,SQL Server,SQL Server XML...

SQL Server

Site Classified