Hi All,
I am a new user of DOM4J.
Formerly I was using strictly DOM-Level 2 to manipulate XML object tree.
Decided to switch to DOM4J because DOM-level 2 offers no support for
managing external entities.
But now I am missing a DOM feature missing in DOM4J, namely the
DocumentFragment class.
Why is there no org.dom4j.DocumentFragment ? Is it because some other DOM4J
class offers equivalent functionality?
What I need is a class that represents the same thing as
org.w3c.dom.DocumentFragment, basicaly a set of nodes.
This is is very usefull when you work with external entities. Let me
explain with an example:
Consider the following XML document, stored in a file called company.xml :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE company SYSTEM Company.dtd>
<company>
<departmentSet>
<department>
<departmentId>123</departmentId>
<name>Accounting</name>
</department>
<department>
<departmentId>456</departmentId>
<name>Personnel</name>
</department>
</departmentSet>
</company>
Now lets say I want to store the list of departments in a seperate file
called departments.xml that looks like this :
<department>
<departmentId>123</departmentId>
<name>Accounting</name>
</department>
<department>
<departmentId>456</departmentId>
<name>Personnel</name>
</department>
To make this transparent to users of company.xml, I define an external
entity in company.xml :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE company SYSTEM Company.dtd [<!ENTITY departments SYSTEM
"departments.xml" >] >
<company>
<departmentSet>&departments;</departmentSet>
</company>
The parser that will parse company.xml will replace the entity reference
&departments; with the contents of document departments.xml
Now, what I need to achieve this programatically is a DOM4J object that
will represent my set of departments (set of Elements), but which is not in
itself an Element. This is what is it would look like:
Company.xml :: Document
|
+--- company :: Element
|
+--- departmentSet :: Element
|
+-- departments :: Entity
departments.xml :: DocumentFragment
|
+--- department :: Element
| |
| +--- departmentId :: Element
| | |
| | +--- 123 :: Text
| +--- name :: Element
| |
| +--- Accounting :: Text
|
+--- department :: Element
|
+--- departmentId :: Element
| |
| +--- 456 :: Text
+--- name :: Element
|
+--- Personnel :: Text
I am looking into implementing a org.dom4j.DocumentFragment interface that
would extend org.dom4j.Branch.
But maybe some of you experimented DOM4J users out there have a better idea
?
Thanx,
Luca
--
DISCLAIMER:
This e-mail contains proprietary information some or all of which may be
legally privileged. It is for the intended recipient only. If an addressing
or transmission error has misdirected this e-mail, please notify the author
by replying to this e-mail. If you are not the intended recipient you must
not use, disclose, distribute, copy, print, or rely on this e-mail.
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user