Hi,

> Is there any API that will let me insert an element at the right spot > based on the order dictated by DTD?
>
> Without such APIs, if some user asks me to insert servlet-mapping,
> then I will have to search for any existing servlet-mapping and insert
> after them. If there are no servlet-mapping, then search if there are > any servlet then insert after them, If no servlets ..., you get then
> idea.


Well actually your problem is not that simple since the insertion point
is not necessarely defined in a unique way by the DTD.The DTD can tell
you if the insertion point you choosed is valid, but in the reverse way
a DTD might be ambigous. Imagine simply adding a <table> element using
an HTML DTD, since <table> may contain other <table> how could the DTD
help you ?. In other word DTD (and any XML schema) do not give a
one way relationship between elements and elements positions, therefore it is not really possible to produce a general algorithm for providing the service you are asking. However it is possible to work this out
for a specific non ambigous DTD, but this will remain a DTD specific code. You may also imagine a more general code that warns you if the DTD
were it applies is ambigous and therefore not suitable. This kind of
functionnality will cover a very small set of DTD (i.e. the DTDs where
each element may appear only at one place and once in a document).

Without using DTD you could still use XPath to speed up looking for your insertion point


For general XML update API, you may be interested by looking at :

http://www.xmldb.org/xupdate/

Sincerely,

Thierry


-----------------------------------------------------------------------
IXELIS - Systèmes d'Information Sémantique

http://www.ixelis.com

17 rue des Cèdres, F67200 STRASBOURG (France)

Tél : +33 (0)3 88 27 81 39 Portable : 06 30 07 65 73
E-mail : [EMAIL PROTECTED] Fax : +33 (0)3 88 27 81 39
-----------------------------------------------------------------------



-------------------------------------------------------
This SF.NET email is sponsored by: Thawte.com
Understand how to protect your customers personal information by implementing
SSL on your Apache Web Server. Click here to get our FREE Thawte Apache Guide: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0029en
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to