0
votes

I need this in my xslt, but xmlns:s="{$service-uri}" did not extracted:


    <xsl:variable name="service-uri" select="'http://something/'"/>
    ...
    <xsl:template match="cxf:cxfEndpoint[last()]">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>     
        </xsl:copy>
        <cxf:cxfEndpoint 
            xmlns:s="{$service-uri}"
            endpointName="s:{$service-name}Port"
            id="{$service-name}_RemoteEndpoint"
            serviceName="s:{$service-name}"
            wsdlURL="wsdl/remote/{$service-name}.wsdl">
            <cxf:properties>
                <entry key="continuationTimeout" value="120000"/>
                <entry key="mtom-enabled" value="true"/>
                <entry key="dataFormat" value="PAYLOAD"/>
            </cxf:properties>
        </cxf:cxfEndpoint>
    </xsl:template>

How can I extract service-uri variable in the namespace definition? thx Zamek

1

1 Answers

1
votes

Attribute value templates cannot be used for namespace declarations. Remember that XSLT is XML, and the namespace declaration xmlns:x="..." has to be understood by the XML parser as well as the XSLT processor.

In XSLT 2.0 you can create a namespace node dynamically using the xsl:namespace instruction:

<xsl:namespace name="s" select="$service-uri"/>

If you're in 1.0 it's more difficult. You can do it by creating an element node in the relevant namespace:

<xsl:variable name="dummy">
  <xsl:element name="s:dummy" namespace="{$service-uri}"/>
</xsl:variable>

and then copying the relevant namespace node to the new element:

<xsl:copy-of select="exslt:node-set($dummy/*/namespace::s)"/>