|
Download
:
Download
XMLtoANY v1.0 full
package
(Binaries + XML/XSL Samples + Xerces/Xalan)
here
(980 KB - zip
or tar.gz).
Installation
:
To
run XMLtoANY servlet you need a servlet engine
Servlets 2.1 API compliant + a JVM 1.2
(or higher). XMLtoANY is provided with Xerces
1.3.1 and Xalan 1.2.2, from apache,
for XML and XLST features.
XMLtoANY package follows J2EE
directory structure . It should be installed as
a J2EE WebApp.
xmltoany/
readme.txt
conf/
xmltoany.dtd
xmltoany.xml
(configuration file)
WEB-INF/
web.xml
(webapp deployment descriptor)
lib/
xmltoany.jar
(core)
xalan.jar
(XSLT component)
xerces.jar
(XML parser)
data/
html.xsl
(xsl sample for xml to html)
wml.xsl
(xsl sample for xml to wml)
moreovernews.dtd
java.xml
(xml sample from moreover.com)
Note
: If you're not familiar with J2EE then you just
need to make xmltoany.jar, xalan.jar, xerces.jar
available in your servlet engine CLASSPATH.
Configuration
:
To
configure XMLtoANY you have to :
-
Setup
xmlconfig
parameter with the absolute path to xmltoany.xml
file.
To do so, edit WEB-INF/web.xml
and modify <param-value> tag.
Note
: If you're not familiar with J2EE then simply
setup xmlconfig as an init parameter in your servlet
engine.
-
Setup conf/xmltoany.xml
by filling in <target> and <source>
tags.
<SOURCE> tag is the path to the XML
source. It could be local
(e.g. : /aHardDiskPath/data/mysource.xml) or remote
(e.g : http://www.acontentprovider.com/channel/source.xml)
You can also setup the CACHE attribute
to enable caching features. It is useful for remote
source. Cache value is a time period in seconds.
-1 means no cache.
<TARGET> tags define relations between
device, content-type and xsl. For each target
you have to setup the following nodes :
<ACCEPT> tag is the string that must
match to the HTTP ACCEPT header from the device's
request.
<CONTENTTYPE> tag is the associated
HTTP response content-type.
<STYLESHEET> tag is the XSL stylesheet
that converts XML to content viewable by the device
matching to the current target.
If you have caching feature enabled you have to
setup the CACHEFILE attribute with the
absolute path to cache file.
Here
is a sample file : xmltoany.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE XMLTOANY SYSTEM "xmltoany.dtd">
<XMLTOANY>
<TARGET
CACHEFILE="D:/jakarta-tomcat-3.2.1/webapps/xmltoany/data/javanews.wml">
<STYLESHEET>D:/jakarta-tomcat-3.2.1/webapps/xmltoany/data/wml.xsl</STYLESHEET>
<ACCEPT>wap.wml</ACCEPT>
<CONTENTTYPE>text/vnd.wap.wml</CONTENTTYPE>
</TARGET>
<!--
Default Target is the last one. It should be the HTML
one -->
<TARGET CACHEFILE="D:/jakarta-tomcat-3.2.1/webapps/xmltoany/data/javanews.html">
<STYLESHEET>D:/jakarta-tomcat-3.2.1/webapps/xmltoany/data/html.xsl</STYLESHEET>
<ACCEPT>*/*</ACCEPT>
<CONTENTTYPE>text/html</CONTENTTYPE>
</TARGET>
<SOURCE
CACHE="300">D:/jakarta-tomcat-3.2.1/webapps/xmltoany/data/java.xml</SOURCE>
</XMLTOANY>
Online
Demonstration
:
Here
is a demonstration of XMLtoANY with a remote XML
source provided by http://www.moreover.com.
Caching feature is enabled and refresh period is
about two hours. The servlet performs classical
browser HTTP requests (IE, Netscape ...) and portable
device HTTP requests (PDA, Nokia 7110, ...).
Servlet URL : http://www.javazoom.net/servlet/xmltoany
XMLtoHTML
demo
XMLtoWML
demo
(copy/paste the servlet url above in the wapsilon
emulator)
|