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.Durango2008 wrote:
> <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">
> <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/
Monday, March 12, 2012
issue with XML and Schema namespace
Labels:
database,
file,
filesroboerrorlog,
microsoft,
mysql,
namespace,
oracle,
schema,
server,
sql,
time,
validation,
xml,
xsdltrobomssschema
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment