Solved

XPath in XQuery:  Casting to xs:decimal

Posted on 2015-01-22
1
109 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
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Custom Java Application connects to database: Which one of the 20? 4 35
tomcat startup error 5 105
Xsl-fo show PDF when no results are returned 2 20
XML SQL 8 27
The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

830 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