473,685 Members | 2,925 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

attribute not declared for validating schema init


Hello,

I get the following error when instanciating an XmlReader that performs validation:

"The 'http://tenbase2.com/DVDTimestamps:s chemaLocation' attribute is not declared."

My beginning XML tag starts as follows:

<DVDTimestamp s xmlns:tb2="http ://tenbase2.com/DVDTimestamps" tb2:schemaLocat ion="DVDTimesta mpXmlSchema.xsd ">

What am I missing?

Thanks,
William Johnston

Feb 16 '07 #1
5 9518
William Johnston wrote:
I get the following error when instanciating an XmlReader that
performs validation:

"The 'http://tenbase2.com/DVDTimestamps:s chemaLocation' attribute is
not declared."

My beginning XML tag starts as follows:

<DVDTimestamp s xmlns:tb2="http ://tenbase2.com/DVDTimestamps"
tb2:schemaLocat ion="DVDTimesta mpXmlSchema.xsd ">

What am I missing?
If you want to specify the schema location(s) then that attribute
schemaLocation needs to be in the namespace
http://www.w3.org/2001/XMLSchema-instance and needs to have URL pairs
namespaceURL schemaURL as its value e.g.
<root xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://example.com/2007/ns1
http://example.com/schema1.xsd"
xmlns="http://example.com/2007/ns1">

If you happen to have your own attribute named schemaLocation then you
need to make sure your schema defines that for the DVDTimestamps element.


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Feb 16 '07 #2
"William Johnston" <wi******@tenba se2.comwrote:
>
Thanks for your reply.

I am still getting the error.

The modified tag is now:

<DVDTimestamp s xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://tenbase2.com/DVDTimestamps DVDTimestampXml Schema.xsd"
xmlns="http://tenbase2.com/DVDTimestamps">

I also used a url and full path for schema file name.

Regards,
William Johnston

Feb 16 '07 #3
William Johnston wrote:
I am still getting the error.

The modified tag is now:

<DVDTimestamp s xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://tenbase2.com/DVDTimestamps DVDTimestampXml Schema.xsd"
xmlns="http://tenbase2.com/DVDTimestamps">

I also used a url and full path for schema file name.
Please show the exact error message and the relevant code setting up the
validating XmlReader and show the relevant parts of the schema.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Feb 16 '07 #4
"William Johnston" <wi******@tenba se2.comwrote:
>
Thanks again for your reply.

The init code for the validating XML reader is:

StreamReader stream = new StreamReader(st rFilename);

// Create the XmlSchemaSet class.
DVDXmlSchemaSet sc = new DVDXmlSchemaSet (strTargetNames pace, strSchemaFilena me);

XmlReaderSettin gs settings = new XmlReaderSettin gs();
settings.Valida tionType = ValidationType. Schema;
settings.Valida tionFlags |= XmlSchemaValida tionFlags.None;
settings.Schema s = sc;
settings.Valida tionEventHandle r += new ValidationEvent Handler(Validat ionCallBack);

reader = XmlReader.Creat e(stream, settings);

/// <summary>
/// schema filename
/// </summary>
private static string strTargetNamesp ace = "urn:DVDTimesta mps";
/// <summary>
/// schema filename
/// </summary>
private static string strSchemaFilena me = "DVDTimestampXm lSchema.xsd";
The DVDXmlSchemaSet class has a base class of XmlSchemaSet and has a constructor of:

class DVDXmlSchemaSet : MyXmlSchemaSet
{
public DVDXmlSchemaSet (string strTargetNamesp ace, string strFileName)
: base(strTargetN amespace, strSchemaPath, strFileName)
{
}
/// <summary>
/// field that contains the XML schema path
/// </summary>
public static string strSchemaPath = "G:\\DVD\\MyPro grams output\\xml schemas\\";
}
Finally, the MyXmlSchemaSet constructor is:

public MyXmlSchemaSet( string strTargetNamesp ace, string strPath, string strFilename) : base()
{
object[] formatParams = new object[2];
formatParams[0] = strPath;
formatParams[1] = strFilename;
string strSchemaFile = string.Format(" {0}{1}", formatParams);
Add(strTargetNa mespace, strSchemaFile);
}

The exact exception and error message is:

System.Xml.Sche ma.XmlSchemaVal idationExceptio n: "The 'http://tenbase2.com/DVDTimestamps:s chemaLocation' attribute is not declared."

