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.

Similar Messages

  • Help,about jsp+xml+xslt

    if I write like this:
    <?xml version="1.0" encoding="GB2312"?>
    <%@ page contentType="text/html;charset=GB2312"%>
    <?xml-stylesheet type="text/xsl" href="xslt/test.xslt"?>
    <news>
    <word>
    link
    </word>
    <link>
    abc.jsp
    </link>
    </news>
    the test.xslt can convert the xml to html
    but I write like this:
    <?xml version="1.0" encoding="GB2312"?>
    <%@ page contentType="text/html;charset=GB2312"%>
    <?xml-stylesheet type="text/xsl" href="xslt/href.xslt"?>
    <%
    out.println("<news><word>link</word><link>abc.jsp</link></news>");
    %>
    the test.xslt would not work,why????

    first the xslt is in a .xsl file
    second I'm pretty sure you can't put java in an xsl file.

  • Web Based Messageboard (JSP, XML, XSLT) - Just Looking For Advice Please!

    I have a general question - I am not looking for any code, just some advice if possible. I am studying on a Masters course and I have been given an assignment to do which I am having difficult getting started. I have worked a lot with Java up until now, however this is the first time I have had to JSP on my course.
    My current assignment is that I am required to create a simple web based message board, using JSP and XML, which allows users to post messages to the board, and also to reply to messages. The content of the message board is stored in an XML file, and there is no database involved. The message data needs to be formatted for viewing in a browser using XSL transformations.
    I am stuck as to how to go about starting the project, and this is all I am asking for advice in. I have created the basic XML file which has some preliminary data stored within it, and I have created an XSL stylesheet to transform this data, however I am stuck with the JSP. Do I need to create a seperate JSP page for each page of the website? How does this link in with the XSLT?
    I would welcome and really appreciate any advice, but I stress that I am not looking for anyone to give me any code or anything like that.
    Thanks.

    You can use XSLT to convert XML to HTML. Then include this HTML in your JSP. Further on you've a plain HTML form with an input field for a message which you submit to a servlet. In the servlet validate/convert/whatever this message and add it to the XML file and then forward/redirect the request back to the JSP.

  • 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

  • Help with XML to HTML or JS or ASP?

    Let me begin by saying that I am new to using XML.
    I have been able to create a simple tree menu using XML tags, and then saved it as *.xml.  I am using Version 6.0.
    My problem is that I do not know how to convert the xml file into a viewable web page for my users, wheather it is HTML or JSP or ASP.
    Below is the xml that I have created:
    <?xml version="1.0" encoding="UTF-8"?>
    <menu>
    <style>left menu</style>
    <name>BIMI Menu</name>
    <item>
    <name>Home</name>
    <related-page>index.htm</related-page>
    </item>
    <menu>
    <name>HBCA</name>
      <menu>
      <name>Actuate</name>
       <menu>
       <name>Direct Weekly</name>
        <item>
         <name>DR03w - Direct Weekly</name>
         <related-page>#</related-page>
        </item>
       </menu>
       <menu>
       <name>Intraweek Acquisition Weekly</name>
        <item>
         <name>Intraweek Acquisition Weekly</name>
         <related-page>#</related-page>
        </item>
       </menu>
       <menu>
       <name>OAO (OSA) Weekly</name>
        <item>
         <name>DR01w - New Accounts</name>
         <related-page>#</related-page>
        </item>
        <item>
         <name>DR01w - OSA Weekly</name>
         <related-page>#</related-page>
        </item>
        <item>
         <name>DR01w - Promo Code</name>
         <related-page>#</related-page>
        </item>
       </menu>
       <menu>
       <name>Weekly Commercial Checking</name>
        <item>
         <name>Commercial Checking Report - MNY N</name>
         <related-page>#</related-page>
        </item>
       </menu>
      </menu>
      <menu>
      <name>Cognos</name>
       <item>
        <name>Product Analysis Monthly Dashboard</name>
        <related-page>#</related-page>
       </item>
      </menu>
    </menu>
    <menu>
    <name>HBUS</name>
      <menu>
      <name>Cognos</name>
       <menu>
       <name>Product Analysis</name>
        <item>
         <name>PA101 - New Account Analysis Dashboard</name>
         <related-page>#</related-page>
        </item>
       </menu>
       <menu>
       <name>Balance Tier Analysis</name>
        <item>
         <name>BT101 - Balance Tier Analysis Report</name>
         <related-page>#</related-page>
        </item>
       </menu>
       <menu>
       <name>RM Data Analysis</name>
        <item>
         <name>RM191 RM Portfolio - Personal Customer Details By District</name>
         <related-page>#</related-page>
        </item>
       </menu>
      </menu>
       <name>Actuate</name>
       <related-page>#</related-page>
    </menu>
    </menu>
    If someone can point me in the right direction, it would be a great help!
    Thank you in advance.

    I am currently using Dreamweaver version 6, and based on what I read the transformation options for XSLT are only seen on version 8.
    So in order for me to make this work I would have to create an xslt file by scratch that would loop through the xml code and transform it so that I could render it in html or maybe jsp.
    This is where my knowledge is lacking.
    I found this code that I thought could be useful:
    <?xml version='1.0'?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <xsl:for-each select="//menu/entry">
      <xsl:call-template name="SubMenu">
      <xsl:with-param name="strCSS">Parent IsVisible</xsl:with-param>
    </xsl:call-template>
    </xsl:for-each>
    </xsl:template>
    <xsl:template name="SubMenu">
    <xsl:param name="strCSS" />
    <xsl:variable name="strURL" select="url" />
    <div class="{$strCSS}">
      <xsl:choose>
       <xsl:when test="count(entry) > 0">
        <!-- Element has children, it can be expanded -->
        <input type="hidden" id="hidIsExpanded" value="0" />
        <label id="lblExpand" class="Expander" onclick="ExpanderClicked()">+
        </label>
       </xsl:when>
       <xsl:otherwise>
        <label class="Expander">  </label>
       </xsl:otherwise>
      </xsl:choose>
      <a href="{$strURL}"><xsl:value-of select="name" /></a>
      <xsl:for-each select="entry">
       <xsl:call-template name="SubMenu">
        <xsl:with-param name="strCSS">NotVisible</xsl:with-param>
       </xsl:call-template>
      </xsl:for-each>
    </div>
    </xsl:template>
    </xsl:stylesheet>
    Along with this I have some javascript for the expand/collapse functionality....but even with this xslt I am unable o view the menu...so I must be doing something wrong????

  • JSP xml to html

    I keep getting this error when I try to transform an xml file into html.
    org.apache.jasper.JasperException: Unable to open taglibrary http://jakarta.apache.org/taglibs/xsl-1.0 : null
    Here is the jsp file
    <%@taglib uri="http://jakarta.apache.org/taglibs/xsl-1.0"
    prefix="xsltlib" %>
    <html>
    <head>
    <title>Book Inventory</title>
    </head>
    <body bgcolor="white">
    <center>
    Welcome
    <font color="red">
    On Sale Today ...
    </font>
    <p></p>
    <xsltlib:apply xml="cdcatalog.xml" xsl="cdcatalog.xsl"/>
    </center>
    </body>
    </html>

    org.apache.jasper.JasperException: Unable to open
    taglibrary http://jakarta.apache.org/taglibs/xsl-1.0 :
    nullWell, like the first answer to your post, it's like the error message says:
    The file ist not there! Try to open it with your browser and you'll get an error message.
    I think, it's not a good idea to reference remote URLs, because not everyone got a dedicated line. So download the xsl-taglib from
    http://jakarta.apache.org/builds/jakarta-taglibs/nightly/projects/xsl/
    The documentation and all other stuff is located at
    http://jakarta.apache.org/taglibs/doc/xsl-doc/intro.html
    Hope this helps.

  • JSP(XML+XSL)=HTML : error: sealing violation

    Hi,
    I have this jsp which will transform an xml file to html using xsl file... but its giving me a sealing violation. i tried the same code in a java application and its working...
    The error thrown is this:
    Internal Servlet Error:
    javax.servlet.ServletException: sealing violation
    Root cause:
    java.lang.SecurityException: sealing violation
    <%@ page language="java" session="true" import="java.io.*,javax.xml.parsers.*,org.w3c.dom.*,javax.xml.transform.*,javax.xml.transform.stream.*" %>
    <%
    StreamSource xml = new StreamSource( new File( "C:\\Tomcat\\webapps\\pc\\logs\\TransactionLog.xml" ) );
    StreamSource xsl = new StreamSource( new File( "C:\\Tomcat\\webapps\\pc\\logs\\TransactionLog.xsl" ) );
    StreamResult result = new StreamResult( out );
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer( xsl );
    transformer.setParameter( "recordsPerPage", "10" );
    transformer.setParameter( "pageNumber", request.getParameter( "pageNumber" ) );
    transformer.transform( xml, result ); // this is where the error is thrown...
    %>
    i hope somebody can help me with this...
    thanks,
    mitch

    Hi
    I think that It's because of some confilict between packages, try to set more priority for your jar files in tomcat.bat file as below :
    set cp=%CLASSPATH%
    set CLASSPATH=.
    set CLASSPATH=%TOMCAT_HOME%\classes
    set CLASSPATH=%CLASSPATH%;%TOMCAT_HOME%\lib\webserver.jar
    set CLASSPATH=%CLASSPATH%;%TOMCAT_HOME%\lib\jasper.jar
    set CLASSPATH=%CLASSPATH%;%TOMCAT_HOME%\lib\xml.jar
    set CLASSPATH=%CLASSPATH%;%TOMCAT_HOME%\lib\servlet.jar
    set CLASSPATH=%CLASSPATH%;%JAVA_HOME%\lib\tools.jar
    if "%cp%" == "" goto next
    set CLASSPATH=%cp%;%CLASSPATH%
    ALI

  • Help on XML+SQL- HTML

    I use the following SP to test transformation of XML and XSL, but the processXML seems didn't work, the result which should be a HTML is XML itself, please help.
    create or replace procedure xslsample is
    p xmlparser.Parser;
    xmldoc xmldom.DOMDocument;
    xmldocnode xmldom.DOMNode;
    proc xslprocessor.Processor;
    ss xslprocessor.Stylesheet;
    xsldoc xmldom.DOMDocument;
    docfrag xmldom.DOMDocumentFragment;
    docfragnode xmldom.DOMNode;
    xslelem xmldom.DOMElement;
    nspace varchar2(50);
    xslcmds xmldom.DOMNodeList;
    xml Clob;
    xsl Clob;
    buffer varchar2(2000);
    begin
    p := xmlparser.newParser;
    xmlparser.setValidationMode(p, FALSE);
    xmlparser.setErrorLog(p, 'c:\err.log');
    xmlparser.setPreserveWhiteSpace(p, TRUE);
    --xmlparser.setBaseDir(p, 'c:\');
    select content into xml from snippet where id=5 ; -- parse xml
    xmlparser.parseClob(p, xml);
    xmldoc := xmlparser.getDocument(p);
    select content into xsl from snippet where id=6; -- parse xsl
    xmlparser.parseClob(p, xsl);
    xsldoc := xmlparser.getDocument(p);
    proc := xslprocessor.newProcessor;
    ss := xslprocessor.newStylesheet(xsldoc, 'c:\iden.xsl');
    -- xmldocnode := xmldom.makeNode(xmldoc);
    xslprocessor.processXSL(proc, ss, xmldoc,buffer);
    -- docfrag :=docfragnode := xmldom.makeNode(docfrag);
    dbms_output.put_line('Writing transformed document');
    -- xmldom.writeToBuffer(docfragnode, buffer);
    dbms_output.put_line(substr(buffer,1,200));
    xslprocessor.freeStyleSheet(ss);
    xslprocessor.freeProcessor(proc);
    -- deal with exceptions
    exception
    when xmldom.INDEX_SIZE_ERR then
    raise_application_error(-20120, 'Index Size error');
    when xmldom.DOMSTRING_SIZE_ERR then
    raise_application_error(-20120, 'String Size error');
    when xmldom.HIERARCHY_REQUEST_ERR then
    raise_application_error(-20120, 'Hierarchy request error');
    when xmldom.WRONG_DOCUMENT_ERR then
    raise_application_error(-20120, 'Wrong doc error');
    when xmldom.INVALID_CHARACTER_ERR then
    raise_application_error(-20120, 'Invalid Char error');
    when xmldom.NO_DATA_ALLOWED_ERR then
    raise_application_error(-20120, 'Nod data allowed error');
    when xmldom.NO_MODIFICATION_ALLOWED_ERR then
    raise_application_error(-20120, 'No mod allowed error');
    when xmldom.NOT_FOUND_ERR then
    raise_application_error(-20120, 'Not found error');
    when xmldom.NOT_SUPPORTED_ERR then
    raise_application_error(-20120, 'Not supported error');
    when xmldom.INUSE_ATTRIBUTE_ERR then
    raise_application_error(-20120, 'In use attr error');
    end xslsample;
    null

    I use the following SP to test transformation of XML and XSL, but the processXML seems didn't work, the result which should be a HTML is XML itself, please help.
    create or replace procedure xslsample is
    p xmlparser.Parser;
    xmldoc xmldom.DOMDocument;
    xmldocnode xmldom.DOMNode;
    proc xslprocessor.Processor;
    ss xslprocessor.Stylesheet;
    xsldoc xmldom.DOMDocument;
    docfrag xmldom.DOMDocumentFragment;
    docfragnode xmldom.DOMNode;
    xslelem xmldom.DOMElement;
    nspace varchar2(50);
    xslcmds xmldom.DOMNodeList;
    xml Clob;
    xsl Clob;
    buffer varchar2(2000);
    begin
    p := xmlparser.newParser;
    xmlparser.setValidationMode(p, FALSE);
    xmlparser.setErrorLog(p, 'c:\err.log');
    xmlparser.setPreserveWhiteSpace(p, TRUE);
    --xmlparser.setBaseDir(p, 'c:\');
    select content into xml from snippet where id=5 ; -- parse xml
    xmlparser.parseClob(p, xml);
    xmldoc := xmlparser.getDocument(p);
    select content into xsl from snippet where id=6; -- parse xsl
    xmlparser.parseClob(p, xsl);
    xsldoc := xmlparser.getDocument(p);
    proc := xslprocessor.newProcessor;
    ss := xslprocessor.newStylesheet(xsldoc, 'c:\iden.xsl');
    -- xmldocnode := xmldom.makeNode(xmldoc);
    xslprocessor.processXSL(proc, ss, xmldoc,buffer);
    -- docfrag :=docfragnode := xmldom.makeNode(docfrag);
    dbms_output.put_line('Writing transformed document');
    -- xmldom.writeToBuffer(docfragnode, buffer);
    dbms_output.put_line(substr(buffer,1,200));
    xslprocessor.freeStyleSheet(ss);
    xslprocessor.freeProcessor(proc);
    -- deal with exceptions
    exception
    when xmldom.INDEX_SIZE_ERR then
    raise_application_error(-20120, 'Index Size error');
    when xmldom.DOMSTRING_SIZE_ERR then
    raise_application_error(-20120, 'String Size error');
    when xmldom.HIERARCHY_REQUEST_ERR then
    raise_application_error(-20120, 'Hierarchy request error');
    when xmldom.WRONG_DOCUMENT_ERR then
    raise_application_error(-20120, 'Wrong doc error');
    when xmldom.INVALID_CHARACTER_ERR then
    raise_application_error(-20120, 'Invalid Char error');
    when xmldom.NO_DATA_ALLOWED_ERR then
    raise_application_error(-20120, 'Nod data allowed error');
    when xmldom.NO_MODIFICATION_ALLOWED_ERR then
    raise_application_error(-20120, 'No mod allowed error');
    when xmldom.NOT_FOUND_ERR then
    raise_application_error(-20120, 'Not found error');
    when xmldom.NOT_SUPPORTED_ERR then
    raise_application_error(-20120, 'Not supported error');
    when xmldom.INUSE_ATTRIBUTE_ERR then
    raise_application_error(-20120, 'In use attr error');
    end xslsample;
    null

  • Help Please ! -- transform XML to HTML using xslt tag in JSP

    Hello,
    I have problem to do XSL transform in JSP.
    I have an XSL : test.xsl
    I have an XML : test.xml
    In JSP I have:
    <x:xslt media="html" xml="test.xml">
    <x:stylesheet media="html" uri="test.xsl" />
    </x:xslt>
    But It doesn't work the way it suppose to. What is wrong in my code ? I followed the URL http://e-docs.bea.com/wls/docs81/xml/xml_apps.html
    Thanks in advance,
    Christina

    Basically:
        try{
          //Setting up parameters.
          xml=new StreamSource(new File(xmlInput));
          xsl=new StreamSource(new File(xslInput));
          baos=new ByteArrayOutputStream();
          htmlResult=new StreamResult(baos);
          //Transform input(xml, xsl) onto html output.
          TransformerFactory tfactory=TransformerFactory.newInstance();
          Transformer transformer=tfactory.newTransformer(xsl);
          transformer.transform(xml, htmlResult);
          baos.writeTo(out);
          //System.err.println(htmlResult.getOutputStream().toString());
        catch(...){
        }I havent tested and I havent use this for a while, but I hope this can serve as a staring point.
    Regards,
    OO

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

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

  • XML 2 HTML. Please help..

    Is there any standard API / programme(already written) in Java, to convert a HTML document to XML and also XML to HTML.
    Any suggestions, tips, links are appreciated. Please help.
    Thanks in advance,
    Xej.

    Hi!
    For XML to HTML conversion I use XSL transformation utilizing Xalan for Java(xml.apache.org). The other way round is not such an easy task because HTML is a little bit unpredictable with its tag usage. For example a <br> tag as line break is ok for all browsers but it's not well formed XML - in this case it should be
    If HTML is well formed in XML terms it's called XHTML and since that is a XML language you could use XSL for transforming it into another XML document.
    ~k

  • XML to HTML help

    This is just for a hobby, thanks for any suggestions or help.
    Digitech makes guitar multi-effects pedals and they have a public user forum for sharing preset files to simulate a variety of guitar sounds. The particular products I am interested in are older discontinued models RPx400, RP300A and RP300, the RPx400 uses a USB computer interface to store and share preset files as XML data, the older RP300 and RP300A models have the same effects and user controls but lack the computer interface. By viewing the contents of the XML preset file from the newer unit, one can manually enter the preset into the older models. So in the interest of helping to share some guitar sounds among the small user community of these older model discontinued effects pedals, I was interested in creating a XML to HTML preset patch viewer for the RPx400 files so that RP300 and RP300A users could try them out. (I am not affiliated with Digitech at all).
    An example preset file from the RPx400 is here:
    http://www.digitech.com/soundcomm/patches/RPx400/Queen.r4p
    Another line of GNX effects pedals has a preset viewer on the web, based on a different file format, but is a good example of how I would like to display the HTML to be more human-readable:
    preset viewer example
    So, I am a little familiar with perl and would lean towards using that, and I would want to set it up as a web page on my Tiger G3 with Personal Web Sharing which I have running with a DynDNS static alias to my dynamic IP.
    Any pointers on how to set this up would be most appreciated.

    Glen Doggett wrote:
    Yes, exactly how I would like to set it up, since I'd like to share this patch viewer with others on my Personal Web Sharing server. I understand how to write the perl, but the part about setting up the CGI I'm not sure about,
    Any Perl script can run as a CGI. Look for the CGI.pm module, which should always be installed. It is pretty simple. You get the Apache environment in the Perl %ENV hash when your script is run. If handling a POST request, the query comes in on standard input. The CGI.pm module can handle all of this very nicely.
    like what directory to put the perl script, does it matter?
    Yes. it has to go into your CGI-BIN directory, wherever your Apache configuration has that configured to be. Getting the cgi-bin directory straight is the hardest part of writing a CGI in Perl. This is the #1 reason why PHP is so popular. The default configuration for PHP allows PHP scripts to run in any directory. The default for Perl requires them to be in the cgi-bin directory. That's the only difference - the default setting.
    Is there a good reference book or on-line on the Mac-version of CGI how to set it up?
    Yes, but there are probably a few hundred. For this, there is nothing Mac about it. Just look for Apache CGI in Perl on UNIX. I have an ancient book on my desk titled "CGI Programming on the World Wide Web" circa 1996. It doesn't have CGI.pm and the screenshots are Netscape on MacOS 7. Still, it is just out of date, nothing in it is wrong per se.
    It should be a 5-10 line Perl script, depending on how many comments you write.

  • Error in xml to html transform function in 11g(Help needed urgent)

    We are migrating from 9g to 11g.Code given below is working fine with 9g but giving following error while converting xml to html.
    Error:Exception occurred in XML_TO_HTML :ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00609: Function call with invalid number of arguments in 'position (//USER)'.
    Code :<?xml version='1.0'?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
    <HTML>
    <BODY>
    <!--begin header-->
    <xsl:for-each select="AMAP_REMMIT_EMP/HEADERS/HEADER">
    <TABLE border="0" cellpadding="0" cellspacing="0" style="padding:1px" width="100%" height="95" bgcolor="#EAEAEA"><font size="6" face="Arial">amdocs </font>
    <TR >
    <TD width="50%" align="left" ><b/><font size="2" face="Verdana" /> <xsl:value-of select="VENDOR_NAME"/></TD>
    <TD width="50%" align="left"><b/><font size="2" face="Verdana" />Date: <xsl:value-of select="RUN_DATE"/>
    </TD>
    </TR>
    <TR >
    <TD width="50%" align="left" ><b/><font size="2" face="Verdana" /> <xsl:value-of select="ADDRESS"/></TD>
    <TD width="50%" align="left"><b/><font size="2" face="Verdana" /> <xsl:value-of select="TAX_ID"/>
    </TD>
    </TR>
    <TR >
    <TD width="50%" align="left" ><b/><font size="2" face="Verdana" /> <xsl:value-of select="CITY"/> <xsl:value-of select="ZIP"/></TD>
    <TD width="50%" align="left"><b/><font size="2" face="Verdana" />Vendor Number: <xsl:value-of select="OSEK_MURSHE"/>
    </TD>
    </TR>
    <TR >
    <TD width="50%" align="left" ><b/><font size="2" face="Verdana" /> </TD>
    <TD width="50%" align="left"><b/><font size="2" face="Verdana" />Fax Number: <xsl:value-of select="FAX"/>
    </TD>
    </TR>
    </TABLE>
    </xsl:for-each>
    <!--end header-->
    <!--begin lines-->
    <p dir="ltr" align="center">
    <span style="font-family: Arial; text-decoration: underline; font-weight: 700">
    Subject: Remittance Advice</span></p>
    <table border="1" cellspacing="1" width="100%" bgcolor="#C0C0C0">
    <tr>
    <th width="20%"><font face="Arial"><b>Invoice Date</b></font></th>
    <th width="20%"><font face="Arial"><b>Invoice Number</b></font></th>
    <th width="40%"><font face="Arial"><b>Description</b></font></th>
    <th width="20%"><font face="Arial"><b><xsl:value-of select="AMAP_REMMIT_EMP/HEADERS/HEADER/CURRENCY"/> Amount</b></font></th>
    </tr>
    <xsl:for-each select="AMAP_REMMIT_EMP/MERGE_LINE/LINES/LINE">
    <tr>
    <td width="20%" >
    <xsl:attribute name="bgcolor">
    <xsl:if test="position() mod 2 = 0">#DDDDDD</xsl:if>
    <xsl:if test="position() mod 2 = 1">#FFFFCC</xsl:if>
    </xsl:attribute>
    <xsl:value-of select="INVOICE_DATE"/></td>
    <td width="20%" >
    <xsl:attribute name="bgcolor">
    <xsl:if test="position() mod 2 = 0">#DDDDDD</xsl:if>
    <xsl:if test="position() mod 2 = 1">#FFFFCC</xsl:if>
    </xsl:attribute>
    <xsl:value-of select="INVOICE_NUM"/></td>
    <td width="40%" >
    <xsl:attribute name="bgcolor">
    <xsl:if test="position() mod 2 = 0">#DDDDDD</xsl:if>
    <xsl:if test="position() mod 2 = 1">#FFFFCC</xsl:if>
    </xsl:attribute>
    <xsl:value-of select="DESCRIPTION"/></td>
    <td width="20%" >
    <xsl:attribute name="bgcolor">
    <xsl:if test="position() mod 2 = 0">#DDDDDD</xsl:if>
    <xsl:if test="position() mod 2 = 1">#FFFFCC</xsl:if>
    </xsl:attribute>
    <xsl:value-of select="AMOUNT"/></td>
    </tr>
    </xsl:for-each>
    <tr>
    <td width="80%" bgcolor="#FFFFFF" colspan="3" align="right">
    <b>Total Payment:</b></td>
    <td width="20%" bgcolor="#FFFFFF"><xsl:value-of select="//TOTAL"/></td>
    </tr>
    </table>
    <p dir="ltr" align="left"><span style="font-family: Arial"><font size="2">In accordance with your instructions, this amount will be transferred to your <xsl:if test="AMAP_REMMIT_EMP/MERGE_LINE/SITES/SITE/INCLUDE_BANK_DETAILES='Y'">
    account number <xsl:value-of select="AMAP_REMMIT_EMP/MERGE_LINE/LINES/LINE/ACCOUNT"/> in bank
    <xsl:value-of select="AMAP_REMMIT_EMP/MERGE_LINE/LINES/LINE/BANK"/> , branch <xsl:value-of select="AMAP_REMMIT_EMP/MERGE_LINE/LINES/LINE/BRANCH"/>
    on the date of <xsl:value-of select="AMAP_REMMIT_EMP/MERGE_LINE/LINES/LINE/CHECK_DATE"/>.
    </xsl:if>
    <xsl:if test="AMAP_REMMIT_EMP/MERGE_LINE/SITES/SITE/INCLUDE_BANK_DETAILES!='Y'">
    account on the date of <xsl:value-of select="AMAP_REMMIT_EMP/MERGE_LINE/LINES/LINE/CHECK_DATE"/>.
    </xsl:if>
    <xsl:if test="AMAP_REMMIT_EMP/MERGE_LINE/CREDITNOTES/CREDITNOTE/CREDITNOTE>'0'">
    <p>The payment will be credited in two days from the payment date in your account.</p>
    </xsl:if>
    <p>In case this date is not a valid value date in the bank system, the money will be transferred in the next valid value date.</p>
    <xsl:value-of select="AMAP_REMMIT_EMP/MERGE_LINE/NOTES/NOTE/DESCRIPTION"/>
    </font></span></p>
    <TABLE border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" height="50">
    <TR >
    <TD width="60%" ></TD>
    <TD width="40%" align="left"><b/><font size="2" face="Verdana" />Yours sincerely,</TD>
    </TR>
    <TR >
    <TD width="60%" ></TD>
    <TD width="40%" align="left"><b/><font size="2" face="Verdana" /> <xsl:value-of select="AMAP_REMMIT_EMP/MERGE_LINE/LINES/LINE/COMPANY_NAME"/></TD>
    </TR>
    <!--end lines-->
    <!--end trailer-->
    </TABLE>
    <table cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-left-width: 1; border-right-width: 1; border-top-style: solid; border-top-width: 1; border-bottom-width: 1; padding: 0" bordercolor="#111111" width="100%">
    <tr>
    <td width="34%">Alert No:<xsl:value-of select="AMAP_REMMIT_EMP/HEADERS/HEADER/ALERT_ID"/></td>
    <td width="33%">Environment: <xsl:value-of select="AMAP_REMMIT_EMP/HEADERS/HEADER/DB_NAME"/></td>
    <td width="33%">Date:<xsl:value-of select="AMAP_REMMIT_EMP/HEADERS/HEADER/MAIL_DATE"/></td>
    </tr>
    </table>
    <!--end trailer-->
    </BODY>
    </HTML>
    </xsl:template>
    </xsl:stylesheet>
    Thanks in advance.

    #1. We need to see the code that is being used to invoke the stylesheet.
    #2. We need to see the document that is being transformed...
    It's most likely a bug in 9g which has been fixed in 11g...

  • Jsp & XML-XSL

    Hello.
    I have a device that produce XML output file( dynamically )
    I need to read it by Jsp page.
    I able to do it using XSL but when XML changes my Jsp page is not updated.
    Only if i recompile jsp page i get new data
    Do you know some methods to get dynamically XLM data?
    Thx
    Riccardo
    example code:
    <%@page contentType="text/html"%>
    <html><head><title>XSLT Example</title>
    <%@ taglib uri='/WEB-INF/tlds/xslt.tld' prefix='xslt' %>
    </head>
    <body>
    <xslt:apply xsl='Fieldgate.xsl'>
         <%@ include file='output.xml' %>
    </xslt:apply>
    </body></html>

    Thats because you are including your XML in your JSP.
    If you were to parse your XML in your in your JSP using SAX or DOM and then use them to populate the dynamic contents of your JSP then you will not need to recomplie your JSP.
    Read the following article. It will help you out and possibly give you some other Ideas.
    http://developer.java.sun.com/developer/technicalArticles/xml/WebAppDev2/#code13

Maybe you are looking for