Subject:choosing namespace.... Author:seb lemming Date:29 Mar 2007 01:53 AM
Dear all,
I try to transform two xml's that have the same structure, but with
a different namespace.
To do so I 'switch' on the namespace for a element that is always in the
xml and call the template that applies for this namespace.
I would like to call an other template that is the same for both the xml's. However since the xml namespace are diffirent I would like to set the namespace declaration in xsl dynamicly.
Example (which clears up my story big time):
<!-- test determ which template must be used for the message -->
<xsl:template match="/">
<wrapper>
<namespace-detected>
<xsl:value-of select="$source_namespace"/>
</namespace-detected>
<!-- switch here -->
<xsl:choose>
<xsl:when test="$source_namespace='http://test/v_0_1'">
<xsl:call-template name="test"/>
</xsl:when>
<xsl:when test="$source_namespace='http://test/v_0_2'">
<xsl:call-template name="test2"/>
</xsl:when>
</xsl:choose>
</wrapper>
</xsl:template>
<!-- Templates for all each known message type -->
Subject:choosing namespace.... Author:(Deleted User) Date:30 Mar 2007 07:57 AM
Hi Seb,
you cannot define a namespace prefix using variables (xmlns:source is an XML definition, so it must be processed before the XSLT engine has even started looking at template, variables and so on). You can try using XSLT 2.0 and match expressions like *:common that will select a 'common' node from any namespace.