Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 24th, 2007, 02:24 AM
Registered User
Join Date: Feb 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using ref in xml

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:element ref="chartUrl"/>
        <xs:element ref="total" minOccurs="0"/>
        <xs:element ref="responseText" minOccurs="0"/>

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);
            "file:///" + Constants.SCHEMA_FOLDER + schemaFilename);

Brian Barnett

Old February 24th, 2007, 06:10 AM
mhkay's Avatar
Wrox Author
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

The schema seems perfectly OK, and it validates fine with Saxon. You haven't shown your source document. Perhaps it's a problem of trying to load the same schema twice into the cache - that would make it a Xerces-specific problem.

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ref numbers RubyRue ASP.NET 2.0 Basics 2 January 16th, 2008 11:29 AM
Membership - Ref: Chapter 8 JayLou BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 0 April 11th, 2007 10:24 AM
convert from 'ref double[]' to 'ref object' wakeup C# 0 April 7th, 2006 05:14 AM
By Val By Ref B.V.Madhav Crystal Reports 1 May 12th, 2005 11:37 PM
Array to ref parameter dedex C# 4 February 12th, 2005 02:58 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.