简体   繁体   English

XSL。 在字符串中传递参数

[英]XSL. Passing param in string

Here is my XSL: 这是我的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. 这两个参数值通过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-" ? 问题是如何使用xmlns:rsa="com/rsa/eosago/schema-"传递和连接param <xsl:param name="RSA-schema-version"/> 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. 我得到了我的<xsl:param name="RSA-InsurerID"/> <xsl:value-of select="$RSA-InsurerID" ,但我不知道如何将它传递给值文本。

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! 太谢谢了!

Try 尝试

<InsurerID>
            <xsl:value-of select="$RSA-InsurerID"
                          xmlns:ns2="com/rsa/eosago/schema-{$RSA-schema-version}"/>

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. 但我认为会有更多问题出现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM