mmidy 99/12/14 07:13:24
Modified: src/org/apache/xalan/xslt/client XSLTProcessorApplet.java
Log:
Update applet test
Revision Changes Path
1.6 +46 -47
xml-xalan/src/org/apache/xalan/xslt/client/XSLTProcessorApplet.java
Index: XSLTProcessorApplet.java
===================================================================
RCS file:
/home/cvs/xml-xalan/src/org/apache/xalan/xslt/client/XSLTProcessorApplet.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XSLTProcessorApplet.java 1999/11/28 04:25:16 1.5
+++ XSLTProcessorApplet.java 1999/12/14 15:13:24 1.6
@@ -60,6 +60,7 @@
import java.awt.*;
import java.io.*;
import java.net.*;
+import java.lang.reflect.Constructor;
import org.apache.xalan.xslt.*;
import org.apache.xalan.xpath.xml.*;
// import org.apache.xalan.xpath.xml.xml4j.*;
@@ -129,6 +130,7 @@
* @serial
*/
private URL m_codeBase = null;
+ private URL m_documentBase = null;
private Document m_docTree = null;
private Document m_styleTree = null;
@@ -215,6 +217,7 @@
String param;
param = getParameter(PARAM_parser);
whichParser = (param != null) ? param : "ANY";
+
// styleURL: Parameter description
//----------------------------------------------------------------------
param = getParameter(PARAM_styleURL);
@@ -226,6 +229,7 @@
if (param != null)
setDocumentURL(param);
m_codeBase = this.getCodeBase();
+ m_documentBase = this.getDocumentBase();
// If you use a ResourceWizard-generated "control creator" class to
// arrange controls in your applet, you may want to call its
@@ -234,17 +238,9 @@
// CreateControls() does its own resizing.
//----------------------------------------------------------------------
resize(320, 240);
- try
- {
- m_processor = XSLTProcessorFactory.getProcessor();
- m_processor.setDiagnosticsOutput(System.out);
- m_liaison = m_processor.getXMLProcessorLiaison();
- }
- catch(org.xml.sax.SAXException se)
- {
- throw new RuntimeException(se.getMessage());
- }
-// initLiaison();
+
+ initLiaison();
+
}
/**
@@ -252,31 +248,32 @@
*/
protected void initLiaison()
{
- /*
+ //String parserName = (whichParser.equals("ANY")) ?
Constants.LIAISON_CLASS : whichParser ;
+ String parserName = Constants.LIAISON_CLASS;
try
{
- // This will throw an exception if not XML4J 2.0.X
- Class.forName("org.apache.xerces.parsers.NonValidatingDOMParser");
- Class classObj =
Class.forName("org.apache.xalan.xpath.xdom.XercesLiaison");
- m_liaison = (XMLParserLiaison)classObj.newInstance();
+ Class parserLiaisonClass = Class.forName(parserName);
+
+ Constructor parserLiaisonCtor =
parserLiaisonClass.getConstructor(null);
+ m_liaison = (XMLParserLiaison)parserLiaisonCtor.newInstance(null);
}
catch(Exception e)
{
- try
- {
- // See if any XML4J is loaded.
- Class.forName("org.apache.xerces.parser.TXDocument");
- Class classObj =
Class.forName("org.apache.xalan.xpath.xml.xml4j.ProcessXSL");
- m_liaison = (XMLParserLiaison)classObj.newInstance();
- }
- catch(Exception e2)
- {
- e2.printStackTrace();
- }
+ e.printStackTrace();
+
//System.err.println(XSLMessages.createMessage(XSLTErrorResources.ERROR0025,
new Object[] {parserLiaisonClassName})); //"Could not create XML Processor
Liaison: "+parserLiaisonClassName);
+ return;
+ }
+ try
+ {
+ m_processor = XSLTProcessorFactory.getProcessor();
+ m_processor.setDiagnosticsOutput(System.out);
+
+ }
+ catch(org.xml.sax.SAXException se)
+ {
+ se.printStackTrace();
+ throw new RuntimeException(se.getMessage());
}
- */
-// m_liaison = new org.apache.xalan.xpath.xdom.XercesLiaison();
- // m_processor = XSLTProcessorFactory.getProcessor();
}
@@ -498,24 +495,26 @@
* Get a DOM tree as escaped text, suitable for display
* in the browser.
*/
- public String getTreeAsText(Document tree)
+ public String getTreeAsText(String treeURL)
throws IOException
{
- String text = null;
- /*
+ String text = "";
+ byte[] buffer = new byte[50000];
+
try
- {
- org.apache.xalan.xpath.xml.Formatter formatter =
(org.apache.xalan.xpath.xml.Formatter)m_liaison;
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- formatter.toMarkup(tree, pw, Formatter.OUTPUT_METH_HTML, true);
- text = escapeString(sw.toString());
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- */
+ {
+ URL docURL = new URL(m_documentBase, treeURL);
+ InputStream in = docURL.openStream();
+
+ int nun_chars;
+ while ( ( nun_chars = in.read( buffer, 0, buffer.length
) ) != -1 )
+ {
+ text = text + new String( buffer, 0, nun_chars
);
+ }
+ in.close();
+ }
+ catch ( Exception any_error )
+ {any_error.printStackTrace();}
return text;
}
@@ -528,7 +527,7 @@
public String getSourceTreeAsText()
throws Exception
{
- return getTreeAsText(m_docTree);
+ return getTreeAsText(m_documentURL);
}
/**
@@ -540,7 +539,7 @@
public String getStyleTreeAsText()
throws Exception
{
- return getTreeAsText(this.m_styleTree);
+ return getTreeAsText(m_styleURL);
}
/**