Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > how to create a DocumentFragment in Xalan java extension function?

Reply
Thread Tools

how to create a DocumentFragment in Xalan java extension function?

 
 
Arjen Haayman
Guest
Posts: n/a
 
      03-01-2004
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>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the bettter/performant way to compare org.w3c.dom.DocumentFragment Mausam Java 7 01-18-2012 05:29 AM
Upgrade of Xalan 1.2.2 and Xerces 1.4.4 to Xalan 2.6 and Xerces 2.6.2 cvissy XML 0 11-16-2004 07:06 AM
JARV and DocumentFragment validation Christian Schuhegger XML 0 10-20-2003 04:43 PM
can i create a xalan java extension function where the function name has dashes (-) in it ? _clb_ Chris Bedford Java 0 08-17-2003 12:57 AM
can i create a xalan java extension function where the function name has dashes (-) in it ? _clb_ Chris Bedford XML 0 08-17-2003 12:57 AM



Advertisments