Hello - again - Lisa.
Now that I have addressed the design issue, I would also like to offer some help with the practical issues of the schema and instance that you posted.
I suspect that you already know that the document will not/cannot be stored into the schema because of the differing root nodes.
(Tamino will store a document into the doctype defined for the document’s root node. In the document the root node is “book_directory”, but the schema defines the root node for “tree”.)
One approach that you could take is to use an “Open Content” schema in Tamino. As long as the root node (book_directory) is defined, you will be able to store any XML content inside that.
The drawback of this is that you can only define indexes on nodes that are defined in the schema. If only the root node is defined, you would not be able to create an index on (for example) “first_directory”.
This can be addressed to a certain extent by defining “enough” structure in the schema to allow the creation of the necessary indexes.
It is also possible to use xs:any elements in the schema to allow non-defined XML to be stored at that position in the tree.
Tamino can only validate incoming documents against the schema that is defined though, and the less that is defined, the less Tamino will have to validate against…
In order to store your document, I have changed it (a lot), and changed the schema (a little).
With the attached schema it is possible to store documents like this:
<directory level="root">
<selfnodename>Book Directory</selfnodename>
<directory level="first">
<selfnodename>computer book</selfnodename>
<directory level="second">
<selfnodename> databases </selfnodename>
<directory level="third">
<selfnodename>Native XML</selfnodename>
<leafnode>Tamino</leaafnode>
</directory>
<directory level="third">
<selfnodename>Relational</selfnodename>
<leafnode> oracle </leafnode>
<leafnode> sql server 2000 </leafnode>
<leafnode> db2 </leafnode>
</directory>
</directory>
<directory level="second">
<selfnodename> programe language </selfnodename>
<directory level="third">
<selfnodename>Java</selfnodename>
<leafnode>Java 1.0</leafnode>
<leafnode>Java 1.1</leafnode>
<leafnode>Java 1.2</leafnode>
<leafnode>Java 1.3.1</leafnode>
<leafnode>Java 1.4.1</leafnode>
<leafnode>Java 1.4.2</leafnode>
</directory>
<leafnode> c++ </leafnode>
</directory>
<leafnode> hardware book </leafnode>
</directory>
</directory>
You can then execute XPath queries like:
//directory[@level=“second”]
or
/directory/directory/directory
to find all the second level directories.
Greetings,
Trevor.
tfo_treetest.tsd (1.19 KB)
#webMethods#Tamino#API-Management