I'm working on some XSLT to extract the values from complex XML.
The xml:
<bean id="timingAdvice"
class="org.springframework.aop.interceptor.PerformanceMonitorInterceptor" />
<bean id="XMLhandler" class="com.order.OrderStatusSAXHandler">
</bean>
The output I wish to achieve:
<bean>
<id>timingAdvice</id>
<class>org.springframework.aop.interceptor.PerformanceMonitorInterceptor</class>
</bean>
<bean>
<id>XMLhandler</id>
<class>com.citi.get.rio.order.OrderStatusSAXHandler</class>
</bean>
I am using this XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes" />
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="beans/bean">
<xsl:element name="{@class}">
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="beans/bean">
<xsl:element name="{@id}">
<xsl:apply-templates />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
However this outputs:
<?xml version="1.0" encoding="UTF-8"?>
<beans>
<timingAdvice/>
<XMLhandler>
</XMLhandler>
</beans>
Which is not what I am looking for.
I am want to inspect each attribute of the xml print them like the following:
<attributeName>value<attributeName>
EDIT
I've encountered the problem with the beans tag it holds a number of spring references to the Spring Framework:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd"
default-lazy-init="false">
The solution provided doesn't provide the required output when this is the opening tag. Is there a way to ignore these references within the beans tag