Existing schema won't validate

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

Existing schema won't validate

Sun Aug 19, 2012 9:41 pm

Hello,

I need to work with an XML schema written by a company that has gone out of business. The schema was generated by the company's collection management system, a database to which I need to add records exported from Excel. The schema does not validate in Oxygen. I'm new to schemas and still get confused by namespace declarations, locations, attribute groups, etc. All I want to do is use the schema to help in converting Excel data so it can be imported into the collection management system database. The Xerces error messages I'm getting have to do with references to attributes based on Xlink. Here's the first of two:

Description: src-resolve.4.2: Error resolving component 'xl:href'. It was detected that 'xl:href' is in namespace 'http://www.w3.org/TR/xlink', but components from this namespace are not referenceable from schema document 'file:/C:/Users/.../mavis_schema.xsd'. If this is the incorrect namespace, perhaps the prefix of 'xl:href' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added...

But there is an import element in the mavis schema for Xlink:

Code: Select all

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
   targetNamespace="http://www.wizardis.com.au/2005/12/MAVIS"
   xmlns="http://www.wizardis.com.au/2005/12/MAVIS" xmlns:xl="http://www.w3.org/TR/xlink"
   elementFormDefault="qualified">
   <xs:import namespace="http://www.w3.org/XML/1998/namespace"
      schemaLocation="http://www.w3.org/2001/xml.xsd"></xs:import>
   <xs:import namespace="http://www.w3.org/1999/xlink" schemaLocation="xlink.xsd"></xs:import>
   ...
   <xs:complexType name="mavis_reference">
      <xs:annotation>
         <xs:documentation>The xl:href attribute of elements of this type should reference
            another MAVIS object.</xs:documentation>
         <xs:documentation>The element itself may contain CDATA (if the referenced object
            supports CDATA matching on import), but no sub-elements</xs:documentation>
      </xs:annotation>
      <xs:simpleContent>
         <xs:extension base="xs:string">
            <xs:attributeGroup ref="xlink_attributes"></xs:attributeGroup>
         </xs:extension>
      </xs:simpleContent>
   </xs:complexType>
   <xs:attributeGroup name="xlink_attributes">
      <xs:attribute ref="xl:href" use="optional"></xs:attribute>
      <xs:attribute ref="xl:title" use="optional"></xs:attribute>
   </xs:attributeGroup>


The second error concerns the attributeGroup above. "The content of 'xlink_attributes' must match (annotation?, ((attribute | attributeGroup)*, anyAttribute?)). A problem was found starting at: attribute."

What might be wrong here? Thank you very much, indeed.
adrian
Posts: 2443

Re: Existing schema won't validate

Tue Aug 21, 2012 5:16 pm

Hello,

If your schema is using the Xlink standard as described by the W3C, then you seem to be using the wrong namespace:
http://www.w3.org/TR/xlink/#att-method

You are currently using: http://www.w3.org/TR/xlink/ but the specification says the correct namespace is: http://www.w3.org/1999/xlink

So change the namespace prefix declaration from the schema root:

Code: Select all

xmlns:xl="http://www.w3.org/TR/xlink"
with:

Code: Select all

xmlns:xl=" http://www.w3.org/1999/xlink"
and it should validate.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
bingley
Posts: 7

Re: Existing schema won't validate

Wed Aug 22, 2012 11:33 pm

OK, I made the change you kindly suggested (thank you!), and now I get a different error message. Now Xerces says "The prefix 'xs' for element 'xs:schema' is not bound." Well, yes it is! (Isn't it?)

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.wizardis.com.au/2005/12/MAVIS"
xmlns="http://www.wizardis.com.au/2005/12/MAVIS" xmlns:xl="http://www.w3.org/1999/xlink"
elementFormDefault="qualified">
<xs:import namespace="http://www.w3.org/1999/xlink" schemaLocation="xlink.xsd"></xs:import>
...

I don't need an import element for XMLSchema, do I? If I double click on the Xerces error message, the imported xlink.xsd file opens up, and there is no namespace declaration for xs:schema there -- but I didn't write that file, it's the Xlink schema file! I did copy the xlink.xsd file to the directory on my PC that contains the MAVIS schema file above, but I copied the xlink.xsd file from the Xlink site. If I remove the @schemaLocation attribute from the <import> element above, I get yet other error messages. Ack!

The reason I need this MAVIS schema to validate is so I can it as an XML map in Excel (Excel also tells me it doesn't validate). Thank you so much.
adrian
Posts: 2443

Re: Existing schema won't validate

Thu Aug 23, 2012 11:45 am

Hi,

Since the error message points to "xlink.xsd", it means the error is in that file.

You've probably copied a broken "xlink.xsd" file. Don't just copy/paste the content of the file from the web browser (some browsers omit namespace declarations), right click on the link and save the entire file instead. Better yet, don't use a web browser at all, open the URL of the file in Oxygen: File > Open URL, http://www.w3.org/1999/xlink.xsd and save it locally.

BTW, Oxygen already resolves the schema location URI for this particular resource through an XML catalog to its local copy of "xlink.xsd" (Oxygen\frameworks\xlink\xlink.xsd). So, if you're only going to use this schema in Oxygen, you shouldn't actually need to save that file, you just have to change schema location to point to the remote URI:

Code: Select all

<xs:import namespace="http://www.w3.org/1999/xlink" schemaLocation="http://www.w3.org/1999/xlink.xsd"/>

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
bingley
Posts: 7

Re: Existing schema won't validate

Thu Aug 23, 2012 7:15 pm

YES! I pasted in the <import> element as you stated it -- and the document finally validated! I knew none of the information you provided so I'll print it out and keep it close at hand. I can't thank you enough.

Return to “XML Schemas”

Who is online

Users browsing this forum: No registered users and 0 guests