Solved

XPath in XQuery:  Casting to xs:decimal

Posted on 2015-01-22
1
110 Views
Last Modified: 2015-01-26
This works well for me

fn:sum($asset/(in:currentprice * in:quantity))

Open in new window


But I have tried to convert this to an xs:decimal as follows, but they do not work:

fn:sum($asset/(in:currentprice * in:quantity))/xs:decimal()

fn:sum($asset/(in:currentprice * in:quantity)/xs:decimal())

Open in new window


How can I cast the following XPath statement to xs:decimal ?

fn:sum($asset/(in:currentprice * in:quantity))

Open in new window


Thanks
0
Comment
Question by:Anthony Lucia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 40565939
If the casting to decimal is a precision issue,
you need to cast prior to the calculation in order to obtain correct results

fn:sum($asset/(in:currentprice/xs:decimal() * in:quantity/xs:decimal()))

I
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question