|
-
March 1st, 2006, 01:09 PM
#1
"element is not declared" when xsd on an xml file
Can anyone tell me why when I atempt to validate my below xml file against the xsd file, I get the below error message?
Many thanks.
The 'ItemList' element is not declared. An error occurred at file:///g:/temp/WDWEBSVC.XML, (4, 2).: Message:{0}
****************************************************************************
<?xml version="1.0" encoding="us-ascii" standalone="yes"?>
<?xml-stylesheet version='1.0'?>
<!--this file contains wdog xml data for all items-->
<ItemList xmlns:il="http://tempuri.org/WDWEBSVC.xsd">
<Item>
<strItemName>Ping Nifty Tools</strItemName>
<strItemAddress>www.niftytools.com</strItemAddress>
<strItemType>Ping</strItemType>
<strItemStatus>Ping</strItemStatus>
</Item>
<Item>
<strItemName>Html download Nifty Tools</strItemName>
<strItemAddress>http://www.niftytools.com</strItemAddress>
<strItemType>HTML Download</strItemType>
<strItemStatus>HTML Download</strItemStatus>
</Item>
<Item>
<strItemName>Screen Saver</strItemName>
<strItemAddress>http://infodeli.3com.com/index.htm</strItemAddress>
<strItemType>NT Screen Saver</strItemType>
<strItemStatus>NT Screen Saver</strItemStatus>
</Item>
</ItemList>
****************************************************************************
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="ItemList" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:il="http://tempuri.org/WDWEBSVC.xsd"
targetNamespace="http://tempuri.org/WDWEBSVC.xsd">
<xs:element name="ItemList" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Item">
<xs:complexType>
<xs:sequence>
<xs:element name="strItemName" type="xs:string" minOccurs="0" />
<xs:element name="strItemAddress" type="xs:string" minOccurs="0" />
<xs:element name="strItemType" type="xs:string" minOccurs="0" />
<xs:element name="strItemStatus" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
****************************************************************************
MyXmlTextReader = new XmlTextReader ( strCheckFile );
MyXmlValidatingReader = new XmlValidatingReader ( MyXmlTextReader );
try {
MyXmlValidatingReader.Schemas.Add ( strCheckUrn, strCheckSchema );
MyXmlValidatingReader.ValidationType = ValidationType.Schema;
MyXmlValidatingReader.ValidationEventHandler += new ValidationEventHandler ( ValidationCallback );
try {
// read whole file and check it
m_bXmlFileIsValid = true;
while ( MyXmlValidatingReader.Read() )
{
if ( m_bXmlFileIsValid == false ) break; // abort if error
}
return ( m_bXmlFileIsValid ); // set in ValidationCallback()
}
catch ( Exception e )
{
if ( MyXmlValidatingReader != null ) MyXmlValidatingReader.Close();
Debug.WriteLine ( "Validate error: " + e.ToString() );
m_bXmlFileIsValid = false;
return ( m_bXmlFileIsValid );
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|