How to display Xml in a JEditorPane(in an applet)

Hi All,
I have an applet and i want to display xml in a JEditorPane in an applet. This xml document has a xsl attached to it for transformation. How can i do the transformation??
Help or sample code or link to a sample code is highly appreciated!!!!
Thanks
Ragu

Look this servlet which does a transformation. JEditorPane could call this servlet (with the method setPage) to do the transformation:
public class SampleXSLTServlet extends javax.servlet.http.HttpServlet {
public final static String FS = System.getProperty("file.separator");
// Respond to HTTP GET requests from browsers.
public void doGet (javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException, java.io.IOException
// Set content type for HTML.
response.setContentType("text/html; charset=UTF-8");
// Output goes to the response PrintWriter.
java.io.PrintWriter out = response.getWriter());
try
javax.xml.transform.TransformerFactory tFactory =
javax.xml.transform.TransformerFactory.newInstance();
//get the real path for xml and xsl files.
String ctx = getServletContext().getRealPath("") + FS;
// Get the XML input document and the stylesheet, both in the servlet
// engine document directory.
javax.xml.transform.Source xmlSource =
new javax.xml.transform.stream.StreamSource
(new java.net.URL("file", "", ctx+"foo.xml").openStream());
javax.xml.transform.Source xslSource =
new javax.xml.transform.stream.StreamSource
(new java.net.URL("file", "", ctx+"foo.xsl").openStream());
// Generate the transformer.
javax.xml.transform.Transformer transformer =
tFactory.newTransformer(xslSource);
// Perform the transformation, sending the output to the response.
transformer.transform(xmlSource,
new javax.xml.transform.stream.StreamResult(out));
// If an Exception occurs, return the error to the client.
catch (Exception e)
out.write(e.getMessage());
e.printStackTrace(out);
// Close the PrintWriter.
out.close();

Similar Messages

  • How to display xml to html using xsl?

    hi all...may i know how to display xml to html page?
    i ve included <xsl:output method="html" indent="yes" /> inside my xsl file. i clicked on output.xml file and everything is displayed correctly but the format is xml instead of html. is there anyway to transform it to html?
    below are my xsl and xml codes:
    // xsl file
    <?xml version='1.0'?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" indent="yes" />
    <xsl:template match="/">
    <html>
    <body>
    <h2>Document Contents</h2>
    <table border="1">
    <tr bgcolor="#9acd32">
         <th align="center">Document Name</th>     
         <th align="center">Document ID</th>          
         <th align="center">Owner</th>               
    </tr>
    <xsl:for-each select="Document/Contents">
    <tr>
    <td><xsl:value-of select="DocumentName"/></td>
    <td><xsl:value-of select="DocumentID"/></td>
    <td><xsl:value-of select="Originator"/></td>
    </tr>
    </xsl:for-each>
    </table>
    </body>
    </html>
    // xml file
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="xsltStyleSheet.xsl"?>
    <Document>
         <Contents>
              <DocumentName>register</DocumentName>
              <DocumentID>1</DocumentID>
              <Originator>hhh</Originator>
         </Contents>
    </Document>
    </xsl:template></xsl:stylesheet>

    your XSL transforms to HTML (in fact XHTML): what more do you expect? did you expected anything different from the following output? if yes: what and why?
    <html>
         <body>
              <h2>Document Contents</h2>
              <table border="1">
                   <tr bgcolor="#9acd32">
                        <th align="center">Document Name</th>
                        <th align="center">Document ID</th>
                        <th align="center">Owner</th>
                   </tr>
                   <tr>
                        <td>register</td>
                        <td>1</td>
                        <td>hhh</td>
                   </tr>
              </table>
         </body>
    </html>

  • How to Display XML in a UIWebView?

