View Single Post
 
Old February 24th, 2007, 02:24 AM
ooper01 ooper01 is offline
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using ref in xml

Hi,
I'm getting this error when validating my xml:

"A schema cannot contain two global components with the same name"

Here is the schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xs:element name="chartUrl"/>
  <xs:element name="total" type="xs:double"/>
  <xs:element name="responseText" type="xs:string"/>
  <xs:element name="bud02Out">
    <xs:complexType>
      <xs:all>
        <xs:element ref="chartUrl"/>
        <xs:element ref="total" minOccurs="0"/>
        <xs:element ref="responseText" minOccurs="0"/>
      </xs:all>
    </xs:complexType>
  </xs:element>
</xs:schema>

XML Spy does not complain when I save the schema file, but when I run an xml document that conforms to this schema through a validating parser, I get the error above. Any suggestions?

Here is code that creates the validating parser (java):

SAXBuilder builder = new SAXBuilder("org.apache.xerces.parsers.SAXParser", true);

builder.setFeature("http://apache.org/xml/features/validation/schema", true);
builder.setFeature("http://xml.org/sax/features/validation", true);
builder.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
            "file:///" + Constants.SCHEMA_FOLDER + schemaFilename);

TIA,
Brian Barnett