It is a generic Java servlet that uses XSLT to provide
final content from the given XML source and associated XSL stylesheet. You have to provide
for this servlet a configuration file, where you can describe your XML data,
XSL stylesheets and business rules how to proceed requests. Rules are parameterized by
parameters from request's header (User-Agent and Accept). In other words
each rule looks like: "if User-Agent is ... then use this XML data with
this XSL stylesheet" or "if client accepts such content-type then use
this XML data with this XSL stylesheet".
the usage is standard: a) copy XMLgatePackage.jar into WEB-INF/lib b) describe XMLgate servlet in web.inf file. You must
set an initial parameter for this servlet. Parameter name is config.
This parameter describes a configuration file for XMLgate:
<servlet> <servlet-name>XMLgate</servlet-name> <servlet-class>com.jsos.xmlgate.XMLgate</servlet-class> <init-param> <param-name>config</param-name> <param-value>path_to_your_configuration_file</param-value> </init-param> </servlet> c) define a mapping:
<servlet-mapping>
Now you can use this servlet:
http://your_host/servlet/XMLgate also you can pass configuration file as a parameter:
http://your_host/servlet/XMLgate?config=path_to_your_configuration_file Configuration file is XML file. You must define the following elements:
Config => (cache, +xmlsource, +xslsource, +rule, default) cache - defines cache directory. It is some existing directory on your server. Note: all files from this directory will be deleted!. E.g.: <cache>c:/xml/tmp</cache> xmlsource - defines xml source. Could be local or remote. Attributes are: name - unique name, cache - cache policy. Possible values are: -1 - static data, will be cached after the first usage, 0 - means no-cache, any positive integer value - defines cache time in seconds. E.g.: <xmlsource name="first" cache="-1">c:/data/file1.xml</xmlsource>
xslsource - defines xsl sheet. Could be local or remote. Attributes are: name - unique name, cache - cache policy. Possible values are: -1 - static data, will be cached after the first usage, 0 - means no-cache, any positive integer value - defines cache time in seconds. E.g.: <xslsource name="first" cache="-1">c:/data/file1.xsl</xmlsource>
rule - defines rule (condition, trigger). There are two forms:
<rule agent="MSIE" xml="second" xsl="first" type="text/html"/> a) if accept header contains this string then use that pair of <XML-source, XSL-source> and that content-type for the output. E.g.: if client accepts wap.wml than set content type to text/vnd.wap.wml and use XML source with name first and XSL source with name second: <rule accept="wap.wml" xml="first" xsl="second" type="text/vnd.wap.wml"/> Attributes are: accept - defines accept header, agent - defines user-agent header, xml - xml source name, xsl - xsl source name, type - defines content-type for output. default - defines default transformation (if all conditions are failed). Attributes are: xml - xml source name, xsl - xsl source name, type - defines content-type for output. E.g.: <default xml="xml0" xsl="xsl0" type="text/html"/> Notes: 1. Servlet uses JAXP for parsing XML files. 2. Config file can be saved anywhere on your server. You may use the full path for setting data file location. For downloading: XMLgate package: XMLgatePackage.jar
See also JSOS - the largest collection of servlets and filters.
|
Also in Coldtags:
|