Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

XSD validation fails on a regex for valid data

987833Feb 11 2013 — edited Sep 6 2013
Hello,

For whatever reason the following regex expression is falling for 5095.0000

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

Please advise.

This is the XML:
<?xml version="1.0" encoding="iso-8859-1"?>
<root DataFeedDate="2013-02-11" xmlns="http://www.abccompany.com">
	<r>
		<ExchangeRateUSD>5095.0000</ExchangeRateUSD>
	</r>
</root>
This is the XSD:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" version="0.92" targetNamespace="http://www.abccompany.com" xmlns="http://www.abccompany.com">
	<xs:element name="root">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="r" maxOccurs="unbounded"/>
			</xs:sequence>
			<xs:attribute name="DataFeedDate" use="required" type="xs:date"/>
		</xs:complexType>
	</xs:element>
	<xs:element name="r">
		<xs:complexType>
			<xs:sequence>				
				<xs:element ref="ExchangeRateUSD" minOccurs="0"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="ExchangeRateUSD">
		<xs:simpleType>
			<xs:restriction base="xs:decimal">
				<xs:totalDigits value="8"/>
				<xs:fractionDigits value="4"/>
				<xs:pattern value="[0-9]{1,4}[.][0-9]{4}"/>
			</xs:restriction>
		</xs:simpleType>
	</xs:element>
</xs:schema>
This is the error:
ORA-31154: invalid XML document
ORA-19202: Error occurred in XML processing
LSX-00333: literal "5095" is not valid with respect to the pattern
ORA-31154: invalid XML document
ORA-19202: Error occurred in XML processing
LSX-00333: literal "5095" is not valid with respect to the pattern

ORA-06512: at "SYS.XMLTYPE", line 354
ORA-06512: at line 7
This is the XSD registration and validation:
begin
  DBMS_XMLSCHEMA.REGISTERSCHEMA(
    SCHEMAURL => 'http://abccompany.com/SpendAnalysis.xsd'
  , schemaDoc => xmltype(bfilename('TMP','SpendAnalysis.xsd'), nls_charset_id('AL32UTF8'))
  , local => true
  , genTypes => false
  , genTables => false
  , enableHierarchy => dbms_xmlschema.ENABLE_HIERARCHY_NONE  
  );
end;


declare
  l_xml xmltype;
begin
  L_XML := XMLTYPE(BFILENAME('TMP','SpendAnalysis.xml'), NLS_CHARSET_ID('WE8ISO8859P1'));
  l_xml := l_xml.createSchemaBasedXML('http://abccompany.com/SpendAnalysis.xsd');
  
  l_xml.schemaValidate();
  DBMS_OUTPUT.PUT_LINE('XML IS VALID.');

  exception 
	when others then
		DBMS_OUTPUT.PUT_LINE(SQLerrm);
		DBMS_OUTPUT.PUT_LINE(DBMS_UTILITY.FORMAT_ERROR_STACK);		
		DBMS_OUTPUT.PUT_LINE(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
end;
This post has been answered by odie_63 on Feb 11 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 4 2013
Added on Feb 11 2013
4 comments
993 views