Validating a decimal 3.4 in the XSD schema ^{1,3}(?:\.{1,4})?$

I need to mount an XSD to validate a decimal number 3.4. The entire piece can have up to 3 characters and the fraction part is not mandatory, but if any, need to have up to 4 characters.

The regular expression ^[0-9]{1,3}(?:.[0-9]{1,4})?$ works in the test sites, but when I put in the XSD get the error: "InvalidRegex: Pattern value '^[0-9]{1,3}(?:.[0-9]{1,4})?$' is not a valid regular expression. The reported error was: 'This expression is not supported in the current option setting.' at column '{2}'."

XSD Schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:simpleType name="st_decimal7-4">
	 <xs:restriction base="xs:decimal">
		<xs:pattern value="^[0-9]{1,3}(?:\.[0-9]{1,4})?$"/>	     
	 </xs:restriction>
  </xs:simpleType>

  <xs:element name="teste">
	 <xs:complexType>
		<xs:sequence>
		  <xs:element name="valor" type="st_decimal7-4" />
		</xs:sequence>
	  </xs:complexType>
  </xs:element>
</xs:schema>
				 

Answers


You cannot have non-capturing groups there and start/end signs. Just change the line with the pattern to this and you're good to go:

<xs:pattern value="[0-9]{1,3}(\.[0-9]{1,4})?"/>

You are using several constructs that are not available in the XSD-defined regular expression syntax. (Some schema processors, e.g. Microsoft, are known to ignore this syntax and just use whatever works in the regular expression library that they use internally).

The disallowed constructs include ^ and $ (not needed because the regex is implicitly anchored), and "(?"


Need Your Help

C# perform action for every row in a dataGridView

c# datagridview foreach

So I need to be able to convert each row of the Data grid separately with the xWMAEncode.exe program and how the xwmaEncode works is like this xwmaencode.exe InputFile OutputFile so like this would

Primefaces downloadFile java.io.IOException: Stream Closed after second time

primefaces jsf-2.2

I have issue with primefaces 5.0 component p:fileDownload , I have following bean store DefaultStreamedContent , and I get the value stored to download it simply :