2011-11-01 68 views
0

我是新来的XQuery所以请记住这一点响应时但请不要回应。我一直试图解决这个问题一个星期,并发现xquery帮助那里最好是斑点。的Xquery程序转换为SOAP消息

我写下面的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> 

那么,如何改变细节线条的格式?我的预感是partschema应该与它有关,但它嵌入在SOA服务中,所以我不确定如果我真的得到它,因为我没有通过任何凭据来清除授权。

回答

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

遗漏添加一些语句来计算它们或如何将它们从原来的数据添加字段。

+0

我能得到所需的输出,但转换的领域,我讨厌做的领域需要硬编码的值。有什么更好的方式来获得细节行转换为我的原始文章中显示的格式? – user1023997

+0

从哪里可以获得替代格式? “所有大写”意味着最少的信息,除了所有小型或随机大小写外,其他所有格式都需要从其他地方获取信息。也许你可以分成几个词,看看[functx](http://www.functx.com/)包含字符串处理的一些xquery函数库。要处理所有行,请使用inline-flowr-expression。 –