0

I wrote XML type in my XSD file:

  <xs:simpleType name="refId">
    <xs:restriction base="xs:ID">
      <xs:maxLength value="30"/>
      <xs:minLength value="5"/>
      <xs:pattern value="^ref-"/>
    </xs:restriction>
  </xs:simpleType>

All values must start with "ref-" text. But I get incorrect result for string: "ref-title". Why does this happen?

4

2 に答える 2

0

The pattern applies to the whole string rather than just finding a match inside the string, you'll probably find that

<xs:pattern value="ref-.*" />

will work.

于 2012-04-05T12:31:44.253 に答える
0

The circumflex ^ does not represent "start of string" in the XSD regex dialect, it represents itself. Therefore your pattern says that the ID values must start with "^", which of course would make them invalid IDs. XSD patterns are implicitly anchored, so value="ref-.*" is what you need.

于 2012-04-05T18:04:38.763 に答える