Skip to content

Commit

Permalink
Schema adjustments to repair broken regexes and to simplify use of ex…
Browse files Browse the repository at this point in the history
…iting types
  • Loading branch information
david-waltermire committed Apr 10, 2023
1 parent b5bbd5b commit a45eb2b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 43 deletions.
52 changes: 32 additions & 20 deletions schema/json/metaschema-datatypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"definitions" : {
"Base64Datatype": {
"type": "string",
"pattern": "^[0-9A-Fa-f]+$",
"pattern": "^[0-9A-Za-z+/]+={0,2}$",
"contentEncoding": "base64"
},
"BooleanDatatype": {
Expand All @@ -32,22 +32,30 @@
"DayTimeDurationDatatype": {
"type": "string",
"format": "duration",
"pattern": "^[-+]?P([-+]?[0-9]+D)?(T([-+]?[0-9]+H)?([-+]?[0-9]+M)?([-+]?[0-9]+([.,][0-9]{0,9})?S)?)?$"
"pattern": "^-?P([0-9]+D(T(([0-9]+H([0-9]+M)?(([0-9]+|[0-9]+(\\.[0-9]+)?)S)?)|([0-9]+M(([0-9]+|[0-9]+(\\.[0-9]+)?)S)?)|([0-9]+|[0-9]+(\\.[0-9]+)?)S))?)|T(([0-9]+H([0-9]+M)?(([0-9]+|[0-9]+(\\.[0-9]+)?)S)?)|([0-9]+M(([0-9]+|[0-9]+(\\.[0-9]+)?)S)?)|([0-9]+|[0-9]+(\\.[0-9]+)?)S)$"
},
"DecimalDatatype": {
"type": "number",
"pattern": "^(\\+|-)?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)$"
},
"EmailAddressDatatype": {
"type": "string",
"format": "email",
"pattern": "^.+@.+$"
"allOf": [
{"$ref": "#/definitions/StringDatatype"},
{
"type": "string",
"format": "email",
"pattern": "^.+@.+$"
}
]
},
"HostnameDatatype": {
"allOf": [
{"$ref": "#/definitions/StringDatatype"},
{"format": "idn-hostname"}
]
"allOf": [
{"$ref": "#/definitions/StringDatatype"},
{
"type": "string",
"format": "idn-hostname"
}
]
},
"IntegerDatatype": {
"type": "integer"
Expand All @@ -70,18 +78,22 @@
"type": "string"
},
"NonNegativeIntegerDatatype": {
"allOf": [
{"$ref": "#/definitions/IntegerDatatype"},
{"minimum": 0,
"type": "number"}
]
"allOf": [
{"$ref": "#/definitions/IntegerDatatype"},
{
"type": "number",
"minimum": 0
}
]
},
"PositiveIntegerDatatype": {
"allOf": [
{"$ref": "#/definitions/IntegerDatatype"},
{"minimum": 1,
"type": "number"}
]
"allOf": [
{"$ref": "#/definitions/IntegerDatatype"},
{
"type": "number",
"minimum": 1
}
]
},
"StringDatatype": {
"type": "string",
Expand All @@ -108,7 +120,7 @@
"YearMonthDurationDatatype": {
"type": "string",
"format": "duration",
"pattern": "^[-+]?P([-+]?[0-9]+Y)?([-+]?[0-9]+M)?([-+]?[0-9]+W)?([-+]?[0-9]+D)?$"
"pattern": "^-?P([0-9]+Y([0-9]+M)?)|[0-9]+M$"
}
}
}
25 changes: 10 additions & 15 deletions schema/xml/metaschema-datatypes.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,13 @@

<xs:simpleType name="Base64Datatype">
<xs:restriction base="xs:base64Binary">
<xs:pattern value="\S(.*\S)?">
<xs:annotation>
<xs:documentation>A trimmed string, at least one character with no
leading or trailing whitespace.</xs:documentation>
</xs:annotation>
</xs:pattern>
<xs:pattern value="[0-9A-Za-z+/]+={0,2}"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="BooleanDatatype">
<xs:restriction base="xs:boolean">
<xs:pattern value="\S(.*\S)?">
<xs:annotation>
<xs:documentation>A trimmed string, at least one character with no
leading or trailing whitespace.</xs:documentation>
</xs:annotation>
</xs:pattern>
<xs:pattern value="true|1|false|0"/>
</xs:restriction>
</xs:simpleType>

Expand Down Expand Up @@ -56,7 +46,7 @@

<xs:simpleType name="DayTimeDurationDatatype">
<xs:restriction base="xs:duration">
<xs:pattern value="[-+]?P([-+]?[0-9]+D)?(T([-+]?[0-9]+H)?([-+]?[0-9]+M)?([-+]?[0-9]+([.,][0-9]{0,9})?S)?)?"/>
<xs:pattern value="-?P([0-9]+D(T(([0-9]+H([0-9]+M)?(([0-9]+|[0-9]+(\.[0-9]+)?)S)?)|([0-9]+M(([0-9]+|[0-9]+(\.[0-9]+)?)S)?)|([0-9]+|[0-9]+(\.[0-9]+)?)S))?)|T(([0-9]+H([0-9]+M)?(([0-9]+|[0-9]+(\.[0-9]+)?)S)?)|([0-9]+M(([0-9]+|[0-9]+(\.[0-9]+)?)S)?)|([0-9]+|[0-9]+(\.[0-9]+)?)S)"/>
</xs:restriction>
</xs:simpleType>

Expand All @@ -76,7 +66,7 @@
<xs:documentation>An email address</xs:documentation>
</xs:annotation>
<xs:restriction base="StringDatatype">
<xs:pattern value="\S.*@.*\S">
<xs:pattern value=".+@.+">
<xs:annotation>
<xs:documentation>Need a better pattern.</xs:documentation>
</xs:annotation>
Expand Down Expand Up @@ -237,5 +227,10 @@
</xs:pattern>
</xs:restriction>
</xs:simpleType>
</xs:schema>

<xs:simpleType name="YearMonthDurationDatatype">
<xs:restriction base="xs:duration">
<xs:pattern value="-?P([0-9]+Y([0-9]+M)?)|[0-9]+M"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
9 changes: 1 addition & 8 deletions schema/xml/metaschema.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,7 @@
<xs:element name="define-flag" type="GlobalFlagDefinitionType"/>
</xs:choice>
</xs:sequence>
<xs:attribute name="abstract">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="yes"/>
<xs:enumeration value="no"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="abstract" type="YesNoType" default="no"/>
</xs:complexType>
<xs:unique name="unique-constraint-ids">
<xs:selector xpath=".//allowed-values|.//matches|.//index-has-key|.//is-unique|.//has-cardinality|.//expect|.//index"/>
Expand Down

0 comments on commit a45eb2b

Please sign in to comment.