This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Problem...while using Java with XSLT.
- From: "Michael Kay" <michael dot h dot kay at ntlworld dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Wed, 25 Sep 2002 12:45:22 +0100
- Subject: RE: [xsl] Problem...while using Java with XSLT.
- Reply-to: xsl-list at lists dot mulberrytech dot com
You are probably loading the DOM tree correctly; you are then applying
templates to it, and the built-in templates merely extract the text.
Use xsl:copy-of instead of xsl:apply-templates.
And please... any problem that isn't pure XSLT, please say what product
you are using. There are half a dozen XSLT implementations in Java, and
the way they do extension functions are all slightly different.
Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com
> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com] On Behalf Of
> Mukul.Mudgal@etindia.com
> Sent: 25 September 2002 11:42
> To: xsl-list@lists.mulberrytech.com
> Subject: [xsl] Problem...while using Java with XSLT.
>
>
> Hello Friends
>
> I'm trying to use Java with XSLT.
>
> What I'm doing is ....I'm trying to get a node structure from
> the Java class.....while doing the transformation. And that
> node structure should be append into where I called the Java
> Class in XSL file.
>
> But instead of showing the appended node structure ...it is
> showing it's value
>
> Result Currently getting.......
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <AA xmlns:java="java" xmlns:date="com.example.MeraClass">
> <BB>FunnyFunny1</BB>
> </AA>
>
>
>
> Result expected
> <?xml version="1.0" encoding="UTF-8" ?>
> <AA xmlns:java="java" xmlns:date="com.example.MeraClass">
> <BB>
> <CC>
> <DD>Funny</DD>
> <EE>Funny1</EE>
> </CC>
> </BB>
> </AA>
>
> These are my xsl and java code...
>
> ****************XSL************
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:date="com.example.MeraClass"
> xmlns:java="java" >
>
> <xsl:output method="html" encoding="UTF-8"/>
>
> <xsl:template match="date">
> <AA>
> <BB>
> <xsl:apply-templates select="date:format(.)"/> <!-- Calling
> of Java Class i.e com.example.MeraClass -->
> </BB>
> </AA>
> </xsl:template>
>
> </xsl:stylesheet>
> *******************************************************************
>
> Java Class..
> import java.util.*;
> import java.text.*;
> import org.w3c.dom.*;
> import javax.xml.parsers.*;
> import org.apache.xml.utils.WrappedRuntimeException;
>
>
> public class MeraClass {
>
> public static Node format (String date) {
>
> try {
> Document doc = DocumentBuilderFactory.newInstance
> ().newDocumentBuilder().newDocument();
>
> Element dateNode = doc.createElement("CC");
> addChild(dateNode, "DD", "Funny");
> addChild(dateNode, "EE", "Funny1");
>
> return dateNode;
> } catch (Exception ex) {throw new
> WrappedRuntimeException(ex);}
>
> }
>
> private static void addChild (Node parent, String name,
> String text) {
> Element child = parent.getOwnerDocument().createElement(name);
>
> child.appendChild(parent.getOwnerDocument().createTextNode(text));
> parent.appendChild(child);
> }
> }
>
> Please help how could I do this.
>
> thanks
> Mukul
>
>
>
>
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list