[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: What is the data type of a fixed element that has no type attribute?

From: G. Ken Holman <gkholman@CraneSoftwrights.com>
Date: Mon, 26 Mar 2012 14:03:19 -0400
Message-Id: <7.0.1.0.2.20120326135609.0236f1e8@wheresmymailserver.com>
To: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Re: What is the data type of a fixed element that has no type   attribute?
At 2012-03-26 17:45 +0000, Costello, Roger L. wrote:
>Hi Folks,
>
>What is the data type of this fixed element:
>
>       <element name="Aircraft" fixed="boeing:AC-747" />

A "simple ur-type definition" because you haven't said otherwise.

   W3C Schema Part 1 Section 3.2.2:
   "The default when no simple type definition is referenced or provided
    is the ·simple ur-type definition·, which imposes no constraints at all."

>Can an XML instance document specify that its type is a QName, like so:
>
>       <Aircraft xsi:type="xs:QName">boeing:AC-747</Aircraft>
>
>That results in an error, why?

There are a bunch of errors there.  To make it well-formed you need:

<Aircraft xsi:type="xs:QName"
           xmlns:boeing="urn:X-MD"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:xs="http://www.w3.org/2001/XMLSchema">boeing:AC-747</Aircraft>

But you can't make it schema valid to your 
constraint of the value being a fixed string, 
because the value is a QName.  Lexically they may 
be the same, but the schema values are different types.

If you take out the fixed= from the schema then 
the above instance validates against it because 
there is no constraint on the schema value.

Now, if you change your schema to require the 
value to be a QName, then the above instance will validate against this:

<?xml version="1.0" encoding="US-ASCII"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:boeing="urn:X-MD">

<xsd:annotation>
  <xsd:documentation xml:lang="en">

  </xsd:documentation>
</xsd:annotation>

<xsd:element name="Aircraft" fixed="boeing:AC-747" type="xsd:QName"/>

</xsd:schema>

But it won't validate against:

<Aircraft>boeing:AC-747</Aircraft>

... because the data type states the value is a 
QName and the prefix cannot be resolved.

I think you are mixing up the lexical expression 
and the schema value.  The fixed= constraint in 
the schema is on the schema value, not on the lexical expression.

For example, this validates against the QName schema above:

<Aircraft xmlns:roger="urn:X-MD">roger:AC-747</Aircraft>

... because the constraint is on the schema 
value, not on the lexical value.  In the schema 
value of a QName, the lexical prefix is 
irrelevant and used only to obtain the URI value.

   W3C Schema Part 1 Section 3.2.1:
   "Note that it is values that are supplied and/or checked, not strings."

I hope this helps.

. . . . . . . . . Ken

--
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/uoui9h
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/x/
G. Ken Holman                   mailto:gkholman@CraneSoftwrights.com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal
Received on Monday, 26 March 2012 18:08:14 GMT

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.