It Worked. Thanks.
to resolve the imports.
Priya Lakshminarayanan wrote:
> This is because the xml-dsig schema has DTD definition in it and by default
> .NET XmlSchemaSet parses the schema with a reader that has ProhibitDtd =
> true.
> For your case, on XmlSchemaSet.Add(), you will get the following warning:
>
> Exception Severity: Warning
> Cannot resolve the 'schemaLocation' attribute.
> An Error Occurred at: file:///E:/bugrepro/new1.xsd, (8,2)
> Inner exception: System.Xml.XmlException: For security reasons DTD is
> prohibited in this XML document. To enable DTD processing
> set the ProhibitDtd property on XmlReaderSettings to false and pass the
> settings into XmlReader.Create method.
> at System.Xml.XmlTextReaderImpl.Throw(Exception e)
> at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl()
> at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
> at System.Xml.XmlTextReaderImpl.Read()
> at System.Xml.Schema.Parser.StartParsing(XmlReader reader, String
> targetNamespace)
> at System.Xml.Schema.Parser.Parse(XmlReader reader, String
> targetNamespace)
> at System.Xml.Schema.Preprocessor.LoadExternals(XmlSchema schema)
> System.Xml.Schema.XmlSchemaImport 8 2
>
> In order to be able to parse schemas that have DTDs in them, you need to
> create an XmlReader that allows dtds as shown below:
> XmlReaderSettings schemaReaderSettings = new XmlReaderSettings();
> schemaReaderSettings.ProhibitDtd = false;
> XmlReader schemaReader = XmlReader.Create("new.xsd", schemaReaderSettings);
> try {
> XmlSchemaSet set = new XmlSchemaSet();
> set.Add(null, schemaReader);
> set.Compile();
> }
> catch(XmlException e) {
> Console.WriteLine(e.Message + " at" + e.LineNumber);
> }
>
> Thanks,
> Priya
>
> <sachinvyas@gmail.com> wrote in message
> news:1146326183.744905.320970@j33g2000cwa.googlegroups.com...
> > Hi,
> >
> > I have following schema saved in new.xsd
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <xs:schema
> > targetNamespace="
http://www.smpte-ra.org/schemas/429.7/2006/CPL"
> > xmlns:xs="
http://www.w3.org/2001/XMLSchema" > > xmlns:ds="
http://www.w3.org/2000/09/xmldsig#" > > xmlns:cpl="
http://www.smpte-ra.org/schemas/429.7/2006/CPL"
> > elementFormDefault="qualified" attributeFormDefault="unqualified">
> > <xs:import namespace="
http://www.w3.org/2000/09/xmldsig#" > > schemaLocation="
http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd"/>
> > <xs:element name="CompositionPlaylist"
> > type="cpl:CompositionPlaylistType"/>
> > <xs:complexType name="CompositionPlaylistType">
> > <xs:sequence>
> > <xs:element name="Id" type="cpl:UUID"/>
> > <xs:element name="AnnotationText" type="cpl:UserText"
> > minOccurs="0"/>
> > <xs:element name="Signer" type="ds:KeyInfoType" minOccurs="0"/>
> > <xs:element ref="ds:Signature" minOccurs="0"/>
> > </xs:sequence>
> > </xs:complexType>
> > <xs:simpleType name="UUID">
> > <xs:restriction base="xs:anyURI">
> > <xs:pattern
> > value="urn:uuid:[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"/>
> > </xs:restriction>
> > </xs:simpleType>
> > <xs:complexType name="UserText">
> > <xs:simpleContent>
> > <xs:extension base="xs:string">
> > <xs:attribute name="language" type="xs:language" use="optional"
> > default="en"/>
> > </xs:extension>
> > </xs:simpleContent>
> > </xs:complexType>
> > </xs:schema>
> >
> > I am using following code to add the schema to schemaset and compile.
> > Compile generates exception -
> >
http://www.w3.org/2000/09/xmldsig#:KeyInfoType' is not declared.
> >
> > Any suggestions as to what I may be doing wrong or what I need to do in
> > addition to this. Actually I need to validate XML against schema and I
> > am using XMLReaderSettings and was not able to create the xmlreader so
> > I just added compile statement to see if my SchemaSet.schemas has
> > everything and looks like the issue is with Schemaset since it is not
> > compiling also in .Net 2.0 Add does not compile the schema
> > automatically.
> >
> > Suggestions will be of great help
> >