hello everyone, can you help me?
I want to define a tree structure with the schema,
This tree is arbitrary:
At first,the depth of this tree isn’t unknow, either the number of children node in one node.
And each node have different children node and leaf node (may be the node have the children node as well as leaf children node ,may be the parent have either children node or leaf children node).
An intrances of this tree is describe as follow(see the attach file directory_tree.xml):
I define this tree schema is as follow(see the attach file treetest.TSD), using the recursion idea, but i think there are some problems in this schema, at least,it isn’t optimum define.how can i difine this tree optimun.
[This message was edited by lisa on 30 Apr 2003 at 07:28.]
directory_tree.xml (889 Bytes)
I can’t upload two attach files at the same time,
the treetest.TSD attach file is here
treetest.TSD (1.09 KB)
Hello Lisa,
I’m sorry, but I am not sure whether you would like some specific help with defining the treetest.TSD schema to store the directory_tree.xml document, or some general help with designing the schema in the first place?
I feel certain that we can help you define the schema that you need, but I am a little uncomfortable with the schema design at the moment.
The reason for this may be my personal taste, but I would recommend against a “document is the database” approach when using a database.
In your treetest schema, it looks like you plan to store all the information about the directories into a single document. (Hence “document is the database”.)
If you are using a database, it is probably better to model at a lower level - that is, store individual directory information (or even individual books) in individual documents.
(The reasons for this are the usual: if you put all the information into a single document, this becomes a bottle-neck when multiple users want to update the document. Maybe this is acceptable if users will only ever read, not update, but it is something to keep in mind.)
I would recommend having a look at the “Advanced Concepts” chapter in the Tamino documentation. This chapter explains topics such as Optimization far better than I can, and develops an on-going example throughout.
I hope that helps,
Trevor.
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)
Hello Trevor,
First , thank you very much ,Trevor.
Second, I will explain myself.
I am not very familiar with the product tomino, this is my first use it, and first design the schema.
In my mind, I also Hence “document is the database”. treetest.TSD is just one of schemas design. I also have other schemas, such as book_basic_inf.TSD ,book_detail_inf.TSD, and others.
I put all the information of the directory into a single document, Because those directories have been fixuped ,they won’t be update generally .Also all users only have read right. this book directory will be displayed in the frame of the web, then if a user click one of leafnode ,all the books(basci information) which belong to this leafnode will be displayed in another frame.
Trevor,thanks again ,
That is my want,i think it is optimal.
Can you help me solve another urgent question “the authentication question”:http://tamino.forums.softwareag.com/viewtopic.php?p=9686
Hello Lisa,
I have just posted a reply to “the authentication question”.
I hope it is helpful to you!
Greetings,
Trevor.