ConceptioArchiveW3C TR
W3C TRopen access

xsd precisionDecimal

W3C · w3c_tr
W3C TR · Standards · License: Open Access
Open Source ↗
w3c, standard

An XSD datatype for IEEE floating-point decimal code { font-family: monospace; }

div.constraint, div.issue, div.note, div.notice { margin-left: 2em; }

ol.enumar { list-style-type: decimal; } ol.enumla { list-style-type: lower-alpha; } ol.enumlr { list-style-type: lower-roman; } ol.enumua { list-style-type: upper-alpha; } ol.enumur { list-style-type: upper-roman; }

div.exampleInner pre { margin-left: 1em; margin-top: 0em; margin-bottom: 0em} div.exampleOuter {border: 4px double gray; margin: 0em; padding: 0em} div.exampleInner { background-color: #d5dee3; border-top-width: 4px; border-top-style: double; border-top-color: #d3d3d3; border-bottom-width: 4px; border-bottom-style: double; border-bottom-color: #d3d3d3; padding: 4px; margin: 0em } div.exampleWrapper { margin: 4px } div.exampleHeader { font-weight: bold; margin: 4px}

div.odiff-nsq-add { background-color: #DFDFDF; } div.odiff-nsq-del { display: none; background-color: #FFDFDF } div.idiff-nsq-del { display: none; text-decoration: line-through } div.odiff-nsq-chg { background-color: #DFDFDF } div.diff-nsq-off { }

span.odiff-nsq-add { background-color: #DFDFDF; } span.diff-nsq-add { background-color: #DFDFDF; } span.odiff-nsq-del { display: none; background-color: #FFDFDF } span.idiff-nsq-del { display: none; text-decoration: line-through } span.diff-nsq-del { display: none; background-color: #FFDFDF ; text-decoration: line-through } span.odiff-nsq-chg { background-color: #DFDFDF } span.diff-nsq-chg { background-color: #DFFFDF } span.diff-nsq-off { }

td.odiff-nsq-add { background-color: #DFDFDF; } td.odiff-nsq-del { display: none; background-color: #FFDFDF } td.odiff-nsq-chg { background-color: #DFDFDF } td.diff-nsq-off { }

table { width: 100%; } img { color: white; border: none } span.rfc2119 { font-variant: small-caps } span.nav { float: right} span.arrow { font-style: normal; font-weight: bold } span.enumval { font-style: italic; font-weight: bold }

code { font-family: monospace; font-size: 100%} span.propdef { font-weight: bold; font-family: monospace } span.termdef {color: #850021} div.termdef {color: #850021} a.termref:visited, a.termref:link {font-family: sans-serif; font-style: normal; color: black; text-decoration: none } a.eltref:visited, a.eltref:link { font-family: sans-serif; color: black; text-decoration: none } a.propref:visited, a.xpropref:visited, a.propref:link, a.xpropref:link { color: black; text-decoration: none; font-family: sans-serif } div.component {border: 2px solid black; margin-top: 1ex} span.propdef { font-weight: bold; font-family: monospace } div.ownDesc {margin-top: -2ex; margin-bottom: -2ex} a.compref {font-family: sans-serif; font-style: normal; color: black; text-decoration: none} dl.props, dl.psvi {margin-bottom: .5em; margin-top: 0em} div.toc1 {margin-left: 5ex} div.toc2 {margin-left: 2ex} div.tocLine{margin: 0em; text-indent: -6ex} h3.withToc {margin-bottom: 0em} div.constraintnote { margin-top: 1em } div.constraint { margin-left: 1em; } div.constraintlist { margin-left: 1em; margin-bottom: 0em } div.clnumber { text-indent: -1em; margin-top: 0em; margin-bottom: 0em } div.schemaComp { border: 4px double gray; margin: 0em 1em; padding: 0em } div.scHead { border: 4px double gray; border-bottom: 0px; text-align: center; margin-left: 1em; padding: .5em } div.compHeader { margin: 4px; font-weight: bold } span.schemaComp { color: #A52A2A } div.compBody { border-top-width: 4px; border-top-style: double; border-top-color: #d3d3d3; padding: 4px ; margin: 0em} div.psviDef { border: 4px double gray; margin: 1em 1em; padding: 0em } div.psviHeader { margin: 4px; font-weight: bold } span.psviDef { color: #A52A2A } div.psviBody { border-top-width: 4px; border-top-style: double; border-top-color: #d3d3d3; padding: 4px ; margin: 0em} div.reprdef { border: 4px double gray; margin: 0em 1em; padding: 0em } div.reprHeader { margin: 4px; font-weight: bold } span.reprdef { color: #A52A2A } div.reprBody, div.reprcompmulti, div.reprdep { border-top-width: 4px; border-top-style: double; border-top-color: #d3d3d3; padding: 4px ; margin: 0em} div.reprcomp {padding: 4px ; margin: 0em} div.reprHead { text-align: center; } div.mapSep { font-size: 50% ; clear: both} div.mapProp {clear: left; float: left; width: 5em; max-width: 12em; min-width: 5em } div.mapRepr { margin-left: 6.5em } p.element-syntax-1 { font-family: monospace; margin-top: 0em; margin-bottom: .5em } p.element-syntax { font-family: monospace; border-top-width: 1px; border-top-style: solid; border-top-color: #d3d3d3; padding: 4px ; margin: 0em} div.exampleInner pre { margin-left: 1em; margin-top: 0em; margin-bottom: 0em} div.exampleOuter {border: 4px double gray; margin: 0em; margin-bottom: 0.6em; padding: 0em} div.exampleInner { background-color: #d5dee3; border-top-width: 4px; border-top-style: double; border-top-color: #d3d3d3; border-bottom-width: 4px; border-bottom-style: double; border-bottom-color: #d3d3d3; padding: 4px; margin: 0em } div.exampleWrapper { margin: 4px } div.exampleHeader { font-weight: bold; margin: 4px} table.restricts { margin-top: 1em; margin-bottom: 1em; margin-left: -2em} table.restricts th { margin-left: 0em } table.ubc td, table.ubc th { font-size: smaller } table.dtdemo th { text-align: center; background-color: #d5dee3} table.dtdemo pre { margin-left: 0em; margin-bottom: 0em} table.dtdemo td {background-color: #bedce6} table.scrap {margin: .5em; background-color: #f5dcb3} table.defset {background-color: #ffeedd } table.defset thead, table.diffed-defset thead { color: red; font-weight: bold } img { color: white; border: none } span.nav { float: right} span.arrow { font-style: normal; font-weight: bold } .shrink {font-size: 80% ; } .defset ul { margin-top: 0 ; margin-bottom: 0 ; } div.defset { margin: 4px ; border-width: 4px ; border-style: double ; border-color: gray ; } div.aux { background-color: #eeeeee ; color: #333333 ; } div.defset-head { font-weight: bold ; padding: 0.6em ; border-bottom-width: 4px ; border-bottom-style: double ; border-color: #cfcfcf ; } div.deftop {background-color: #d5dee3 ; margin-top: 1.5em; padding-bottom: 0.3em } div.defindent { margin-left: 1em ; margin-top: 0em ; margin-bottom: 0em ; } div.defargs { margin-left: 3em ; } div.prod { margin: 1em ; margin-left: 5em ; } .lhs { margin-left: -4em ; } table table, .defset table { margin: 0 ; border: 0 ; padding: 0 ; } .note { margin-left: 2em ; margin-top: 1em ; margin-bottom: 1em ; } div.issue { background-color: #d5bbbb} .giLabel, .pdName { margin-bottom: 0 ; font-weight: bold } .giDef, .pdDef { margin-left: 2.5em ; margin-top: 0} div.pvlist { border: 4px double gray; margin-bottom: .5em; margin-left: 1em; padding: .5em; padding-right: 1em; padding-bottom: 1em } div.pvVal div.pvlist { border: 4px double gray; margin-top: 1.2em; margin-bottom: .5em; /* margin-left: -5em; */ margin-left: -1.3em; padding: .5em; padding-right: 1em; padding-bottom: 1em; } div.clnumber div.pvlist { border: 4px double gray; margin-bottom: .5em; margin-left: 1em; padding-top: .5em; text-indent: 0; padding-right: 1em; padding-bottom: 1em } div.mapRepr div.pvlist { border: 4px double gray; margin-top: .5em; margin-bottom: .5em; padding: .5em; padding-right: 1em; padding-bottom: 1em }

div.pvSep { font-size: 50% ; clear: both} div.pvProp {clear: left; float: left; width: 7em; max-width: 12em; min-width: 7em } div.pvVal { margin-left: 8em } div.pvpair { clear: both; padding: 0.3em; padding-right: 0; }

div.sfsScrap { border: 4px double gray; margin: 0em 1em; padding: 0em } div.sfsHead { margin: 4px; font-weight: bold } div.sfsBody { border-top-width: 4px; border-top-style: double; border-top-color: #d3d3d3; padding: 4px ; margin: 0em} div.ednote { display: block; margin: 1.33em 0; } a.scrapref { font-family: serif, sans-serif; }

/* Added 2008-01-30. Value may be tweaked, but whatever it is, * make it the same for these three different ways of saying * 'paragraph'. */ p, div.p, div.block { margin: 1em 0; } p.image-caption { margin-left: 2em; margin-right: 2em; margin-bottom: 3em; font-style: italic; }

var { /* color: green; */ color: navy; /* or perhaps try MediumBlue */ font-style: italic; font-weight: bold; }

table.blocknames, table.blocknames td, table.blocknames th { border-style: solid; border-width: thin; empty-cells: show; }

table.blocknames td, table.blocknames th { padding: 0.2em; } This version: http://www.w3.org/TR/2011/NOTE-xsd-precisionDecimal-20110609/ Latest version: http://www.w3.org/TR/xsd-precisionDecimal/ Editors: David Peterson, invited expert (SGML Works! <[email protected]> C. M. Sperberg-McQueen, Black Mesa Technologies LLC <[email protected]> Copyright W3C ® MIT ERCIM Keio liability trademark document use This document defines a datatype designed for compatibility with IEEE 754 floating-point decimal data, which can be supported by XSD 1.1 processors as an implementation-defined This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index This document is a W3C Working Group Note World Wide Web Consortium Process Document In its current state, this document contains all the material specific to the precisionDecimal [XSD 1.1 Part 2: Datatypes] To-do list (non-normative) (§D) Comments on this document should be sent to the W3C XML Schema comments mailing list, [email protected] archive Publication as a Working Group Note does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress. This document has been produced by the W3C XML Schema Working Group XML Activity This document was produced by a group operating under the 5 February 2004 W3C Patent Policy public list of any patent disclosures Essential Claim(s) section 6 of the W3C Patent Policy 1 Introduction Definitions The precisionDecimal datatype Value Space Lexical Mapping Facets Facets for constraining precisionDecimal values totalDigits totalDigits Validation Rules maxScale The maxScale Schema Component XML Representation of maxScale Schema Components maxScale Validation Rules Constraints on maxScale Schema Components minScale The minScale Schema Component XML Representation of minScale Schema Components minScale Validation Rules Constraints on minScale Schema Components Implementation issues Implementation limits Interfacing with XPath Mapping functions A Normative references Non-normative references Acknowledgements (non-normative) To-do list (non-normative) This document defines an XSD datatype intended to support the floating-point decimal defined by IEEE 754. IEEE 754 defines both floating-point binary and floating-point decimal formats. The binary formats have been widely adopted since their initial introduction; if the floating-point decimal formats are also widely adopted for applications, it will be convenient to be able to represent values of that type in XML documents or in other contexts where XSD datatypes are used. The following terms are used in this specification with the meanings indicated. Except as specified below, in this specification terms defined in [XSD 1.1 Part 2: Datatypes] [Definition:] constraining facet A schema component whose value may be set or changed during derivation [Definition:] fundamental facet A schema component that provides a limited piece of information about some aspect of a datatype. [Definition:] special value One of the possible values of the · · precisionDecimal [XSD 1.1 Part 2: Datatypes] positiveInfinity negativeInfinity notANumber Informally, any precisionDecimal · · Note: special values [Definition:] precisionDecimal [IEEE 754-2008] Note: precisionDecimal Note: [IEEE 754-2008] The datatype precisionDecimal 2 2.00 Note: conformance note [XSD 1.1 Part 2: Datatypes] Properties of precisionDecimal · · a decimal number, positiveInfinity negativeInfinity notANumber · · an integer or absent absent · · · · positive negative absent must positive · · positiveInfinity must negative · · negativeInfinity must absent · · notANumber Note: · · · · · · · · Note: NaN precisionDecimal · · notANumber · · positiveInfinity negativeInfinity precisionDecimal Note: [IEEE 754-2008] s q m s sign q exponent m significand q exponent significand precisionDecimal · · s q m · · q sign s · · significand m · · · · q · · The single NaN of precisionDecimal lexical representations The individual decimal formats defined by [IEEE 754-2008] exponent significand precision For datatypes derived from precisionDecimal · · · · q Note: precisionDecimal precisionDecimal Equality and order for precisionDecimal Two numerical precisionDecimal · · · · equal not INF is equal only to itself, and is greater than −INF and all numerical precisionDecimal −INF is equal only to itself, and is less than INF and all numerical precisionDecimal NaN is incomparable including itself The lexical space of precisionDecimal INF +INF -INF NaN Lexical Space [1] pDecimalRep noDecimalPtNumeral decimalPtNumeral scientificNotationNumeral numericalSpecialRep Note: pDecimalRep [XSD 1.1 Part 2: Datatypes] The pDecimalRep (\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+)([Ee](\+|-)?[0-9]+)? The lexical mapping precisionDecimal · · canonical mapping · · For example, each of the lexical representations · · · · · · canonical representation ' 3 positive 3 ' 3.00 positive 3.00 ' 03.00 positive 3.00 ' 300 positive 300 ' 3.00e2 positive 300 ' 3.0e2 positive 3.0E2 ' 30e1 positive 3.0E2 ' .30e3 positive 3.0E2 lexical representations only lexical representations Note: [IEEE 754-2008] lexical representations value space value space precisionDecimal lexical representations precisionDecimal · · [IEEE 754-2008] INF NaN INFINITY INF NaN + + Note: lexical representations precisionDecimal lexical representations · · 0.1 · · · · literal 0.1 This interaction between datatype restriction and rounding has as a consequence that it will typically be more convenient for users if restricted-precision numeric types are derived from precisionDecimal float double The precisionDecimal · · fixed must not whiteSpace = collapse Datatypes derived by restriction from precisionDecimal may · · totalDigits maxScale minScale pattern enumeration maxInclusive maxExclusive minInclusive minExclusive assertions The precisionDecimal · · ordered partial bounded false cardinality countably infinite numeric true The assertions enumeration maxInclusive maxExclusive minExclusive minInclusive pattern [XSD 1.1 Part 2: Datatypes] precisionDecimal [XSD 1.1 Part 2: Datatypes] The totalDigits [XSD 1.1 Part 2: Datatypes] precisionDecimal totalDigits (§4.1) totalDigits (§4.1) totalDigits [XSD 1.1 Part 2: Datatypes] precisionDecimal In addition, two facets not defined by [XSD 1.1 Part 2: Datatypes] precisionDecimal maxScale (§4.2) minScale (§4.3) For precisionDecimal · · nV · · aP value t aP log 10 nV div t t Validation Rule: totalDigits Valid A precisionDecimal v value t 1 v precisionDecimal · · positiveInfinity negativeInfinity notANumber 2 v precisionDecimal · · nV · · aP v aP log 10 nV div t 4.2.1 The maxScale Schema Component XML Representation of maxScale Schema Components maxScale Validation Rules Constraints on maxScale Schema Components [Definition:] maxScale · · precisionDecimal {value} maxScale m · · m value space · · i n i n n m {value} maxScale must integer The term 'maxScale' is chosen to reflect the fact that it restricts the value space maxScale maxScale lexical space Example The following is the definition of a user-defined datatype which could be used to represent a floating-point decimal datatype which allows seven decimal digits for the coefficient and exponents between −95 and 96. Note that the scale is −1 times the exponent. <simpleType name='decimal32'> <restriction base='precisionDecimal'> <totalDigits value='7'/> <maxScale value='95'/> <minScale value='-96'/> </restriction> </simpleType> Schema Component: maxScale {annotations} A sequence of Annotation {value} An xs:integer value. Required. {fixed} An xs:boolean value. Required. If {fixed} true {base type definition} must not maxScale {value} The XML representation for a maxScale <maxScale> XML Representation Summary maxScale maxScale Schema Component Property Representation {value} The actual value value [attribute] {fixed} The actual value fixed [attribute] false {annotations} The annotation mapping <maxScale> XML Representation of Annotation Schema Components [XSD 1.1 Part 1: Structures] Validation Rule: maxScale Valid A precisionDecimal v maxScale 1 v · · {value} maxScale 2 The · · v absent Schema Component Constraint: maxScale valid restriction It is an error maxScale {facets} {base type definition} {value} {value} maxScale 4.3.1 The minScale Schema Component XML Representation of minScale Schema Components minScale Validation Rules Constraints on minScale Schema Components [Definition:] minScale · · precisionDecimal {value} minScale m · · m · · i n i n n m The term minScale value space minScale lexical space Example The following is the definition of a user-defined datatype which could be used to represent amounts in a decimal currency; it corresponds to a SQL column definition of DECIMAL(8,2) <simpleType name='price'> <restriction base='precisionDecimal'> <totalDigits value='8'/> <minScale value='2'/> <maxScale value='2'/> </restriction> </simpleType> Schema Component: minScale {annotations} A sequence of Annotation {value} An xs:integer value. Required. {fixed} An xs:boolean value. Required. If {fixed} true {base type definition} must not minScale {value} The XML representation for a minScale <minScale> XML Representation Summary minScale minScale Schema Component Property Representation {value} The actual value value [attribute] {fixed} The actual value fixed [attribute] false {annotations} The annotation mapping <minScale> XML Representation of Annotation Schema Components [XSD 1.1 Part 1: Structures] Validation Rule: minScale Valid A precisionDecimal v minScale 1 v · · {value} minScale 2 The · · v absent Schema Component Constraint: minScale less than or equal to maxScale It is an error minScale maxScale Note that it is not minScale Schema Component Constraint: minScale valid restriction It is an error minScale {facets} {base type definition} {value} {value} minScale All minimally conforming must precisionDecimal value space derived maxScale minScale Note: [IEEE 754-2008] maxScale minScale [XPath 2.0] For interoperability, it is recommended that XPath processors intending to support precisionDecimal as an additional primitive data type follow the recommendations in [Chamberlin 2006] post-schema-validation infoset should xs:precisionDecimal If the XPath processor does not support precisionDecimal, then any precisionDecimal values in the post-schema-validation infoset should decimal · · positiveInfinity negativeInfinity notANumber should float post-schema-validation infoset post-schema-validation infoset [XDM] implementation-defined As a consequence of the above variability, it is possible that XPath expressions that perform various kinds of type introspections will produce different results when different XPath processors are used. If the schema author wishes to ensure interoperable results, such introspections will need to be avoided. The functions defined below make frequent reference to functions defined in [XSD 1.1 Part 2: Datatypes] Auxiliary Functions for Reading Instances of pDecimalRep · · LEX Maps a decimalPtNumeral · · precisionDecimal Arguments: LEX : matches decimalPtNumeral Result: an integer Algorithm: LEX . fracFrag F n digit Return n F 0   otherwise. · · LEX Maps a scientificNotationNumeral · · precisionDecimal Arguments: LEX : matches scientificNotationNumeral Result: an integer Algorithm: LEX noDecimalPtNumeral decimalPtNumeral C E e noDecimalPtNumeral E Return −1 × noDecimalMap E C noDecimalPtNumeral · · C noDecimalMap E Lexical Mapping · · LEX precisionDecimal Maps a pDecimalRep precisionDecimal Arguments: LEX : matches pDecimalRep Result: a precisionDecimal Algorithm: Let pD precisionDecimal Set pD · · noDecimalMap LEX LEX noDecimalPtNumeral decimalPtMap LEX LEX decimalPtNumeral scientificMap LEX LEX scientificNotationNumeral specialRepValue LEX Set pD · · 0   when LEX noDecimalPtNumeral · · LEX LEX decimalPtNumeral · · LEX LEX scientificNotationNumeral absent Set pD · · absent LEX NaN negative LEX - positive Return pD Canonical Mapping · · pD pDecimalRep Maps a precisionDecimal canonical representation pDecimalRep Arguments: pD : a precisionDecimal Result: a literal pDecimalRep Algorithm: Let nV · · pD Let aP · · pD If pD specialRepCanonicalMap nV Otherwise, if nV aP nV noDecimalPtCanonicalMap nV Otherwise, if aP nV s decimalPtCanonicalMap nV f s f aP s aP f 0 Otherwise, it will be the case that nV aP s scientificCanonicalMap nV m s n s p n f m f aP p t aP p f 0 m aP p f m t E n IEEE. IEEE Standard for Floating-Point Arithmetic http://ieeexplore.ieee.org/xpl/mostRecentIssue.jsp?punumber=4610933 World Wide Web Consortium. W3C XML Schema Definition Language (XSD) 1.1 Part 2: Structures http://www.w3.org/TR/xmlschema11-2/ Chamberlin, Don. Impact of precisionDecimal on XPath and XQuery http://www.w3.org/XML/2007/dc.pd.xml http://www.w3.org/XML/2007/dc.pd.html World Wide Web Consortium. XQuery 1.0 and XPath 2.0 Data Model (XDM) http://www.w3.org/TR/xpath-datamodel/ World Wide Web Consortium. XML Path Language 2.0 http://www.w3.org/TR/2007/REC-xpath20-20070123/ World Wide Web Consortium. W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures http://www.w3.org/TR/xmlschema11-1/ This document was prepared by the W3C XML Schema Working Group. The members at the time of publication were: Gioele Barabucci, University of Bologna Paul V. Biron, Invited expert David Ezell, National Association of Convenience Stores (NACS) ( chair Shudi (Sandy) Gao 高殊镝, IBM Mary Holstege, Mark Logic Sam Idicula, Oracle Michael Kay, Invited expert Nan Ma, China Electronics Standardization Institute Paolo Marinelli, University of Bologna Jim Melton, Oracle Noah Mendelsohn, Invited expert Dave Peterson, Invited expert Liam Quin, W3C C. M. Sperberg-McQueen, Black Mesa Technologies (for W3C) ( staff contact Henry S. Thompson, University of Edinburgh Scott Tsao, The Boeing Company Fabio Vitali, University of Bologna Stefano Zacchiroli, University of Bologna Kongyi Zhou, Oracle Some changes are expected to be made in future work on this document: Draft fuller introduction. Add section on conformance to this spec. Add section claiming conformance to XSD 1.1 and pointing to the required information.

Related documents

Record · ID 153239 · SHA-256 e4dd98b3e61c4893
Conceptio Open Knowledge Archive — every document is proof-bundled with source, license, and retrieval metadata.