Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xml-dev] Brain Teaser: Element Author is of type xsd:string, what's an illegal value of Author?

From: "Michael Kay" <mike@--------.--->
To: "'Costello, Roger L.'" <costello@-----.--->,<xml-dev@-----.---.--->
Date: 2/9/2007 3:02:00 PM
I thought your answer was going to be that the XML Schema spec requires a
string to be finite length whereas the XML spec allows the content of an
element to be of infinite length; but a validator might take a long time to
report the error...

The invalid strings you list cannot appear in XML 1.0 documents, only in XML
1.1.

There's a W3C note on handling XML 1.1 with XML Schema:

http://www.w3.org/TR/xml11schema10/

and it recommends (see the last line of the note) that with that
combination, the definitions of the built-in types should be "stretched" to
accommodate the characters allowed in XML 1.1. With that strategy, there
will never be an invalid instance of xs:string.

Michael Kay
http://www.saxonica.com/


> -----Original Message-----
> From: Costello, Roger L. [mailto:costello@m...] 
> Sent: 09 February 2007 12:59
> To: xml-dev@l...
> Subject: [xml-dev] Brain Teaser: Element Author is of type 
> xsd:string, what's an illegal value of Author?
> 
> Hi Folks,
> 
> [This may be obvious to you.  It wasn't to me, so I thought 
> that I'd share my insight.]
> 
> Suppose I declare an Author element to be of type string:
> 
> <xsd:element name="Author" type="xsd:string" />
> 
> Then I create an XML instance document:
> 
> <?xml version="1.0"?>
> <Book>
>         <Author>...</Author>
> </Book>
> 
> Question: what is an invalid (non-string) value for <Author>?
> 
> If the Author contains "<" or "@"
> 
>        <Author> if A < B then </Author>
> 
> then it is not well-formed.  However, that's not the same 
> thing as giving Author a non-string value.
> 
> So what's the answer?  Doesn't "string" mean that Author can 
> contain anything, and there are no illegal values for Author?
> 
> Scroll down to see the answer.....
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> These are the characters that comprise the string datatype 
> (these are the hex values of the characters):
> 
> #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
> 
> Thus, an illegal value of Author is any character that falls 
> outside this set of characters.  For example, this is illegal:
> 
>        <Author>&#x8;</Author>
> 
> because hex 8 is not in the above list of hex values.  But hex 9 is
> allowed:
> 
>        <Author>&#x9;</Author>
> 
> So, these are all illegal values of Author:
> 
> &#x0;  &#x1;   &#x2;  &#x3;    &#x4;    &#x5;    &#x6;     &#x7;
> &#x8;    &#xB;  
> &#xC;  &#xE;  &#xF;  &#x11;  &#x12;  &#x13;  &#x14;   &#x15;  &#x16;
> &#x17;  &#x18;  &#x19;  &#x1A;   &#x1B;  &#x1C;  &#x1D;  
> &#x1E;  &#x1F;
> ...
> 
> ______________________________________________________________
> _________
> 
> XML-DEV is a publicly archived, unmoderated list hosted by 
> OASIS to support XML implementation and development. To 
> minimize spam in the archives, you must subscribe before posting.
> 
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@l...
> subscribe: xml-dev-subscribe@l... List archive: 
> http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
>


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent