Re: [xml] "Proper" way to use XML (not library specific)





-----Original Message-----
From: Rush Manbert [mailto:rush manbert com] 
Sent: Wednesday, February 14, 2007 4:50 PM
To: Will Sappington
Cc: John Dennis; xml gnome org
Subject: Re: [xml] "Proper" way to use XML (not library specific)

<snip>

I think your original post mentioned some difficulty due to 
unfamiliarity with XPath. Here's a very good tutorial site that helped 
me learn to use XSLT:
http://www.zvon.org/index.php?nav_id=tutorials&mime=html

Best regards,
Rush

Thanks for this info, Rush, I'll check it out.  The difficulty I was
having was not with XPath itself, but rather how to implement this
particular solution with the Xalan/Xerces libraries.  I really would
rather be using libxml, but the decision was more or less made for me.

The difficulty was that the DOM instance is bound to an instance of
another object, a "parser liaison" such that when the parser liaison
goes out of scope, it takes the DOM with it and both are destroyed.  The
example code I was looking at built the DOM and did the XPath queries
all in one function, but what I needed to do with the Profile class was
open the file and parse/build the DOM in one method - open() - and then
do the XPath queries in another method - getItem().  The problem with it
is that the parser gets instantiated in the open() call and then goes
out of scope when open() returns.  The parser could not be instantiated
as member data, as the DOM pointer could, because it does things in the
default constructor that fail if the X library initialize() methods
haven't been called first.  

What I ended up doing was using a static member function in the Profile
class to call the initialize() methods, then instantiate the Profile
object via 'new' and return a pointer to it.  Now when the parser
instantiates as member data, the X libraries are initialized and
everyone is happy.

Thank you all very much for your thoughts and for the help you've given
me.

Best,

-will



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]