Link to home
Start Free TrialLog in
Avatar of CFree
CFree

asked on

how to use JAXP in applet?

how to use JAXP in applet?
hi,
The codes as following really do work, but when I add them to a Applet,error occured:
Output method is xml could not load output_xml.properties<check CLASSPATH>
at org.apache.xalan.templates.OutputProperties......

I never set classpath after all. I just copied the .jar files from JAXP 1.4 to java\j2re1.4.0\lib\ext\
thanks in advance!

import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import javax.xml.transform.dom.DOMSource;
import java.io.*;
import org.w3c.dom.*;


public class XmlString
{    
  public static void main(String[] args)
  {    
         
    try
    {
      DocumentBuilderFactory docFac = DocumentBuilderFactory.newInstance();    
       DocumentBuilder db = docFac.newDocumentBuilder();    
      Document m_dDoc = db.newDocument();
      Element   e1=m_dDoc.createElement("first");
      Text tx;
      tx=m_dDoc.createTextNode("hi");
      e1.appendChild(tx);/* */    
      m_dDoc.appendChild(e1);
       TransformerFactory tfac = TransformerFactory.newInstance();    
       StringWriter strWtr = new StringWriter();    
       StreamResult strResult = new StreamResult(strWtr);    
       Transformer trans = tfac.newTransformer();    
       trans.transform(new DOMSource(m_dDoc.getDocumentElement()), strResult);    
       System.out.println(strResult.getWriter().toString());
     }
     catch(Exception e)
     {
     }

   } // main
}
Avatar of heyhey_
heyhey_

  catch(Exception e)
    {
      e.printStackTrace();
    }

and copy and paste the exception stacktrace.
Avatar of CFree

ASKER

org.apache.xml.utils.WrappedRuntimeException: Output method is xml could not loa
d output_xml.properties (check CLASSPATH)
        at org.apache.xalan.templates.OutputProperties.getDefaultMethodPropertie
s(OutputProperties.java:364)
        at org.apache.xalan.templates.OutputProperties.<init>(OutputProperties.j
ava:130)
        at org.apache.xalan.transformer.TransformerIdentityImpl.<init>(Transform
erIdentityImpl.java:104)
        at org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(Tran
sformerFactoryImpl.java:804)
        at XMLTest.init(XMLTest.java:36)
        at sun.applet.AppletPanel.run(AppletPanel.java:341)
        at java.lang.Thread.run(Thread.java:536)
JAXP implementaion may not work in an Applet as it checks for default properties on the system. Under normal circumstances, Applet cannot access system resources, so it cannot load default properties
ASKER CERTIFIED SOLUTION
Avatar of heyhey_
heyhey_

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CFree

ASKER

gvjay:would you tell me some special way to let JAXP work in applet?

Avatar of CFree

ASKER

gvjay:would you tell me some special way to let JAXP work in applet?

Avatar of CFree

ASKER

gvjay:would you tell me some special way to let JAXP work in applet?

Avatar of girionis
>org.apache.xml.utils.WrappedRuntimeException: Output method
> is xml could not load output_xml.properties (check CLASSPATH)

  The output_xml.properties file resides under the src/org/apache/xalan/templates under the subdirectory on where you install the JAXP classes. Adjust your CLASSPATH accordingly.

  Hope it helps.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- PAQ'ed and points NOT refunded

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

vemul
Cleanup Volunteer
I don't agree

on the URL that I posted above

http://xml.apache.org/xalan-j/usagepatterns.html#applet

it's cleare explained how to use Xalan in applet (which was the original question)
Comment from expert accepted as answer

Computer101
E-E Admin