Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Writing to XML through XOM APIs

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • To: Ravi Nathwani <ravinathwani AT yahoo.com>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Writing to XML through XOM APIs
  • Date: Fri, 23 Jan 2004 09:54:49 -0500

At 3:45 AM -0800 1/23/04, Ravi Nathwani wrote:

The nu.xom APIs for the ëElementí class does have a
getValue() method, but it does not have a setValue()
method.


That's because the value does not have a unique representation in XML. In other words, any given child element has exactly one value, but there are many different child elements with that one value. For instance, consider the value "Hello Ravi". This could be

<child>Hello Ravi</child>
<child>Hello <name>Ravi</name></child>
<child><word>Hello</word> <word>Ravi</word></child>
<child><message><word>Hello</word> <word>Ravi</word></message></child>

Therefore you have to be more explicit about what you want to put in the element rather than just providing the value. The value is a computed property, not a fundamental one.

If you're starting with an empty element and you only want to put text in it, you just need to say child.appendChild("Hello Ravi"). If the element is not empty you may need to remove some content first.

--

Elliotte Rusty Harold
elharo AT metalab.unc.edu
Effective XML (Addison-Wesley, 2003)
http://www.cafeconleche.org/books/effectivexml
http://www.amazon.com/exec/obidos/ISBN%3D0321150406/ref%3Dnosim/cafeaulaitA




Archive powered by MHonArc 2.6.24.

Top of Page