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 December 8th, 2009, 09:06 AM
Authorized User
 
Join Date: Nov 2009
Posts: 13
Thanks: 3
Thanked 0 Times in 0 Posts
Unhappy duplicate global elements and refs

Say I have a duplicate global element A using two different definitions:

Code:
    
<xsd:complexType name="AType">
      <xsd:sequence>
    	<xsd:element name="first" type="xsd:string"/>
      </xsd:sequence>
    </xsd:complexType>
    

    <xsd:complexType name="CType">
    <xsd:complexContent>
      <xsd:extension base="BType">
      <xsd:sequence>
    	<xsd:element name="third" type="xsd:string"/>
      </xsd:sequence>
      </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="A" type="AType" />
    <xsd:element name="A" type="xsd:string" />
    
    <xsd:element name="B" substitutionGroup="A">
        <xsd:complexType>
		    <xsd:complexContent>
   		 	  <xsd:extension base="AType">
		      <xsd:sequence>
 		   		<xsd:element name="second" type="xsd:string"/>
		      </xsd:sequence>
		      </xsd:extension>
		    </xsd:complexContent>
	    </xsd:complexType>
    </xsd:element>
    
    <xsd:element name="C" substitutionGroup="B" type="CType" />
    
    <xsd:element name="container">
    <xsd:complexType>
      <xsd:sequence>
    	<xsd:element ref="A" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
As you can see A, B and C are supposed to be in a tree of which A is root. The container referencing A accepts either type. However this would of course be the case if the second definition of A
Code:
<xsd:element name="A" type="xsd:string" />
wouldn't be there.

1: is this legal at all (i.e. the global duplicate element)
2: if 1:YES - How can the ref="A" be resolved?

Thanks for the advice.
 
Old December 8th, 2009, 11:09 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

No, it's not legal. You can only have one global element with a given name. The other would have to be local.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
dexter62 (December 8th, 2009)
 
Old December 8th, 2009, 11:36 AM
Authorized User
 
Join Date: Nov 2009
Posts: 13
Thanks: 3
Thanked 0 Times in 0 Posts
Smile Thanks..

I hoped for this answer. Otherwise it would have been utterly complicated..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chap 16 pg 574: Elements not supported Elements not known tomche BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 August 6th, 2009 02:48 PM
How to declare the global variable in global.asax? calyn_gately ASP.NET 3.5 Basics 0 August 6th, 2008 08:06 PM
DTD Notation, specificlly <!ENTITY> refs mphare XSLT 3 April 29th, 2008 08:57 PM
Removing duplicate edge elements geoGregory3 XSLT 2 February 27th, 2008 06:08 AM
converting cross refs between HTML documents skelton XSLT 2 October 22nd, 2003 11:00 AM





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