首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Xproc:将动态href传递给<p:http-request>

Xproc:将动态href传递给<p:http-request>
EN

Stack Overflow用户
提问于 2015-04-23 00:07:48
回答 1查看 234关注 0票数 1

我有一个管道,它在输入上运行一个XSLT,然后通过<p:http-request>步骤将结果放入数据库。

这里的棘手之处在于,我需要使用来自<p:xslt> XML输出的元数据构建一个动态href。

下面是我想要实现的伪代码:

代码语言:javascript
复制
  <p:xslt name="XSLT1">
            <p:input port="stylesheet">
                <p:document href="XSLT-1.xslt" />
            </p:input>
        </p:xslt>

    <p:variable name="href" select="concat('http://localhost:8000/myRESTendpoint?uri=/mydb/', /*/@name, /*/@number,'.xml')"/>

        <p:sink />

        <p:insert position="first-child" match="c:body">
            <p:input port="source">
                    <p:inline>
                        <c:request 
                            href="{$href}" 
                            auth-method="basic" 
                            username="user" 
                            password="pw" 
                            method="put">
                            <c:body content-type="text/xml" >
                            </c:body>
                        </c:request> 
                    </p:inline>            
            </p:input>
            <p:input port="insertion">
                <p:pipe step="XSLT1" port="result" />        
            </p:input>
        </p:insert>

    <p:http-request  omit-xml-declaration="false" encoding="UTF-8">
       <p:input port="source"/>
    </p:http-request>

正如您在<p:variable>步骤中看到的,我正在尝试构建一个字符串,并使用来自<p:xslt>步骤的输出XML的属性值构造它,并将其提供给我的<c:request>步骤的href选项。

我尝试添加一个<p:attribute match>步骤来更改<p:http-request>之前的href属性,但它没有获取我需要的/*/@name/*/@number值:

代码语言:javascript
复制
<p:add-attribute match="/c:request" attribute-name="href">
    <p:with-option name="attribute-value" select="concat('http://localhost:8000/myRESTendpoint?uri=/mydb/', /*/@name, /*/@number,'.xml')"/>
</p:add-attribute>
EN

回答 1

Stack Overflow用户

发布于 2015-04-23 00:39:43

好的,我能够弄明白这一点。

看起来添加一个<p:add-attribute>步骤是正确的方法,这里的问题只是我的Xpath中的一个错误...

代码语言:javascript
复制
<p:with-option name="attribute-value" select="concat('http://localhost:8000/myRESTendpoint?uri=/mydb/', /*/*/@name, /*/*/@number,'.xml')"/>

由于PUT主体被包装在一个元素中,我需要再往下一层才能到达XML文档(XSLT1输出)的根元素处所需的元数据,因此需要将我的XPath值更新为/*/*/@name/*/*/@number

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29803188

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档