Поделиться через


Rowset Data Type (XMLA)

Defines a derived data type that represents a root element that returns tabular data from a Discover or Execute method call.

Namespace urn:schemas-microsoft-com:xml-analysis:rowset

Синтаксис

<root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset">
   <!-- The following elements extend Resultset -->
   <!-- Optional schema elements -->
   <row>...</row>
</root>

Data Type Characteristics

Characteristic Description

Base data types

Resultset

Derived data types

None

Data Type Relationships

Relationship Element

Parent elements

None

Child elements

row

Derived elements

root

Замечания

XML does not allow certain characters as element and attribute names. To address this naming constraint, XML for Analysis (XMLA) supports encoding as defined by Microsoft SQL Server 2005. For column names that contain XML name characters that are not valid according to the XML 1.0 specification, XMLA uses the corresponding hexadecimal values to encode Unicode characters that are not valid . The hexadecimal values are escaped as _xHHHH_, where HHHH stands for the four-digit hexadecimal UCS-2 code for the character in the most-significant bit first order. For example, XMLA encodes the name, "Order Details," as Order_x0020_Details, replacing the space character with the corresponding hexadecimal code.

Encoding can make Extensible Style Language (XSL) transformations difficult. To support a quick lookup of the actual, unencoded column names, add the sql:field attribute to the XML rowset schema for each column, as shown in the following example:

<xsd:element name="Order_x0020_Details" type="string" sql:field="Order Details" />
ms187127.note(ru-ru,SQL.90).gifПримечание.
The sql:field attribute is in the "urn:schemas-microsoft-com:xml-sql" namespace.

Expressing a Null Value

There are two ways to express a null value for a column within a row:

  • A missing column element implies that the column is null.
  • The column element may use the xsi:nil='true' attribute to indicate that it has a null value.

For example, a row has a single column called, Store_Name, and the value of that column is NULL. The value of the Store_Name column can be represented as a missing column element:

<row>
</row>

Or, the value of the Store_Name column can be represented using the xsi:nil='true' attribute:

   <row>
      <Store_name xsi:nil='true'/>
   </row>

Пример

XMLA Rowset for Flat Data

For flat data, column names that are specific to the query are defined in the schema as the element names. Also, a pair of <row> tags encapsulates each row.

The following example shows the XMLA rowset format for flat data.

<return>
   <root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset">
   <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sql="urn:schemas-microsoft-com:xml-sql">
   </xsd:element>
      <xsd:complexType name="row">
         <xsd:choice maxOccurs="unbounded" minOccurs="0">
            <xsd:element name="CATALOG_NAME" type="xsd:string" sql:field="CATALOG_NAME"></xsd:element>
            <xsd:element name="DESCRIPTION" type="xsd:string" sql:field="DESCRIPTION"></xsd:element>
            <xsd:element name="ROLES" type="xsd:string" sql:field="ROLES"></xsd:element>
            <xsd:element name="DATE_MODIFIED" type="xsd:time" sql:field="DATE_MODIFIED"></xsd:element>
         </xsd:choice>
      </xsd:complexType>
   </xsd:schema>
   <row>
      <CATALOG_NAME>FoodMart 2000</CATALOG_NAME>
      <DESCRIPTION></DESCRIPTION>
      <ROLES>All Users</ROLES>
      <DATE_MODIFIED>3/11/2001 6:49:36 PM</DATE_MODIFIED>
   </row>
   ...
</root>
XMLA Rowset for Hierarchical Data

Some rowsets contain hierarchical data (or nested rowsets). Rowsets returned by data mining queries are hierarchical. For hierarchical data, the structure of the rows is not changed, but the data-specific schema defines an element subtype that contains the nested data.

