Condividi tramite


Mapping XSD Data Types to XPath Data Types [SQLXML 4.0]

When an XPath query is executed against an XSD schema and the XSD type is specified in the xsd:type attribute, XPath uses the data type specified when it processes the query.

The XPath data type of a node is derived from the XSD data type in the schema, as shown in the following table. (The EmployeeID node is used for the purpose of illustration.)

XSD data type XDR data type Equivalent XPath data type SQL Server conversion that is used

Base64Binary

HexBinary

None

bin.base64bin.hex

Not applicable

None

EmployeeID

Boolean

boolean

boolean

CONVERT(bit, EmployeeID)

Decimal, integer, float, byte, short, int, long, float, double, unsignedByte, unsignedShort, unsignedInt, unsignedLong

number, int, float,i1, i2, i4, i8,r4, r8ui1, ui2, ui4, ui8

number

CONVERT(float(53), EmployeeID)

id, idref, idrefsentity, entities, notation, nmtoken, nmtokens, DateTime, string, AnyURI

id, idref, idrefsentity, entities, enumeration, notation, nmtoken, nmtokens, char, dateTime, dateTime.tz, string, uri, uuid

string

CONVERT(nvarchar(4000), EmployeeID, 126)

decimal

fixed14.4

Not applicable (There is no data type in XPath that is equivalent to the fixed14.4 XDR data type.)

CONVERT(money, EmployeeID)

date

date

string

LEFT(CONVERT(nvarchar(4000), EmployeeID, 126), 10)

time

time

time.tz

string

SUBSTRING(CONVERT(nvarchar(4000), EmployeeID, 126), 1 + CHARINDEX(N'T', CONVERT(nvarchar(4000), EmployeeID, 126)), 24)