On 03/18/2011 01:19 PM, Hussein Shafie wrote:
> Philippe Nobili wrote:
>> 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 is just the obvious part, but there is another part which
> integrates the above snippet to XXE.
Indeed... This was to illustrate what changes we want to make to the 
document... Integration with XXE works OK, and the code of the 
validation hook itself looks OK to me.
> Such validators are automatically invoked when you use Tools|Validate or
> File|Open and/or File|Save.
Yes, that's exactly what we want.
>> 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.
> I don't see how this could be possible. Once attached to the document
> tree, there is no difference between newly created elements and other
> elements.
Actually, there is a subtlety here... the validate hook runs after the 
standard validation code I guess...

So we fixed some of the issues in our validation hook (e.g. bad IDs), 
but only after the standard validation code has ran. Therefore, the 
valdiation diagnostics (e.g, 'Invalid IDs') and the document itself are 
not in sync. since the second validation pass (i.e. our "hook") has 
fixed the problems...

That's why we got the impression that we had to run it twice... We had 
to run it twice, but just to get the right messages, the document itself 
was OK after the first pass.

I don't know if this is clear ?
Best regards.
Philippe.

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

Reply via email to