Hi Luiz,

> My question: Considering this dataset model, how can I to write this query
> without change its semantics?

I think you'll need to change its semantics, or need to explain a bit
more what you trying to do. See the following query as example:

XQUERY:

  for $lineitem in <xml>
    <LineItem>
      <Discount>0.0913</Discount>
      <ReturnFlag>A</ReturnFlag>
    </LineItem>
    <LineItem>
      <Discount>0.0674</Discount>
      <ReturnFlag>A</ReturnFlag>
    </LineItem>
  </xml>/LineItem
  group by $returnflag := $lineitem/ReturnFlag
  return <record>{ $lineitem/Discount }</record>

RESULT:

<record>
  <Discount>0.0913</Discount>
  <Discount>0.0674</Discount>
</record>

The returned record contains two Discount elements. In your original
query, you are trying subtracting two values from a single number
(1-$lineitem/Discount), so I am not sure what result you expect here?
Maybe this already answers your question?


> I wouldn't want to use extra functions (e.g., fn:for-each), because I need
> to submit the same query in an limited xquery processor.

For general questions on XQuery, the [email protected] mailing list may
be a better choice.

Best,
Christian

Reply via email to