Hi Guys
I understand your reservations Dane; we should be careful about adding every
kind of helper feature to dom4j and bloating it. Its funny quite a few
people have asked for such a thing over the years, a quick way to add a
section of static XML to a document.
You can do this right now today...
Document document = DocumentHelper.parseText(
"<node1 name='hello'><node2/></node1>"
);
element.add( document.getRootElement().detach() );
Its not quite as simple as Silvain's idea but it does work..
It might be nice to wrap this up in a new helper method like this...
DocumentHelper.addXml( element, "<node1 name='hello'><node2/></node1>" );
I'll think about it a bit more but I'm quite tempted, it looks good. Its one
extra helper method, not very much code but offers a nice and easy way to
add a small block of XML to any branch (element or document).
Thoughts?
James
----- Original Message -----
From: "Dane Foster" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Silvain Piree" <[EMAIL PROTECTED]>
Sent: Friday, November 02, 2001 6:51 PM
Subject: Re: [dom4j-user] adding XML in Java
> Silvain>If it were possible to use the XML syntax in Java, then I would
> have the best of two worlds! It would be great if we could write
> code like:
>
> myElement.addXml("<node1 name='hello'><node2/></node1>");
>
> The xml code would be parsed, and added as child elements to myElement.
>
> Is this already possible? Would it be difficult to implement?
>
>
> Me>Can I vote on this or do I have to be on the developer's list? If I
can
> I vote NO, if I can't let me know so I can join the developers list.
>
> The functionality mentioned is something Silvain can build as his own
layer
> above dom4j. Its not that hard to implement. Off the top of my head; for
> each XML string fragment create a dom4j object via SAX -> get access to
the
> root node -> detach it from the current dom -> append it to its new
parent.
> The solution is certainly not very efficient but can work (ignoring
> potential namespace issues of course).
>
> Dane Foster
> Equity Technology Group, Inc
> http://www.equitytg.com.
> 954.360.9800
> ----- Original Message -----
> From: "Silvain Piree" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, November 02, 2001 12:39 PM
> Subject: [dom4j-user] adding XML in Java
>
>
>
> Hi,
>
> I switched from XSL to DOM4J/Java because the XSL scripts were
> becoming too complex. It's a lot easier to build the transformation logic
> in Java!
>
> But .... now I have another problem: I have to write a lot of
> addElement/addAttribute calls to build XML nodes, whereas
> in XSL I could use XML syntax.
>
> If it were possible to use the XML syntax in Java, then I would
> have the best of two worlds! It would be great if we could write
> code like:
>
> myElement.addXml("<node1 name='hello'><node2/></node1>");
>
> The xml code would be parsed, and added as child elements to myElement.
>
> Is this already possible? Would it be difficult to implement?
>
> Silvain
>
>
>
> _______________________________________________
> dom4j-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
>
>
>
> _______________________________________________
> dom4j-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user