2011-11-01 70 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。 –