On Apr 22, 2009, at 4:25 AM, André Warnier wrote:
Allright, but I'm afraid this is still somewhat flying over my head,
what we me not being /either/ a Java expert, /nor/ a Tomcat expert, /
nor/ an XML expert. (What am I then doing on this list, one might
ask).
So, since everyone but me seems to know pretty well how to do it,
sometimes even in several ways, and since from previous threads I
believe there is more interest for this, would it be possible for
someone to give an effective simple example (or maybe two or three)
based for example on this :
<?xml version="1.0"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>MyApp</display-name>
<description>
My simple webapp.
</description>
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>my.servlet</servlet-class>
<init-param>
<param-name>someParam</param-name>
<param-value>someValue</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
...
</web-app>
of how one could make it so that the <param-value> of the above
<param-name> "someParam" is a reference to some value defined
elsewhere, for example in a file in the Tomcat "conf" directory ?
OK, here you cannot use entities in an external file because you have
already defined a DTD (one of the problems with DTDs).
As for XInclude, the problem is slightly different: The XInclude
support has to be turned on for the parser. From Xerces:
http://xerces.apache.org/xerces2-j/faq-xinclude.html
"Applications using JAXP 1.3 can enable XInclude processing by setting
XInclude awareness on the parser factory. The following demonstrates
how to accomplish this with SAX:
import javax.xml.parsers.SAXParserFactory;
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setXIncludeAware(true);
...
You can also enable XInclude processing by turning on the XInclude
feature."
BTW, here is an article that has some examples:
http://www.xml.com/pub/a/2002/07/31/xinclude.html
Your example might look like:
<?xml version="1.0"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app xmlns:xi="http://www.w3.org/2001/XInclude">
<display-name>MyApp</display-name>
<description>
My simple webapp.
</description>
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>my.servlet</servlet-class>
<init-param>
<param-name>someParam</param-name>
<param-value>
<!-- someParam.txt just contains the text 'someValue' -->
<xi:include href="someParam.txt" parse="text">
<xi:fallback>defaultValue</xi:fallback>
</xi:include>
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
</web-app>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org