|
From: David B. <viv...@gm...> - 2005-02-17 15:18:44
|
I've been thinking about an extension to the mechanism for specifying
XML sources for Spring beans, where you specify an XML source and an
XSL transform. Something like this:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
WEB-INF/normalContext.xml,
WEB-INF/cusomtContext.xml | WEB-INF/transformCustomContext.xsl
</param-value>
In the example above, the new ResourcePatternResolver would look for a
| "operator", and "pipe" the first xml file through the second xsl
transform, and use the result to build the BeanFactory..
And to be more ambitious, maybe someone could do something like this
when using the Struts plugin. If you turned validation off on the
struts parsing, you could mix in certain spring document elements, and
transform the struts-config into a spring context file, possibly
eliminating the need for an additional action-servlet.xml file.
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/struts-config.xml | /WEB-INF/struts-transform.xsl"/>
</plug-in>
Another benefit of this is it could make it easier for someone to
define common beans. Instead of
<bean class="com.abc.domain.Entry">
<constructor-arg index="0"><value>someKey</value></constructor-arg>
<constructor-arg index="1"><value>someValue</value></constructor-arg>
</bean>
which is very wordy if you specify 10 or 15 of those objects, you
could write an xsl transform that would produce the above output from
this:
<entry key="someKey" value="someValue"/>
I haven't researched exactly where in the Spring code this would have
to be extended (it looks like it would just involve extending some of
the implementations of ResourcePatternResolver). Before I work on it
(and no promises), I'm curious if this interests anyone else? If so,
any thoughts on what the XSL transform "operator" should be? "|" is
quite intuitive to me, but it could be any of the following:
custom.xml * transform.xsl
transform(custom.xml, transform.xsl) // If very ambitious, allow a
user to "plug-in" implementations of the function
transform:/(custom.xml, transform.xsl) //Looks more like a URI
/David Bowers
|