用于转换soap消息的Xquery程序

用于转换soap消息的Xquery程序,soap,transform,message,xquery,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 ns

我是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>
<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>
declare namespace soapenv=”http://schemas.xmlsoap.org/soap/envelope/";
声明命名空间soap env=”http://schemas.xmlsoap.org/soap/envelope/";
声明命名空间ns0=”http://xmlns.oracle.com/pcbpel/adapter/db/GPDSND/SP_GET_PART_ATTRIBUTES/";
声明命名空间com=“com:companyname:part:partspecification:partfinder:types:partschema:1:0”;
{
对于文档中的$x(“soap.xml”)/soapenv:Envelope/soapenv:Body/ns0:OutputParameters/ns0:P_CURSOR/ns0:Row
返回$x
}
产生以下输出:

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>
<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>

20831727
1727U
20831727
但是我想要以下格式的
详细信息行:

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>
<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>
20875646
20875634

那么如何更改详图线的格式呢?我的直觉是partschema应该与之相关,但它嵌入到SOA服务中,因此我不确定是否真的可以使用它,因为我没有传递任何凭据来清除授权。

像将输出粘贴到模板中那样使用元素构造

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>
}
用于文档中的$x(“soap.xml”)/soapenv:Envelope/soapenv:Body/ns0:OutputParameters/ns0:P_CURSOR/ns0:Row
返回{data($x)}
}

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

我能够获得所需的输出,但转换字段和字段值需要硬编码,我不喜欢这样做。有什么更好的方法可以让细节线转换成我原来帖子中显示的格式?从哪里可以得到其他格式?“所有大写字母”意味着最少的信息,每种其他格式(除了所有小号或随机大写字母)都需要从其他地方获取信息。也许您可以拆分几个单词,看看包含字符串处理的xquery函数库。要处理所有行,请使用内联Flower表达式。