1

文字列をxpathに集める

<property xmlns:t="https://services" name="xPathElemet" expression="fn:concat(//t:SNILS/, $func:element)"/>

この xpath を実行して、プロパティの値を書き込みたい

<property name="KEY" expression="get-property('xPathElemet')"/>

しかし、収集された文字列のみを受け取ります

プロパティのxpathの方法は?

コードシーケンスの例:

<iterate continueParent="true" expression="//t:Employee">
    <target>
        <sequence>
            <call-template target="save_element">
                <with-param name="key_element" value="Name"/>
            </call-template>
        </sequence>
    </target>
</iterate>

サンプル コード テンプレート:

<template xmlns="http://ws.apache.org/ns/synapse" name="save_element">
    <parameter name="key_element"/>  <!--example: "Name"-->
    <sequence>
        <property name="KEY" expression="fn:concat(//t:Employee/t:SNILS, ':' ,$func:key_element)" scope="default"
                  type="STRING"/>             <!--example: "111-111-111-1:Name"-->
        <property name="xPathElemet" expression="fn:concat('//t:Employee/t:', $func:element)"/>      <!--example: "//t:Employee/t:Name"-->
        <property name="VALUE" expression="get-property('xPathElemet')" scope="default" type="STRING"/>      <!--example: Den (Now it does not work)-->
        <dbreport>
            <connection>
                <pool>
                    <seetings/>
                </pool>
            </connection>
            <statement>
                <sql>
                    <![CDATA[insert into cache( key , value ) values (?, ?);]]></sql>      <!--insert new line where key = "111-111-111-1:Name" and value = "Den"-->
                <parameter expression="get-property('KEY')" type="VARCHAR"/>
                <parameter expression="get-property('VALUE')" type="VARCHAR"/>
            </statement>
        </dbreport>
    </sequence>
</template>

xml の例:

<Employees xmlns="https://services">
    <Employee>
        <SNILS>111-111-111-1</SNILS>
        <Name>Den</Name>
    </Employee>
    <Employee>
        <SNILS>111-111-111-2</SNILS>
        <Name>Elena</Name>
    </Employee>
</Employees>
4

2 に答える 2

3

評価を使用する

あなたの場合:

<property xmlns:t="https://services" name="xPathElemet" expression="fn:concat(//t:SNILS/, $func:element)"/>
<property name="KEY" expression="evaluate(get-property('xPathElemet'))"/>

詳細については、このブログを参照してください。

于 2016-01-14T11:02:02.460 に答える
0

以下を試して、動作するかどうかを確認してください

<property xmlns:t="https://services" name="xPathElemet" expression="fn:concat(//t:SNILS/, $func:element)"/>
<property xmlns:t="https://services" name="xPathfull" expression="fn:concat(get-property('xPathElemet'),'/text()')"/>
<property name="KEY" expression="get-property('xPathfull')"/>

コードに欠けて/text()いたのは、指定された xpath のパラメーターを参照するものでした。これを試してください

于 2013-07-12T07:59:47.597 に答える