Reputation: 833
I have an xml like this (FUSE blueprint definition file):
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
xmlns:jaxws="http://cxf.apache.org/blueprint/jaxws"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
http://cxf.apache.org/blueprint/jaxws
http://cxf.apache.org/schemas/blueprint/jaxws.xsd
http://camel.apache.org/schema/blueprint/cxf
http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0
http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd">
...
<bean class="xxxxx.fuse.util.CommonAuthInterceptor" id="authorizationInterceptor">
<property name="methodRolesMap">
<map>
<entry key="xxxElemE1" value="xxxElemE1Role"/>
<entry key="xxxTipusE1" value="xxxTipusE1Role"/>
<entry key="xxxLekerdezE1" value="xxxLekerdezE1Role"/>
<entry key="xxxValtozasE1" value="xxxValtozasE1Role"/>
</map>
</property>
<property name="globalRoles" value="xxxUsers"/>
</bean>
...
<camelContext id="xxxContext" xmlns="http://camel.apache.org/schema/blueprint">
<route id="xxxModositE1_Route" streamCache="true">
<from id="xxxModositE1_from1" uri="cxf:bean:xxxModositE1_LocalEndpoint?dataFormat=PAYLOAD"/>
<convertBodyTo id="xxxModositE1_convertBodyTo1" type="java.lang.String"/>
<wireTap id="xxxModositE1_wireTap1" uri="direct-vm:logRequest"/>
<to id="xxxModositE1_to2" uri="cxf:bean:xxxModositE1_RemoteEndpoint?dataFormat=PAYLOAD"/>
<convertBodyTo id="xxxModositE1_convertBodyTo3" type="java.lang.String"/>
<wireTap id="xxxModositE1_wireTap3" uri="direct-vm:logResponse"/>
</route>
...
</camelContext>
</blueprint>
I have to add new element after the last entry and last route. The problem is that xslt generates extra namespace definitions in the newly added route elements but not in entry. That is my relevant part of xslt:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
exclude-result-prefixes="xsd">
<xsl:param name="service-name"/>
<xsl:output omit-xml-declaration="yes" indent="yes"/>
...
<xsl:template match="*:map/*:entry[last()]">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
<entry key="{$service-name}" value="{$service-name}Role"/>
</xsl:template>
...
<xsl:template match="*:camelContext/*:route[last()]">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
<route id="{$service-name}_xslt_Route" streamCache="true">
<from id="{$service-name}_from1" uri="cxf:bean:{$service-name}_LocalEndpoint?dataFormat=PAYLOAD"/>
<convertBodyTo id="{$service-name}_convertBodyTo1" type="java.lang.String"/>
<wireTap id="{$service-name}_wireTap1" uri="direct-vm:logRequest"/>
<to id="{$service-name}_to2" uri="cxf:bean:{$service-name}_RemoteEndpoint?dataFormat=PAYLOAD"/>
<convertBodyTo id="{$service-name}_convertBodyTo3" type="java.lang.String"/>
<wireTap id="{$service-name}_wireTap3" uri="direct-vm:logResponse"/>
</route>
</xsl:template>
<xsl:stylesheet>
The output of entry is correct, there is no extra namespace in it, but route contains:
<route xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
id="xxxKeresE1_xslt_Route"
streamCache="true">
How can I eliminate extra namespace definition in route? thx, Zamek
Upvotes: 1
Views: 30
Reputation: 167516
As you want the route
element to be in a different namespace, you need to use that namespace where you create the element, i.e. change
<route id="{$service-name}_xslt_Route" streamCache="true">
<from id="{$service-name}_from1" uri="cxf:bean:{$service-name}_LocalEndpoint?dataFormat=PAYLOAD"/>
<convertBodyTo id="{$service-name}_convertBodyTo1" type="java.lang.String"/>
<wireTap id="{$service-name}_wireTap1" uri="direct-vm:logRequest"/>
<to id="{$service-name}_to2" uri="cxf:bean:{$service-name}_RemoteEndpoint?dataFormat=PAYLOAD"/>
<convertBodyTo id="{$service-name}_convertBodyTo3" type="java.lang.String"/>
<wireTap id="{$service-name}_wireTap3" uri="direct-vm:logResponse"/>
</route>
to
<route xmlns="http://camel.apache.org/schema/blueprint" id="{$service-name}_xslt_Route" streamCache="true">
<from id="{$service-name}_from1" uri="cxf:bean:{$service-name}_LocalEndpoint?dataFormat=PAYLOAD"/>
<convertBodyTo id="{$service-name}_convertBodyTo1" type="java.lang.String"/>
<wireTap id="{$service-name}_wireTap1" uri="direct-vm:logRequest"/>
<to id="{$service-name}_to2" uri="cxf:bean:{$service-name}_RemoteEndpoint?dataFormat=PAYLOAD"/>
<convertBodyTo id="{$service-name}_convertBodyTo3" type="java.lang.String"/>
<wireTap id="{$service-name}_wireTap3" uri="direct-vm:logResponse"/>
</route>
Upvotes: 2