how to create a DocumentFragment in Xalan java extension function?

Arjen Haayman

Usenet Archive
Joined
Aug 30, 2002
Messages
5
Reaction score
0
Hello,

I'm using Xalan and have written Java classes as extension functions.

According the documentation the return value of an extension function can be a Result tree fragment: (== org.w3c.doc.DocumentFragment)

Now I can't figure out how to create an empty DocumentFragment from a Java class that has been created in an XSL stylesheet

This is what I have so far:

public Object toSVG( ExpressionContext context)
{
Object retval;

try
{
Node node = context.getContextNode;
Document doc = node.getOwnerDocument;
DocumentFragment fragment = doc.createDocumentFragment;

Element text = doc.createElement( "text");
text.setPrefix( "svg");
text.setAttribute( "font-size", "2");
text.setAttribute( "transform", this.Transform);
text.setAttribute( "x", Double.toString( this.X));
text.setAttribute( "y", Double.toString( this.Y));
fragment.appendChild( text);
fragment.appendChild( bijpijling);

retval = fragment;
}
catch( DOMException e)
{
String error = Integer.toString( e.code);
Debug.Msg( 10, "error: " + error);
retval = error;
}

return( retval);
}

example usage (simplified)

<xsl:variable name="Tekst" select="map:TText.new( "aText")/> <svg:a xlink:href="{$url}"> <xsl:for-each select="map:toSVG( $Tekst)"> <xsl:copy-of select="." /> </xsl:for-each> </svg:a>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,223
Members
248,131
Latest member
Tonypshaw1

Latest Threads

Top