Regards,
William Johnston
Feb 17 '07 #5
William Johnston wrote:
settings.Valida tionType = ValidationType. Schema;
settings.Valida tionFlags |= XmlSchemaValida tionFlags.None;
settings.Schema s = sc;
settings.Valida tionEventHandle r += new ValidationEvent Handler(Validat ionCallBack);

reader = XmlReader.Creat e(stream, settings);
private static string strTargetNamesp ace = "urn:DVDTimesta mps";
So the target namespace you use in your C# code is "urn:DVDTimesta mps".
The XML document sample you have shown earlier has

DVDTimestamps xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://tenbase2.com/DVDTimestamps
DVDTimestampXml Schema.xsd"
xmlns="http://tenbase2.com/DVDTimestamps">

so there the elements ae in the namespace
"http://tenbase2.com/DVDTimestamps". That is one issue at least that
does not make sense to me.

The exact exception and error message is:

System.Xml.Sche ma.XmlSchemaVal idationExceptio n: "The 'http://tenbase2.com/DVDTimestamps:s chemaLocation' attribute is not declared."
Show the relevant parts of the XML document and the schema, the snippet
above does not have an attribute named schemaLocation in the namespace
http://tenbase2.com/DVDTimestamps.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Feb 18 '07 #6

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

Similar topics

1
1601
by: Duncan Smith | last post by:
Hello All, Has anyone found a way to specify an xsd schema programatically when using the apache xerces xml processor? I know that the validation works fine as long as the xml instance document explicitly refernces the schema via an 'xsd:xsi schemaLocation=...' tab. But how can you validate xml documents which don't contain the schemaLocation? Reading the instance and assigning the schemaLocation before flushing it back out and...
12
4945
by: Stefano | last post by:
Hi all, what is the correct use of the "default" attribute in XML Schema? For example: <xs:element name="myProperty" type="xs:string" default="myDefaultValue"/> What can I do with it? What is the meaning of < ....default="myDefaultValue" /> ?
1
1325
by: Brad Wood | last post by:
Using 2.0, but I think this applies to 1.1. Given an XmlSchemaElement object (retrieved from an XmlSchema object), how do I get to it's attributes? I tried this against a document that has attributes, but got nothing: foreach ( XmlSchemaAttribute attr in schema.Attributes ) { Console.WriteLine( attr.Name ); }
4
2287
by: bibsoconner | last post by:
Hi, I hope someone can please help me. I'm having a lot of trouble with schema files in .NET. I have produced a very simple example that uses "include" to include other schema files. It all works with SPY, but when I pick "Validate Schema" from the .NET 2003 menu, it fails with message: "Type XType is not declared." As I hinted at in my subject line, I suspect that it has to do with including another schema multiple times.
7
3260
by: Oisin Grehan | last post by:
Hi, I have a UserControl derived class: <ns:votingbutton runat="server" id="btn1" onclick="votingbuttonclick" /> My question is, what code do I need in place in the codebehind for this to be wired up? All the examples I've seen wire up the event programatically, thus making this declarative attribute irrelevant. e.g.
2
1889
by: smachin1000 | last post by:
Hi All, In the sample schema & document below, I'd like the attribute "name" to be unique for all function elements under function_list. The tools I'm using (XML Spy and xmllint) all validate the sample document and do not pick up that the name is not unique. Any clues as to what could be going wrong? Thanks.
2
3037
by: Mark | last post by:
Hi... I've been trying the .Validate() method on the XmlDocument to validate some xml against a schema, but one thing I noted was that unless the document explicitly declares the schema as a default namespace, Validate() just lets it slide through as a success. Is there a way to Validate() either a) mandating against a particular schema, or at the very least b) supplying a default namespace to be used even when not explicitly declared?
2
1399
by: pstachy | last post by:
Hi all, I've got this problem declaring attribute for the element. W3C Validator doesn't find this ok. I really dont know how to declare the attribute for the tag which has simle content(doesn't have other tags in itself). In this case: <price curr="PLN">12.30</price> My Schema for that:
3
3625
by: jh3an | last post by:
Please give me your advice! I made two files according to xml book, but when validating these two files, it gives me an error that I totally don't understand. Is there a problem in these codes? I checked xml and schema files through these following sites: http://tools.decisionsoft.com/schemaValidate/
0
8577
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8507
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8761
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7589
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6431
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5792
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4302
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
1927
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.