Segfault-Inc / Multicorn

Data Access Library
https://multicorn.org/
PostgreSQL License
700 stars 145 forks source link

Support xml as a column type for XMLFdw #114

Open jeffjanes opened 9 years ago

jeffjanes commented 9 years ago

If a create foreign table with type xml, is it possible to get the full child xml tree, not just the text from the tree?

create server xmlfdw foreign data wrapper multicorn options (wrapper 'multicorn.xmlfdw.XMLFdw');
create foreign table xml_test ("thing1" text, "thing2" xml) server xmlfdw 
    options (filename '/tmp/test.xml', elem_tag 'child');

And if /tmp/text.xml is

<root>
  <child>
    <thing1>foo</thing1>
    <thing2><leaf1>leaf1</leaf1><leaf2>leaf2</leaf2></thing2>
  </child>
  <child>
    <thing1>bar</thing1>
    <thing2><leaf1>bar_leaf1</leaf1><leaf2>bar_leaf2</leaf2><leaf3>bar_leaf3</leaf3></thing2>
  </child>
</root>

Because thing2 is defined to be of type xml, I'd like it to return the xml fragment, rather than just a concatenation of all the textual contents as it does now.

Bengreen commented 8 years ago

i have been looking at something a bit similar and found XQuery. Using XQuery syntax you can create all the logic to search, parse and modify the XML to return just the contents as you want it and to restructure it on the fly to the formats you need on output.

I am considering to use it to build an XML FDW based on BaseX as the target engine to hold the XML.