The XmlTextReader cannot resolve the external Product.xsd if you give it a
Stream, since the Stream class does not provide a way to get the base URI.
"Jeff" <it_consultant1@hotmail.com.NOSPAM> wrote in message
news:ueyTPIYaEHA.1652@TK2MSFTNGP09.phx.gbl...
> IDE: Visual Studio 2003 .NET (7.1.3088)
> OS: XP Pro
> .NET Framework 1.1 (1.1.4322)
>
> I'm experimenting with xml in .net, and having trouble to get a xml file
> validated without any errors/warnings in VS . So I searched the web and
> found this example at
>
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q307379&ID=kb;en-us;Q307379&SD=MSDN > section "Use Namespaces in the XSD Schema"
>
> ProductWithXSD.xml:
> <?xml version="1.0"?>
> <Product ProductID="123"
> xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" > xmlns="urn:MyNamespace"
> xsi:schemaLocation="urn:MyNamespace Product.xsd">
> <ProductName>Rugby jersey</ProductName>
> </Product>
>
> Product.xsd:
> <?xml version="1.0"?>
> <xsd:schema xmlns:xsd="
http://www.w3.org/2001/XMLSchema" > targetNamespace="urn:MyNamespace" elementFormDefault="qualified">
> <xsd:element name="Product">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="ProductName" type="xsd:string"/>
> </xsd:sequence>
> <xsd:attribute name="ProductID" use="required" type="xsd:int"/>
> </xsd:complexType>
> </xsd:element>
> </xsd:schema>
>
> When I in VS chooses XML | Validate XML Data I get these errors (XmlSpy
> reports that both files are valid):
>
> C:\MyProjects\Visual Studio
Projects\ReadXml\support\ProductWithXSD.xml(1):
> Visual Studio could not locate a schema for this document. Validation can
> only ensure this is a well formed XML document and cannot validate the
data
> against a schema.
>
> C:\MyProjects\Visual Studio
Projects\ReadXml\support\ProductWithXSD.xml(2):
> The 'urn:MyNamespace:Product' element is not declared. An error occurred
at
> , (2, 2).
>
> C:\MyProjects\Visual Studio
Projects\ReadXml\support\ProductWithXSD.xml(6):
> The 'urn:MyNamespace:ProductName' element is not declared. An error
occurred
> at , (6, 5).
>
> In addition. When I'm in the schema editor in VS, I get an error when
> switching from xml view to schema view: "Document Element tag xsd:schema
> must indentify a qualifier for the targetNamespace "urn:MyNamespace""
>
> Any clues to why I get these errors will be appreciated!
>
> Jeff
>
>