xml - xs:integer validation issue with pattern restriction and canonical representation -
i have problem receive third party xml document according third party xml schema. schema uses pattern restriction on xs:integer element:
<xs:simpletype name="numericinteger_length8to8"> <xs:annotation> <xs:documentation xml:lang="en">format limitations: n8</xs:documentation> </xs:annotation> <xs:restriction base="xs:integer"> <xs:pattern value="-?[0-9]{8,8}" /> </xs:restriction> </xs:simpletype>
the xml received shows integers of 8 digits 1 or more leading digits zeros:
<examplecode>01234567</examplecode>
when parse xml valid matches pattern. next, have send out same xml text message again. xml renderer sends out canonical representation of integer, without leading zero:
<examplecode>1234567</examplecode>
the receiving system tries validate message sent , throws error value 1234567 no longer matches pattern restriction.
since received xml stored internally xml document in system, transformed real integer, lexical representation lost. next, when render xml document, initial lexical representation gone, hence no leading zero. don't see nice way around problem. possibility me alter xml schema internally, e.g. make type definition xs:string passed without change, prefer not touch (third party) schema.
my question whether valid use of pattern facet xs:integer, third party xml schema valid schema? w3 impose restrictions or guidelines on use of patterns?
i find few similar issues, e.g.
http://technet.microsoft.com/en-us/library/ms190665(v=sql.90).aspx (canonical forms ... section) http://mail-archives.apache.org/mod_mbox/xerces-j-users/200409.mbox/%3c20040909151622.ga9712@hamachi.dyndns.org%3e
it's legal, in view, bad practice.
w3c isn't in business of producing guidelines or usage advice, leaves others.
Comments
Post a Comment