Hello again Daniel, and all, Apologies in advance if this is too long, but this is about
as briefly as I can describe the issue clearly. The company I work for is standardizing on XML as the means
for representing various types of data, our configuration files being one of
them. We currently use what we call an application profile, just a
hierarchical structure of name/value pairs, organized in an application/section/item
hierarchy. The functional interface to the profile is 1) open(), which opens
the file and loads it into memory, 2) execute one or more getItem()’s to
pull out configuration items specified by application-name/section-name/item-name,
and 3) close() the profile. I’m new to XML, but based on a recommendation and my
own analysis after the fact, XPath seemed a reasonable way to replicate this
functionality in XML because it allows you to directly access specific elements.
I’ve had some trouble implementing this, mostly due to a lack of understanding
of the library that was chosen (Xalan/Xerces). In response to my
troubles, my manager is saying that the problem is with how I’m trying to
use XML, not with the library. He says XPath is not appropriate for this,
that I should “marshal” the entire XML file into a different form,
toss the DOM, and operate on the transformed data. I’ll put his
email to me, edited for brevity, below. But my question is, if XPath isn’t
appropriate for this, then what is it appropriate for? From the
perspective of a configuration utility, it certainly seems to be reasonable, if
not obvious for the interface to be such that the user can read specific
configuration items from the file in whatever order is desired, and XPath appears
to be designed to do specifically that with XML data. So why would it not
be an appropriate tool to use for migrating our existing name/value pairs (.ini
files) to XML? Many thanks in advance for any thoughts you might care to
share. -will (edited (snipped) comments mentioned above) The problem is with the way you want to
use the library. You have been working way too long with
things like configuration files where you read out the parameters as you need
them. Here is what you need to do:
What this is called is marshaling the
data. If you want, you could download an evaluation copy of an XML tool and it
would generate the code to do all that for you. This is the way most people use XML. You
need to learn to do it this way. The system reads the XML file one and only
one time. The code loads the data from the DOM tree then gets rid of the DOM
tree. |