Schema Error

This should cover W3C XML Schema, Relax NG and DTD related problems.
nlpalmquist
Posts: 1

Schema Error

Thu Aug 02, 2012 7:19 pm

I can not seem to get the validation to like the XML/XSD documents

My XML starts:

<?xml version="1.0" encoding="UTF-8" ?>
<MetroBill
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="Metrobill.xsd">

My XSD starts:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" >

I get an error that says:

Severity: warning
Description: SchemaLocation: schemaLocation value = 'Metrobill.xsd' must have even number of URI's.
Start location: 4:25
End location: 4:40

I can not figure out what the heck that means. It does not seem that any change I make removes this error.

When I display the .xsd file it shows the message:

Cannot find the declaration of element 'xs:schema' and highlights that in the document.

This could be two different issues but maybe it is the same problem. I would really appreciate any help. I tried have Oxygen generate a new Schema and it is still indicating the same error about the URI's but added an error about the target namespace of a attribute declaration must not match 'http://www.w3.org/2001/XMLSchema-instance'

Any help at all would be greatly appreciated. :(
george
Site Admin
Posts: 2100

Re: Schema Error

Fri Aug 03, 2012 8:00 am

Hi,

Your schema does not define a target namespace therefore you should use the xsi:noNamespaceSchemaLocation instead of xsi:schemaLocation to associate the schema with the document

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<MetroBill
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="Metrobill.xsd">


If your schema defined a target namespace, let's say http://www.example.com/namespace then you would have associated the schema with the document with something like

Code: Select all

  xsi:schemaLocation="http://www.example.com/namespace Metrobill.xsd"

that is adding the namespace to the schema location value.

oXygen provides an associate schema action that helps you by automatically inserting the right xsi: attribute and value to associate the selected schema.

Regards,
George
George Cristian Bina

Return to “XML Schemas”

Who is online

Users browsing this forum: No registered users and 1 guest