编写Oracle和XSD数据类型之间的对应关系

时间:2021-12-20 22:40:41

My task is to create a conversion from Oracle metadata to XSD formatting to ensure correct translation of data from Oracle to XML.

我的任务是创建从Oracle元数据到XSD格式的转换,以确保将数据从Oracle正确转换为XML。

To accomplish this I need to provide a correspondence table for the Oracle data types and XSD data types. The following is such a table for numbers. Right part of the expression is Oracle's Number datatype format, and the left one are the tags to be inserted into the "restriction" element of xs:decimal tag in XSD. Then the explanation goes.

为此,我需要提供Oracle数据类型和XSD数据类型的对应表。以下是数字表。表达式的右侧部分是Oracle的Number数据类型格式,左侧是要插入XSD中xs:decimal标记的“restriction”元素的标记。然后解释说。

Number(null,null) <-> totalDigits=38 : any 38 digits with/without decimal point

Number(null,null)< - > totalDigits = 38:任意带/不带小数点的38位数

Number(4,2) <-> totalDigits=4; fractionDigits=2 : any 4 digits with decimal point from a missing one to the one in the middle of 4 digits; but what about "1600" ? it matches XSD, but not sure its ok for Oracle's Number(4,2)

数字(4,2)< - > totalDigits = 4; fractionDigits = 2:从缺失的一个到4个中间的一个小数点的任何4位数字;但是“1600”怎么样?它匹配XSD,但不确定甲骨文的数字是否正常(4,2)

Number(4,0) <-> totalDigits=4;fractionDigits=0 : integer with 4 digits

Number(4,0)< - > totalDigits = 4; fractionDigits = 0:4位整数

(1) Is my understanding correct? Could you provide me with a better match between Oracle and XSD numeric data types?

(1)我的理解是否正确?你能否为我提供Oracle和XSD数字数据类型之间更好的匹配?

(2) Is there a built-in way to generate XSD from Oracle table?

(2)是否有从Oracle表生成XSD的内置方法?

1 个解决方案

#1


0  

This restriction is not a good idea. The number type is defined as NUMBER(precision, scale), see examples in Table 2-2 in http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements001.htm.
You have to generate regexp pattern for the restriction, e.g.:

这种限制不是一个好主意。数字类型定义为NUMBER(精度,比例),请参阅http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements001.htm中的表2-2中的示例。您必须为限制生成正则表达式模式,例如:

NUMBER(4) "-?[0-9]{1,4}"
NUMBER(4,2) "-?([0-9]{1,2})?(\.[0-9]{1,2})?"
NUMBER(4,-2) "0|-?[0-9]{1,4}0{2}"
NUMBER(2,-4) "0|-?[0-9]{1,2}0{4}"
NUMBER(2,4) "0|-?0?\.0{2}[0-9]{1,2}"

NUMBER(4)“ - ?[0-9] {1,4}”NUMBER(4,2)“ - ?([0-9] {1,2})?(\。[0-9] {1 ,2})?” NUMBER(4,-2)“0 | - ?[0-9] {1,4} 0 {2}”NUMBER(2,-4)“0 | - ?[0-9] {1,2} 0 {4}“NUMBER(2,4)”0 | - ?0?\。0 {2} [0-9] {1,2}“

For NUMBER types with positive scale you can use combination of totalDigits, fractionDigits, minExclusive and maxExclusive.

对于具有正比例的NUMBER类型,您可以使用totalDigits,fractionDigits,minExclusive和maxExclusive的组合。

NUMBER(4) totalDigits="4" fractionDigits="0"
NUMBER(4,2) totalDigits="4" fractionDigits="2" minExclusive="-100" maxExclusive="100"
NUMBER(2,4) totalDigits="4" fractionDigits="4" minExclusive="-.01" maxExclusive=".01"

NUMBER(4)totalDigits =“4”fractionDigits =“0”NUMBER(4,2)totalDigits =“4”fractionDigits =“2”minExclusive =“ - 100”maxExclusive =“100”NUMBER(2,4)totalDigits =“ 4“fractionDigits =”4“minExclusive =” - 。01“maxExclusive =”。01“

#1


0  

This restriction is not a good idea. The number type is defined as NUMBER(precision, scale), see examples in Table 2-2 in http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements001.htm.
You have to generate regexp pattern for the restriction, e.g.:

这种限制不是一个好主意。数字类型定义为NUMBER(精度,比例),请参阅http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements001.htm中的表2-2中的示例。您必须为限制生成正则表达式模式,例如:

NUMBER(4) "-?[0-9]{1,4}"
NUMBER(4,2) "-?([0-9]{1,2})?(\.[0-9]{1,2})?"
NUMBER(4,-2) "0|-?[0-9]{1,4}0{2}"
NUMBER(2,-4) "0|-?[0-9]{1,2}0{4}"
NUMBER(2,4) "0|-?0?\.0{2}[0-9]{1,2}"

NUMBER(4)“ - ?[0-9] {1,4}”NUMBER(4,2)“ - ?([0-9] {1,2})?(\。[0-9] {1 ,2})?” NUMBER(4,-2)“0 | - ?[0-9] {1,4} 0 {2}”NUMBER(2,-4)“0 | - ?[0-9] {1,2} 0 {4}“NUMBER(2,4)”0 | - ?0?\。0 {2} [0-9] {1,2}“

For NUMBER types with positive scale you can use combination of totalDigits, fractionDigits, minExclusive and maxExclusive.

对于具有正比例的NUMBER类型,您可以使用totalDigits,fractionDigits,minExclusive和maxExclusive的组合。

NUMBER(4) totalDigits="4" fractionDigits="0"
NUMBER(4,2) totalDigits="4" fractionDigits="2" minExclusive="-100" maxExclusive="100"
NUMBER(2,4) totalDigits="4" fractionDigits="4" minExclusive="-.01" maxExclusive=".01"

NUMBER(4)totalDigits =“4”fractionDigits =“0”NUMBER(4,2)totalDigits =“4”fractionDigits =“2”minExclusive =“ - 100”maxExclusive =“100”NUMBER(2,4)totalDigits =“ 4“fractionDigits =”4“minExclusive =” - 。01“maxExclusive =”。01“