The following example shows the XMLA rowset format for hierarchical data. In this example, the element subtype that contains the nested data is <NODE_DISTRIBUTION>.

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset">
   <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:sql="urn:schemas-microsoft-com:xml-sql">
      <xsd:complexType name="row">
         <xsd:choice maxOccurs="unbounded" minOccurs="0">
            <xsd:sequence maxOccurs="unbounded" minOccurs="0">
               <xsd:element name="NODE_DISTRIBUTION" sql:field="NODE_DISTRIBUTION">
                  <xsd:complexType>
                     <xsd:choice maxOccurs="unbounded" minOccurs="0">
                        <xsd:element name="ATTRIBUTE_NAME" type="xsd:string" sql:field="ATTRIBUTE_NAME"></xsd:element>
                        <xsd:element name="ATTRIBUTE_VALUE" type="xsd:string" sql:field="ATTRIBUTE_VALUE"></xsd:element>
                        <xsd:element name="SUPPORT" type="xsd:double" sql:field="SUPPORT"></xsd:element>
                        <xsd:element name="PROBABILITY" type="xsd:double" sql:field="PROBABILITY"></xsd:element>
                        <xsd:element name="VARIANCE" type="xsd:double" sql:field="VARIANCE"></xsd:element>
                        <xsd:element name="VALUETYPE" type="xsd:int" sql:field="VALUETYPE"></xsd:element>
                     </xsd:choice>
                  </xsd:complexType>
               </xsd:element>
            </xsd:sequence>
            <xsd:element name="MODEL_CATALOG" type="xsd:string" sql:field="MODEL_CATALOG"></xsd:element>
            <xsd:element name="MODEL_SCHEMA" type="xsd:string" sql:field="MODEL_SCHEMA"></xsd:element>
            <xsd:element name="MODEL_NAME" type="xsd:string" sql:field="MODEL_NAME"></xsd:element>
            <xsd:element name="ATTRIBUTE_NAME" type="xsd:string" sql:field="ATTRIBUTE_NAME"></xsd:element>
            <xsd:element name="NODE_NAME" type="xsd:string" sql:field="NODE_NAME"></xsd:element>
            <xsd:element name="NODE_UNIQUE_NAME" type="xsd:string" sql:field="NODE_UNIQUE_NAME"></xsd:element>
            <xsd:element name="NODE_TYPE" type="xsd:unsignedInt" sql:field="NODE_TYPE"></xsd:element>
            <xsd:element name="NODE_GUID" type="xsd:string" sql:field="NODE_GUID"></xsd:element>
            <xsd:element name="NODE_CAPTION" type="xsd:string" sql:field="NODE_CAPTION"></xsd:element>
            <xsd:element name="CHILDREN_CARDINALITY" type="xsd:unsignedInt" sql:field="CHILDREN_CARDINALITY"></xsd:element>
            <xsd:element name="PARENT_UNIQUE_NAME" type="xsd:string" sql:field="PARENT_UNIQUE_NAME"></xsd:element>
            <xsd:element name="NODE_DESCRIPTION" type="xsd:string" sql:field="NODE_DESCRIPTION"></xsd:element>
            <xsd:element name="NODE_RULE" type="xsd:string" sql:field="NODE_RULE"></xsd:element>
            <xsd:element name="MARGINAL_RULE" type="xsd:string" sql:field="MARGINAL_RULE"></xsd:element>
            <xsd:element name="NODE_PROBABILITY" type="xsd:double" sql:field="NODE_PROBABILITY"></xsd:element>
            <xsd:element name="MARGINAL_PROBABILITY" type="xsd:double" sql:field="MARGINAL_PROBABILITY"></xsd:element>
            <xsd:element name="NODE_SUPPORT" sql:type="xsd:double" sql:field="NODE_SUPPORT"></xsd:element>
            <xsd:element name="MSOLAP_MODEL_COLUMN" sql:type="xsd:string" sql:field="MSOLAP_MODEL_COLUMN"></xsd:element>
            <xsd:element name="MSOLAP_NODE_SCORE" sql:type="xsd:double" sql:field="MSOLAP_NODE_SCORE"></xsd:element>
            <xsd:element name="MSOLAP_NODE_SHORT_CAPTION" sql:type="xsd:string" sql:field="MSOLAP_NODE_SHORT_CAPTION"></xsd:element>
         </xsd:choice>
      </xsd:complexType>
   </xsd:schema>
   <row>
      <MODEL_CATALOG>FoodMart 2000</MODEL_CATALOG>
      <MODEL_NAME>customer pattern discovery</MODEL_NAME>
      <ATTRIBUTE_NAME>Customers.Name.Member Card</ATTRIBUTE_NAME>
      <NODE_NAME>2147483652</NODE_NAME>
      <NODE_UNIQUE_NAME>2147483652</NODE_UNIQUE_NAME>
      <NODE_TYPE>2</NODE_TYPE>
      <NODE_CAPTION>All</NODE_CAPTION>
      <CHILDREN_CARDINALITY>8</CHILDREN_CARDINALITY>
      <PARENT_UNIQUE_NAME>0</PARENT_UNIQUE_NAME>
      <NODE_DESCRIPTION>All</NODE_DESCRIPTION>
      <NODE_RULE></NODE_RULE>
      <MARGINAL_RULE></MARGINAL_RULE>
      <NODE_PROBABILITY>1</NODE_PROBABILITY>
      <MARGINAL_PROBABILITY>1</MARGINAL_PROBABILITY>
      <NODE_DISTRIBUTION>
         <ATTRIBUTE_NAME>Customers.Name.Member Card</ATTRIBUTE_NAME>
         <ATTRIBUTE_VALUE>missing</ATTRIBUTE_VALUE>
         <SUPPORT>0</SUPPORT>
         <PROBABILITY>0</PROBABILITY>
         <VARIANCE>0</VARIANCE>
         <VALUETYPE>1</VALUETYPE></NODE_DISTRIBUTION>
      <NODE_DISTRIBUTION>
         <ATTRIBUTE_NAME>Customers.Name.Member Card</ATTRIBUTE_NAME>
         <ATTRIBUTE_VALUE>Bronze</ATTRIBUTE_VALUE>
         <SUPPORT>3077</SUPPORT>
         <PROBABILITY>0.551334886221107</PROBABILITY>
         <VARIANCE>0</VARIANCE>
         <VALUETYPE>4</VALUETYPE></NODE_DISTRIBUTION>
      <NODE_DISTRIBUTION>
         <ATTRIBUTE_NAME>Customers.Name.Member Card</ATTRIBUTE_NAME>
         <ATTRIBUTE_VALUE>Golden</ATTRIBUTE_VALUE>
         <SUPPORT>659</SUPPORT>
         <PROBABILITY>0.118079197276474</PROBABILITY>
         <VARIANCE>0</VARIANCE>
         <VALUETYPE>4</VALUETYPE></NODE_DISTRIBUTION>
      <NODE_DISTRIBUTION>
         <ATTRIBUTE_NAME>Customers.Name.Member Card</ATTRIBUTE_NAME>
         <ATTRIBUTE_VALUE>Normal</ATTRIBUTE_VALUE>
         <SUPPORT>1332</SUPPORT>
         <PROBABILITY>0.238666905572478</PROBABILITY>
         <VARIANCE>0</VARIANCE>
         <VALUETYPE>4</VALUETYPE></NODE_DISTRIBUTION>
      <NODE_DISTRIBUTION>
         <ATTRIBUTE_NAME>Customers.Name.Member Card</ATTRIBUTE_NAME>
         <ATTRIBUTE_VALUE>Silver</ATTRIBUTE_VALUE>
         <SUPPORT>513</SUPPORT>
         <PROBABILITY>9.19190109299409E-02</PROBABILITY>
         <VARIANCE>0</VARIANCE>
         <VALUETYPE>4</VALUETYPE></NODE_DISTRIBUTION>
      <NODE_SUPPORT>5581</NODE_SUPPORT>
      <MSOLAP_MODEL_COLUMN>Customers.Name.Member Card</MSOLAP_MODEL_COLUMN>
      <MSOLAP_NODE_SCORE>1948.401692055</MSOLAP_NODE_SCORE>
      <MSOLAP_NODE_SHORT_CAPTION>All</MSOLAP_NODE_SHORT_CAPTION>
</row>
</root>

См. также

Другие ресурсы

XML Data Types (XMLA)

Справка и поддержка

Получение помощи по SQL Server 2005