    Hi everybody. I like how Safari displays XML files and I would like to emulate that functionality in an iPhone UIWebView. However, I just can't get it to look the same when passing a URL to the UIWebView.
    For example, take a simple XML file like http://molottery.com/rss-num.xml. Viewing that in Safari looks okay, but passing that same URL into a UIWebView just shows a blank page.
    I changed the web protocol from http to feed (feed://molottery.com/rss-num.xml) and it launches the page in Safari instead of my UIWebView. Looks good, but it quit my app... :- (
    I noticed that XML files on the iPhone get re-routed through reader.mac.com so I tried appending that to my URL (http://reader.mac.com/mobile/v1/http://molottery.com/rss-num.xml) but that did not work either.
    When I tried URLEncoding the string like Safari does (http://reader.mac.com/mobile/v1/http%3A%2F%2Fmolottery.com%2Frss-num.xml) I get a UIWebView saying that "This Application Is Viewable Only On iPhone".
    So how can I emulate the regular Safari XML functionality inside my UIWebView? I will post my code upon request, if that will help. Any assistance from the Developer Community would be greatly appreciated.
    Thanks!

    You may have better luck in the iPhone dev forums...
    https://devforums.apple.com/community/iphone/web

  • How to display XML file that XI sent to my j2ee appl?

    Hi,
    In my scenario File->XI->J2EE appl.
    I got XML page cannot be displayed.
    XML document must have a top level element. Error processing resource 'http://localhost:7001/Invoke/DisplayRes'.
    I deployed my .ear file on BEA Weblogic application server9.0
    I found no error when i tested in SXI_MONI and RWB->Message monitor as well.
    This is my servlet code:
    public class DisplayRes extends HttpServlet {
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         doPost(request,response);
         public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
         BufferedReader brin =new BufferedReader(new InputStreamReader(request.getInputStream()));
         String inputLine;
         StringBuffer sBuf = new StringBuffer();
         PrintWriter out = response.getWriter();
         response.setContentType("text/xml");
         while ((inputLine = brin.readLine()) != null)
             sBuf.append(inputLine);       
             //out.setContentType("text/xml");
             //out.println(sBuf.toString());
             out.write(sBuf.toString());
              brin.close();
             out.flush();
    What went wrong.All helpful answers are highly rewarded.
    Thanks

    Hi
    Can anyone tell me how XI sends messages to applications like J2EE. In REceiver comm channel, I think we specify about the target system like J2EE appl.
    Aadapter Type: HTTP
                   Receiver
    Transport Protocol:  HTTP1.0
    Message Protocol:    XI payload in HTTP body
    Adapter Engine:      Integration Server
    Addressing Type:     URL address
    Target host:         localhost
    Service Number:      7001(Port number of Weblogic appl server--where my J2EE appl is deployed).
    Path     :  /Invoke/DisplayRes/
    Authentication Type:Use Logon Data for SAP System
    Content Type: text/xml
    Username:   xiappluser
    password:   xx
    XML code:   UTF-8
    I suppose XI sends msgs to http://localhost:7001/Invoke/DisplayRes/........
    in this example if am correct?
    Then I have given all tyhe necessary setting but my servlet is not able to display XML msg in browser?
    This is my servlet code:
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
         PrintWriter out = response.getWriter();
         BufferedReader brin =new BufferedReader(new InputStreamReader(request.getInputStream()));
         String inputLine;
         StringBuffer sBuf = new StringBuffer();
            response.setContentType("text/xml");
         while ((inputLine = brin.readLine()) != null)
             sBuf.append(inputLine);
             out.println("hi");            
                out.println(sBuf.toString());
             brin.close();
             out.flush();
    What went wrong?
    Help me, all helpful answers are highly rewarded.
    Thanks

  • How to display xml attributes in Layout (indesign cs2)

    Hi,
    Javascript
    Indesign CS2
    PC Version
    Any one tell me, i want to display the ids in the margin. i read xml attribute, but i didn't know how to display to the margin. Help me.

    One way of doing that is to use JDOM...
    u create an xml tree, and then output using XMLOutputter class...it will be displayed in text...im not sure if thats what u want...however, if u do want to represent it visually then u may need to draw a tree...u may use the Graphics2D for that...there are alot of ways to do such thing, and the 2 possibilities arent the best...depends on what u want...elaborate more pls.

  • How to display XML content in a JSP

    Hi,
    can anyone help me in displaying xml content in a JSP?

    I think you want to display value from XML page to the
    JSP.If thats the case you can try out this
    xml...
    <component-profile>
            <property name="parm" value="Hi"/>
    </component-profile>
    jsp...
    <% var=profile.getProperty("parm");%>
    Hope this helps
    gEorgE

  • How to display XML file in java swing

    hi all
    now i do my M.Sc., project on data maining.this time i have one problem,thats i can't display XML file in swing frame.so any one know this plz give me that idea or code.
    Thanks to all.
    RSK

    One way of doing that is to use JDOM...
    u create an xml tree, and then output using XMLOutputter class...it will be displayed in text...im not sure if thats what u want...however, if u do want to represent it visually then u may need to draw a tree...u may use the Graphics2D for that...there are alot of ways to do such thing, and the 2 possibilities arent the best...depends on what u want...elaborate more pls.

  • JEditorPane - How to display XML Linked HTML File in JEditorPane ?

    Dear Friends,
    I have a HTML File consisting of stylesheet, xml linked (for data) and with headers, footers...
    When i called a ordinary html file using setpage property of JEditorpane..it's working no problem...but when i call the html file having xml linked or buttons...it's not properly displayed....
    If anybody hits this problem....pls...help me....
    Regards,
    V.Prasanna

    If you only need to display it, consider your HttpServletRequest just as byte stream. :) Just read from ServletInputStream and write it back into ServletOutputStream of HttpServletResponse.
    If you want to process incoming XML, please give some details first, what exactly you want to do. :)

  • How to display XML file(as markup) in jsp page..?

    Hi All,
    * I have to display the XML file(as markup) in jsp page (Tree Format)....
    * My XML file is an java.io.file object , and how to view this XML file on my JSP page...........
    Thanks in Advance,
    JavaImran

    You mean you want to see the XML source?
    You need to replace the characters '<' and '&' with corresponding entities '&lt;' and '&amp;'. You can use replaceAll, but do the ampersands first.
    Then I suggest you probably want to put them in a <PRE> block.

  • How to display XML file in browser using Servlets?

    Hi My XML file is like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:purchase_order_MT xmlns:ns0="http://filetohttp.com">
    <ORDER_HEADER_IN>
    <purchase_date/>
    <purchase_group/>
    <purchase_org/>
    </ORDER_HEADER_IN>
    <vendor/>
    <ORDER_ITEMS_IN>
    <item>
    <storage_location/>
    <plant/>
    <quantity/>
    <material/>
    </item>
    </ORDER_ITEMS_IN>
    <ORDER_SCHEDULES_IN>
    <item>
    <delivery_date/>
    </item>
    </ORDER_SCHEDULES_IN>
    </ns0:purchase_order_MT>
    My Servlet receives this XML file and it should display the above XML as it is, How to do that?
    Please help me I have posted same question in many forums but i got no proper reply.
    Thanks a lot

    If you only need to display it, consider your HttpServletRequest just as byte stream. :) Just read from ServletInputStream and write it back into ServletOutputStream of HttpServletResponse.
    If you want to process incoming XML, please give some details first, what exactly you want to do. :)

