Validating Newlines and Carriage Returns via Schema
Is there a facet pattern that will allow for the inclusion of a
newline or carriage return to occur within a tag? From the W3C schema
document and from previous posts I've read that [\n\r] should take care
of this situation, however when I include that pattern (and a
newline\carriage return) I still recieve an error telling me that my
data is an invalid value according to its data type. When I remove the
returns and new lines the error is alieviated.
Any thoughts would be appreciated.
Re: Validating Newlines and Carriage Returns via Schema
"Porthos" <firstname.lastname@example.org> writes:
> Hello all,
> Is there a facet pattern that will allow for the inclusion
> of a newline or carriage return to occur within a tag?
I'm going to assume you mean "within an element", i.e.
after the start-tag and before the end-tag.
(If you actually do mean "within a tag", i.e. within the
start-tag or end-tag, the answer is no, XML Schema does
not allow conditions on the white space within start- and
> From the W3C schema document and from previous posts I've
> read that [\n\r] should take care of this situation, however
> when I include that pattern (and a newline\carriage return)
> I still recieve an error telling me that my data is an
> invalid value according to its data type. When I remove the
> returns and new lines the error is alieviated.
> Any thoughts would be appreciated.
You need to show us the type declaration and some sample
data. Without more detail, you won't get any responses
except vague generalities.
In the following, I am assuming that you are talking
about simple types, not complex types.
Vague generality no. 1: the XML Schema pattern facet
can restrict the lexical space of a type, but cannot
enlarge it. If the base type does not allow newlines,
the derived type won't allow them just because they
occur in a pattern: the lexical forms for the derived
type must match the pattern, but they must also be
in the lexical space of the base type. (The effective
lexical space of any type is the intersection of the
language defined by its pattern facet and the lexical
space of its base type.)
Vague generality no. 2: Remember that whitespace
processing is independent of the lexical space; what
happens in validation is that (1) the string you see in
the document is handled by the XML parser, and then
(2) the output from the XML parser (what the XML
Schema spec calls the 'actual value') undergoes the
whitespace processing appropriate to the type, and
then (3) the result is checked to see whether it's
a legal lexical form for the type in question.
So perhaps what you want to do is adjust the value
of the whitespace facet, rather than adding a pattern
Vague generality no. 3: on Usenet, specific questions
often get better answers than vague ones. If this is
not intuitively obvious to you, you should probably
--C. M. Sperberg-McQueen
World Wide Web Consortium
|All times are GMT. The time now is 02:14 AM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.