Jsp xml and xslt architecture

I am thinking of using xslt to generate html in jsps.
Can somebody point me to some good examples on how to architecture such a server side system. On best practices and so...
Thanks
-S

here is an example that you can use
I did put all of it in a bean, this is just for testing xsl
<%@ page
import="javax.xml.parsers.*,
org.w3c.dom.*,
javax.xml.transform.*,
javax.xml.transform.stream.*,
java.io.*"%>
<%
     StreamSource xml = new StreamSource(new File("c:/xml/file.xml"));
     StreamSource xsl = new StreamSource(new File("c:/xml/file.xsl"));
     StreamResult result = new StreamResult(out);
     TransformerFactory tFactory = TransformerFactory.newInstance();
     Transformer transformer = tFactory.newTransformer(xsl);
     transformer.transform(xml, result);
%>

Similar Messages

  • Examples related to XML and XSLT

    Hello friends,
    In relation to XML and XSLT
    1. As I can transform an XML file using XSLT.
    2. I view the XML file using XSLT
    3. XSL and XSLT files are equal...?
    Thanks for the support

    http://docs.oracle.com/javaee/1.4/tutorial/doc/JAXPXSLT6.html

  • [svn] 3663: Dita xml and xslt support for SkinStates

    Revision: 3663
    Author: [email protected]
    Date: 2008-10-15 13:04:27 -0700 (Wed, 15 Oct 2008)
    Log Message:
    Dita xml and xslt support for SkinStates
    Bugs: SDK-17166
    QA: Yes
    Doc: No
    Tests: checkintests
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-17166
    Modified Paths:
    flex/sdk/trunk/asdoc/templates/class-parts.xslt
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/TopLevelClassesGenerator.ja va

    http://docs.oracle.com/javaee/1.4/tutorial/doc/JAXPXSLT6.html

  • Generate HTML from XML and XSLT

    Hi,
    I have asked in different forum but did not get my answer so asking here again
    i want to generate a HTML file from XML and XSLT in a temp folder and then read it into a java.lang.String, so can email it or write to a database file.
    how can i do it, is there any engine which will merger XML and XSLT and give a HTML file or a String as output
    Ashish

    Hi,
    Follow the simple steps.
    1) Create XML Document (I hope u have it)
    2) Create XSL Stylesheet for your XML document
    3) Put both files in one directory some where in your local system or web server upto u
    4) Invoke the XML document from webbrowser and you are done.
    http://localhost/test/Catalog.xml OR C:\XXXXDIR\test\Catalog.xml
    For Ex: XML File Content, Catalog.xml
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <?xml-stylesheet type="text/xsl" href="Catalog.xsl"?>
    <catalog>
    <cd>
    <title>Empire Burlesque</title>
    <artist>Bob Dylan</artist>
    <country>USA</country>
    <company>Columbia</company>
    <price>10.90</price>
    <year>1985</year>
    </cd>
    </catalog>
    XSL File Content: Catalog.xsl
    <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">
    <html>
    <body>
    <h2>My CD Collection</h2>
    <table border="1">
    <tr bgcolor="#9acd32">
    <th align="left">Title</th>
    <th align="left">Artist</th>
    </tr>
    <xsl:for-each select="catalog/cd">
    <tr>
    <td><xsl:value-of select="title"/></td>
    <td><xsl:value-of select="artist"/></td>
    </tr>
    </xsl:for-each>
    </table>
    </body>
    </html>
    </xsl:template></xsl:stylesheet>

  • Problem with XML and XSLT, help...

    Okay, I have this XML doc (called stocks.xml):
    <?xml:stylesheet type="text/xsl" href="stocks.xsl" version="1.0" encoding="UTF-8"?>
    <portfolio>
    <stock>
    <symbol> SUNW </symbol>
    <name> Sun Microsystem </name>
    <price> 12.95 </price>
    </stock>
    <stock>
    <symbol> HPW </symbol>
    <name> Hewlet Packard </name>
    <price> 53.50 </price>
    </portfolio>
    And I have this XSLT doc (called stocks.xls):
    ?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xls="http://www.w3.org/TR/WD-xsl">
    <xsl:template match="/">
    <html>
    <head>
    <title> Stocks </title>
    <body bgcolor="#ffffcc">
    <xsl:apply-template />
    </body>
    </head>
    </html>
    </xsl template>
    <xsl:template match="portfolio">
    <table border="2">
    <tr>
    <th> Stock Symbol </th><th> Company Name </th><th> Price </th>
    </tr>
    <xsl:for-each select="stock">
    <tr>
    <td>
    <i><xsl:value-of select="symbol" /></i>
    </td>
    <td>
    <xsl:value-of select="price" />
    </td>
    </tr>
    </xsl:for-each>
    </table>
    </xsl template>
    </stylesheet>
    When I try to retrieve the stocks.xml document with
    IE, the browser said, there is an error on line 2, can not
    recognize xsl:
    The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    Reference to undeclared namespace prefix: 'xsl'. Error processing resource 'http://localhost:8080/examples/jsp/stocks/stocks.xsl'. Line 2, Position 71
    <xsl:stylesheet version="1.0" xmlns:xls="http://www.w3.org/TR/WD-xsl">
    I just follow this from an example of XML tutorial.
    Please help, what is it that I miss? Seems everything
    I have is okay....??
    Thanks,
    Ted.

    Thanks you all!
    You have spotted that mistyped.
    However, turns out Internet Browser that I have does not permit the use of XSL. After I fixed the file, I got this
    message:
    The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    Keyword xsl:apply-template may not be used here.
    Oh well...
    Anybody knows, if IE can or can not be used to view the
    XML that reference XSL??
    Thanks,
    Ted.

  • XML and XSLT Filter Application

    I have a problem with an XSLT filter in EP6 SP2 exact version :
    6.0.2.5.4_ContentManagement_Collaboration
    6.0.2.5.0.Enterprise_Portal_Service_Pack_2
    I have defined an XSL stylesheet as follows in KM Config
    Configuration --> Content Management --> Repository Filters --> XSLT Filter
    name : local_fxrates_xslfilter
    Extensions 
    Formatter 
    MIME Type       text/html
    MIME Types 
    Paths            /webcontent/xml/exchange.xml
    Resource Type 
    Stylesheet       wcm://etc/filter/xsl/exchrates.xsl
    Active       yes
    Priority     1 
    Repositories       feeds
    I have another process that retrieves the appropriate exchange.xml file from a remote source and places it in the
    directory above.  The feeds repository is an fsdb not that it should make any difference.  Now I have a bog standard iview
    thats based on the com.sap.km.cm.docs pointing at the appropriate xml file - the path is the same as above.  This iview
    exists on a page that has a number of other iviews.
    The problem is that periodically I get a server 500 error - a browser refresh ALWAYS makes the problem dissapear and the
    content is then displayed in the correct manner.  This is not an isolated case, any iview I create based on the same
    master and using an XSLT filter to transform some XML content displayes the same behaviour.  To test this I have disabled the XSLT filter and the iview always displays the XML -- all the time everytime leading me to believe that its something to do with the application of the filter ?
    Has anyone else come across this issue before and can point me in the right direction.
    Thanks
    Haydn

    Having been right around the houses now - im confident that both the XSL file and indeed the XML file are correctly constructed and under normal conditions work fine.
    The problem appears to be the CM repository (FSDB mode) being used.  It appears that once an XML file has been changed in the filesystem for whatever reason the first read ALWAYS results in a 500 being thrown.  Subsequent reads are 100% successful until the file is updated again - then the same process begins again. 
    What is even stranger is that if I create a brand new file in the directory (not in portal ui but direct in the FS) I cannot see it in the repository.  BUT if I construct a url to access it in a fresh browser window (which btw works fine) then a refresh of the KM explorer then shows the file - weird huh ?  Of course any actions that occur using the portal UI are also 100% successful.
    If I dont use a CM repository and just use a plain ordinary file system repository - it works faultlessly.
    Haydn

  • Regarding XML and XSLT in Weblogic

    Hi All,
    My servlet should read an XML file in the server and send HTML to the client. I want to convert XML into HTML thru XSL processor. Where should I store my XSL file and XML file. Also are there any things to attach to my classpath.
    Thanx in advance.
    Gopichand.

    I did this using Cocoon along with WebLogic 5.1. You might want to check out
    xml.apache.org to find out about Cocoon. It is not a big deal to integrate it with WebLogic 5.1. I am also posting another message now with the steps i followed to integrate Cocoon into weblogic.
    Thanks
    sai
    Gopichand wrote:
    Hi All,
    My servlet should read an XML file in the server and send HTML to the client. I want to convert XML into HTML thru XSL processor. Where should I store my XSL file and XML file. Also are there any things to attach to my classpath.
    Thanx in advance.
    Gopichand.

  • JSP, XML, XSLT: applying XSL on JSP-generated XML doc

    Hello,
    I am currently trying to figure out how to do the following:
    let's consider (that's not entirely hypothetical :) ) a web application working with JSP (on apache/tomcat 3.1) and oracle BC4J Application modules.
    The JSPs call oracle webbeans to perform updates and retrieve data from an 8.1.6 database.
    Now I'm thinking of moving to a combination of JSP, XML and XSL, which (hopefully) would allow to customize the application depending on the user's browser, language etc...(that's the point isn't it?)
    It doesn't seem to be a problem to produce XML from a jsp, send it directly to the client browser, which in turn goes to look for the proper XSL file and does all the transformation stuff.
    However this only works with I.E 5 for the moment right? and most website need to support various kinds of browsers...
    The need is:
    * When a non XML-capable browser is detected, apply the proper XSL(s) on the server side before sending the result back, in html/wml/whatever...
    * For XML-capable browsers, produce raw XML, maybe apply some XSL(s), and eventually send the result to the browser which handles the rest of the XSL stuff itself.
    Therefore, I'd like to:
    - Have the jsp produce the raw xml data (maybe adding extra tags, to indicate the browser and/or the language that the jsp engine has detected).
    - Pass the output to a first XSLT engine which would take care of the language stuff
    - Feed the result into a second XSLT engine to handle browser specificities for instance...
    - Send the final output to the client browser.
    Now, there are 2 problems:
    * 1/ I have seen various engines capable of chaining XSL transforms, and it is easy to produce XML from a jsp, but I don't know how to feed a jsp's output into an XML engine. is that possible? how?
    * 2/ I'm a bit concerned about the cost of applying three (or more) process stages, does anyone have insight on the performance issues this could raise?
    bonus question ;) : is there a simpler approach?
    Thanks a lot in advance, Remi
    null

    Hello,
    I am currently trying to figure out how to do the following:
    let's consider (that's not entirely hypothetical :) ) a web application working with JSP (on apache/tomcat 3.1) and oracle BC4J Application modules.
    The JSPs call oracle webbeans to perform updates and retrieve data from an 8.1.6 database.
    Now I'm thinking of moving to a combination of JSP, XML and XSL, which (hopefully) would allow to customize the application depending on the user's browser, language etc...(that's the point isn't it?)
    It doesn't seem to be a problem to produce XML from a jsp, send it directly to the client browser, which in turn goes to look for the proper XSL file and does all the transformation stuff.
    However this only works with I.E 5 for the moment right? and most website need to support various kinds of browsers...
    The need is:
    * When a non XML-capable browser is detected, apply the proper XSL(s) on the server side before sending the result back, in html/wml/whatever...
    * For XML-capable browsers, produce raw XML, maybe apply some XSL(s), and eventually send the result to the browser which handles the rest of the XSL stuff itself.
    Therefore, I'd like to:
    - Have the jsp produce the raw xml data (maybe adding extra tags, to indicate the browser and/or the language that the jsp engine has detected).
    - Pass the output to a first XSLT engine which would take care of the language stuff
    - Feed the result into a second XSLT engine to handle browser specificities for instance...
    - Send the final output to the client browser.
    Now, there are 2 problems:
    * 1/ I have seen various engines capable of chaining XSL transforms, and it is easy to produce XML from a jsp, but I don't know how to feed a jsp's output into an XML engine. is that possible? how?
    * 2/ I'm a bit concerned about the cost of applying three (or more) process stages, does anyone have insight on the performance issues this could raise?
    bonus question ;) : is there a simpler approach?
    Thanks a lot in advance, Remi
    null

  • Importing xml with xslt in InDesign CS4

    Hello All,
    i need someone's help who's an expert at xml and xslt features of InDesign CS4.
    i work in publication, besides our magazines we produce yearbooks with lots of repetative information fields in them. we get the data in xml fromat which we flow in to InDesign. the xml files are very simple, here's an example:
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    <Root>
    <Story>
          <Country> Afganistan </Country>
    <Company_ID>
       <Company_Name> Kam Air </Company_Name>
       <Company_Code> 1 </Company_Code>
       <Address_text> 1205 Qalla Fatuha </Address_text>
       <Address_text> P.O.Box 456 </Address_text>
       <Address_text> Kabul </Address_text>
       <Address_text> 22004 </Address_text>
       <Address_text> Afganistan </Address_text>
       <Telephone_text> Telephone: +93 20 2200 108 </Telephone_text>
       <Fax_text> Fax: +93 20 2200 110 </Fax_text>
       <Email_text> E-mail: [email protected] </Email_text>
       <Website_text> Website: www.flykamair.com </Website_text>
       <Personel_text> Abdul Raquib, chief Executive <Personel_text>
       <Personelmail_text> ([email protected]) </Personelmail_text>
       <Job_code> A1 </Job_code>
    </Company_ID>
         <Country> Albania </Country>
    etc.
    </Story>
    </Root>
    the problem is we don't want <Company_Code> and <Job_code> elements displayed in the InDesign file.
    so we created an xslt file that shoud get rid of these two unwanted elements (obviously the xml file above was pointed to this xslt file)
    <?xml version="1.0" ?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
    <Root>
    <Story>
      <Country>
    <xsl:for-each select="Company_ID">
       <Company_ID>
          <xsl:value-of select="Company_Name"/>
          <xsl:value-of select="Address"/>
          <xsl:value-of select="Telephone_text"/>
          <xsl:values-of select="Fax_tex"/>
          <xsl:value-of select=Email_text"/>
          <xsl:value-of select="Website_text"/>
          <xsl:value-of select="Personel_text"/>
          <xsl:value-of select="Pesronelmail_text"/>
       </Company_ID>
      </xsl:for-each>
    </Story>
    </Root>
    </xsl:template>
    </xsl:stylesheet>
    but it doesn't work. could someone tell me what's wrong with the xslt file? or what would the correct xslt file look like?
    Thanks everyone!

    Here's the sort of thing I mean in more detail.
    First, the XML file:
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    <?xml-stylesheet type="text/xsl" href="transform2.xsl"?>
    <Root>
    <Country>
    <Country_name>Afganistan</Country_name>
    <Company_ID>
       <Company_Name> Kam Air </Company_Name>
       <Company_Code> 1 </Company_Code>
       <Address_text> 1205 Qalla Fatuha </Address_text>
       <Address_text> P.O.Box 456 </Address_text>
       <Address_text> Kabul </Address_text>
       <Address_text> 22004 </Address_text>
       <Address_text> Afganistan </Address_text>
       <Telephone_text> Telephone: +93 20 2200 108 </Telephone_text>
       <Fax_text> Fax: +93 20 2200 110 </Fax_text>
       <Email_text> E-mail: [email protected] </Email_text>
       <Website_text> Website: www.flykamair.com </Website_text>
       <Personel_text> Abdul Raquib, chief Executive </Personel_text>
       <Personelmail_text> ([email protected]) </Personelmail_text>
       <Job_code> A1 </Job_code>
    </Company_ID>
    <Company_ID>
       <Company_Name> Another Company </Company_Name>
       <Company_Code> 2 </Company_Code>
       <Address_text> Elswhere</Address_text>
       <Address_text> P.O.Box 123</Address_text>
       <Address_text>Another City</Address_text>
       <Address_text> 22005 </Address_text>
       <Address_text> Afganistan </Address_text>
       <Telephone_text> Telephone: +12345678 </Telephone_text>
       <Fax_text> Fax: +12345678 </Fax_text>
       <Email_text> E-mail: [email protected] </Email_text>
       <Website_text> Website: www.dfhdfh.com </Website_text>
       <Personel_text> dfhdfhdfhdfhdfh</Personel_text>
       <Personelmail_text>dfhdfhdfhdfh</Personelmail_text>
       <Job_code> A2 </Job_code>
    </Company_ID>
    </Country>
         <Country>
    <Country_name>Albania</Country_name>
    <Company_ID>
       <Company_Name> Number 3 </Company_Name>
       <Company_Code>3</Company_Code>
       <Address_text>Somewhere in Albania</Address_text>
       <Address_text>Freedonia Avenue</Address_text>
       <Address_text>Whatever the captial of Albania is called</Address_text>
       <Address_text> 88888</Address_text>
       <Address_text> Albania </Address_text>
       <Telephone_text> Telephone: + 666 666 666 666 </Telephone_text>
       <Fax_text> Fax: + 777 777 777 777</Fax_text>
       <Email_text> E-mail: [email protected] </Email_text>
       <Website_text> Website: www.albaniar.com </Website_text>
       <Personel_text>Ludwig Wittgenstein, chief Executive </Personel_text>
       <Personelmail_text> ([email protected]) </Personelmail_text>
       <Job_code> A1 </Job_code>
    </Company_ID>
    </Country>
    </Root>
    Note that I have renamed the XSL file "transform2.xsl". I have got rid of the "Story" tag, and I have nested the tags more appropriately, with a new tag "Country_name". Here's the XSL:
    <?xml version="1.0" ?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
    <Root>
    <xsl:for-each select="/Root/Country">
    <Country>
    <Country_name><xsl:value-of select="Country_name"/></Country_name>
    <xsl:for-each select="Company_ID">
    <Company_Name><xsl:value-of select="Company_Name"/></Company_Name>
    <Address_text><xsl:value-of select="Address_text"/></Address_text>
    <Telephone_text><xsl:value-of select="Telephone_text"/></Telephone_text>
    <Fax_text><xsl:value-of select="Fax_text"/></Fax_text>
    <Email_text><xsl:value-of select="Email_text"/></Email_text>
    <Website_text><xsl:value-of select="Website_text"/></Website_text>
    <Personel_text><xsl:value-of select="Personel_text"/></Personel_text>
    <Personelmail_text><xsl:value-of select="Personelmail_text"/></Personelmail_text>
    </xsl:for-each>
    </Country>
    </xsl:for-each>
    </Root>
    </xsl:template>
    </xsl:stylesheet>
    (That file should be saved as "transform2.xsl" to match the link on line 2 of the XML.)
    Hope that works -- Jeremy

  • Using include-xml and different character encodings

    I have static XML documents which contain different character encodings in the xml prolog....
    ISO-8859, UTF-8, and SHIFT_JIS.
    Each of these documents has entities declared in an internal doctype declaration.
    I have an XSQL page with several <xsql:include-xml href="???.xml"/> statements.
    I want to make either --
    1) UTF-8 as the ultimate encoding of the resulting XML data
    2) Force the encodings on the individual documents to be changed to UTF-8
    I want to get a final XML data steam which can be successfully parsed and transformed. The xsql page has a stylesheet reference.
    Any assistance would be greatly appreciated.
    null

    karol wrote:XML and XSLT are separate, but they're not suitable for printing / pdf generation - LaTeX is. XML is really fluid and has no notions of typesetting built in. It's perfect for on-line reports you view with a web browser.
    Can I ask why XML and XSLT aren't suitable for printing / pdf generation?  Using XSL-FO I can define a page size, margin widths, etc., right?  Just because it isn't normally done doesn't immediately make it a bad idea.  I was under the impression that XML was intended to be abstract enough that it could be used for more than just web pages or data transfer.

  • 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.

  • Using XSLT to link XML and ABAP data

    Hi Experts,
    I am using XSLT to deal with XML and ABAP data.
    I using the following statement to convert a Internal Table to XML String:
    CALL TRANSFORMATION id SOURCE  root = lt_sflight RESULT XML l_xml_string.
    And I get the XML String:
    <?xml version="1.0" encoding="utf-16" ?>
    <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    <asx:values>
    <ROOT>
    <SFLIGHT>
    </SFLIGHT>
    <SFLIGHT>
    </SFLIGHT>
    </ROOT>
    </asx:values>
    </asx:abap>
    But What I expected is:
    <?xml version="1.0" encoding="utf-16" ?>
    <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    <asx:values>
    <ROOT>
    <DATA>
    </DATA>
    <DATA>
    </DATA>
    </ROOT>
    </asx:values>
    </asx:abap>
    Could you tell me how to get my dream format using XSLT?
    Best Regards,
    Guo Guo Qing
    Edited by: guoqing guo on Jun 11, 2008 9:58 AM

    Hi Experts,
    I am using XSLT to deal with XML and ABAP data.
    I using the following statement to convert a Internal Table to XML String:
    CALL TRANSFORMATION id SOURCE  root = lt_sflight RESULT XML l_xml_string.
    And I get the XML String:
    <?xml version="1.0" encoding="utf-16" ?>
    <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    <asx:values>
    <ROOT>
    <SFLIGHT>
    </SFLIGHT>
    <SFLIGHT>
    </SFLIGHT>
    </ROOT>
    </asx:values>
    </asx:abap>
    But What I expected is:
    <?xml version="1.0" encoding="utf-16" ?>
    <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    <asx:values>
    <ROOT>
    <DATA>
    </DATA>
    <DATA>
    </DATA>
    </ROOT>
    </asx:values>
    </asx:abap>
    Could you tell me how to get my dream format using XSLT?
    Best Regards,
    Guo Guo Qing
    Edited by: guoqing guo on Jun 11, 2008 9:58 AM

  • JSP Servlet and convert the result set of an SQL Query To XML file

    Hi all
    I have a problem to export my SQL query is resulty into an XML file I had fixed my servlet and JSP so that i can display all the records into my database and that the goal .Now I want to get the result set into JSP so that i can create an XML file from that result set from the jsp code.
    thisis my servlet which will call the jsp page and the jsp just behind it.
    //this is the servlet
    import java.io.*;
    import java.lang.reflect.Array;
    import java.sql.*;
    import java.util.ArrayList;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.naming.*;
    import javax.sql.*;
    public *class *Campaign *extends *HttpServlet
    *private* *final* *static* Logger +log+ = Logger.+getLogger+(Campaign.*class*.getName());
    *private* *final* *static* String +DATASOURCE_NAME+ = "jdbc/SampleDB";
    *private* DataSource _dataSource;
    *public* *void* setDataSource(DataSource dataSource)
    _dataSource = dataSource;
    *public* DataSource getDataSource()
    *return* _dataSource;
    *public* *void* init()
    *throws* ServletException
    *if* (_dataSource == *null*) {
    *try* {
    Context env = (Context) *new* InitialContext().lookup("java:comp/env");
    _dataSource = (DataSource) env.lookup(+DATASOURCE_NAME+);
    *if* (_dataSource == *null*)
    *throw* *new* ServletException("`" + +DATASOURCE_NAME+ + "' is an unknown DataSource");
    } *catch* (NamingException e) {
    *throw* *new* ServletException(e);
    protected *void *doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    Connection conn = *null*;
    *try* {
    conn = getDataSource().getConnection();
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select post_id,comments,postname from app.posts");
    // out.println("Le r&eacute;sultat :<br>");
    ArrayList <String> Lescomments= *new* ArrayList<String>();
    ArrayList <String> Lesidentifiant = *new* ArrayList<String>();
    ArrayList <String> Lesnoms = *new* ArrayList <String>();
    *while* (rs.next()) {
    Lescomments.add(rs.getString("comments"));
    request.setAttribute("comments",Lescomments);
    Lesidentifiant.add(rs.getString("post_id"));
    request.setAttribute("id",Lesidentifiant);
    Lesnoms.add(rs.getString("postname"));
    request.setAttribute("nom",Lesnoms);
    rs.close();
    stmt.close();
    *catch* (SQLException e) {
    *finally* {
    *try* {
    *if* (conn != *null*)
    conn.close();
    *catch* (SQLException e) {
    // les param&egrave;tres sont corrects - on envoie la page r&eacute;ponse
    getServletContext().getRequestDispatcher("/Campaign.jsp").forward(request,response);
    }///end of servlet
    }///this is the jsp page called
    <%@ page import="java.util.ArrayList" %>
    <%
    // on r&eacute;cup&egrave;re les donn&eacute;es
    ArrayList nom=(ArrayList)request.getAttribute("nom");
    ArrayList id=(ArrayList)request.getAttribute("id");
    ArrayList comments=(ArrayList) request.getAttribute("comments");
    %>
    <html>
    <head>
    <title></title>
    </head>
    <body>
    Liste des campagnes here i will create the xml file the problem is to display all rows
    <hr>
    <table>
    <tr>
    </tr>
    <tr>
    <td>Comment</td>
    <td>
    <%
    for( int i=0;i<comments.size();i++){
    out.print("<li>" + (String) comments.get(i) + "</li>\n");
    }//for
    %>
    </tr>
    <tr>
    <td>nom</td>
    <td>
    <%
    for( int i=0;i<nom.size();i++){
    out.print("<li>" + (String) nom.get(i) + "</li>\n");
    }//for
    %>
    </tr>
    <tr>
    <td>id</td>
    <td>
    <%
    for( int i=0;i<id.size();i++){
    out.print("<li>" + (String) id.get(i) + "</li>\n");
    }//for
    %>
    </tr>
    </table>
    </body>
    </html>
    This is how i used to create an XML file in a JSP page only without JSP/SERVLET concept:
    <%@ page import="java.sql.*" %>
    <%@ page import="java.io.*" %>
    <%
    // Identify a carriage return character for each output line
    int iLf = 10;
    char cLf = (*char*)iLf;
    // Create a new empty binary file, which will content XML output
    File outputFile = *new* File("C:\\Users\\user\\workspace1\\demo\\WebContent\\YourFileName.xml");
    //outputFile.createNewFile();
    FileWriter outfile = *new* FileWriter(outputFile);
    // the header for XML file
    outfile.write("<?xml version='1.0' encoding='ISO-8859-1'?>"+cLf);
    try {
    // Define connection string and make a connection to database
    Connection conn = DriverManager.getConnection("jdbc:derby://localhost:1527/SAMPLE","app","app");
    Statement stat = conn.createStatement();
    // Create a recordset
    ResultSet rset = stat.executeQuery("Select * From posts");
    // Expecting at least one record
    *if*( !rset.next() ) {
    *throw* *new* IllegalArgumentException("No data found for the posts table");
    outfile.write("<Table>"+cLf);
    // Parse our recordset
    // Parse our recordset
    *while*(rset.next()) {
    outfile.write("<posts>"+cLf);
    outfile.write("<postname>" + rset.getString("postname") +"</postname>"+cLf);
    outfile.write("<comments>" + rset.getString("comments") +"</comments>"+cLf);
    outfile.write("</posts>"+cLf);
    outfile.write("</Table>"+cLf);
    // Everything must be closed
    rset.close();
    stat.close();
    conn.close();
    outfile.close();
    catch( Exception er ) {
    %>

    Please state your problem that you are having more clearly so we can help.
    I looked at your code I here are a few things you might consider:
    It looks like you are putting freely typed-in comments from end-users into an xml document.
    The problem with this is that the user may enter characters in his text that have special meaning
    to xml and will have to be escaped correctly. Some of these characters are less than character, greater than character and ampersand character.
    You may also have a similiar problem displaying them on your JSP page since there may be special characters that JSP has.
    You will have to read up on how to deal with these special characters (I dont remember what the rules are). I seem to recall
    if you use CDATA in your xml, you dont have to deal with those characters (I may be wrong).
    When you finish writing your code, test it by entering all keyboard characters to make sure they are processed, stored in the database,
    and re-displayed correctly.
    Also, it looks like you are putting business logic in your JSP page (creating an xml file).
    The JSP page is for displaying data ONLY and submitting back to a servlet. Put all your business logic in the servlet. Putting business logic in JSP is considered bad coding and will cause you many hours of headache trying to debug it. Also note: java scriptlets in a JSP page are only run when the JSP page is compiled into a servlet by java. It does not run after its compiled and therefore you cant call java functions after the JSP page is displayed to the client.

  • Query on sorting  XML using XSLT and getting the same XML as output !

    Hi,
    Looking for one information regarding sorting XML using XSLT , with the sorted XML as output. For eg. my XML is :
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="sort1.xsl"?>
    <levelone>
         <child ID="1" sort="5">
              <name>Paul</name>
         </child>
         <child ID="2" sort="1">
              <name>Adam</name>
         </child>
         <child ID="3" sort="2">
              <name>Will</name>
         </child>
    </levelone>
    and XSL :
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/levelone">
         <xsl:copy>
         <xsl:apply-templates>
              <xsl:sort select="@sort"/>
         </xsl:apply-templates>
              </xsl:copy>
         </xsl:template>
         <xsl:template match="child">
              <xsl:copy-of select="."/>
         </xsl:template>
    </xsl:stylesheet>
    This does the sort based on Name. But I want to get the same xml as output with the name sorted. Eg.
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="sort1.xsl"?>
    <levelone>
         <child ID="2" sort="1">
              <name>Adam</name>
         </child>
         <child ID="1" sort="5">
              <name>Paul</name>
         </child>
         <child ID="3" sort="2">
              <name>Will</name>
         </child>
    </levelone>
    Any pointers will be highly appreciated.
    - Thanks

    Don't you want <xsl:sort select="name"/> rather than <xsl:sort select="@sort"/>?

  • Using XML extraction from Oracle and XSLT data transformation

    Hi
    How can transfer data ie: Using XML extraction from Oracle and XSLT data transformation with java application?
    usually i use to do querying sql, getting data from table assinging to model class then send it to UI. how can i go for XML extraction form oracle?
    thanks

    Sorry, I don't understand what exactly you want to do. And I'm under the impression that you might not know exactly what you want to do as well. Could you explain a bit more detailed what you want to achieve?

Maybe you are looking for

  • MW not showing Internet Expenses pre-upgrade tasks

    User logins to MW, Selects project from "Select Role" "Engineer", Select category "Prep for Upgrade" from Process Steps. An assigned task/step for that user does not appear. For this particular user it is Category=Prep for Upgrade, Prod Family=Financ

  • LibACE.so.5.5 core dump  if link libCstd.so.1, but link libCstd.a is ok?

    i think libACE.so.5.5 is conflict with libCstd.so.1, but how to prove? very thank! ********complie env root@cm440 # showrev Hostname: cm440 Hostid: *** Release: 5.8 Kernel architecture: sun4u Application architecture: sparc Hardware provider: Sun_Mic

  • Re: corrupted database

    Interestly. If I trivially modify am action class and save it, I see the session variables in the variable view. It is as if I need to touch all the action classes to make it rebuild correctly. "Alan Berezin" <[email protected]> wrote in message news

  • How can I get column totals with group breaks

    We manually generate a report of file groups and their associated data files each day for each of our databases. For each database we take data from dbcc showfilestats and assemble it into an Excel spreadsheet (see below). I would like to use a SQL j

  • My iPhone 5s is stuck in recovery loop after update to IOS8.1

    Can anyone help me, my iPhone 5s keeps saying my phone needs to go into recovery mode, though iTunes just says i need to connect it, when i plug it in it docent recognise it anyway. The download starts however this takes 2 hours, during this time i g