Validating Newlines and Carriage Returns via Schema

P

Porthos

Hello all,

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.

Thanks,

James
 
C

C. M. Sperberg-McQueen

Porthos said:
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
end-tags.)
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
facet.

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
read http://catb.org/~esr/faqs/smart-questions.html

--C. M. Sperberg-McQueen
World Wide Web Consortium
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top