HighTechTalks DotNet Forums  

issue with XML and Schema namespace

Dotnet XML microsoft.public.dotnet.xml


Discuss issue with XML and Schema namespace in the Dotnet XML forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Durango2008
 
Posts: n/a

Default issue with XML and Schema namespace - 12-19-2007 , 03:51 AM






Hi I am having a hard time with validation of my XML file with given schema.

Here are the files:

roboerrorlog.xsd

<robomss:schema xmlns:robomss="http://www.w3.org/2001/XMLSchema"
xmlns="robomss"
elementFormDefault="qualified" targetNamespace="robomss">
<robomss:element name="roboErrorLog" type="errorLogType"/>
<robomss:complexType name="errorLogType">
<robomss:sequence maxOccurs="unbounded">
<robomss:element name="error" type="errorType"/>
</robomss:sequence>
</robomss:complexType>
<robomss:complexType name="errorType">
<robomss:sequence>
<robomss:element name="user" type="robomss:string"/>
<robomss:element name="datetime" type="robomss:string"/>
<robomss:element name="message" type="robomss:string"/>
<robomss:element name="stack" type="stackType"/>
</robomss:sequence>
</robomss:complexType>
<robomss:complexType name="stackType">
<robomss:sequence>
<robomss:element name="functionName" type="robomss:string"/>
<robomss:element name="lineNumber" type="robomss:string"/>
</robomss:sequence>
</robomss:complexType>
</robomss:schema>


roboerrorlog.xml

<?xml version="1.0" encoding="utf-8"?>
<roboErrorLog xmlns:robomss="http://www.w3.org/2001/XMLSchema">
<error>
<user>steve</user>
<datetime>12/18/2007 2:31:33 PM</datetime>
<message>Null reference error!</message>
<stack>
<functionName>Void btnSearch_Click(System.Object,
System.EventArgs)</functionName>
<lineNumber>300</lineNumber>
</stack>
</error>
<error>
<user>steve</user>
<datetime>12/18/2007 2:31:38 PM</datetime>
<message>Null reference error!</message>
<stack>
<functionName>Void btnSearch_Click(System.Object,
System.EventArgs)</functionName>
<lineNumber>300</lineNumber>
</stack>
</error>
<error>
<user>steve</user>
<datetime>12/18/2007 2:31:43 PM</datetime>
<message>Null reference error!</message>
<stack>
<functionName>Void btnSearch_Click(System.Object,
System.EventArgs)</functionName>
<lineNumber>300</lineNumber>
</stack>
</error>
<error>
<user>steve</user>
<datetime>12/18/2007 3:22:37 PM</datetime>
<message>Null reference error!</message>
<stack>
<functionName>Void btnSearch_Click(System.Object,
System.EventArgs)</functionName>
<lineNumber>300</lineNumber>
</stack>
</error>
<error>
<user>steve</user>
<datetime>12/18/2007 3:22:38 PM</datetime>
<message>Null reference error!</message>
<stack>
<functionName>Void btnSearch_Click(System.Object,
System.EventArgs)</functionName>
<lineNumber>300</lineNumber>
</stack>
</error>
</roboErrorLog>

When I pass these files to a validator it has an issue with the roboErrorLog
declaration.

Now the weird thing is if I change the namespace in the opening tag to
xmlns="robomss" than the validator sees it as valid

So the valid tag looks like <roboErrorLog xmlns="robomss"> rather than
<roboErrorLog xmlns:robomss="http://www.w3.org/2001/XMLSchema">

If anyone knows what the issue is I'd appreciate your help.



Reply With Quote
  #2  
Old   
Martin Honnen
 
Posts: n/a

Default Re: issue with XML and Schema namespace - 12-19-2007 , 06:42 AM






Durango2008 wrote:

Quote:
robomss:schema xmlns:robomss="http://www.w3.org/2001/XMLSchema"
xmlns="robomss"
elementFormDefault="qualified" targetNamespace="robomss"
As the targetNamespace of your schema is "robomss" and as
elementFormDefault is "qualified" the schema defines all its elements in
the namespace "robomss".
Thus for an XML instance document to be valid against the above schema
you need to have
<roboErrorLog xmlns="robomss">
or use some prefix (e.g. "rb")
<rb:roboErrorLog xmlns:rb="robomss">

Quote:
roboErrorLog xmlns:robomss="http://www.w3.org/2001/XMLSchema"
Why do you think that the XML instance document needs to use the XSD
schema namespace "http://www.w3.org/2001/XMLSchema"? You need that in
the schema to indicate you are authoring a schema in the W3C schema
language but using that namespace in the instance document is not
meaningful.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.