It's a bug and it still exists in Xerces 2.7.1. While executing 
Document.normalizeDocument(), the DOM normalizer receives default 
attributes from the validator and adds them to the DOM using an internal 
insert method which doesn't notify event listeners about the insert. There 
appear to be some other problems with this method, including the one you 
reported in your next post to the list [1]. Will take a look at it when I 
find some time.

If you move up to Xerces 2.7, you do have another option. Xerces now 
implements the JAXP 1.3 Validation API [2]. If you validate a DOM using a 
JAXP Validator (specifying both the source and the result as the same 
node) your event listener will receive events for the defaulted 
attributes.

Thanks.

[1] http://marc.theaimsgroup.com/?l=xerces-j-dev&m=113043971008576&w=2
[2] 
http://xml.apache.org/xerces2-j/javadocs/api/javax/xml/validation/package-summary.html

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

Dick <[EMAIL PROTECTED]> wrote on 10/26/2005 05:54:09 PM:

> Please see my original question I had a month ago.
> I added Eventlisteners to the Document (at the level of DocumentNode) 
> for all kind of MuationEvents.
> For all my updates/inserts/removes this works as suspected.
> But my original problem still exists. When I do a validation of the 
> document I don't get MutationEvents of attributes that are inserted by 
> the validator. (May be I do not get any mutationEvents at all during 
> valiadtion, but I am not sure of this and I did not tested that)
> For example:
> I have in instance document personal.xml
> Before validation the person element looks like:
> 
>    <person id="Big.Boss" >
>      <name><family>Boss</family> <given>Big</given></name>
>      <email>[EMAIL PROTECTED]</email>
>      <link subordinates="one.worker two.worker three.worker four.worker 
> five.worker"/>
>    </person>
> 
> After validation a "contr" attributes is added, without coming in to 
> the EventListener.
> <person contr="false" id="Big.Boss">
>      <name><family>Boss</family> <given>Big</given></name>
>      <email>[EMAIL PROTECTED]</email>
>      <link subordinates="one.worker two.worker three.worker four.worker 
> five.worker"/>
>   </person>
> 
> Here a part of the personal.xsd
> <xs:element name="person">
>    <xs:complexType>
>     <xs:sequence>
>       <xs:element ref="name"/>
>       <xs:element ref="email" minOccurs='0' maxOccurs='unbounded'/>
>       <xs:element ref="url"   minOccurs='0' maxOccurs='unbounded'/>
>       <xs:element ref="link"  minOccurs='0' maxOccurs='1'/>
>     </xs:sequence>
>     <xs:attribute name="id"  type="xs:ID" use='required'/>
>     <xs:attribute name="note" type="xs:string"/>
>     <xs:attribute name="contr" default="false">
>      <xs:simpleType>
>       <xs:restriction base = "xs:string">
>         <xs:enumeration value="true"/>
>         <xs:enumeration value="false"/>
>       </xs:restriction>
>      </xs:simpleType>
>     </xs:attribute>
>     <xs:attribute name="salary" type="xs:integer"/>
>    </xs:complexType>
>   </xs:element>
> 
> So my question is:
> Is this a bug or am I doing something wrong?
> I really need the notifcation of the added attribute,, otherwise my 
> JTree becomes corrupt.
> 
> Dick Deneer
> DonkeyDevelopment.com
> 
> 
> -----Oorspronkelijk bericht-----
> Van: Michael Glavassevich [ mailto:[EMAIL PROTECTED]
> Verzonden: donderdag 29 september 2005 19:16
> Aan: [email protected]
> Onderwerp: Re: Notification of Document changes during validation
> 
> 
> The Xerces DOM implementation supports DOM Level 2 events [1][2],
> specifically Mutation Events [3] which notify an application of
> modifications/additions/removals made to the DOM. I believe that's what
> you're looking for.
> 
> [1] http://www.w3.org/TR/DOM-Level-2-Events/ [2] 
> http://xml.apache.org/xerces2-j/javadocs/api/org/w3c/dom/events/ 
> package- summary.html
> [3] 
> http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events- 
> eventgrouping s-mutationevents
> 
> <[EMAIL PROTECTED]> wrote on 09/28/2005 05:08:57 AM:
> 
>  > I'm using xerces dom3 (version 2.6.2) to validate a dom document.The
>  > document is displayed in a Jtree. The Jtree should always display the
>  > latest content of the document. Problem is that the document.
>  > normalizeDocument actually changes the content of the document (for
>  > instance it inserts required attributes with fixed values). I don't
>  > want to reload the whole Jtree. I am using an errorHandler for
>  > notification of validation errors and will get an error when the
>  > parser detects a default required attributes that is not present, but
>  > how do I match this error with the attribute that is inserted? In
>  > general : how can I get a notification of Node changes, inserts (or
>  > removes) during the validation. DD 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to