Java Doc for ApplyXSLT.java in  » J2EE » enhydra » servlet » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » enhydra » servlet 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.servlet.GenericServlet
      javax.servlet.http.HttpServlet
         servlet.ApplyXSLT

ApplyXSLT
public class ApplyXSLT extends HttpServlet (Code)
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)


Field Summary
public static  StringCURRENTDIR
    
final public static  StringEOL
     String representing the end of line characters for the System.
final public static  StringFS
     String representing the file separator characters for the System.
final protected static  StringHEADER_NAME
     The HTTP Header used for matching the Stylesheet attribute via the media properties file selected.
final public static  StringROOT
     String representing the current directory for properties files.
final protected static  StringSTYLESHEET_ATTRIBUTE
     The attribute name in the tag used in stylesheet selection.
protected  ApplyXSLTPropertiesourDefaultParameters
     Operational parameters for this class.
protected  OrderedPropsourMediaProps
     Mapping of HTTP request's user-Agent values to stylesheet media= values.


Method Summary
protected  voiddisplayException(HttpServletResponse response, ApplyXSLTException xse, boolean debug)
     Invokes response.sendError setting an HTTP status code and optionally an error message as an HTML page.
public  voiddoGet(HttpServletRequest request, HttpServletResponse response)
     HTTP Get method passed on to process().
public  StringgetContentType(Templates templates)
     Returns the response content type specified by the media-type and encoding attributes of the <xsl:output> element(s) of the stylesheet.
Parameters:
  xslSourceRoot - XSL Stylesheet to be examined for <xsl:output> elements.
protected  StreamSourcegetDocument(HttpServletRequest request, ApplyXSLTListener listener)
     Returns an XML XSLTInputSource DOM.
public  StringgetMedia(HttpServletRequest request)
    
protected  StreamSourcegetStylesheet(TransformerFactory tFactory, HttpServletRequest request, StreamSource xmlSource, ApplyXSLTListener listener)
     Returns a Templates (StylesheetRoot) object.
public static  StringgetXSLURLfromDoc(StreamSource xmlSource, String attributeName, String attributeValue, TransformerFactory tFactory)
     Returns the XSL stylesheet URL associated with the specified XML document.
public  voidinit(ServletConfig config)
     Initialize operational parameters from the configuration.
public  voidprocess(TransformerFactory tFactory, HttpServletRequest request, HttpServletResponse response)
     Coordinates applying an XSL stylesheet to XML data using operational parameters.

If successfully applied, the result tree will be streamed to the response object and the content type set according to the XSL stylesheet's <xsl:output> element(s).

If there is a problem in parsing the XML/XSL or if there is a problem in applying the XSL to the XML, an exception will be streamed to the response object.

protected  voidsetDefaultParameters(ServletConfig config)
     Sets the default parameters for the servlet from the configuration.
protected  voidsetMediaProps(String mediaURLstring)
     Loads the media properties file specified by the given string.
Parameters:
  mediaURLstring - Location of the media properties file.
public  voidsetStylesheetParams(Transformer transformer, HttpServletRequest request)
     Defines and sets select top-level XSL stylesheet variables from the HTTP request, which can be evaluated using <xsl:param-variable>.
protected  URLConnectiontoAcceptLanguageConnection(URL url, HttpServletRequest request)
     Returns a connection which respects the Accept-Language header of the HTTP request.
protected  voidwriteLog(ApplyXSLTException axe)
    
protected  voidwriteLog(String msg, int statusCode, Throwable t)
    
protected  voidwriteLog(String msg, int statusCode)
    

Field Detail
CURRENTDIR
public static String CURRENTDIR(Code)



EOL
final public static String EOL(Code)
String representing the end of line characters for the System.



FS
final public static String FS(Code)
String representing the file separator characters for the System.



HEADER_NAME
final protected static String HEADER_NAME(Code)
The HTTP Header used for matching the Stylesheet attribute via the media properties file selected.



ROOT
final public static String ROOT(Code)
String representing the current directory for properties files. See init().



STYLESHEET_ATTRIBUTE
final protected static String STYLESHEET_ATTRIBUTE(Code)
The attribute name in the tag used in stylesheet selection.



ourDefaultParameters
protected ApplyXSLTProperties ourDefaultParameters(Code)
Operational parameters for this class.

Request-time values override init-time values which override class defaults.


See Also:   ApplyXSLT.init



ourMediaProps
protected OrderedProps ourMediaProps(Code)
Mapping of HTTP request's user-Agent values to stylesheet media= values.

This mapping is defined by a file pointed to by the operational parameter "mediaURL" which can either contain a full URL or a path relative to the System's server.root /servlets directory.


See Also:   ApplyXSLT.setMediaProps
See Also:   ApplyXSLT.getMedia





Method Detail
displayException
protected void displayException(HttpServletResponse response, ApplyXSLTException xse, boolean debug)(Code)
Invokes response.sendError setting an HTTP status code and optionally an error message as an HTML page.

If running in debug mode, also try to return a stack trace of the exception and and xml/xsl processor messages.


Parameters:
  response - Where to stream the exception to
Parameters:
  xse - The wrapper which contains the exception and its HTTP status code
Parameters:
  debug - Indicates whether to include stack trace, etc.



doGet
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException(Code)
HTTP Get method passed on to process().
Parameters:
  request - The request
Parameters:
  response - The response
See Also:   ApplyXSLT.process
exception:
  ServletException - Never thrown
exception:
  IOException - Never thrown



getContentType
public String getContentType(Templates templates)(Code)
Returns the response content type specified by the media-type and encoding attributes of the <xsl:output> element(s) of the stylesheet.
Parameters:
  xslSourceRoot - XSL Stylesheet to be examined for <xsl:output> elements. The response content type (MIME type and charset) of the stylesheet output
See Also:   ApplyXSLT.process



getDocument
protected StreamSource getDocument(HttpServletRequest request, ApplyXSLTListener listener) throws ApplyXSLTException(Code)
Returns an XML XSLTInputSource DOM. Attempts will be make to create the DOM from the following sources:
  1. A relative URL specified in the HTTP request's path information. This capability is intended for use by servlet engines that map some or all XML data to be processed at the server.
  2. A URL specified in the HTTP request's URL= parameter. This capability is intended for clients wishing to selectively process XML data at the server. For security reasons, this URL will be forced to the local IP host.
  3. The HTTP request's XML input stream. This capability is intended for use by chained servlets.

Parameters:
  request - May contain or point to the XML XSLTInputSource
Parameters:
  listener - To record detailed parsing messages for possible return to requestor XML XSLTInputSource DOM, or null if the XSLTInputSource could not be parsed
exception:
  ApplyXSLTException - Thrown if exception occurs while handling request



getMedia
public String getMedia(HttpServletRequest request)(Code)



getStylesheet
protected StreamSource getStylesheet(TransformerFactory tFactory, HttpServletRequest request, StreamSource xmlSource, ApplyXSLTListener listener) throws ApplyXSLTException(Code)
Returns a Templates (StylesheetRoot) object. Attempts will be make to create the Stylesheet from the followingsources:
  1. A URL specified in the HTTP request's xslURL= parameter. This capability is intended for clients wishing to selectively override the server algorithm for applying XSL stylesheets. For security reasons, this URL will be forced to the local IP host.
  2. XML association. XML documents may contain references to one or more stylesheets using this W3C proposed recommendation. If the XML document does contain such references, a best match will be chosen based on the browser type making the request and the default association. This capability enables relationships to be defined between client capabilities and stylesheets capable of acting on these capabilities.
  3. A configured default stylesheet URL

Parameters:
  request - May contain or point to the XSL XSLTInputSource
Parameters:
  xmlSource - May point to the XSL XSLTInputSource
Parameters:
  listener - To record detailed parsing messages for possible return to requestor XSL XSLTInputSource, or null if the request could not be parsed
See Also:   ApplyXSLT.makeDocument
See Also:   ApplyXSLT.getMedia
See Also:   ApplyXSLT.STYLESHEET_ATTRIBUTE
See Also:   ApplyXSLT.getXSLURLfromDoc
See Also:   ApplyXSLT.toAcceptLanguageConnection
exception:
  ApplyXSLTException - Thrown if exception occurs while handling request



getXSLURLfromDoc
public static String getXSLURLfromDoc(StreamSource xmlSource, String attributeName, String attributeValue, TransformerFactory tFactory)(Code)
Returns the XSL stylesheet URL associated with the specified XML document. If multiple XSL stylesheets are associated with the XML document, preference will be given to the stylesheet which contains an attribute name/value pair that corresponds to the specified attributeName and attributeValue.
Parameters:
  xmlSource - XML XSLTInputSource to be searched for associated XSL stylesheets
Parameters:
  attributeName - Attribute name to provide preferential matching
Parameters:
  attributeValue - Attribute value to provide preferential matching The preferred XSL stylesheet URL, or null if no XSL stylesheet association is found
See Also:   ApplyXSLT.getStylesheet



init
public void init(ServletConfig config) throws ServletException(Code)
Initialize operational parameters from the configuration.
Parameters:
  config - Configuration
exception:
  ServletException - Never thrown



