0

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 Answer 1

1

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)"/>
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Michael, unfortunately I am not an xslt guru, can you explain how can I insert it into my current xslt?
Which do you want, the 1.0 version or the 2.0?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.