Xml2rel

Converts XML data to its relational equivalent.

Usage

xml2rel (indata, attr, substruct, tagattr : outdata)

Details

XML data stored in attribute attr of relation indata is converted into its relational form and then joined back with indata (i.e., a dependent join) to form outdata. During this process, only the XML data at the substructure level of substruct or below is used (see example). When joining data back to indata, tagattr becomes the name an attribute in outdata that contains the number associated with the order that the substructure instance appeared (this is because data in XML documents has order).

Notes

Known Bugs

Example

Using the input:
      RELATION document: xmltext char
      <?xml version="1.0"?> <orderitem> <customer>Joe</customer> <books> <book> <title>Title1</title> <author>Author1</author> </book> <book> <title>Title2</title> <author>Author2</author> <prices> <price>100</price> <price>200</price> </prices> </book> </books> </orderitem>
    
when executing the plan:
      PLAN test
      {
        INPUT: stream document
        OUTPUT: stream books
  
        BODY
        {
          xml2rel (document, "xmltext", "/orderitem/books", "grouping_ind" : books)
        }
      }
    
will generate the following output:
      ----------------------------------------------
      RELATION: uxml2rel1_books
         attrs: grouping_ind, xmltext, book_prices_price, book_title, book, book_prices, book_author
      ----------------------------------------------
      0|<?xml version="1.0"?> <orderitem> <customer>Joe</customer> <books> <book> <title>Title1</title> <author>Author1</author> </book> <book> <title>Title2</title><author>Author2</author> <prices> <price>100</price> <price>200</price> </prices> </book> </books> </orderitem>| |Title1|book#0| |Author1
      1|<?xml version="1.0"?> <orderitem> <customer>Joe</customer> <books> <book> <title>Title1</title> <author>Author1</author> </book> <book> <title>Title2</title><author>Author2</author> <prices> <price>100</price> <price>200</price> </prices> </book> </books> </orderitem>|100|Title2|book#2|prices#1|Author2
      2|<?xml version="1.0"?> <orderitem> <customer>Joe</customer> <books> <book> <title>Title1</title> <author>Author1</author> </book> <book> <title>Title2</title><author>Author2</author> <prices> <price>100</price> <price>200</price> </prices> </book> </books> </orderitem>|200|Title2|book#2|prices#1|Author2
      ----------------------------------------------