我用用户定义的函数创建了XQuery。一切都按预期罚款,但是当我在标签OrderItem上添加测试条件(if($ CountFirstName> 0)" if-then-else"逻辑时,我收到错误" {err XP0003:表达式无效:期待''"""在我的OSB中我不确定语法出了什
**
**
declare namespace ns2 = "http://www.sterlingcommerce.com/documentation/YCP/getPage/output";
declare namespace ns1 = "http://www.openapplications.org/oagis/9";
declare namespace ns4 = "http://www.ibm.com/xmlns/prod/commerce/9/order";
declare namespace ns3 = "http://www.ibm.com/xmlns/prod/commerce/9/foundation";
declare namespace ns0 = "http://WCToSSFSMediationModule";
declare namespace xf = "http://tempuri.org/POC_HttpMethodCall/XQueries/getPageRequestoShowOrder/";
declare namespace _ord = "http://www.ibm.com/xmlns/prod/commerce/9/order";
declare namespace _wcf ="http://www.ibm.com/xmlns/prod/commerce/9/foundation";
declare function local:getfor-eachLoop($valueMaps as element() * , $Order as element()*) as element() *
{
let $scStatus := data($Order/@MaxOrderStatus),
$status := $valueMaps/*:ValueMaps/*:Map[@name='scStatusToWcStatus']/*:Entry[@key=$scStatus]/text(),
$statusF := if (data($Order/@MultipleStatusesExist) = 'Y') then 'S' else $status,
$scCurrency := data($Order/*:PriceInfo/@Currency),
$wcCurrency := $valueMaps/*:ValueMaps/*:Map[@name='scCurrencyToWcCurency']/*:Entry[text()=$scCurrency]/@key,
$currency := if(fn:string-length(normalize-space($wcCurrency)) > 0) then $wcCurrency else $scCurrency ,
$FirstName := data($Order/*:PersonInfoShipTo/@FirstName),
$LastName := data($Order/*:PersonInfoShipTo/@LastName),
$CountFirstName :=fn:string-length(normalize-space($FirstName))
return
(
<_ord:Order>
<_ord:OrderIdentifier>
<_wcf:UniqueID>{data($Order/@OrderNo)}</_wcf:UniqueID>
<_wcf:ExternalOrderID>{data($Order/@OrderHeaderKey)}</_wcf:ExternalOrderID>
</_ord:OrderIdentifier>
<_ord:OrderAmount>
<_wcf:GrandTotal currency = "{$currency}">{data($Order/*:OverallTotals/@GrandTotal)}</_wcf:GrandTotal>
</_ord:OrderAmount>
<_ord:OrderStatus>
<_ord:Status>{$statusF}</_ord:Status>
</_ord:OrderStatus>
<_ord:PlacedDate>{data($Order/@OrderDate)}</_ord:PlacedDate>
if ($CountFirstName > 0) then
<_ord:OrderItem>
<_ord:OrderItemShippingInfo>
<_ord:ShippingAddress>
<_wcf:ContactName>
<_wcf:FirstName>
{$CountFirstName}
</_wcf:FirstName>
</_wcf:ContactName>
</_ord:ShippingAddress>
</_ord:OrderItemShippingInfo>
</_ord:OrderItem>
else ()
</_ord:Order>
)
};
declare function xf:getPageRequestoShowOrder($valueMaps as element() * , $getPageRequest as element()*) as element() *
{
let $OrganizationCode := data($getPageRequest/*:Output/*:OrderList/*:Order/@EnterpriseCode),
$storeId := data($valueMaps/*:Map[@name='storeIdToOrganizationCode']/*:Entry[@key=$OrganizationCode]),
$recordSetCount := if (data($getPageRequest/*:Output/*:OrderList/@TotalOrderList) > 0 ) then data($getPageRequest/*:Output/*:OrderList/@TotalOrderList) else 0,
$recordSetTotal := if (data($getPageRequest/*:Output/*:OrderList/@TotalNumberOfRecords) > 0) then data($getPageRequest/*:Output/*:OrderList/@TotalNumberOfRecords) else 0,
$RCmpltInd := if (data($getPageRequest/@IsLastPage) = 'Y') then 'true' else 'false',
$xml :=
<ns4:ShowOrder>
<ns1:ApplicationArea>
<ns1:CreationDateTime>{fn:current-dateTime()}</ns1:CreationDateTime>
</ns1:ApplicationArea>
<ns4:DataArea>
<ns1:Show recordSetCount = "{$recordSetCount}" recordSetTotal = "{$recordSetTotal}" recordSetCompleteIndicator = "{$RCmpltInd}" />
{
for $Order in $getPageRequest/*:Output/*:OrderList/*:Order
return
local:getfor-eachLoop($valueMaps,$Order)
}
</ns4:DataArea>
</ns4:ShowOrder>
return $xml
};
declare variable $valueMaps as element(ns0:ValueMaps) external;
declare variable $getPageRequest as element(ns2:Page) external;
xf:getPageRequestoShowOrder($valueMaps,$getPageRequest)
(:
let $valueMaps := fn:doc(ValueMaps.xml')
let $getPageRequest := fn:doc(getPageresponeNS.xml')
let $x := xf:getPageRequestoShowOrder($valueMaps/*:ValueMaps,$getPageRequest/*:Page)
return $x
:)
**
**
<?xml version="1.0" encoding="UTF-8"?>
<!--
=================================================================
Licensed Materials - Property of IBM
WebSphere Commerce
(C) Copyright IBM Corp. 2011 All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or
disclosure restricted by GSA ADP Schedule Contract with
IBM Corp.
=================================================================
-->
<!-- Maps WC values to SSFS values -->
<mm:ValueMaps
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mm="http://WCToSSFSMediationModule"
>
<mm:Map name="scStatusToWcStatusGroup">
<mm:Entry key="1100">not shipped</mm:Entry>
<mm:Entry key="1300">not shipped</mm:Entry>
<mm:Entry key="1310">not shipped</mm:Entry>
<mm:Entry key="1400">not shipped</mm:Entry>
<mm:Entry key="1500">not shipped</mm:Entry>
<mm:Entry key="3200">not shipped</mm:Entry>
<mm:Entry key="3200.10000">not shipped</mm:Entry>
<mm:Entry key="3200.20000">not shipped</mm:Entry>
<mm:Entry key="3350">not shipped</mm:Entry>
<mm:Entry key="3700">shipped</mm:Entry>
<mm:Entry key="3700.01">returned</mm:Entry>
<mm:Entry key="3700.02">returned</mm:Entry>
<mm:Entry key="9000">cancelled</mm:Entry>
<mm:Entry key="M">not shipped</mm:Entry>
<mm:Entry key="H">not shipped</mm:Entry>
</mm:Map>
<mm:Map name="scCurrencyToWcCurency">
<mm:Entry key="USD">USD</mm:Entry>
</mm:Map>
</mm:ValueMaps>
**
**
<out:Page GeneratedOn="2014-06-19T16:30:15-04:00" IsFirstPage="Y" IsLastPage="Y" IsValidPage="Y" PageNumber="1" PageSize="30" xmlns:out="http://www.sterlingcommerce.com/documentation/YCP/getPage/output">
<out:Output>
<out:OrderList LastOrderHeaderKey="7289297001" LastRecordSet="Y" ReadFromHistory="N" TotalOrderList="7">
<out:Order MaxOrderStatus="3700" MaxOrderStatusDesc="Shipped" MinOrderStatus="3700" MinOrderStatusDesc="Shipped" MultipleStatusesExist="N" OrderDate="2013-11-19T10:23:56-05:00" OrderHeaderKey="201311191026091646239229" OrderNo="20019358516" Status="Shipped">
<out:PriceInfo Currency="USD" EnterpriseCurrency="USD" HeaderTax="0.00" ReportingConversionDate="2013-11-19T10:26:09-05:00" ReportingConversionRate="0.00" TotalAmount="113.42"/>
<out:PersonInfoShipTo AddressLine1="4872 Strand Road" AddressLine2="" AddressLine3="" AddressLine4="" AddressLine5="" AddressLine6="" AlternateEmailID="" Beeper="" City="Westerville" Company="" Country="US" Createprogid="ANFCreateOrderFromWCSIntegServer" Createts="2013-10-11T15:45:07-04:00" Createuserid="ANFCreateOrderFromWCSIntegServer" DayFaxNo="" DayPhone="1000001521" Department="" EMailID="nouser1521@example.com" ErrorTxt="" EveningFaxNo="" EveningPhone="" FirstName="Jon" HttpUrl="" JobTitle="" LastName="Fitch1521" Lockid="0" MiddleName="" MobilePhone="" Modifyprogid="ANFCreateOrderFromWCSIntegServer" Modifyts="2013-10-11T15:45:07-04:00" Modifyuserid="ANFCreateOrderFromWCSIntegServer" OtherPhone="" PersonID="" PersonInfoKey="201310111545071262322239" PreferredShipAddress="" ShortZipCode="43081" State="OH" Suffix="" Title="" UseCount="0" VerificationStatus="" ZipCode="43081" isHistory="N"/>
<out:OverallTotals GrandCharges="10.00" GrandDiscount="0.00" GrandShippingBaseCharge="0.00" GrandShippingCharges="0.00" GrandShippingDiscount="0.00" GrandShippingTotal="0.00" GrandTax="7.42" GrandTotal="113.42" HdrCharges="0.00" HdrDiscount="0.00" HdrShippingBaseCharge="0.00" HdrShippingCharges="0.00" HdrShippingDiscount="0.00" HdrShippingTotal="0.00" HdrTax="0.00" HdrTotal="0.00" LineSubTotal="96.00" ManualDiscountPercentage="0.00" PercentProfitMargin="100.00"/>
</out:Order>
<out:Order MaxOrderStatus="3700" MaxOrderStatusDesc="Shipped" MinOrderStatus="3700" MinOrderStatusDesc="Shipped" MultipleStatusesExist="N" OrderDate="2013-12-10T09:32:04-05:00" OrderHeaderKey="201312100933011987586483" OrderNo="20020096797" Status="Shipped">
<out:PriceInfo Currency="USD" EnterpriseCurrency="USD" HeaderTax="0.00" ReportingConversionDate="2013-12-10T09:33:01-05:00" ReportingConversionRate="0.00" TotalAmount="78.11"/>
<out:PersonInfoShipTo AddressLine1="4872 Strand Road" AddressLine2="" AddressLine3="" AddressLine4="" AddressLine5="" AddressLine6="" AlternateEmailID="" Beeper="" City="Westerville" Company="" Country="US" Createprogid="ANFCreateOrderFromWCSIntegServer" Createts="2013-10-11T15:45:07-04:00" Createuserid="ANFCreateOrderFromWCSIntegServer" DayFaxNo="" DayPhone="1000001521" Department="" EMailID="nouser1521@example.com" ErrorTxt="" EveningFaxNo="" EveningPhone="" FirstName="Jon" HttpUrl="" JobTitle="" LastName="Fitch1521" Lockid="0" MiddleName="" MobilePhone="" Modifyprogid="ANFCreateOrderFromWCSIntegServer" Modifyts="2013-10-11T15:45:07-04:00" Modifyuserid="ANFCreateOrderFromWCSIntegServer" OtherPhone="" PersonID="" PersonInfoKey="201310111545071262322239" PreferredShipAddress="" ShortZipCode="43081" State="OH" Suffix="" Title="" UseCount="0" VerificationStatus="" ZipCode="43081" isHistory="N"/>
<out:OverallTotals GrandCharges="10.00" GrandDiscount="10.00" GrandShippingBaseCharge="0.00" GrandShippingCharges="0.00" GrandShippingDiscount="0.00" GrandShippingTotal="0.00" GrandTax="5.11" GrandTotal="78.11" HdrCharges="0.00" HdrDiscount="0.00" HdrShippingBaseCharge="0.00" HdrShippingCharges="0.00" HdrShippingDiscount="0.00" HdrShippingTotal="0.00" HdrTax="0.00" HdrTotal="0.00" LineSubTotal="73.00" ManualDiscountPercentage="0.00" PercentProfitMargin="100.00"/>
</out:Order>
<out:Order MaxOrderStatus="3700" MaxOrderStatusDesc="Shipped" MinOrderStatus="3700" MinOrderStatusDesc="Shipped" MultipleStatusesExist="N" OrderDate="2013-12-16T09:36:56-05:00" OrderHeaderKey="201312160938002091967609" OrderNo="20023794266" Status="Shipped">
<out:PriceInfo Currency="USD" EnterpriseCurrency="USD" HeaderTax="0.00" ReportingConversionDate="2013-12-16T09:38:00-05:00" ReportingConversionRate="0.00" TotalAmount="159.43"/>
<out:PersonInfoShipTo AddressLine1="4872 Strand Road" AddressLine2="" AddressLine3="" AddressLine4="" AddressLine5="" AddressLine6="" AlternateEmailID="" Beeper="" City="Westerville" Company="" Country="US" Createprogid="ANFCreateOrderFromWCSIntegServer" Createts="2013-10-11T15:45:07-04:00" Createuserid="ANFCreateOrderFromWCSIntegServer" DayFaxNo="" DayPhone="1000001521" Department="" EMailID="nouser1521@example.com" ErrorTxt="" EveningFaxNo="" EveningPhone="" FirstName="Jon" HttpUrl="" JobTitle="" LastName="Fitch1521" Lockid="0" MiddleName="" MobilePhone="" Modifyprogid="ANFCreateOrderFromWCSIntegServer" Modifyts="2013-10-11T15:45:07-04:00" Modifyuserid="ANFCreateOrderFromWCSIntegServer" OtherPhone="" PersonID="" PersonInfoKey="201310111545071262322239" PreferredShipAddress="" ShortZipCode="43081" State="OH" Suffix="" Title="" UseCount="0" VerificationStatus="" ZipCode="43081" isHistory="N"/>
<out:OverallTotals GrandCharges="15.00" GrandDiscount="15.00" GrandShippingBaseCharge="0.00" GrandShippingCharges="0.00" GrandShippingDiscount="0.00" GrandShippingTotal="0.00" GrandTax="10.43" GrandTotal="159.43" HdrCharges="0.00" HdrDiscount="0.00" HdrShippingBaseCharge="0.00" HdrShippingCharges="0.00" HdrShippingDiscount="0.00" HdrShippingTotal="0.00" HdrTax="0.00" HdrTotal="0.00" LineSubTotal="149.00" ManualDiscountPercentage="0.00" PercentProfitMargin="100.00"/>
</out:Order>
</out:OrderList>
</out:Output>
</out:Page>
此致 TJ
答案 0 :(得分:0)
因为您要返回多行输出,所以在每行输出的末尾添加一个逗号,但最后一行除外。
if ($CountFirstName > 0) then
<_ord:OrderItem>,
<_ord:OrderItemShippingInfo>,
<_ord:ShippingAddress>,
<_wcf:ContactName>,
<_wcf:FirstName>{$CountFirstName}</_wcf:FirstName>,
</_wcf:ContactName>,
</_ord:ShippingAddress>,
</_ord:OrderItemShippingInfo>,
</_ord:OrderItem>
else
</_ord:Order>