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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Costello, Roger L.
Hi Folks,

What is the data type of this fixed element:

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

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?

/Roger

Reply | Threaded
Open this post in threaded view
|

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

G. Ken Holman
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:[hidden email]
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal


Reply | Threaded
Open this post in threaded view
|

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

C. M. Sperberg-McQueen-2
In reply to this post by Costello, Roger L.

On Mar 26, 2012, at 11:45 AM, Costello, Roger L. wrote:

> Hi Folks,
>
> What is the data type of this fixed element:
>
>      <element name="Aircraft" fixed="boeing:AC-747" />

I think the spec says that the type of 'Aircraft' is xsd:anyType.

> 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?


In the document you give, no binding for the prefix 'boeing' is
visible.  If a processor were to validate the Aircraft element
against xsd:QName in that document, I'd expect it to find the
element invalid.

But you seem to be saying the processors you've tried have
given you an error message, instead, not a report that the
input is invalid.  (Or are you treating invalidity as an error?)

Hard to say what the processor is thinking, if you don't provide
more complete input and don't report what the processor actually
says.

--
****************************************************************
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com 
* http://cmsmcq.com/mib                 
* http://balisage.net
****************************************************************





Reply | Threaded
Open this post in threaded view
|

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

C. M. Sperberg-McQueen-2
In reply to this post by G. Ken Holman
Nice work, Ken!  You seem to have disproved my claim that it's hard
to tell what the processor might be complaining about, if the query
does not tell us what the processor says.

On Mar 26, 2012, at 12:03 PM, G. Ken Holman wrote:

> 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."

True as far as it goes, but 3.2.2 is talking about attribute declarations,
not element declarations.

Here, I think the governing text is the mapping rule for the {type
definition} property of element declarations, described in 3.3.2.1.

>
>> 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.

Good point.  (For those who want to trace this back to the spec, check
the rule for the {value constraint} property in section 3.3.2.1:  if a value
constraint is specified for an element whose type is not a simple type
and not a complex type with simple content, then xsd:string is used as
the type for the value constraint.


--
****************************************************************
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com 
* http://cmsmcq.com/mib                 
* http://balisage.net
****************************************************************