Restricting an Elements value
Posted: Fri Mar 30, 2012 1:39 pm
I am trying to restriction a value that is allowed to be captured for a particular feature. My current schema has the following
Validating against the following examples:
{ABDD8E39-0BB7-407F-9BAA-CF300A7AF661}
{EB42708E-44764-9F98-0CB6E5A6FAFB}
{A699AB0A-26-8C4A-E040-A40A262C4E4E}
{00000000-0000-0000-0000-000000000000}
It will successfully 'fail' the second and third example, but pass the fourth! What i trying to validate is that the value range captured must be alphanumeric.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml">
<!-- The following simplyType feature has been added to constrain the allowed value range supplied
VARCHAR2 (38 Byte) i.e. Programming: GUID (including brackets using parentheses)) -->
<xs:simpleType name="ReferenceGUID">
<xs:restriction base="xs:token">
<xs:pattern value="\{[A-Z0-9]{8}(\-[A-Z0-9]{4}){3}\-[A-Z0-9]{12}\}"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
Validating against the following examples:
{ABDD8E39-0BB7-407F-9BAA-CF300A7AF661}
{EB42708E-44764-9F98-0CB6E5A6FAFB}
{A699AB0A-26-8C4A-E040-A40A262C4E4E}
{00000000-0000-0000-0000-000000000000}
It will successfully 'fail' the second and third example, but pass the fourth! What i trying to validate is that the value range captured must be alphanumeric.