Hi Dave, (sorry for the top-posting but OutHouse doesn't maintain the
threading on emails very well so bottom-posting doesn't work very well.)

I just got back to this and I'm having trouble implementing it.  I moved
the XalanSourceTreeInit and XalanSourceTreeParserLiaison instances to
the private member data of the class and put the appropriate includes
and "XALAN_USING_XALAN" statements at the top.  These are the 4
instances of Xalan member data:

XalanDocument* _pXmlDoc;        ///< ptr to the Xalan DOM document
XalanSourceTreeDOMSupport   _DomSupport;

// Initialize the XalanSourceTree subsystem...
XalanSourceTreeInit     theSourceTreeInit;
XalanSourceTreeParserLiaison    theLiaison(_DomSupport);

  The compiler gives an error on the XalanSourceTreeParserLiaison
declaration, specifically on the symbol _DomSupport.  I'm not sure why
this construction works inside as local function data and not as member
data, but regardless, I looked up the XalanSourceTreeParserLiaison API
for a different constructor and saw that this form has been deprecated.
It now suggests the form that takes only a memory manager reference
(defaulted to XALAN_DEFAULT_MEMMGR).  I looked for a corresponding
setter to set the DOMSupport instance but couldn't find one.  What am I
missing here?  Thanks in advance for any help.

-will

-----Original Message-----
From: David Bertoni [mailto:[EMAIL PROTECTED] 
Sent: Monday, February 12, 2007 1:50 AM
To: xalan-c-users@xml.apache.org
Subject: Re: Problem evaluating XPath expressions

Will Sappington wrote:
> Hello all,
> 
>  
> 
> I'm writing a configuration utility that we call an "application 
> profile" or simply profile, that is essentially an ini file on 
> steroids.  It's a hierarchical structure - application/section/item - 
> that allows multiple applications to use a single profile.  I'm 
> migrating it from "key = value" format to XML and I'm using
Xalan/Xerces 
> for evaluating XPath expressions to retrieve the configuration items.
>

...

> 
> XalanDocumentPrefixResolver     thePrefixResolver(_pXmlDoc);
> 
>  
> 
> where _pXmlDoc is in the Profile class private member data
>

 From looking at your code, I suspect the _pXmlDoc data member is
pointing 
to an instance that's already been destroyed.

Here's what the comments for XMLParserLiason::parseXMLStream() say:

/**
  * Parse the text pointed at by the reader as XML, and return a DOM
  * Document interface.  It is recommended that you pass in some sort of
  * recognizable name, such as the filename or URI, with which the
reader
  * can be recognized if the parse fails.
  *
  * The liaison owns the XalanDocument instance, and will delete it when
  * when asked (see DestroyDocument()), or when the liaison is reset, or
  * goes out of scope.
  */

So, the instance you created is destroyed when the 
XalanSourceTreeParserLiaison instance is destroyed in
Profile::_openXmlDoc().

In general, Xalan-C implements very tightly controlled ownership of 
objects.  The easiest way for you to handle this is to make the 
XalanSourceTreeParserLiason instance a member of your class.

Dave

Reply via email to