That sounds like a bug. SAXReader should be using the document factory you
set when it transforms the
org.w3c.Nodes to org.dom4j.Nodes. What do you think James?

Chuck Simpson
[EMAIL PROTECTED]


                                                                                       
                                                          
                    Vivek                                                              
                                                          
                    Sahasranaman         To:     [EMAIL PROTECTED]             
                                                          
                    <vivek@ffnet.        cc:                                           
                                                          
                    com>                 Subject:     Re: [dom4j-dev] Problem with 
UserData{Element,Attribute}                                   
                                                                                       
                                                          
                    01/18/02                                                           
                                                          
                    04:06 PM                                                           
                                                          
                                                                                       
                                                          
                                                                                       
                                                          




Hi Chuck :
  Yes I have done that. The documentFactory is however, not recorded in
the UserDataElement that is created (in the DOM representation of the XML)
So if you add an attribute to the DOM received from parsing (as you
suggest below), that does not add a UserDataAttribute but a
DefaultAttribute.


 I'm doing something like :
>             SAXReader reader = new SAXReader();
>             reader.setDocumentFactory(factory);
              Document doc = reader.read(xmlfile);
              doc.getRootElement().addAttribute("foo","fee"); <--

 the call marked <-- doesn't add a UserDataAttribute but a
DefaultAttribute, assuming the attribute doesn't exist in the xmlfile.

Thanks
Vivek

On Fri, 18 Jan 2002 [EMAIL PROTECTED] wrote:

>
> Vivek,
>
> If you are using Dom4j to get a SAX parser you can do the following:
>
>
>             SAXReader reader = new SAXReader();
>             reader.setDocumentFactory(factory);
>
> Where factory is a UserDataDocumentFactory. I know this works with Xerces
> and Crimson.
>
> Chuck Simpson
> [EMAIL PROTECTED]
>
>
> |--------+------------------------------------->
> |        |          Vivek Sahasranaman         |
> |        |          <[EMAIL PROTECTED]>          |
> |        |          Sent by:                   |
> |        |          [EMAIL PROTECTED]|
> |        |          eforge.net                 |
> |        |                                     |
> |        |                                     |
> |        |          01/18/02 01:55 PM          |
> |        |                                     |
> |--------+------------------------------------->
>   >
--------------------------------------------------------------------------------------------------------------|

>   |
|
>   |       To:     [EMAIL PROTECTED]
|
>   |       cc:     [EMAIL PROTECTED]
|
>   |       Subject:     Re: [dom4j-dev] Problem with
UserData{Element,Attribute}                                  |
>   >
--------------------------------------------------------------------------------------------------------------|

>
>
>
>
>
> Thanks for the reply. I'm trying to create new elements/attributes
*after*
> the DOM has been "parsed in", so I'm traversing to the element and
> calling addAttribute(..args..). At this time the element no longer
> remembers that its document factory is the UserDataDocumentFactory
without
> making the changes below. I just saw a similar mail on the archive by
> someone who was trying to do the same thing on org.w3c.DOM Elements, so
> maybe this problem is more generic than I thought.
>
>
>
https://sourceforge.net/mailarchive/forum.php?thread_id=98464&forum_id=2702
>
> Thanks
> Vivek
>
> On Fri, 18 Jan 2002 [EMAIL PROTECTED] wrote:
>
> >
> > You can use the UserDataDocumentFactory like this?
> >
> > DocumentFactory factory = UserDataDocumentFactory().getInstance();
> >
> > Create your document using the factory and it should return
> > UserDataElements and UserDataAttributes.
> > Hope this helps.
> >
> > Chuck Simpson
> > [EMAIL PROTECTED]
> >
> >
> > |--------+------------------------------------->
> > |        |          Vivek Sahasranaman         |
> > |        |          <[EMAIL PROTECTED]>          |
> > |        |          Sent by:                   |
> > |        |          [EMAIL PROTECTED]|
> > |        |          eforge.net                 |
> > |        |                                     |
> > |        |                                     |
> > |        |          01/18/02 01:23 PM          |
> > |        |                                     |
> > |--------+------------------------------------->
> >   >
>
--------------------------------------------------------------------------------------------------------------|

>
> >   |
> |
> >   |       To:     [EMAIL PROTECTED]
> |
> >   |       cc:
> |
> >   |       Subject:     [dom4j-dev] Problem with
> UserData{Element,Attribute}                                      |
> >   >
>
--------------------------------------------------------------------------------------------------------------|
>
> >
> >
> >
> >
> >  Hi :
> >   I'm trying to use a Dom4J DOM adorned with User defined objects
> > (UserDataElement)
> >   I tried to add an attribute to a UserDataElement (org.dom4j.util)
> > after the DOM was created, and found that it added a "DefaultAttribute"
> > rather than a "UserDataAttribute". Upon looking a bit at the source
code,
> > seems like the "getDocumentFactory() method that UserDataElement
inherits
> > from DefaultElement should be overriden so that it can provide it's own
> > documentFactory. Can someone verify this is correct ? (Or do I have a
> > version that is old ?)
> >
> > Thanks a lot
> > Vivek
> >
> >
> > _______________________________________________
> > dom4j-dev mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/dom4j-dev
> >
> >
> >
> >
> >
> >
>
>
> _______________________________________________
> dom4j-dev mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/dom4j-dev
>
>
>
>
>
>







_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to