dimanche 19 décembre 2021

Defining a Regex pattern for permutation string restriction in XSD

Trying to define a permutation string that allows only one character value occurrence. That is, no duplicate values. To use the simplest "abc" example:

<xsd:simpleType name="perm">
  <xsd:restriction base="xsd:string">
    <xsd:pattern value="[a-c]{0,1}" /> <!-- not sure this is sufficient for uniqueness -->
    <xsd:maxLength value="3" />
  </xsd:restriction>
</xsd:simpleType>

I need the further guarantee of prohibiting duplicate character values Valid values should only include the following permutations: [a-c]{1} a; or b; or c [the first candidate character works] OR a[bc]{1}; or b[ca]{1}; or c[ab]{1} [The second needs to exclusive OR the above and not AND or UNION of them ] ab, or ac; ba, or bc; ca, or cb OR abc, or acb; bac, or bca; cab, or cba [The Regex I know will not nest any of above combinations into exclusive ORs] The pattern I seek needs to disallow strings containing duplicate (or triplicate) character values for example aa, aba, aca, abb, ...cca, ... bcc, ... cbb, ... cbc, ... ccc

The StackOverflow FAQ says of Regex quantifier {min,max} occurrences: {n,m} means "repeat the previous element at least n times and at most m times" But that does not guarantee unique values via non-duplicate restriction because repeat can duplicate

Does XSD have a permutation restriction pattern construct?

My actual problem is for maintaining a permutation register for unique Hexadecimals 'digit' values with the same restrictions as above by saying:

<xsd:simpleType name="hexdecperm">
  <xsd:restriction base="xsd:string">
    <xsd:pattern value="[0-9a-f]{0,1}" /> <!-- for'integers' -->
    <xsd:pattern value="[1-9a-g]{0,1}" /> <!-- for'naturals' -->
    <xsd:maxLength value="16" />
  </xsd:restriction>
</xsd:simpleType>

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire