[jdom-interest] XML variables

Laurent Bihanic laurent.bihanic at atosorigin.com
Tue Mar 5 04:38:10 PST 2002


Hi,

DTDs provide a mecanism that may suit you: ID and IDREF attributes.

An ID is an attribute of an element that is used to uniquely identify this 
element throughout the XML document. IDREFs can then be used to convey the 
value of one or several ID attributes, hence allowing one element to reference 
other elements.
Please note that this mecanism only supports referencing elements but not 
strings (attribute values, text...).

Of course for JDOM to be aware of ID and IDREF attributes, you need to attach 
a DTD to you documents. Once this done, the org.jdom.contrib.ids.IdFactory can 
help you to create documents supporting the method getElementById(String).

Laurent

craig r wrote:
> Hi, I'm using JDOM to access an XML document I have created.  In 
> this XML document I have would like to create a variable for a string 
> I use throughout the document rather than type it each time.  The 
> effect I would like to achieve is the same as that which is used 
> in ANT build.xml files where the xml element "property" has a name 
> and a value.  Thereafter the property is referred as "${name}".  
> How is this acheived and can are there any "shortcuts" to doing so 
> using JDOM?  XML does not provide for a way to create variables like 
> this does it?  Or is it entirely up to the code that interprets the 
> XML to flag such "property" elements and create the variables?
> 
> Thanks for any pointers,
> 
> Craig R.




More information about the jdom-interest mailing list