Philippe Nobili wrote:
>  On 03/14/2011 10:46 AM, Hussein Shafie wrote:
>> Philippe Nobili wrote:
>>>
>>> Something completely different related to ID-generation; in our XML
>>> dialect, all elements need to be uniquely identified by XML IDs; these
>>> IDs are used internally, so we want to avoid at all price our authors to
>>> bother about them.
>>>
>>> So, we added the *generateIds="true"* property to the 
>>> *newElementContent*  element in our .xxe file. And this works fine. We
>>> have a couple of additional questions to definitely improve ID's
>>> management for our XXE plugin:
>>>
>>> 1)* [minor]* Is there a way to control how these IDs are generated ?
>>> (e.g. providing a common prefix or so)
>>>
>>> 2) *[important]* If we write templates for some elements, is there a way
>>> to add automatically generated IDs in the generated elements, i.e. a
>>> kind of equivalent to the XSL "*generate-id(.)*" function call ?   So
>>> far all we could do is assign erroneous IDs, e.g. id="???" to the new
>>> elements (so, we removed the use of templates since we cannot end-up
>>> with invalid files).
>>>
>>> 3) *[vital] *The copy/paste feature of XXE is really great; is there is
>>> a way to "override" (this is probably a wrong terminology) it to force
>>> IDs of new elements to be re-generated ? (otherwise we end-up with
>>> duplcate IDs which has very bad consequences in our case).   What we had
>>> in mind is a mechanism which would allow us to automatically change
>>> copied elements.
>>>
>> We have nothing against improving the automatic generation of IDs. But
>> let me ask you a question first. Given the fact that all elements
>> eventually have unique, automatically generated IDs, is it really
>> important for an author to have access to these IDs, immediately, in
>> real time. I mean, the author inserts a new element and must be
>> immediately be able to use its unique, automatically generated ID, to
>> create a cross-reference for example.
>>
>> If the answer is no, then a validateHook can automatically generate
>> automatic IDs and also can automatically fix duplicate IDs.
> Thanks for your reply; the answer is 'no' in our case, because the IDs
> are used internally only, the authors are never aware that there are IDs.
> 
> We do use IDs to cross-reference elements, but it's for internal
> processing use, it shall not be a user's concern either. So clearly, we
> do not want authors to bother about IDs or manage IDs in any way... Even
> if they will see the IDs in the default attribute panels, they won't
> dare to edit them if they are not told to do so...
> 
> We understand that we can use a *validateHook* to fix missing/duplicate
> IDs; is there a way to run something equivalent on newly created
> elements only (a 'createHook'...) ?
> 

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



 
--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to