On 03/17/2011 11:18 AM, Hussein Shafie wrote:
This wouldn't be useful because a newly inserted element would get its
automatic ID as soon as the document is validated/saved. (Something
like "???" would be of course automatically replaced.)
In a nutshell, we can guarantee that with such validateHook, after a
document is validated/saved, each element would have its own, unique,
automatic ID matching exactly the text pattern you want.
Such validateHook is quite easy to write in Java.
References:
* http://www.xmlmind.com/xmleditor/_distrib/doc/configure/validateHook.html
* http://www.xmlmind.com/xmleditor/_distrib/doc/dev/validatehook.html
Dear M. Shafie,
The ValidateHook mechanism is really easy to develop & deploy. Ours is
rather simple, just fixing bad IDs, excerpt:
*if( element.hasAttribute(ID) ) {
String idstring = element.getAttribute(ID) ;
if( idstring == null || !XMLText.isNCName(idstring) ) {
element.putAttribute(ID,generateID());
}
}
*This works fine, except under one circumstance: newly created elements
are not fixed and keep their bad ID.
If we run the validator a second time (e.g. from XMLMind), their ID is
fixed.
If we create several new elements, then the ValidateHook fails to fix
them all the first time it is ran, and fixes them all (as expected) the
second time it is ran.
Are newly created elements supposed to be traversed by the ValidateHook
mechanism, or did we do something wrong ?
Many thanks for your help,
Philippe.
--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support