Win a free GMail account by solving this!

Published 01 September 04 08:58 PM | christof claessens

Good news :-)

I've a couple of GMail accounts to give away.  Let's make this a little contest :-)  Since I'm curious how deep the average XML Schema knowledge goes, I'll grant GMail access to the first two people that post a comment explaining what is wrong with the XML Schema below. 

Note: XMLSpy will mark this schema as valid while it certainly is not!  (Has anyone accidently noticed my aversion against this tool? :-))) )

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="myTargetNamespace" xmlns:tns="myTargetNamespace">
   <xs:element name="address" type="tns:addressType"/>

   <xs:element name="customerDetails">
      
<xs:complexType>
      
   <xs:sequence>
            
<xs:element name="firstName" type="xs:string"/>
            
<xs:element ref="tns:address" nillable="true"/>
         
</xs:sequence>
      
</xs:complexType>
   
</xs:element>

   
<xs:complexType name="addressType">
      
<xs:sequence>
         
<xs:element name="street" type="xs:string"/>
         
<xs:element name="number" type="xs:string"/>
      
</xs:sequence>
   
</xs:complexType>
</
xs:schema>

Filed under:

Comments

# Martijn said on September 1, 2004 03:59 PM:

Hi Christoff,

You can't put a nillable attribute on an element that uses ref. Remove the nillable attribute and the schema is just fine.

# Wilco B. said on September 1, 2004 04:10 PM:

Martijn is right. The ref and nillable attributes are mutually exclusive. I think they also refer to this as "dynamic morphing" (reusing a declaration and simultaneously adding a nillable attribute). To achieve this, you'd have to defining a complex type.

# Sachin Kulkarni said on September 1, 2004 08:20 PM:

The fundamental principle here is that any content or attribute declaration should be context-independent. So it’s not only ‘nillable’ but all the following tags are invalid when used with “ref” …
<complexType>, <simpleType>, <key>, <keyref>, <unique>, nillable, default, fixed, form, block and type.
However using context (element) specific tags such as minOccurs, maxOccurs and id are allowed.
I don’t know why XMLSpy validates the schema but this is a well-known Xml Schema issue.

# Peter Stuer said on September 2, 2004 07:37 AM:

Yep, since the parent is not <schema> and ref is present, nillable must be absent according to "3.3.3 Constraints on XML Representations of Element Declarations" of http://www.w3.org/TR/2001/PR-xmlschema-1-20010316/

# alex said on September 23, 2004 03:14 AM:

i need gmail account

# M Kamrul said on September 26, 2004 03:47 AM:

I need a gmail account


kamrul3001@yahoo.com

# tom said on September 26, 2004 03:57 AM:

It’s not only ‘nillable’ but all the following tags are invalid when used with “ref” …
<complexType>, <simpleType>, <key>, <keyref>, <unique>, nillable, default, fixed, form, block and type.
However using context (element) specific tags such as minOccurs, maxOccurs and id are allowed.

# Mohsin said on September 26, 2004 06:10 AM:

ok

# abdul said on September 26, 2004 06:55 AM:

You can't put a nillable attribute on an element that uses ref. Remove the nillable attribute and the schema is just fine.

# joaquin said on September 29, 2004 12:05 PM:

I need gmail please, invite me
juacolk@hotmail.com

# Kulbir Singh 1102556 said on September 30, 2004 02:47 AM:

You can't put a nillable attribute on an element that uses ref
nillable must be absent according to "3.3.3 Constraints on XML Representations of Element Declarations
To achieve this, you'd have to defining a complex type.

# manish_bedi said on September 30, 2004 10:53 AM:

i want a g mail account as i am in need of that bcoz of its security and the features it is providing.

# TrackBack said on October 1, 2004 01:12 AM:
# hamir said on October 1, 2004 06:20 AM:

The fundamental principle here is that any content or attribute declaration should be context-independent. So it’s not only ‘nillable’ but all the following tags are invalid when used with “ref” …
<complexType>, <simpleType>, <key>, <keyref>, <unique>, nillable, default, fixed, form, block and type.
However using context (element) specific tags such as minOccurs, maxOccurs and id are allowed.
I don’t know why XMLSpy validates the schema but this is a well-known Xml Schema issue.

# TrackBack said on October 3, 2004 05:36 AM:
# MD. MAMUNUL KABIR said on July 7, 2007 04:29 AM:

I want a Gmail account

# Josh said on August 17, 2007 05:34 PM:

Ill leave a comment: GMAIL IS FREE IN THE FIRST PLACE!!!!!!

# John said on September 29, 2007 02:52 AM:

aebn.myfreepaysite

# Mary-yj said on November 28, 2008 10:26 AM:

<a href= http://fasster.angelfire.com >baltimore and convention center and headquarters</a> <a href= http://gertui.angelfire.com >nasdaq 100 tennis tournament</a>

# Mary-wh said on November 28, 2008 09:08 PM:

<a href= http://chkola.angelfire.com >avlastkey</a> <a href= http://bustersw.angelfire.com >how to start a strawberry patch in alabama</a>

# Mary-nx said on November 29, 2008 02:10 AM:

<a href= http://kustur.angelfire.com >dad vail regatta</a> <a href= http://trututa.angelfire.com >ratings apartments eagle ridge alabama</a>

# fabiola-te said on March 1, 2009 12:31 AM:

<a href= http://adultchatsfinder.com >singles</a>

Leave a Comment

(required) 
(required) 
(optional)
(required)