[jdom-interest] Element Reference from Attribute
Elliotte Rusty Harold
elharo at metalab.unc.edu
Mon Nov 20 04:50:02 PST 2000
At 10:10 AM -0800 11/19/00, Jason Hunter wrote:
>> 1. Everything needs to know its parent. I don't really care if that
>> adds 4 bytes to each object.
>
>This would make moving objects more consistent as well, since it would
>be easy to detect if the same object existed at two points in a tree and
>disallow that add. The downsides I see are 4 extra bytes per object,
>and extra processing to manage parents.
>
>Can you give the XInclude use case for where knowing the parent helps?
>
XInclude replaces certain <include> elements with other elements or
with strings or with lists of strings and elements. To process a file
I recursively descend the tree. Every time I encounter an include
element, I replace that element in its *parent* element with a
different node or nodes.
This problem is hardly insurmountable with the current design.
However, the solution is less natural than one that allows me to back
up the tree using getParent() when I encounter an include element.
Paul Prescod initially pointed out to me that anything involving
XPath (including XSLT and XPointer, and possibly XML Query Languages)
is going to have similar problems. Not all XPaths begin at the root.
Some begin at the context node. If the context node is simply a JDOM
object, then to implement XPath we'd like to get the parent, short of
searching the entire tree.
--
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| The XML Bible (IDG Books, 1999) |
| http://metalab.unc.edu/xml/books/bible/ |
| http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/ |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://metalab.unc.edu/javafaq/ |
| Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/ |
+----------------------------------+---------------------------------+
More information about the jdom-interest
mailing list