You can use this XSL to convert from old beans xml to new short format.
Save this as "transformbeans.xsl" .
usage:
xsltproc transformbeans.xsl applicationContext.xml > applicationContext.xml.new
or
java -jar xalan.jar -XSL transformbeans.xsl -IN applicationContext.xml -OUT applicationContext.xml.new
- Lari
Here's "transformbeans.xsl":
[/code]Code:<?xml version="1.0" encoding="ISO-8859-1"?> <!-- Transforms old Spring XML beans configuration to new short format --> <!-- Author: Lari Hotari, Sagire Software Oy, 30.7.2005 --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes" encoding="ISO-8859-1" doctype-public="-//SPRING//DTD BEAN//EN" doctype-system="http://www.springframework.org/dtd/spring-beans.dtd" /> <xsl:strip-space elements="*"/> <xsl:template match="bean"> <xsl:copy> <xsl:apply-templates select="@id"/> <xsl:apply-templates select="@name"/> <xsl:apply-templates select="@class"/> <xsl:apply-templates select="@parent"/> <xsl:if test="@abstract!='false'"> <xsl:apply-templates select="@abstract"/> </xsl:if> <xsl:if test="@singleton!='true'"> <xsl:apply-templates select="@singleton"/> </xsl:if> <xsl:if test="@lazy-init!='default'"> <xsl:apply-templates select="@lazy-init"/> </xsl:if> <xsl:if test="@autowire!='default'"> <xsl:apply-templates select="@autowire"/> </xsl:if> <xsl:if test="@dependency-check!='default'"> <xsl:apply-templates select="@dependency-check"/> </xsl:if> <xsl:apply-templates select="@depends-on"/> <xsl:apply-templates select="@init-method"/> <xsl:apply-templates select="@destroy-method"/> <xsl:apply-templates select="@factory-method"/> <xsl:apply-templates select="@factory-bean"/> <xsl:apply-templates select="node()"/> </xsl:copy> </xsl:template> <xsl:template match="entry"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:if test="count(ref) > 0"> <xsl:attribute name="value-ref"> <xsl:choose> <xsl:when test="string-length(ref/@local) > 0"> <xsl:value-of select="ref/@local"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="ref/@bean"/> </xsl:otherwise> </xsl:choose> </xsl:attribute> </xsl:if> <xsl:if test="count(value) > 0"> <xsl:choose> <xsl:when test="string-length(normalize-space(value/text()))=0"> <xsl:apply-templates select="value"/> </xsl:when> <xsl:otherwise> <xsl:attribute name="value"> <xsl:value-of select="value/text()"/> </xsl:attribute> </xsl:otherwise> </xsl:choose> </xsl:if> <xsl:apply-templates select="./node()[name() != 'value' and name() != 'ref']"/> </xsl:copy> </xsl:template> <xsl:template match="property"> <xsl:choose> <xsl:when test="count(ref) > 0"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:attribute name="ref"> <xsl:choose> <xsl:when test="string-length(ref/@local) > 0"> <xsl:value-of select="ref/@local"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="ref/@bean"/> </xsl:otherwise> </xsl:choose> </xsl:attribute> </xsl:copy> </xsl:when> <xsl:when test="string-length(normalize-space(value/text()))=0"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates select="node()"/> </xsl:copy> </xsl:when> <xsl:otherwise> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:attribute name="value"> <xsl:value-of select="value/text()"/> </xsl:attribute> </xsl:copy> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="node()"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates select="node()"/> </xsl:copy> </xsl:template> <xsl:template match="@*"> <xsl:copy /> </xsl:template> </xsl:stylesheet>


Reply With Quote