This issue may relate to a technique that I have been trying, but NOT part
of an extension function. I have been trying to avoid using SAX events with
XalanSourceTreeContentHandler. Rather, I was hoping I could have access to
the underlying XalanSourceTreeDocument returned from
XalanDefaultDocumentBuilder->getDocument(). No exceptions are thrown, but
XalanSourceTreeDocument->createNodeElement(...) doesn't output my data.
Here is the code:
AttributesImpl attrs;
XalanDOMString elemNm, attrNm, attrVal;
const XalanDOMString attrType("CDATA");
XalanDocumentBuilder* const docBldr =
theXalanTransformer.createDocumentBuilder();
if (docBldr)
{
XalanSourceTreeDocument * doc(static_cast <
XalanSourceTreeDocument * >
(docBldr->getDocument()));
if (doc)
{
std::cout << "have XalanSourceTreeDocument\n";
elemNm = "name1";
attrNm = "attr1Nm";
attrVal = "attr1Val";
attrs.addAttribute(c_wstr(attrNm), c_wstr(attrType),
c_wstr(attrVal));
attrNm = "attr2Nm";
attrVal = "attr2Val";
attrs.addAttribute(c_wstr(attrNm), c_wstr(attrType),
c_wstr(attrVal));
XalanSourceTreeElement *
element(doc->createElementNode(attrNm.c_str(),
attrs));
doc->appendChildNode(element);
}
}
Am I also misunderstanding the usage of these classes. I hope really hope
to have access to the underlying tree so that I can get attributes, values,
of an element to be used by its child elements.
Thanks!!!
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 11, 2001 9:30 AM
To: [email protected]
Subject: Re: createElement() inside external function segfaults
It's not a bug in Xalan, it's a bug in your application and your
understanding of XSLT.
You are not allowed to modify the source tree in any way, including
creating new nodes. The function you're calling is throwing an exception
which you're not catching. See the class XalanDOMException and the source
code for XalanSourceTreeDocument for more information on what's being
thrown.
Currently, there's no way in Xalan-C to create new nodes in an extension
function. We can certainly make something like that available, but it
wouldn't be through DOM APIs. Insteand, it would be through getting a SAX
handler and sending events. If this functionality is important to you,
then we should discuss the best way to implement this.
Dave
Edwin Pratomo
<[EMAIL PROTECTED] To:
[email protected]
.org> cc:
Sent by: Subject: createElement()
inside external function segfaults
[EMAIL PROTECTED]
m
12/11/2001 09:56
AM
Hi,
I tried to create new elements inside an external function, but
createElement() segfaults:
virtual XObjectPtr
execute(
XPathExecutionContext& executionContext,
XalanNode* context,
int /* opPos */,
const XObjectArgVectorType& args)
{
XalanDocument *doc = context->getOwnerDocument();
XalanElement *new_node = doc->createElement(XalanDOMString("foo"));
...
Is this a bug? any workaround?
rgds,
Edwin.
--
CPAN home: http://search.cpan.org/search?author=edpratomo