You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用XSLT修改单个属性:提取FilePath值生成目标XML

提取FilePath参数并生成目标XML的XSLT方案

输入XML示例

<?xml version="1.0" encoding="utf-8"?>
<soa:Label identifier="1f9b3588-d069-416b-b7da-e32d203c5bac" name="Label" description="" leftaligncheckboxes="false" instance="c9a32ab9-248e-485f-8f09-b2dd6bc574f0" signature="00000000-0000-0000-0000-000000000000" menuname="" itemmode="closed" xmlns:soa="urn:jondoe.net:soa:core">
    <soa:Parameter type="string" identifier="a2eecb22-53aa-4af4-a7ee-f8a97108d777" bindable="True" name="FilePath" enabled="true" disableable="false" browsable="true" optionseditable="false" row="-1" column="-1" columnspan="1" maxlines="-1">d:\folder\file1.txt<soa:Default></soa:Default>
        <soa:IsRequired>false</soa:IsRequired>
    </soa:Parameter>
</soa:Label>

目标XML示例

<?xml version="1.0" encoding="utf-8"?>
<Sequence path="d:\folder\file1.txt" rate="24" failOnGap="false">
    <OpenSupport timeout="30" enabled="true"/>
</Sequence>

可行的XSLT实现

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:soa="urn:jondoe.net:soa:core">
    <!-- 匹配根节点 -->
    <xsl:template match="/">
        <Sequence 
            path="{soa:Label/soa:Parameter[@name='FilePath']/text()}" 
            rate="24" 
            failOnGap="false">
            <OpenSupport timeout="30" enabled="true"/>
        </Sequence>
    </xsl:template>
</xsl:stylesheet>

关键说明

  • 必须在XSLT中声明输入XML的soa命名空间,否则无法正确选择对应节点
  • 使用属性值模板({}包裹的表达式)直接将FilePath参数的文本值插入到path属性中
  • soa:Label/soa:Parameter[@name='FilePath']/text()用于精准定位到名为FilePath的参数节点,提取其文本内容

内容的提问来源于stack exchange,提问作者ago1965

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 10:13:15