namespace, not necessarily to import another schema document. As such, the
the code to specify the schema locations for each namespace. I haven't
"raj" <raj.muchhala@msbinfo.com> wrote in message
news:uIG3NitaEHA.2812@tk2msftngp13.phx.gbl...
> Pricilla,
>
> Thank you, that worked... What I'd like to do, however, is have the .net
> code in charge of selecting the appropriate set of schemas instead of
> hardcoding the references with an <import>. The fact that there is a
> SchemaCollection implies I should be able to do this -- without having to
> qualify the elements as in the Msoft example. What am I missing?
>
> Your solution provides a viable workaround, though, so thanks :)
>
> Cheers,
>
> Raj
>
> "Priscilla Walmsley" <nospam@datypic.com> wrote in message
> news:eg%23jMgmaEHA.2056@TK2MSFTNGP12.phx.gbl...
> > Hi,
> >
> > If you don't want to qualify the Person and Product elements, you should
> use
> > elementFormDefault="unqualified" in your Company schema. Currently,
you
> > have it set to qualified, meaning that locally declared elements (namely
> > Person and Product) should be qualified.
> >
> > Also, you need to use two xsd:import in your Company schema for the
person
> > and product namespaces.
> >
> > Hope that helps,
> > Priscilla
> >
> > ------------------------------------------------------------------
> > Priscilla Walmsley
> > Author, Definitive XML Schema / XML in Office 2003
> >
http://www.datypic.com > > ------------------------------------------------------------------
> >
> > <anonymous@coolgroups.com> wrote in message
> > news:fdfa63af973e2eb0020f1d17e9dc7e02@news.scbiz.com...
> > > When I use the schema collection to apply many schemas to
> > > one XML instance document, I get an error if I do not
> > > qualify every element with the appropriate namespace.
> > >
> > > Both the W3C site and this article
> > > (
http://www.xfront.com/ZeroOneOrManyNamespaces.html) imply
> > > that I can submit an XML instance without having to
> > > qualify each element.
> > >
> > > How do I accomplish this while still using .Net & the
> > > Validating Reader?
> > >
> > > Thanks,
> > >
> > > Raj (Example code follows)
> > > rajS*P*A*Mmuchhala@yahoo.com
> > >
> > > Example:
> > >
> > > XSD Product
> > > <?xml version="1.0"?>
> > > <xsd:schema xmlns:xsd="
http://www.w3.org/2001/XMLSchema" > > > targetNamespace="http://www.product.org"
> > > xmlns="http://www.product.org"
> > > elementFormDefault="unqualified">
> > > <xsd:complexType name="ProductType">
> > > <xsd:sequence>
> > > <xsd:element name="Type" type="xsd:string"/>
> > > </xsd:sequence>
> > > </xsd:complexType>
> > > </xsd:schema>
> > >
> > > XSD Person
> > > <?xml version="1.0"?>
> > > <xsd:schema xmlns:xsd="
http://www.w3.org/2001/XMLSchema" > > > targetNamespace="http://www.person.org"
> > > xmlns="http://www.person.org"
> > > elementFormDefault="unqualified">
> > > <xsd:complexType name="PersonType">
> > > <xsd:sequence>
> > > <xsd:element name="Name" type="xsd:string"/>
> > > <xsd:element name="SSN" type="xsd:string"/>
> > > </xsd:sequence>
> > > </xsd:complexType>
> > > </xsd:schema>
> > >
> > > XSD Company
> > > <?xml version="1.0"?>
> > > <xsd:schema xmlns:xsd="
http://www.w3.org/2001/XMLSchema" > > > targetNamespace="http://www.company.org"
> > > xmlns:per="http://www.person.org"
> > > xmlns:prod="http://www.product.org"
> > > xmlns="http://www.company.org"
> > > elementFormDefault="qualified">
> > > <xsd:element name="Company">
> > > <xsd:complexType>
> > > <xsd:sequence>
> > > <xsd:element name="Person"
> > > type="per:PersonType"
> > > maxOccurs="unbounded"/>
> > > <xsd:element name="Product"
> > > type="prod:ProductType"
> > > maxOccurs="unbounded"/>
> > > </xsd:sequence>
> > > </xsd:complexType>
> > > </xsd:element>
> > > </xsd:schema>
> > >
> > > I should be able to submit XML like the following (note:
> > > only one element has namespace qualification -> to the
> > > parent XSD file):
> > >
> > > <?xml version="1.0"?>
> > > <c:Company xmlns:c="http://www.company.org">
> > > <Person>
> > > <Name>John Doe</Name>
> > > <SSN>123-45-6789</SSN>
> > > </Person>
> > > <Product>
> > > <Type>Widget</Type>
> > > </Product>
> > > </c:Company>
> > >
> > > My code:
> > >
> > > namespace ConsoleApplication5
> > > {
> > > /// <summary>
> > > /// Summary description for Class1.
> > > /// </summary>
> > > class Class1
> > > {
> > > /// <summary>
> > > /// The main entry point for the
> > > application.
> > > /// </summary>
> > > [STAThread]
> > > static void Main(string[] args)
> > > {
> > > ValidationEventHandler
> > > eventHandler = new ValidationEventHandler
> > > (Class1.ShowCompileErrors);
> > > XmlSchemaCollection
> > > myschemacoll = new XmlSchemaCollection();
> > > XmlValidatingReader vr;
> > > FileStream stream;
> > > try
> > > {
> > > stream = new
> > > FileStream(@"c:\Staging\UDG\Phase Two\Technical
> > > Design\CompTest.xml", FileMode.Open);
> > > //Load the
> > > XmlValidatingReader.
> > > vr = new
> > > XmlValidatingReader(stream, XmlNodeType.Element, null);
> > >
> > > //Add the schemas
> > > to the XmlSchemaCollection object.
> > > myschemacoll.Add
> > > ("http://www.company.org", @"c:\Staging\UDG\Phase
> > > Two\Technical Design\company.xsd");
> > > myschemacoll.Add
> > > ("http://www.person.org", @"c:\Staging\UDG\Phase
> > > Two\Technical Design\person.xsd");
> > > myschemacoll.Add
> > > ("http://www.product.org", @"c:\Staging\UDG\Phase
> > > Two\Technical Design\product.xsd");
> > >
> > > vr.Schemas.Add
> > > (myschemacoll);
> > >
> > > vr.ValidationType
> > > = ValidationType.Schema;
> > >
> > > vr.ValidationEventHandler += eventHandler;
> > > while (vr.Read())
> > >
> > > {//Console.WriteLine(" :: " + vr.Name);
> > > }
> > > Console.WriteLine
> > > ("Validation completed");
> > > }
> > > //This code