Sounds like you should just go with the XNodeSet derivation.  Take a look
at XalanTransformer/XalanParsedSource.hpp for an idea of how you can do
this.  You could just use that class if you don't mind the dependency.  The
XNodeSetBase-derived class can own the instance and delete itself and the
XalanParsedSource instance when it dies.  See XSLT/XResultTreeFrag.hpp for
an example of a class that kills itself when it's dereferenced.

You could just use XResultTreeFrag, but you probably want a node-set for
greater flexibility.

Dave



                                                                                       
                                               
                      "Brian Quinlan"                                                  
                                               
                      <brian@sweetapp.         To:      <[EMAIL PROTECTED]>     
                                               
                      com>                     cc:      (bcc: David N 
Bertoni/Cambridge/IBM)                                          
                                               Subject: RE: Returning new nodes from 
extension function                               
                      04/18/2002 08:23                                                 
                                               
                      PM                                                               
                                               
                      Please respond                                                   
                                               
                      to xalan-dev                                                     
                                               
                                                                                       
                                               
                                                                                       
                                               



> Can't you just load this document using the document() function?

No. The document is dynamically generated in a different process.

> You can't use Xerces to parse a fragment, so it has to be a full
document
> anyway.
> You could do this by installing an EntityResolver and looking for
"magic"
> URLs passed to the parser.  Process the ones you want to in any
special
> way, and defer the others to the parser.
>
> Or is your intent to parse dynamic XML based on the argument to the
> function.  For example, is it a string you're trying to parse?

Yes. Based on a string that is generated as part of the XSLT
transformation, the extension function needs to trigger an external
process that will return XML elements as a string. I want to convert
those elements into a NodeSet for processing.

Since the external process is returning elements, I can create a full
document easily just by wrapping them in a garbage element.

> Can you give a more detailed description of the source of the data?

I don't really know much about the source of the data. Is what I've told
you sufficient?

> It's
> certainly possible to sub-class XNodeSetBase and put everything in it
that
> you need to do this.  The run-time will keep the variable reference-
> counted until it goes out of scope, at which point you can have the
> object delete itself when its reference count goes to 0.
> However, it wouldn't persist until then end of the transformation in
> that case.


That's fine. I didn't know about the reference counting. I just wanted
to make sure that my generated nodes got deleted at some point.

Cheers,
Brian






Reply via email to