process
public void process(TransformerFactory tFactory, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SAXException(Code)
Coordinates applying an XSL stylesheet to XML data using operational parameters.

If successfully applied, the result tree will be streamed to the response object and the content type set according to the XSL stylesheet's <xsl:output> element(s).

If there is a problem in parsing the XML/XSL or if there is a problem in applying the XSL to the XML, an exception will be streamed to the response object. The detail of the information returned in the response object will depend on whether we're running in debug mode or not.


Parameters:
  processor - implementation of TRaX processor
Parameters:
  request - May contain information relevant to creating XML and XSL XSLTInputSource's
Parameters:
  response - Where to write the transformation result
See Also:   ApplyXSLT.getDocument
See Also:   ApplyXSLT.getStylesheet
See Also:   ApplyXSLT.getContentType
See Also:   ApplyXSLT.displayException
See Also:   ApplyXSLT.setStylesheetParams
exception:
  ServletException - Never thrown
exception:
  IOException - Never thrown



setDefaultParameters
protected void setDefaultParameters(ServletConfig config)(Code)
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.
Parameters:
  config - Configuration



setMediaProps
protected void setMediaProps(String mediaURLstring)(Code)
Loads the media properties file specified by the given string.
Parameters:
  mediaURLstring - Location of the media properties file. Can be either a full URL or a path relativeto the System's server.root /servlets directory. If this parameter is null,server.root/servlets/media.properties will be used.
See Also:   ApplyXSL.CURRENTDIR



setStylesheetParams
public void setStylesheetParams(Transformer transformer, HttpServletRequest request)(Code)
Defines and sets select top-level XSL stylesheet variables from the HTTP request, which can be evaluated using <xsl:param-variable>. The following variables will be automatically set:
ParameterName
Each non-reserved request parameter returned from request.getParameterNames(). If a parameter contains more than a single value, only the first value is available.
servlet-RemoteAddr
Contains String output from request.getRemoteAddr(), which is the IP address of the client machine.
servlet-RemoteHost
Contains String output from request.getRemoteHost(), which is the host name of the client machine.
servlet-RemoteUser
Contains String output from request.getRemoteUser(), which was the user name accepted by the server to grant access to this servlet.
servlet-Request
Contains the request object.

Parameters:
  xslprocessor - Where to register parameters to be set
Parameters:
  request - Provides access to all meaningful parameters to set
See Also:   ApplyXSLT.process



toAcceptLanguageConnection
protected URLConnection toAcceptLanguageConnection(URL url, HttpServletRequest request) throws Exception(Code)
Returns a connection which respects the Accept-Language header of the HTTP request. This is useful when XSL files are internationalized for use with Web servers which respect this header.

For example, Apache 1.3.6 may be configured for multiviews. Under this configuration, requests for http://myhost/index.html would return http://myhost/index.html.fr to French browsers and http://myhost/index.html.en to English browsers.


Parameters:
  url - Location to connect to
Parameters:
  request - Could contain an Accept-Language header An Accept-Language-enabled URL connection
See Also:   ApplyXSLT.getStylesheet



writeLog
protected void writeLog(ApplyXSLTException axe)(Code)
Writes the following information to the servlet log:
  1. HTTP status code
  2. Message
  3. Stack trace

Parameters:
  axe - Contains valid HTTP status code, message, and stack trace (optional)



writeLog
protected void writeLog(String msg, int statusCode, Throwable t)(Code)
Writes the following information to the servlet log:
  1. HTTP status code
  2. Message
  3. Stack trace

Parameters:
  msg - Message to be logged
Parameters:
  statusCode - Valid status code from javax.servlet.http.HttpServletResponse
Parameters:
  t - Used to generate stack trace (may be =null to suppress stack trace)



writeLog
protected void writeLog(String msg, int statusCode)(Code)
Writes the following information to the servlet log:
  1. HTTP status code
  2. Message

Parameters:
  msg - Message to be logged
Parameters:
  statusCode - Valid status code from javax.servlet.http.HttpServletResponse



Methods inherited from javax.servlet.http.HttpServlet
protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc)
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc)
protected void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc)
protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc)
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc)
protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc)
protected void doTrace(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc)
protected long getLastModified(HttpServletRequest req)(Code)(Java Doc)
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc)
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException(Code)(Java Doc)

Methods inherited from javax.servlet.GenericServlet
public void destroy()(Code)(Java Doc)
public String getInitParameter(String name)(Code)(Java Doc)
public Enumeration getInitParameterNames()(Code)(Java Doc)
public ServletConfig getServletConfig()(Code)(Java Doc)
public ServletContext getServletContext()(Code)(Java Doc)
public String getServletInfo()(Code)(Java Doc)
public String getServletName()(Code)(Java Doc)
public void init(ServletConfig config) throws ServletException(Code)(Java Doc)
public void init() throws ServletException(Code)(Java Doc)
public void log(String msg)(Code)(Java Doc)
public void log(String message, Throwable t)(Code)(Java Doc)
abstract public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.