XML - XSLT to HTML

I am very new to java and am trying to do a simple transformation from XML to HTML using.
I have been working in JavaScript and do this all the time but i am really strugling to make it work in JAVA.
i have a simple function
public void transformXML()
try
StreamSource myXSLSource=new StreamSource("style.xsl");
TransformerFactory myFactory =TransformerFactory.newInstance();
Transformer myTransformer = myFactory.newTransformer(myXSLSource);
StreamResult out = new StreamResult("output.html");
myTransformer.transform(new StreamSource(new StringReader("input.xml")), out);
}catch(Exception e){
e.printStackTrace();
and i am trying to transform the following XML
<transXML><test>blah blah</test></transXML>
with this XSL
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:msxsl='urn:schemas-microsoft-com:xslt' version='1.0'><xsl:template match="/"><HTML><HEAD></HEAD><BODY>hahahhahaha</BODY></HTML></xsl:template></xsl:stylesheet>
Now i know i am actually translation nothing here but i just want to prove the concept.
I keep getting the error
javax.xml.transform.transformexception: document root element missing
am i on the right track or completely dreaming, if anyone could help it would be apprechiated.
any tutorials or code snipits would be very helpful as well
thanks
Joe

new StreamSource(new StringReader("input.xml"))You are passing the string "input.xml" to be parsed. This obviously isn't valid XML. I expect that you meant "input.xml" to be the name of the file containing your XML, in which case you could just usenew StreamSource("input.xml")(as you did for the XSL source).
PC&#178;

Similar Messages

  • OT:XML/XSLT transformations on iAS6.0 anyone?

    Hi,
    I know this is Off Topic from JATO, but...
    I am trying to come up with a way to process the typical
    transformation of xml & xslt to html.
    For whatever reason I can't seem to get this to work.
    I've tried it by writing my own servlet, but it hangs.
    I've tried to install cocoon, but nothing ever works, and all the
    installation instructions seem to trail off at the most important time
    (like what if the build doesn't create a war file).
    Can someone point to a definitive resource that I can follow for
    something like this which will work on iAS6.0?
    Thanks,
    John Hoskins.

    Yeah, off topic, so I doubt you will get any expert help here. Might try the S1AS 6.x forum.
    sorry

  • HELP: JSP + XML + XSLT = HTML?

    Hello, all.
    I am trying out Weblogic 6 and I am trying to get the JSP + XML + XSLT =>
    HTML chain working.
    I am coming from using Orion and SAXON.. and in that situation I had a JSP
    that contained XML tags... they were filled in at runtime and then using
    Servlet-Chaining was passed along to the SAXON XSLT Processer. SAXON checked
    for the inline XSL specified and then used that to transform the document
    into HTML.
    It worked well, but there were some other features missing/not documented
    that we now need.
    With Weblogic I am trying to use the XSLT Tag Library that comes with the
    distribution, but it seems to be very finicky. I followed the directions and
    I got it to do a sort of roundabout transformation. But it doesn't seem to
    work quite right.
    The best I can get is the following:
    I have an 'xslt' directory url-pattern-mapped to xslt.jsp (as instructed)...
    but can't figure out how to specify the xsl file on-the-fly... that is, if I
    don't hard-code the XSL file in the x:xslt element in the xslt.jsp it
    complains about some XML file not having a root element.
    Ideal situation:
    1. I have a JSP that includes XML elements.
    2. It is filled from a database at runtime and specifys (using a PI) what
    XSL stylesheet it is to be processed with.
    3. Somehow (fingers crossed) the XML is processed and transformed into HTML
    by the appropriate XSL file.
    I think I am mostly stuck moving between steps 2 and 3.
    Can anyone give me some hints? Are there some Weblogic specific
    elements/tags that I have to include in the XML file that Weblogic will
    catch and re-direct to the XSL Parser?
    Please, anyone, if you have some information, I would much appreciate it.
    Dylan Parker
    PS - I apologize for the cross-post, I hope it doesn't cause too much
    traffic.

    Craig,
    I've since discovered how to do it with the WL Taglibrary... and have
    moved on =)
    It has to do with the EXTREMELY BADLY documented x:xml tag that can
    appear within the x:xslt tag body...
    So the WL Tag Library allows something like the following.
    (Please note, angled brackets are omitted in this post to prevent html
    parsing)
    [x:xslt stylesheet="sheet.xsl"]
    [x:xml]
    Here is the XML to run the sheet on.
    This should have all relevant XML syntax: the PIs, the doctype,
    root elements etc...
    [x:xml]
    [x:xslt]
    And that DOES work. But not very well. WL, a little prematurely
    incorporated versions 1.2 of Xerces and Xalan in their product -- and
    these versions have some irritating bugs.
    Also -- There tag library doesn't copy the source XML across as UTF-8
    .. so a lot of the Japanese I have embedded there (from a DB) gets
    mangled somewhere in their code...
    AND -- If you hammer a little bit on an JSP/XML that uses the WL Tag
    Library (eg clicking refresh lots of times in IE)... I get huge
    amounts of irritating exceptions appearing in the log files.
    NullPointerExceptions
    XSL Parsing Exceptions
    XML Parsing Exceptions
    but completely unpredictably...
    In my eyes.. the WL XML/XSL Tag Library using the incorporated and
    untouchable Xalan and Xerces (v1.2) is virtually unusable.
    What a pain.
    BUT! Apache offers a similar OPEN SOURCE XSL Tag Library available
    here:
    http://jakarta.apache.org/taglibs/doc/xsl-doc/intro.html
    And it uses the standard, non-weblogic-incorporated, Xerces and Xalan
    (which means you can provide whatever version you want).. and it works
    impressively well.
    It has almost identical performance as the WL Taglib, and without all
    of the bizarre exceptions being thrown.
    And it does proper passing of the character encoding type!
    If only the taglib did caching though =(
    The performance hit over pure JSP is huge. Almost two orders of
    magnitude. On my desktop box I can get around 500Requests/Sec if I am
    returning HTML direct from a JSP... while if I produce XML that gets
    processed by XSL into HTML the Requests/Sec drops to 5!!!!
    Caching. Caching. And more Caching. A lot of DiskIO is going on with
    the XML/XSL/XHTML chain of events.
    I hope this helps!
    I'd be curious as to what you find out as well.
    Dylan Parker
    On 5 Mar 2001 07:20:00 -0800, "Craig Macha"
    <[email protected]> wrote:
    >
    Yep, I feel Dylan's pain.
    I am trying to accomplish the same thing. A JSP page generating
    dynamic XML content and then utilizing an XSLT stylesheet to transform
    all the content into XHTML.
    Does anyone have some examples that show exactly how to accomplish
    this? Can I do this with WLS and the XML taglib that comes with
    it? Or do I have to move on to something like Cocoon to get this
    capability?
    Any insight would be greatly appreciated.
    Thanks,
    Craig Macha
    "Dylan Parker" <[email protected]> wrote:
    Hello, all.
    I am trying out Weblogic 6 and I am trying to get the
    JSP + XML + XSLT =>
    HTML chain working.
    I am coming from using Orion and SAXON.. and in that situation
    I had a JSP
    that contained XML tags... they were filled in at runtime
    and then using
    Servlet-Chaining was passed along to the SAXON XSLT Processer.
    SAXON checked
    for the inline XSL specified and then used that to transform
    the document
    into HTML.
    It worked well, but there were some other features missing/not
    documented
    that we now need.
    With Weblogic I am trying to use the XSLT Tag Library
    that comes with the
    distribution, but it seems to be very finicky. I followed
    the directions and
    I got it to do a sort of roundabout transformation. But
    it doesn't seem to
    work quite right.
    The best I can get is the following:
    I have an 'xslt' directory url-pattern-mapped to xslt.jsp
    (as instructed)...
    but can't figure out how to specify the xsl file on-the-fly...
    that is, if I
    don't hard-code the XSL file in the x:xslt element in
    the xslt.jsp it
    complains about some XML file not having a root element.
    Ideal situation:
    1. I have a JSP that includes XML elements.
    2. It is filled from a database at runtime and specifys
    (using a PI) what
    XSL stylesheet it is to be processed with.
    3. Somehow (fingers crossed) the XML is processed and
    transformed into HTML
    by the appropriate XSL file.
    I think I am mostly stuck moving between steps 2 and 3.
    Can anyone give me some hints? Are there some Weblogic
    specific
    elements/tags that I have to include in the XML file that
    Weblogic will
    catch and re-direct to the XSL Parser?
    Please, anyone, if you have some information, I would
    much appreciate it.
    Dylan Parker
    PS - I apologize for the cross-post, I hope it doesn't
    cause too much
    traffic.

  • XML/XSLT problem

    I'm currently reading info on using XSLT with XML documents ("Java Server Programming" by WROX), but I'm having quite a few problems getting anything to work. Can someone point me to a page/document that simply explains what .jar files to install, where to get them and where to place them to enable parsing XML files and using XSLT? I'm running jdk1.3.1_02.
    Thank You
    Tom Berry

    - download: http://java.sun.com/xml/downloads/javaxmlpack.html
    - install JAXP
    - follow the XSLT tutorial: http://java.sun.com/webservices/docs/1.0/tutorial/doc/JAXPXSLT.html
    - have fun!

  • HOW TO CONVERT A XML FILE TO HTML FILE FORMAT IN WINDOWS APPLICATION

    Hi iam a fresher iam working on a project in that i should convert the data in xml file to html file. I dont have any idea regarding this can anyone help me how to convert the xml file to a html file format. I just written the code till how to read the xml
    file. Now i stucked how to write the code for converting to html format.
    Thanks and Regards,
    Dileep.

    Hi iam a fresher iam working on a project in that i should convert the data in xml file to html file. I dont have any idea regarding this can anyone help me how to convert the xml file to a html file format. I just written the code till how to read the xml
    file. Now i stucked how to write the code for converting to html format.
    Thanks and Regards,
    Dileep.
    Hello,
    For converting xml file to html, we could refer to the way shared in the following thread which uses an XSLT stylesheet to transform the XML into another format using the
    XslTransform class.
    http://www.codeproject.com/Articles/12047/How-to-Convert-XML-Files-to-HTML
    Regards.
    Carl
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • XML-XSLT XML within XML

    Hi,
    I am in the process of building an application in which the data tier serves XML and the presentation layer uses XSLT to render the desired format. I need to produce an html table with data that is stored in a database(easy). The issue is that in cell 3 for example, I need to select data from my data objects (that return xml)for an html select list. What would be an effective way to merge the two seperate xml docs? Any help would be greatly appreciated.
    Thanks...

    Lets say you want to "include" the file foo.xml in a file called bar.xml. One way way to go about it is to use something similar to:
    <!ENTITY Foo SYSTEM "foo.xml">
    before the top level element your bar.xml and
    &Foo;
    somewhere inside the bar.xml.
    Also sometimes it's easier to just use the document() XSLT function to include whatever node you wish from an external resourse. This function should be used somewhere inside the XSL file which provides you with the desired formarting.
    null

  • JSP   vs.    XML/XSLT

    Hi all!
    I'm in a bit of a dilema. As the least knowledgable member of our small development group (3 people incl. me) I'm caught in the middle of a pretty fierce debate over whether or not to we should implement JSP.
    Currently to seperate business logic from presentation we have our servlets pass XML to the browser and then the browser renders the HTML using the appropriate .xsl (sometimes we use server-side transformation).
    Now one of the guys wants to use MVC/Struts and JSPs in order to create a much needed UI for an application. The plan is to not put any Java code in the JSP (seperation of logic and presentation - good, business logic in both the JSP and Servlet - bad.) but the other guy is still vehemently against it.
    He says that anything JSP can do we can already do with XML/XSLT and to add JSP to our environment would complicate things.
    And while I agree with him there, there are some things that when you do them with JSPs make the code more readable and transparent.
    If you had to take a side, which one would you choose?
    Has anyone else out there already gone through this debate? I'd be interested in knowing the outcome.
    Thanks,
    John

    I have a couple of comments.
    1> "XML to the browser and then the browser renders the HTML using the appropriate .xsl"
    I all cases you should do the transformations on the server. Lot of browser do not know how to
    do a xsl transform. And since you can do it some time why not do it not everytime?
    2> "business logic in both the JSP and Servlet"
    Business logic should neither be in servlets nor in jsp. I think they should be in business logic beans.
    3> "anything JSP can do we can already do with XML/XSLT "
    Although anything can be done using xml/xsl or jsp there are a bit of differences where struts-jsp architecture is more perferable.
    Imaging a web site which has lots of online forms(with textfiedls, checkboxes, select lists, etc) which are to be validated and if some validation fails the same form is to be shown with the values already submitted prefilled. Doing this with xml/xsl or even simple jsp could be a nightmare.
    But if you use struts MVC architecture with jsp and struts taglib this will be very very simple.
    Introducing struts-jsp will not complicate things and if the scnario described above is there or could arise in your application then you should seriously think about using struts+jsp. That does not mean you will have to scrap you xml+xsl architecture. You can still generate the xml using your action bean , put the xml in request and forward it to you jsp for rendetion. The jsp page could then use a taglib which has the xsl transformation code to do the xslt transformation.
    The above comments are not just my thoughts but i have also implemented/experienced the above during various projects and they have proved to be useful.
    Cheers!

  • How to generate the XML file to HTML?

    Hi all,
    I am new to XML.
    Can I somehow see the HTML-Output of the XML-File, when I have the XSL-File too, but don't use any XML-Editor (XMLSpy) and FOP? I do not want use any additional tools - only the database tools.
    What I need for this?
    Do I need the XSLT-File too?
    ============================
    My test.xml file:
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="test.xsl"?>
    <ROW num="1">
         <TABLE_NAME>ABR_ART_ABR_DAU_MATRIX</TABLE_NAME>
         <TABLESPACE_NAME>PS2000_STAMM</TABLESPACE_NAME>
         <PCT_FREE>10</PCT_FREE>
         <INI_TRANS>1</INI_TRANS>
         <MAX_TRANS>255</MAX_TRANS>
         <INITIAL_EXTENT>516096</INITIAL_EXTENT>
         <NEXT_EXTENT>65536</NEXT_EXTENT>
         <MIN_EXTENTS>1</MIN_EXTENTS>
         <MAX_EXTENTS>2147483645</MAX_EXTENTS>
         <PCT_INCREASE>0</PCT_INCREASE>
         <LOGGING>YES</LOGGING>
         <BACKED_UP>N</BACKED_UP>
         <NUM_ROWS>33</NUM_ROWS>
         <BLOCKS>20</BLOCKS>
         <EMPTY_BLOCKS>0</EMPTY_BLOCKS>
         <AVG_SPACE>0</AVG_SPACE>
         <CHAIN_CNT>0</CHAIN_CNT>
         <AVG_ROW_LEN>100</AVG_ROW_LEN>
         <AVG_SPACE_FREELIST_BLOCKS>0</AVG_SPACE_FREELIST_BLOCKS>
         <NUM_FREELIST_BLOCKS>0</NUM_FREELIST_BLOCKS>
         <DEGREE> 1</DEGREE>
         <INSTANCES> 1</INSTANCES>
         <CACHE> N</CACHE>
         <TABLE_LOCK>ENABLED</TABLE_LOCK>
         <SAMPLE_SIZE>33</SAMPLE_SIZE>
         <LAST_ANALYZED>1/8/2004 11:45:1</LAST_ANALYZED>
         <PARTITIONED>NO</PARTITIONED>
         <TEMPORARY>N</TEMPORARY>
         <SECONDARY>N</SECONDARY>
         <NESTED>NO</NESTED>
         <BUFFER_POOL>DEFAULT</BUFFER_POOL>
         <ROW_MOVEMENT>DISABLED</ROW_MOVEMENT>
         <GLOBAL_STATS>YES</GLOBAL_STATS>
         <USER_STATS>NO</USER_STATS>
         <SKIP_CORRUPT>DISABLED</SKIP_CORRUPT>
         <MONITORING>NO</MONITORING>
         <DEPENDENCIES>DISABLED</DEPENDENCIES>
         <COMPRESSION>DISABLED</COMPRESSION>
    </ROW>
    ============================
    ============================
    My test.xsl-file:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:output method="html"/>
    <xsl:template match="/">
    <html>
    <head>
    <title>Test XSL ALL_TABLES</title>
    </head>
    <body>
    <xsl:for-each select="ROW">
    <h2>Tabelle: <xsl:value-of select="TABLE_NAME"/></h2>
         <hr/>
         <table border="1" cellpadding="0">
                             <tr>
                             <td><xsl:value-of select="TABLESPACE_NAME"/></td>
                             <td><xsl:value-of select="PCT_FREE"/></td>
                             </tr>
                        </table>
              </xsl:for-each>          
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>
    ============================
    I am waiting for your answers, when possible with examples please.
    Regards
    Leonid Pavlov

    XSLT to convert the XML document to Html:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html"/>
    <xsl:template match="/">
    <html>
    <head>
    <title>Test XSL ALL_TABLES</title>
    </head>
    <body>
    <table border="1" cellspacing="0">
    <tr>
    <th>TABLE NAME</th>
    <th>TABLESPACE NAME</th>
    <th>PCT FREE</th>
    </tr>
    <xsl:for-each select="ROW">
    <tr>
    <td><xsl:value-of select="TABLE_NAME"/></td>
    <td><xsl:value-of select="TABLESPACE_NAME"/></td>
    <td><xsl:value-of select="PCT_FREE"/></td>
    </tr>
    </xsl:for-each>
    </table>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>

  • DB, XML, XSLT - I have a problem, HELP

    Hi Friends!!
    I have a problem and I need your help guys. I was wondering if there is any tool I can use to minimize my Data Base troubles. I work with 3 DataBases (Oracle, DB2, SQLServer) and I have to re-write almost all my SQL code 3 times. I think I could use XML and XSLT and make some magic like the Java magic of "Write once, runs anywhere". Does anyone know what I have to do to solve my problem ??
    Thanks a lot my friends
    Cleverson

    Oracle XML SQL Utility -- XSU converts a xml to a
    oracle database.
    http://otn.oracle.com/tech/xml/oracle_xsu/content.html
    DB2 XML Extender converts xml to a db2 database.
    http://www-3.ibm.com/software/data/db2/extenders/xmlext
    Another question if I may,
    I am looking for a general tool (using JDBC) to extract data from a genral data base (I need inofmrix, oracle, sqlserver, db2 and more) into xml file. I need it to be an effecient also and not create DOM documents. Do you know about a tool like this (maybe an open source?).
    Thank you very much,
    David

  • Java Translets XML/XSLT Transformation

    Translets "are precompiled XSL documents that are optimized and converted into simple Java classes. When you compile your application Java files, you compile your XSL files into Java class files. During runtime, you can load translets like any regular Java class and perform XSL transformations over and over again.
    The syntax checking and parsing of XSL documents are done when the XSL files are compiled. The transformation therefore takes only as long as the compiled code takes to execute, which improves performance multiple folds.
    The downside to using XSL is that "it can take a considerable amount of time and reduce performance. The time needed to parse XML and XSL documents is directly proportional to the size of the documents. Each transformation requires the XML and XSL documents to be loaded, syntax checked, and parsed." I recommends using translets for the following reasons.
    I had written an application (<a href="http://www.simplygites.com" title="www.simplygites.com">SimplyGites</a>) using standard XSL / XML transformation and experienced some very slow server-side transformation on the very complex screens with large amounts of xml. Timings showed these problem screens took 2-3 seconds to transform, which was totally unacceptable non-functional requirements.
    I considered rewriting these screens as JSP or PHP, then I discovered Translets. And wow what a discovery the timings for these pages now compiled as Translets(java classes) are amazing in comparison to the original timings ? I now have them transforming in 500ms (all now under 1 second).
    I would recommend anyone using XSL/XML transformation to use Translets, these have now been running tried and tested on the <a href="http://www.simplygites.com" title="www.simplygites.com">SimplyGites</a> for the past 6months.
    Technolgies used:
    Weblogic 8.1 SP5
    Java 1.4.2
    Required Jars
    xsltc.jar
    runtime.jar
    BCEL.jar
    JLex.jar
    java_cup.jar
    regexp.jar
    xml-dtm.jar
    For more information see http://xml.apache.org/xalan-j/xsltc_usage.html
    I hope this helps anyone that has XML/XSLT performance issues.
    Mark
    MB Computer Ltd
    www.simplygites.com

    Thanks for your help.
    The problem was that my firewall was blocking my server.

  • Embedding javascript with xslt generated html

    hi,
    I'm using xml/xslt with xdk to generate html with embedded javascript. The solution works except that I am having problem with proper inclusion of the javascript file. I uset this line:
    <xsl:template match="/">
    <head><title>Screener</title>
    <!-- Javascript declarations -->
    <script language="javascript1.2" src="./screener.js">
    </script>
    I have tested the xslt sheet via IE5 and msxml3 processor and it works fine including loading the javascript file.
    Now using XDK and servlet it doesn't seem to retrieve the javascript file so all javascript function do not work.
    I would appreciate any help.
    thanks,
    ted
    null

    hi brian,
    All those files are in same directory i changed the .xsl file to be i am changing at the right place.
    However, as backup i tried the following:
    <?xml version="1.0"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html"/>
    <script language="javascript1.2">
    <![CDATA[
    <!--
    var isNav4, isIE4;
    if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
    isNav4 = (navigator.appName == "Netscape")? true:false
    isIE4 = (navigator.appName.indexOf("Microsoft" != -1)) ? true:false
    if (isNav4) { document.write("<B>It's a Navigator!</B>");}
    else { document.write("It's an Explorer!");}
    //== shared global variables
    function _alert(e)
    alert(e);
    -->
    ]]>
    </script>
    and here is the html output:
    <html>
    <head>
    <title>Screener</title>
    <script language="javascript1.2">
    &#60;!--
    var isNav4, isIE4;
    if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
    isNav4 = (navigator.appName == "Netscape")? true:false
    isIE4 = (navigator.appName.indexOf("Microsoft" != -1)) ? true:false
    if (isNav4) { document.write("&#60;B>It's a Navigator!&#60;/B>");}
    else { document.write("It's an Explorer!");}
    //== shared global variables
    function _alert(e)
    alert(e);
    -->
    </script>
    </head>
    So everything is being output correctly except for <!--; is there a way around this problem? If I leave out <!-- --> it works but
    i was wondering if the present behavior is what's supposed to happen.
    thanks,
    ted
    null

  • XML Vs Javascript/HTML

    Hi! All JDeveloper's Support Group. Normally
    I used Javascript and HTML to create my
    webpage. But recently, I found that XML
    is very much better. Can the code in my
    present Javascript and HTML be enhanced but
    with the mixture of XML? Will the output
    be browsable with any browser, that is,
    IE or Netscape or other browser? Pls let
    me know soon. Thanks & best regards.

    You might want to check out Oracle's XSQL Servlet. It's a free web publishing framework that caters to SQL/XML/XSLT/Java publishing of database information over the web.
    JDev 3.2 ships with BC4J-integration for XSQL Servlet as well.
    http://technet.oracle.com/tech/xml
    Click on "XDK for Java".

  • On XML, XSLT, FO usage

    Hi,
    Any links... help...documents... tutorials... samples on usage of XML, XSLT, FO engine, for pdf generation.
    Ravishankar Swamy

    Hi,
    This Technical Note is very interesting to start point
    http://www.oracle.com/technology/pub/notes/technote_vohra_fop.html
    Follow good references from AMIS
    http://technology.amis.nl/blog/?p=1102
    http://technology.amis.nl/blog/?p=1182
    Best regards

  • How to convert from xml file to html using java code

    How to convert from xml file to html file using java code

    Get yourself Apache Xalan or Saxon or some XSLT processor
    String styleSheet = "/YourXSLTStylesheet.xsl";
    String dataSource = "/YourXMLDocument.xml";
    InputStream stylesheetSource = TransformMe.class.getResourceAsStream(styleSheet);
    InputStream dataSourceStream = TransformMe.class.getResourceAsStream(dataSource);
    OutputStream transformedOut = new FileOutputStream("filename.html");
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer(new StreamSource(stylesheetSource));
    transformer.transform(new StreamSource(dataSourceStream), new StreamResult(transformedOut));You'll also need to learn XSLT if you don't already know that. Here's a good place to start
    http://www.w3schools.com/xsl/

  • Converting XML document to HTMl using xsl

    Hi,
    I'm trying to convert an xml document into html page using xsl. But when I try to open the page in the browser nothing comes up.
    I'm not sure if I am using the PrintWriter correctly.
    StreamResult result = new StreamResult(new PrintWriter(new (File"text.html")));
    Please help.

    Oops! I wrote the parenthesis wrong in the previous mail
    This is the correct one I use in my program.
    StreamResult result = new StreamResult(new PrintWriter(new File("text.html")));
    Please help. Its urgent

Maybe you are looking for