XMLRelation Example: Output Attributes as Nodes | Teradata Vantage - XMLRelation Example: Output Attributes as Nodes - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
9.02
9.01
2.0
1.3
Published
February 2022
Language
English (United States)
Last Update
2022-02-10
dita:mapPath
rnn1580259159235.ditamap
dita:ditavalPath
ybt1582220416951.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

This example outputs the attributes as if they were nodes.

Input

SQL Call

SELECT * FROM XMLRelation (
  ON xmlrelation_input
  USING
  TextColumn ('xmldocument')
  DocIDColumns ('xid')
  MaxDepth (3)
  AttributeAsNode ('true')

) AS dt;

Output

The element column contains both actual nodes and attributes that are output as nodes. For the latter, the attributes column contains a tilde (~).

 xid out_nodeid element attributes         value_col d0id d1id d2id d3id 
 --- ---------- ------- ------------------ --------- ---- ---- ---- ---- 
   1          2 name    ~                  UCLA         1    2 NULL NULL
   1          4 name    ~                  EE           1    3    4 NULL
   1          6 A       ~                  grad         1    3    5    6
   1          7 B       ~                  undergrad    1    3    5    7
   1          8 Student                    Harry        1    3    5    8
   1          9 Grade                      A+           1    3    5    9
   1          5 Class   A=grad,B=undergrad              1    3    5 NULL
   1          3 Dept    name=EE                         1    3 NULL NULL
   1          1 School  name=UCLA                       1 NULL NULL NULL

Download a zip file of all examples and a SQL script file that creates their input tables.