Validating Newlines and Carriage Returns via Schema

Discussion in 'XML' started by Porthos, Jul 20, 2005.

  1. Porthos

    Porthos Guest

    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
    Porthos, Jul 20, 2005
    #1
    1. Advertising

  2. "Porthos" <> 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
    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
    C. M. Sperberg-McQueen, Jul 27, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Iceberg

    Carriage Returns and sockets

    Iceberg, Sep 6, 2003, in forum: Perl
    Replies:
    1
    Views:
    1,148
    Iceberg
    Sep 6, 2003
  2. Schroeder
    Replies:
    1
    Views:
    534
    Jim Gibson
    Jan 26, 2005
  3. Markus
    Replies:
    1
    Views:
    1,528
    Markus
    Nov 23, 2005
  4. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,248
    Stanimir Stamenkov
    Apr 25, 2005
  5. Steve Anderson
    Replies:
    3
    Views:
    249
    Steve Anderson
    Jun 21, 2004
Loading...

Share This Page