You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Arjen Haayman <ah...@hotmail.com> on 2004/03/03 10:00:32 UTC
How to write a Xalan extension function returning DocumentFragment
Hello,
I'm trying to write a Xalan extension function in Java that should return a
DocumentFragment.
So far however I've been unable to figure out how to construct a
DocumentFragment.
The only way I've found is Document.createDocumentFragment(), but how do I
get a document?
This is the best shot so far:
[snip]
public Object toSVG( ExpressionContext context)
{
Object retval;
try
{
Node node = context.getContextNode();
Document doc = node.getOwnerDocument();
DocumentFragment fragment =
doc.createDocumentFragment();
}
catch( DOMException e)
{
String error = Integer.toString( e.code);
Debug.Msg( 10, "error: " + error);
retval = error;
}
return( retval);
}
The result of this is that the createDocumentFragment throws a DOMException
where e.code == 9.
I gather this means "Unimplemented".
_________________________________________________________________
MSN Zoeken, voor duidelijke zoekresultaten! http://search.msn.nl
Re: How to write a Xalan extension function returning
DocumentFragment
Posted by Simon Kitching <si...@ecnetwork.co.nz>.
On Wed, 2004-03-03 at 22:00, Arjen Haayman wrote:
> Hello,
>
> I'm trying to write a Xalan extension function in Java that should return a
> DocumentFragment.
> So far however I've been unable to figure out how to construct a
> DocumentFragment.
>
> The only way I've found is Document.createDocumentFragment(), but how do I
> get a document?
Any old document object will do; it doesn't need to be related to the
document object representing the input or output data.
So just use the normal mechanism for instantiating a Document object.
You can do this each time you need to create a new node, or (more
efficiently) store a Document object somewhere convenient (perhaps as a
singleton) for repeated use as a factory for objects.
Regards,
Simon