You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by "Abram-Profeta, Emmanuel" <ab...@amazon.com> on 2003/04/23 21:38:57 UTC

Best way to create a XalanNode inside an extension function

Hi,

 

I looked at the extensionFunction sample in Xalan 1.4 and 1.5 and I am trying to come up with a function that builds new elements dynamically. 

 

Background: The examples shown deal with string/number like results (e.g., sqrt, cube, etc). For instance (sorry for the tabs...)

 

virtual XObjectPtr

            execute(

                        XPathExecutionContext&                                    executionContext,

                        XalanNode*                                                                    context,

                        const XObjectArgVectorType&                args,

            const LocatorType*                                            locator) const

            {

 

....

 

                        return executionContext.getXObjectFactory().createNumber(sqrt(args[0]->num()));

            }

 

So far, I've been able to do the same thing and use the executionContext.getXObjectFactory().createNodeSet() function to return XalanNode* pointers belonging to XalanDocument objects output by a transform or created from a xerces DOM using the XercesDOMParserLiaison. 

 

However, what I'd like to do is manually create a XalanNode* that would be an XML element with embedded elements within; The difference here is that I am not reusing pointers to locations of existing documents. I'm aware that it may sound like a trivial question but after experimenting with the XalanDOM and the XalanSourceTree classes, I noticed that there's still a lot of functionality that remains to be implemented. (Hence my questions.)

 

One trivial way I thought of was to just create a string containing the XML I need and parse it inside the extension function. But I'm sure there's a smarter and better way to just say "create this XalanNode with this name, append this node set, etc.".

 

Thanks in advance for any help,

 

Emmanuel