473,405 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

xmlSchemaSet compile and xs:import error

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

Apr 29 '06 #1
3 7552
Missed the lil piece of code

try
{
XmlSchemaSet ss = new XmlSchemaSet();
ss.Add(null, "new.xsd");
ss.Compile();
}
catch(XmlSchemaException e)
{
Console.WriteLine(e);
}

Apr 29 '06 #2
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(XmlSc hema 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

<sa********@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.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

May 1 '06 #3
It Worked. Thanks.
But the system should be connected to internet else it will not be able
to resolve the imports.
Thanks

Sachin
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(XmlSc hema 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

<sa********@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.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


May 4 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: PipedreamerGrey | last post by:
I'm trying to create a standalone version (.exe) of PythonCard's Custdb sample using Py2Exe version 0.5.0. Everytime I attempt to compile the program, I get an error during compilation. This is...
1
by: GujuBoy | last post by:
i am using BOOST in linux with python and i can compile my CPP file just fine to make a .so but everytime i do a import i get this error >>> import dirgesh Traceback (most recent call last):...
1
by: Ed Bacon | last post by:
I am trying to produce a generic "audit report" for various transactions in our application. Each transaction type defines a document (and has an associated schema). When a transaction leads to a...
0
by: Rupa | last post by:
Hi, Can anyone tell me how to eliminate the import tags from an XSD? I want to be able to take this XSD into a Dataset using the ReadXMLSchema method of a XMLDataDocument. Currently this fails...
5
by: Brice Prunier | last post by:
Here under 4 schemas i'm working with ( it may be long: sorry...) The context is the following : Resident.xsd imports Person.xsd and includes Common.xsd ( anonimous schema: no TargetNamespace )...
3
by: Nathan Alden | last post by:
Hi all. I have an XML schema that has a couple of <xs:import> tags that reference (using schemaLocation) schemas as embedded resources in a DLL. For example: <xs:import...
3
by: Neter Smith | last post by:
I have run into a problem when trying to import a WSDL reference under VS 2003 and 1.1 of the framework. It appears as if it is in the generation of the proxy that things are failing. When I...
2
by: randar | last post by:
I'm having problems getting an XML document to validate against a fairly complex scenario. Goals: -To have two schemas with two different namespaces, so that I can validate each one seperately...
1
by: Julia | last post by:
Hi I have got two xsd files. One xsd imports the second file using the <xs:import tag. I have now put both files in the App_Code directory (is that ok). When I debug I got an error saying...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.