XML-DBMS: Frequently asked questions
Version 2.0: What elements does XML-DBMS choose to process?
XML-DBMS processes mapped subtrees of the document. A mapped subtree is a subtree in which:
Each element in the subtree is mapped with a ClassMap, PropertyMap, or InlineMap.
Each attribute or PCDATA node is mapped with a PropertyMap.
Except for the root element of the subtree, all elements that are mapped with ClassMaps are also mapped with a RelatedClass element. This RelatedClass element is in the ClassMap or InlineMap element of their parent element.
An additional restriction is:
- The subtree must not have an ancestor that is mapped and to which it is not connected by mapped elements.
For example, suppose you have the following document and want to map the subtrees shown in bold (D, C/F-G/J, and E/I/L) to the database. (For simplicity, elements mapped to columns, attributes, and PCDATA are not shown.)
/ \ / \
D E F G
/ \ |
H I J
These would be mapped to three separate sets of tables:
- A single table (D)
- Four tables connected by primary/foreign keys (C, F, G, and J)
- Two tables connected by primary/foreign keys (E and L). Note there is no table corresponding to I.
To map the D subtree, you need the following elements in the map document:
- A ClassMap element for D
- PropertyMap elements for any mapped attributes, child elements, or PCDATA of D
To map the C/F-G/J subtree, you need the following elements in the map document:
- ClassMap elements for C, F, G, and J
- PropertyMap elements for any mapped attributes, child elements, or PCDATA of C, F, G, and J
- RelatedClass elements for F and G in the ClassMap for C
- A RelatedClass element for J in the ClassMap for G
To map the E/I/L subtree, you need the following elements in the map document. (The InlineMap element for I tells XML-DBMS to skip I but process L. For more information, click here.)
- ClassMap elements for E and L
- PropertyMap elements for any mapped attributes, child elements, or PCDATA of E and L
- An InlineMap element for I in the ClassMap for E
- A RelatedClass element for L in the InlineMap for I
Note, for example, that it is not possible to map the K/M subtree. This is because it has an ancestor (E) that is mapped and to which the K/M subtree is not connected by mapped elements. That is, there is an unmapped element (H) between the subtree and its mapped ancestor.
A note on processing
XML-DBMS processes an XML document by traversing the document hierarchy in depth-first, width-second order and processing the mapped subtrees it finds:
XML-DBMS starts at the root element and traverses the document until it finds an element mapped with a ClassMap. This marks the root of a mapped subtree.
XML-DBMS transfers data for this element and all of its mapped descendants. It stops on any unmapped branch. (This is why it cannot process mapped subtrees that are disconnected from mapped ancestors.)
After XML-DBMS has processed the entire mapped subtree, it goes back to the root of the mapped subtree, finds its next sibling, and starts processing again. If the root of the subtree has no sibling, XML-DBMS moves up a level and continues (and so on).
Back to the XML-DBMS FAQs