On Mon, 17 Jan 2005 08:34:38 +0100, COGOLUEGNES Arnaud <[EMAIL PROTECTED]> wrote: > Hi all, > > Does anyone has means of dividing Struts config files into separate files, > so that one main file can include all separate files? > > I've been working on quite big applications where some code is automatically > generated. Sometimes Struts config files (struts-config.xml, validator.xml > and tiles-defs.xml for example) grow fast and developpers must add their own > stuff in middle of automatically generated stuff, which becomes messy. > > I thought about Struts module but actually it doesn't really suit my needs. > So I tried to divide the files into separate files thanks to XML entities. > So I can have one main struts-config.xml where developpers can work on and > this file can include other files (to define action mappings or forms). Here > is what I did: > > <!DOCTYPE struts-config PUBLIC > "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" > "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd" [ > <!ENTITY generated-forms SYSTEM "generated-forms.xml"> > ]> > > ... > > <form-beans> > <!-- my generated forms --> > &generated-forms; > > <!-- developpers' forms --> > ... > > It works quite well and really clean the mess. I tried the same thing with > tiles-defs.xml but it seems the XML parsing is different: it was trying to > get the included file in my IDE (Eclipse) directory and actually does the > same thing if I change the DTD to SYSTEM. So it's useless as it can look in > the project WEB-INF directory. With validation.xml, it doesn't have any DTD, > so my trick can't work. I also tried XInclude with something like:
You can solve the problem of merging the generated content with the developer content by keeping the files separate. You can specify multiple tiles-def.xml for the "definitions-config" property like so <set-property property="definitions-config" value="/WEB-INF/tiles-defs-generated.xml,/WEB-INF/tiles-defs.xml" /> You can have a tiles definition xml file dedicated for the auto generation and as many required for developer definitions. Similarly for Validation you can specify multiple xml files like so <set-property property="pathnames" value="/WEB-INF/validator-rules.xml, /WEB-INF/validation.xml-generated.xml, /WEB-INF/validation.xml"/> You have have the same thing for struts-config.xml; ("comma specifying multiple struts-config files") which effectively fall under a single module (and are called segments) So, keeping the files separate and specifying as a comma separated list is one of the solutions to consider > > <xi:include href="myFile.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> > > but it doesn't include anything. > > Does anyone tried to divide their config files like this and managed to do > it? Or has a XML guru any mean to include XML into another? > > Thanks, > Arno > > --------------------------------------------------------------------- > 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]