  • How to display XML generated dynamically, as TREE in cluster environment

    hai guys,
    we are generating a tree.xml file in server side as follows.
    path = getServletConfig().getServletContext().getRealPath("/QBE/jsp/tree.xml");
    BufferedWriter out1 = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path),"UTF8"));
    out1.write(xmlString + "</tree>");
    out1.close();
    "xmlString" holds the data in xml tag format.
    in order to display the xml file in TREE structure, we are using a function like
    function createTree()
         var tree = new WebFXLoadTree("SMQ/AMQ List", "tree.xml");
         document.write(tree);
    ALL THIS MECHANISM IS WORKING FINE IN DEVELOPMENT ENVIRONMENT ANS AS WELL AS WHEN WE DEPLOY THE RELEASE IN LOCAL MACHINE. BUT IT IS NOT WORKING WHEN THE RELEASE IS DEPLOYED IN CLUSTER ENVIRONMENT.
    Please help me out how to solve this...
    thanks in advance,
    Ranga
    Edited by: Ranganatha on Jun 5, 2008 5:18 AM

    Hey if you want any more information regarding this problem, i can provide.

  • How to display XML file as is it is in my browser using servlets???

    I have a question like my servlet receives an XML file in its request object. I just need display the same XML file as it is in my browser. How to do that? Please help me out. I have searched so many blogs, but i did not get right solution.
    My XML file file will be like this:
    <ns0:Http_Message_Type_Demo xmlns:ns0="http://abcdemo.com">
    <Name>A</Name>
    <RollNo>123</RollNo>
    <Address>a2</Address>
    </ns0:Http_Message_Type_Demo>
    Thnks

    You mean you want to see the XML source?
    You need to replace the characters '<' and '&' with corresponding entities '&lt;' and '&amp;'. You can use replaceAll, but do the ampersands first.
    Then I suggest you probably want to put them in a <PRE> block.

  • How to Display XML data on a Window within my JDev App?

    I want to display some XML data stored on the database (in a CLOB field) in such a way that the XML tags and values are colored/highlighted as if they were read in a browser like Internet Explorer.
    Currently I am displaying the data using a JEditorPane field and the results are hard to read as the tags and values show on the same color and in plain text.
    I want to dispay this within my application (9i), not going to an external browser; i.e. I want the window (panel) to act as a browser when displaying the data.
    Any ideas would be appreciated.
    Thanks.

    You can use utl_http in the database to call the webservice and display the result in a form item.
    Example:
    http://www.oracle-base.com/articles/9i/ConsumingWebServices9i.php

  • How to display XML document

    Hello All.
    I am using Apex 3.0.1.x. I've uploaded an XML file into an XMLTYPE column in a table and am now trying to display this XML data in an Apex report region.
    I saw a beautiful example of doing this in Denes Kubicek's wonderful demo app 31517, page 90. Here's the link to this page:
    http://htmldb.oracle.com/pls/otn/f?p=31517:90
    I copied the procedure code he uses to display the XML into a package. Here's the code I'm using:
    <pre>
    PROCEDURE DISPLAY_XML (P_ID IN INTEGER)
    AS
    V_PROC VARCHAR2(100);
    V_ERRMSG VARCHAR2(300);
    V_MIME VARCHAR2 (48);
    V_LENGTH NUMBER;
    V_FILE_NAME VARCHAR2 (2000);
    V_LOB_LOC BLOB;
    XML_TO_BLOB_ERROR EXCEPTION;
    BEGIN
    V_PROC := 'ONLINE_MODEL_PKG.DISPLAY_XML_DEVICES';
    V_ERRMSG := NULL;
    SELECT DECODE(V('APP_USER'),NULL,'N','Y')
    INTO V_HTML_FLAG
    FROM DUAL;
    BEGIN
    SELECT X.MIME_TYPE,
    PROC_FUNC_PACK.CLOB2BLOB(X.DEVICE_XML.GETCLOBVAL()),
    X.DEVICE_FILENAME
    INTO V_MIME,
    V_LOB_LOC,
    V_FILE_NAME
    FROM XML_DOCS X
    WHERE X.ID = P_ID;
    EXCEPTION
    WHEN OTHERS THEN
    V_ERRMSG := SUBSTR('ERROR ('||V_PROC||'): DURING DISPLAY OF XML DATA: '||SQLERRM, 1, 300);
    RAISE XML_TO_BLOB_ERROR;
    END;
    V_LENGTH := DBMS_LOB.GETLENGTH (V_LOB_LOC);
    -- set up HTTP header
    -- use an NVL around the mime type and
    -- if it is a null set it to application/octect
    -- application/octect may launch a download window from windows
    OWA_UTIL.MIME_HEADER (NVL (V_MIME, 'application/octet'), FALSE);
    -- SET THE SIZE SO THE BROWSER KNOWS HOW MUCH TO DOWNLOAD
    HTP.P ('Content-length: ' || V_LENGTH);
    -- THE FILENAME WILL BE USED BY THE BROWSER IF THE USERS DOES A SAVE AS
    HTP.P ( 'Content-Disposition: filename="'
    || V_FILE_NAME
    || '"'
    -- CLOSE THE HEADERS
    OWA_UTIL.HTTP_HEADER_CLOSE;
    -- DOWNLOAD THE BLOB
    WPG_DOCLOAD.DOWNLOAD_FILE (V_LOB_LOC);
    EXCEPTION
    WHEN XML_TO_BLOB_ERROR THEN
    V_ERRMSG := PROC_FUNC_PACK.FORMAT_MSG(V_ERRMSG, V_HTML_FLAG);
    RAISE_APPLICATION_ERROR(-20010, V_ERRMSG);
    WHEN OTHERS THEN
    V_ERRMSG := SUBSTR('ERROR ('||V_PROC||'): '||SQLERRM, 1, 300);
    V_ERRMSG := PROC_FUNC_PACK.FORMAT_MSG(V_ERRMSG, V_HTML_FLAG);
    RAISE_APPLICATION_ERROR(-20020, V_ERRMSG);
    END DISPLAY_XML_DEVICES;
    </pre>
    I then invoke this packaged procedure in an iframe, just like what Denes is doing. I put the following code in my report region source field:
    <pre>
    DECLARE
    v VARCHAR2 (500);
    BEGIN
    v :=
    'SELECT '
    || '''<iframe src="#OWNER#.ONLINE_MODEL_PKG.DISPLAY_XML?p_id='
    || :p53_id
    || '"'
    || ' height="800" width="950"></iframe>'''
    || ' document_display'
    || ' FROM DUAL';
    RETURN v;
    END;
    </pre>
    When I run the report in Intenet Explorer (version 6.x), I get a strange security warning popup asking if I want to display unsecure items. When I click "Yes", the report region shows up with a "Could not find web page" error 404 inside the report region.
    I then tried running the app in Fire Fox (version 2.0.0.15). This time I do not get any security warning, but the report region shows up with the message "Procedure Doesn't Exist".
    Another page in my app calling other procedures in my package, and so, I know that Apex is "seeing" the package.
    Does anyone know why I'm seeing these strange things? And, is there, perhaps, another way to display an XML document in an Apex page?
    Thank you.
    Elie

    Hi Arthur,
    I assume you are using EP6.0, below SP3.
    The XML Forms can be displayed using standard SAP layouts only. There is a special type of servlet. This alongwith the CSS is applied when you click to display the "Show" form.
    As far as I know, there is no other way to display as you want to. You can probably get more help by specifying the exact scenario.
    Hope this helps you.
    Regards,
    Sagar

  • How to display xml code in page?

    Hi,
       I have a string which content is a xml file, I want to display the content of string in xml mode, such like dispalying a xml file in IE browser. How to do it?
        Thanks a lot!

    set the MIME type of the page to "text/xml".
    while creating the page if you create it with extention .xml, the system would automatically set this for the page.
    and just place the string holding the XML in the layout .
    <%=stringholdingxml%>
    Regards
    Raja

Maybe you are looking for

  • Ar Invoice Totals don't add up

    Hello, I have an AR Invoice layout which when viewed, the totals in the bottom right hand corner don't total up. To the lines on the invoice. Whilst the correct entries appear to have been made on the system and the only observation we have made is t

  • AR table needed for customer payment terms specified by sales areas

    Hi Experts, What table can I use to see the payment terms of specific customers by sales areas? I have tried T052 and TVZBT but it is not possible to view or filter by sales areas and customers in those sales areas. Any help will be appreciated! Than

  • Find iPhone App Issue

    Hello,   I am using the Find iPhone app for a few weeks now and works perfectly on my iPhone 4S, and iPod Touch but can;t located my iPad 2 ever.  Its a WI-FI only iPad 2,  It always says "No location available".  I don't get it because all the locat

  • Getting Data from Input Structure (in Web Dynpro)

    Hi All, in my Web Dynpro Application, i have problems to get the data form my Input-Structure. In the execution-method I implement the following code, to show the input parameters in my form (in context-nodes): IGPStructure inputStructure = execution

  • Can I install Final Cut on OS 10.3.9?

    The minimum system requirements on my Final Cut is 10.4.4. Vut I read somewhere that it cam be run on 10.3.9. Is this possible?