/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package servlet;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.net.URL;
import java.net.MalformedURLException;
import java.net.URLConnection;
import javax.xml.transform.OutputKeys;
import org.apache.xalan.templates.Constants;
import org.apache.xalan.templates.StylesheetRoot;
import org.apache.xalan.templates.OutputProperties;
// SAX2 Imports
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Locator;
import org.xml.sax.helpers.XMLReaderFactory;
import org.xml.sax.ext.DeclHandler;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
import org.w3c.dom.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import javax.xml.transform.sax.SAXTransformerFactory;
import org.apache.xalan.transformer.TransformerImpl;
import org.apache.xpath.objects.XObject;
import org.apache.xpath.objects.XString;
import org.apache.xalan.processor.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import org.xml.sax.helpers.XMLFilterImpl;
/*****************************************************************************************************
*
* ApplyXSLT supplies the basic
* functions for transforming XML data using XSL stylesheets.
*
* @author Spencer Shepard (sshepard@us.ibm.com)
* @author R. Adam King (rak@us.ibm.com)
* @author Tom Rowe (trowe@us.ibm.com)
* @author Don Leslie (donald_leslie@lotus.com)
*
*****************************************************************************************************/
public class ApplyXSLT extends HttpServlet
{
/**
* Operational parameters for this class.
* <p>Request-time values override init-time values which override class defaults.</p>
* @see #init
* @serial
*/
protected ApplyXSLTProperties ourDefaultParameters = null;
private boolean useDefaultTemplates = false;
private Templates defaultTemplates = null;
/**
* String representing the end of line characters for the System.
*/
public final static String EOL = System.getProperty("line.separator");
/**
* String representing the file separator characters for the System.
*/
public final static String FS = System.getProperty("file.separator");
/**
* String representing the current directory for properties files. See init().
*/
public final static String ROOT = System.getProperty("server.root");
public static String CURRENTDIR;
/**
* Initialize operational parameters from the configuration.
* @param config Configuration
* @exception ServletException Never thrown
*/
public void init(ServletConfig config)
throws ServletException
{
super.init(config);
// If the server.root property --see above-- is null, use current working directory
// as default location for media.properties.
if (ROOT != null)
CURRENTDIR= ROOT + FS + "servlets" + FS;
else
CURRENTDIR = System.getProperty("user.dir")+ FS;
setDefaultParameters(config);
setMediaProps(config.getInitParameter("mediaURL"));
String defaultXSL = config.getInitParameter("xslURL");
try
{
if (defaultXSL !=null && defaultXSL.length() > 0)
compileXSL(defaultXSL);
}
catch (Exception e){}
}
/**
* If a default setting exists for xslURL, create a Templates object
* for rapid transformations.
*/
protected void compileXSL(String defaultXSL)
throws TransformerConfigurationException
{
TransformerFactory tFactory = TransformerFactory.newInstance();
defaultTemplates = tFactory.newTemplates(new StreamSource(defaultXSL));
useDefaultTemplates = true;
}
/**
* Sets the default parameters for the servlet from the configuration.
* Also sets required system properties until we figure out why servlet
* sometimess fails to read properties from properties files.
* @param config Configuration
*/
protected void setDefaultParameters(ServletConfig config)
{
ourDefaultParameters = new DefaultApplyXSLTProperties(config);
}
/**
* Loads the media properties file specified by the given string.
* @param mediaURLstring Location of the media properties file. Can be either a full URL or a path relative
* to the System's server.root /servlets directory. If this parameter is null,
* server.root/servlets/media.properties will be used.
* @see ApplyXSL#CURRENTDIR
*/
protected void setMediaProps(String mediaURLstring)
{
if (mediaURLstring != null)
{
URL url = null;
try
{
url = new URL(mediaURLstring);
}
catch (MalformedURLException mue1)
{
try
{
url = new URL("file", "", CURRENTDIR + mediaURLstring);
}
catch (MalformedURLException mue2)
{
writeLog("Unable to find the media properties file based on parameter 'mediaURL' = "
+ mediaURL
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
xalan-j_2_3_1-bin.zip (2000个子文件)
README.applet 4KB
README.brazil 6KB
README.cjaxp 1KB
stylesheet.css 1KB
Xalan SQL Extension.doc 37KB
README.ejb 3KB
data.gif 58KB
conceptual.gif 44KB
compilation.gif 13KB
xalan1_1x1.gif 12KB
trax.gif 11KB
DOMInterface.gif 10KB
xpath.gif 10KB
runtime_type_mapping.gif 9KB
xslt_abstract.gif 9KB
match_namespace2.gif 9KB
runtime_design.gif 8KB
compiler_design.gif 7KB
match_namespace1.gif 6KB
trax_translet_wrapping.gif 6KB
key_relations.gif 6KB
ast_stage3.gif 5KB
trax_output_settings.gif 5KB
class_loader.gif 5KB
overall_design.gif 5KB
ast_stage2.gif 5KB
dom_namespace3.gif 5KB
uri_resolver.gif 4KB
iterator_stack.gif 4KB
all_namespaces.gif 4KB
type_mappings.gif 4KB
dom_namespace2.gif 4KB
output_namespaces1.gif 3KB
output_namespaces2.gif 3KB
namespace_stack.gif 3KB
logo.gif 3KB
logo.gif 3KB
sort_objects.gif 3KB
dom_namespace1.gif 3KB
ast_stage1.gif 3KB
xmllogo.gif 2KB
button-asf-hi.gif 1KB
button-asf-hi.gif 1KB
button-asf-lo.gif 1KB
button-asf-lo.gif 1KB
button-w3c-hi.gif 1KB
button-w3c-hi.gif 1KB
button-w3c-lo.gif 1KB
button-w3c-lo.gif 1KB
button-xml-hi.gif 1KB
button-xml-hi.gif 1KB
button-xml-lo.gif 1KB
button-xml-lo.gif 1KB
join.gif 1KB
join.gif 1KB
right.gif 1KB
right.gif 1KB
bottom.gif 1KB
bottom.gif 1KB
org_apache.gif 976B
line.gif 924B
line.gif 924B
close.gif 498B
close.gif 498B
note.gif 295B
note.gif 295B
separator.gif 110B
separator.gif 110B
void.gif 49B
dot.gif 49B
void.gif 49B
dot.gif 49B
Xalan SQL Extension.htm 13KB
index-all.html 2.54MB
TransformerException.html 277KB
SAXException.html 264KB
Constants.html 255KB
history.html 235KB
Node.html 233KB
xsltc_history.html 205KB
CSS2Properties.html 193KB
serialized-form.html 173KB
XSLTErrorResources.html 171KB
DOMException.html 146KB
extensions.html 132KB
TransformerImpl.html 124KB
DTMDocumentImpl.html 124KB
XPathContext.html 121KB
XObject.html 119KB
samples.html 113KB
overview-tree.html 111KB
Constants.html 109KB
extensionslib.html 107KB
SAX2DTM.html 106KB
DTMNodeProxy.html 104KB
MethodGenerator.html 99KB
ClassGenerator.html 98KB
usagepatterns.html 97KB
Stylesheet.html 96KB
xsltc_trax.html 94KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
段子手-168
- 粉丝: 4380
- 资源: 2745
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功