1

Here is my XSL:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="RSA-InsurerID"/>
<xsl:param name="RSA-schema-version"/>

<xsl:template match="/">
    <rsa:DriverStatusRequest xmlns:rsa="com/rsa/eosago/schema-"
                             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <InsurerID>
            <xsl:value-of select="$RSA-InsurerID"
                          xmlns:ns2="com/rsa/eosago/schema-"/>
        </InsurerID>
        <IDCheckDriver>
            <xsl:value-of select="ns2:DriverResponse/IDCheckDriver"
                          xmlns:ns2="com/rsa/eosago/schema-"/>
        </IDCheckDriver>
    </rsa:DriverStatusRequest>
</xsl:template>

These two params values are passed via Apache Camel.

The question is how to pass and concat the param <xsl:param name="RSA-schema-version"/> with xmlns:rsa="com/rsa/eosago/schema-" ?

I got my <xsl:param name="RSA-InsurerID"/> with <xsl:value-of select="$RSA-InsurerID", but i have no idea how to pass it to the value text.

I expect this output:

<?xml version="1.0" encoding="UTF-8"?>
<rsa:DriverStatusRequest xmlns:rsa="com/rsa/eosago/schema-1.2" 
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<InsurerID>18800000</InsurerID>
<IDCheckDriver/>
</rsa:DriverStatusRequest>

Big thanks!

bearbeard
  • 15
  • 5

2 Answers2

0

Try

<InsurerID>
            <xsl:value-of select="$RSA-InsurerID"
                          xmlns:ns2="com/rsa/eosago/schema-{$RSA-schema-version}"/>
Kennet
  • 5,736
  • 2
  • 25
  • 24
0

Seems what you try to do is to generate a namespaces dynamically at run time. For example have a look to this or this answers. And try:

<xsl:template match="/">
    <xsl:element name="rsa:DriverStatusRequest" namespace="com/rsa/eosago/schema-{$RSA-schema-version}" >
        <InsurerID>
            <xsl:value-of select="$RSA-InsurerID" />
        </InsurerID>
    </xsl:element>
</xsl:template>

Which will generate:

<rsa:DriverStatusRequest xmlns:rsa="com/rsa/eosago/schema-1.2">
    <InsurerID>18800000</InsurerID>
</rsa:DriverStatusRequest>

But I assume there will be loot more problems coming up.

Community
  • 1
  • 1
hr_117
  • 9,589
  • 1
  • 18
  • 23