The leveraging XDB post (here) from a few years ago is one of the most actively read posts, since that was done there have been a few more updates on the expert posted within it. One of the updated areas was in the generation of XML using the Oracle Database using the expert., the areas include supporting generated a single document vs multiple documents and the ability to include/exclude attributes from the content, plus whether to create the attributes as XML properties or XML elements.
A recent query was regarding how the ‘Create XML from objects’ menu option gets created. This is added just by enabling the expert on the ‘Tables’ node in the tree, here we see the sequence of actions to do this in OWB 11gR2, you must first import the expert’s MDL, then add the expert to the tree as follows.
First right click on Tables node and select ‘Maintain Creation Experts Here' (you can add any of your own custom experts to parts of the tree also);
Then in the XML_ETL folder within public experts, enable the CREATE_XML_FROM_OBJECTS expert;
That’s it! Now you can run the expert from the tree. For example now click on the Tables node, you will see the ‘Create XML from objects’ option.
This then runs the expert, the dialog was enhanced to include a ‘Generate Root’ option – this was added so that all generated XML fragments are wrapped in a single element rather than created as XML documents. Using this lets you generate one document like;
rather than multiple documents like (where Department is the route node);
So let’s select ‘Generate Root’ and see how it works….
As before we get to enter the name of the pluggable map that gets generated.
We then choose the tables for or document, and order the master to the detail, we will have departments and the employees nested inside the department;
We then can define the element name for the root (because we selected generate root), and the dept and emp tables.
For each table we can then define the XML element/attribute names for the columns also, we can also define whether to exclude attributes, or define an element name for the attribute rather than a property name.
For the EMP XML element details we will exclude the foreign key column DEPTNO, and provide nice business names for the properties.
After this, the pluggable mapping is generated. We can use the table function from the earlier post and the pluggable mapping to write the XML to file, for example we generate the following from the SCOTT schema.
Fairly simple example of leveraging the database along with experts to generate based on some basic inputs from the guided expert.