Hi David, I should probably have left your question for Chris... The reason is that he's finishing a web.xml Ant merge task that merges 2 web.xml. You may not know yet, but in Cactus 1.5 we have what we call an Ant Integration Module which can be directly used with no modification. You install it somewhere on your disk and then simply call it from your own Ant build file. Among other things, it contains a default web.xml which contains the needed Cactus redirector definitions and your application web.xml gets automatically merged with it. The end result is that your application web.xml stays clutter-free!
So in essence, we have both done the same thing! Cool! :-) Thanks for your contribution. -Vincent > -----Original Message----- > From: David M. Karr [mailto:[EMAIL PROTECTED] > Sent: 18 March 2003 06:57 > To: [EMAIL PROTECTED] > Subject: Useful to merge production web.xml with cactus with XSLT? > > This isn't a question, but a comment on one issue that I've noticed with > Cactus > usage. > > If you have a normal "web.xml" for your application, it appears there > isn't a > perfect answer to how to properly produce the web.xml which includes the > Cactus > servlets and mappings. > > In the FAQ, there's a demonstration of one way to do this, using a > "filter" > task in the ant script. This works, but it puts "noise" in the normal > web.xml > file. > > A while ago, when I had to work with a JSPC process that didn't give me a > clean > way to merge the normal web.xml with the generated JSP mappings, I decided > to > write an XSLT script that takes an input "web.xml" file and a document > parameter (the web.xml to "merge" in), and produces a result "web.xml" > file. > > It occurs to me that the same script could be used here, unchanged. As a > result, you can produce a normal "web.xml" that has no testing artifacts. > > It's been quite a while since I've looked at this, but if anyone's > interested, > I'll include it here. I wouldn't be surprised if someone better at XSLT > than > me could improve this. > > The "ant" tasking to accomplish this is left as an exercise for the reader > (which means I didn't bother to write it :) ). > > -------------- > <?xml version="1.0"?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > > <!-- This takes a parameter indicating the name of the secondary file > to merge in. When we've matched the "web-app" element, we will > first > insert the "servlet" elements of the include file, then the > "servlet" > elements of the main file, then the "servlet-mapping" elements of > the > include file, then the "servlet-mapping" elements of the main file, > and > then all the remaining elements of the main file (which will be > specified explicitly by element type. > --> > > <xsl:output method="xml" indent="yes" > doctype-public="-//Sun Microsystems, Inc.//DTD Web Application > 2.3//EN" > doctype-system="http://java.sun.com/dtd/web-app_2_3.dtd"/> > > <xsl:param name="includeFile"/> > > <!-- get the required elements of "web-app", in their defined order, > according to the DTD. --> > <xsl:template match="/web-app"> > <web-app> > <xsl:apply-templates select="icon"/> > <xsl:apply-templates select="display-name"/> > <xsl:apply-templates select="description"/> > <xsl:apply-templates select="distributable"/> > <xsl:apply-templates select="context-param"/> > <xsl:apply-templates select="filter"/> > <xsl:apply-templates select="filter-mapping"/> > <xsl:apply-templates select="listener"/> > <xsl:apply-templates select="servlet"/> > <xsl:copy-of select="document($includeFile)/web-app/servlet"/> > <xsl:apply-templates select="servlet-mapping"/> > <xsl:copy-of select="document($includeFile)/web-app/servlet- > mapping"/> > <xsl:apply-templates select="session-config"/> > <xsl:apply-templates select="mime-mapping"/> > <xsl:apply-templates select="welcome-file-list"/> > <xsl:apply-templates select="error-page"/> > <xsl:apply-templates select="taglib"/> > <xsl:apply-templates select="resource-env-ref"/> > <xsl:apply-templates select="resource-ref"/> > <xsl:apply-templates select="security-constraint"/> > <xsl:apply-templates select="login-config"/> > <xsl:apply-templates select="security-role"/> > <xsl:apply-templates select="env-entry"/> > <xsl:apply-templates select="ejb-ref"/> > <xsl:apply-templates select="ejb-local-ref"/> > </web-app> > </xsl:template> > > <xsl:template match="*"> > <xsl:for-each select="@*"> > <xsl:attribute name="{.}"> > <xsl:value-of select="."/> > </xsl:attribute> > </xsl:for-each> > <xsl:copy-of select="."/> > </xsl:template> > > </xsl:stylesheet> > -------------- > > -- > =================================================================== > David M. Karr ; Java/J2EE/XML/Unix/C++ > [EMAIL PROTECTED] ; SCJP; SCWCD > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
