Loading ...
Sorry, an error occurred while loading the content.

jing + RELAX NG xsd:token on attributes: spaces coalesced?

Expand Messages
  • Jason Sachs
    I m confused. If I use the schema attrbug.rnc (see below) it seems to let through multiple spaces in a row, even though that shouldn t be legal. I m using this
    Message 1 of 2 , Feb 27, 2012
    • 0 Attachment
      I'm confused. If I use the schema attrbug.rnc (see below) it seems to
      let through multiple spaces in a row, even though that shouldn't be
      legal.

      I'm using this pattern:
      xsd:token { pattern="[A-Za-z_][A-Za-z_0-9]*( [A-Za-z_][A-Za-z_0-9]*)*" }

      Below is a test file that I'm using with "java -jar jing.jar -c
      attrbug.rnc attrbug.xml".

      What's going on here? Does jing coalesce spaces in attributes before
      matching against xsd:token? Or am I missing something?

      --Jason

      --- begin file attrbug.xml ---
      <?xml version="1.0" encoding="UTF-8"?>
      <model>
      <item class="foo bar baz">we want a class attribute with multiple
      identifiers separated by single spaces.
      </item>
      <item class="foo bar baz">why does this not fail?</item>
      <item class="3 4 5">this fails as expected</item>
      </model>
      --- end file ---

      --- begin file attrbug.rnc ---
      # RELAX NG compact-syntax grammar

      grammar {

      # contains a model element
      # the model element contains one or more item elements

      start = element model { model-content }

      model-content =
      item+

      item =
      (element item { item-content })

      item-content =
      attribute class { identifier-array },
      arbitrary-text-description

      ############### Text patterns ###############

      arbitrary-text-description =
      text

      identifier =
      xsd:token { pattern="[A-Za-z_][A-Za-z_0-9]*" }

      identifier-array =
      xsd:token { pattern="[A-Za-z_][A-Za-z_0-9]*( [A-Za-z_][A-Za-z_0-9]*)*" }

      }
      --- end file ---
    • Syd Bauman
      Well, isn t that what xsd:token means? See http://www.w3.org/TR/xmlschema-2/#token If you want internal whitespace preserved before comparison, I think you
      Message 2 of 2 , Feb 27, 2012
      • 0 Attachment
        Well, isn't that what xsd:token means?
        See http://www.w3.org/TR/xmlschema-2/#token

        If you want internal whitespace preserved before comparison, I think
        you should be using either "string" or "xsd:string".

        > I'm confused. If I use the schema attrbug.rnc (see below) it seems
        > to let through multiple spaces in a row, even though that shouldn't
        > be legal.
        >
        > I'm using this pattern:
        > xsd:token { pattern="[A-Za-z_][A-Za-z_0-9]*( [A-Za-z_][A-Za-z_0-9]*)*" }
        >
        > Below is a test file that I'm using with "java -jar jing.jar -c
        > attrbug.rnc attrbug.xml".
        >
        > What's going on here? Does jing coalesce spaces in attributes
        > before matching against xsd:token? Or am I missing something?
      Your message has been successfully submitted and would be delivered to recipients shortly.