[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Problem...while using Java with XSLT.

Subject: Problem...while using Java with XSLT.
From: Mukul.Mudgal@xxxxxxxxxxx
Date: Wed, 25 Sep 2002 16:12:13 +0530
while en java
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.