Xquery程序转换肥皂消息

时间:2011-11-01 15:59:21

标签: soap transform message xquery

我是xquery的新手所以请在回复时记住这一点,但请回复。我一直试图解决这个问题一个星期,并发现xquery帮助那里充其量只是参差不齐。

我写了以下xquery程序:

declare namespace soapenv = "http://schemas.xmlsoap.org/soap/envelope/";
declare namespace soap-env = "http://schemas.xmlsoap.org/soap/envelope/";
declare namespace ns0 = "http://xmlns.oracle.com/pcbpel/adapter/db/GPDSND/SP_GET_PART_ATTRIBUTES/";
declare namespace com = "com:companyname:part:partspecification:partfinder:types:partschema:1:0";
<soapenv:Envelope>
<soap-env:Body>
<com:PartDetailResponse>
{
for $x in doc("soap.xml")/soapenv:Envelope/soapenv:Body/ns0:OutputParameters/ns0:P_CURSOR/ns0:Row
return $x
}
</com:PartDetailResponse>
</soap-env:Body>
</soapenv:Envelope>

会产生以下输出:

   <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soap-env:Body xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
      <com:PartDetailResponse xmlns:com="com:companyname:part:partspecification:partfinder:types:partschema:1:0">
         <Row xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/GPDSND/SP_GET_PART_ATTRIBUTES/"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
            <Column name="PARTNUMBER" sqltype="CHAR">20831727</Column> 
            <Column name="BROADCASTCODE" sqltype="CHAR">1727U</Column> 
            <Column name="DRAWINGNUMBER" sqltype="CHAR">20831727</Column> 
            <Column name="MAKEFROMPART" sqltype="CHAR"/> 
         </Row>
      </com:PartDetailResponse>
   </soap-env:Body>
</soapenv:Envelope>

但我希望<Column>详细信息行采用以下格式:

<com:Column FieldName="PartNumber" DisplayName="Part Number" ToolTip="String" ContentType="String"><com:Value>20875646</com:Value></com:Column>
<com:Column FieldName="BroadcastCode" DisplayName="Broadcast Code" ToolTip="String" ContentType="String"><com:Value>     </com:Value></com:Column>
<com:Column FieldName="DrawingNumber" DisplayName="Drawing Number" ToolTip="String" ContentType="String"><com:Value/></com:Column>
<com:Column FieldName="MakeFromPart" DisplayName="Make From Part" ToolTip="String" ContentType="String"><com:Value>20875634</com:Value></com:Column>

那么如何更改细节线的格式?我的预感是partchema应该与它有关,但它嵌入在SOA服务中,所以我不确定我是否实际上是因为我没有通过任何凭据来清除授权。

1 个答案:

答案 0 :(得分:0)

使用元素构造,就像您已经将输出粘贴到模板中一样。

for $x in doc("soap.xml")/soapenv:Envelope/soapenv:Body/ns0:OutputParameters/ns0:P_CURSOR/ns0:Row
return <com:Column FieldName="{$x/@name}" [...]><com:Value>{data($x)}</com:Value></com:Column>
}

对于缺少的字段,添加一些语句来计算它们或如何从原始数据中添加它们。