diff options
Diffstat (limited to 'sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join.xq')
-rw-r--r-- | sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join.xq | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join.xq b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join.xq new file mode 100644 index 0000000000..9c521ae67b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join.xq @@ -0,0 +1,37 @@ +declare namespace quoteJoin="scaservice:java/xquery.quote.QuoteJoin";
+
+declare namespace quoteCalculator="scareference:java/xquery.quote.QuoteCalculator";
+
+declare variable $quoteCalculator external;
+
+declare function quoteJoin:joinPriceAndAvailQuotes($priceQuoteDoc, $availQuoteDoc, $taxRate) {
+<quote>
+ <name>{ data($priceQuoteDoc/priceQuote/customerName) }</name>
+ <address>{ concat($priceQuoteDoc/priceQuote/shipAddress/@street , ",", $priceQuoteDoc/priceQuote/shipAddress/@city ,",", fn:upper-case($priceQuoteDoc/priceQuote/shipAddress/@state) , ",", $priceQuoteDoc/priceQuote/shipAddress/@zip) }</address>
+ {
+ for $priceRequest in $priceQuoteDoc/priceQuote/priceRequests/priceRequest,
+ $availRequest in $availQuoteDoc/availQuote/availRequest
+ where data($priceRequest/widgetId) = data($availRequest/widgetId)
+ return
+ <quoteResponse>
+ <widgetId>{ data($priceRequest/widgetId) }</widgetId>
+ <unitPrice>{ data($priceRequest/price) }</unitPrice>
+ <requestedQuantity>{ data($availRequest/requestedQuantity) }</requestedQuantity>
+ <fillOrder>{ data($availRequest/quantityAvail) }</fillOrder>
+ {
+ for $shipDate in $availRequest/shipDate
+ return
+ <shipDate>{ data($shipDate) }</shipDate>
+ }
+ <taxRate>{ $taxRate }</taxRate>
+ <totalCost>{ quoteCalculator:calculateTotalPrice(
+ $quoteCalculator,
+
+ $taxRate,
+ $availRequest/requestedQuantity,
+ $priceRequest/price,
+ $availRequest/quantityAvail) }</totalCost>
+ </quoteResponse>
+ }
+ </quote>
+};
\ No newline at end of file |