XMLParser Example: ErrorHandler | Teradata Vantage - XMLParser Example: ErrorHandler - 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ā„¢

Input

The second XML document is missing the closing tag </bookstore>.

xml_inputs_error
xid xmldocument
1 <bookstore owner="Judy">

: <owner>Billy</owner><items>

: <bookitem category="ASTRONOMY">

: <title lang="en">Cosmos</title>

: <author>Carl Sagan</author>

: <author>Ann Druyan</author>

: <year edition="1">1980</year>

: <price>

: <member>49.99</member>

: <public>60.00</public>

: </price>

: </bookitem>

: </items>

</bookstore>

2 <bookstore>

SQL Call

SELECT * FROM XMLParser (
  ON xml_inputs_error
  USING
  TextColumn ('xmldocument')
  Nodes ('bookstore/owner','bookitem/title','bookitem/author')
  ErrorHandler ('true;xmldocument')
  Accumulate ('xid')
) AS dt ;

Output

The output table has the column ERROR_HANDLER, which contains the value of the input column xmldocument followed by a semicolon.

 xid out_nodeid out_parent_node owner title author                errorhandler 
 --- ---------- --------------- ----- ------ --------------------- ------------ 
   1          1 bookstore       Billy                              NULL        
   1          2 bookitem              Cosmos Carl Sagan,Ann Druyan NULL        
   2       NULL NULL            NULL  NULL   NULL                  <bookstore>;

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