mariita
asked on
Error in XPath 2.0 expression
I switched my XSL from XSLT 1.0 to 2.0 because I wanted to be able to access some of the functions in 2.0, and now I'm getting the following error message:
Error in XPath 2.0 expression, Cast failed, invalid lexical value - xs:double ''
My XSL looks like this:
My XML looks like this:
Error in XPath 2.0 expression, Cast failed, invalid lexical value - xs:double ''
My XSL looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:variable name="SQM_Petroleum_Refining_CH4_Emission_Quantity">
<xsl:choose>
<xsl:when test="/Report/Report_Detail/Sources/SQM/Petroleum_Refining/Emissions/Emission[Gas = 'CH4' ]/Emission_Quantity != '' ">
<xsl:value-of select="number(sum(/Report/Report_Detail/Sources/SQM/Petroleum_Refining/Emissions/Emission[Gas = 'CH4' ]/Emission_Quantity))"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="number(0)"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:template match="/">
<xsl:value-of select="$SQM_Petroleum_Refining_CH4_Emission_Quantity"/>
</xsl:template>
</xsl:stylesheet>
My XML looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="Test.xsl"?>
<Report>
<Report_Detail>
<Sources>
<SQM>
<Petroleum_Refining>
<SectionTitle>(a) catalyst regeneration</SectionTitle>
<Emissions>
<Emission>
<Gas>CH4</Gas>
<Not_Applicable_Indicator>0</Not_Applicable_Indicator>
<Methodology>ON.203(a)(2)</Methodology>
<Emission_Quantity>0.0006</Emission_Quantity>
<Emission_Calculated_Quantity>0.0126</Emission_Calculated_Quantity>
</Emission>
</Emissions>
<SectionTitle>(b) process vents</SectionTitle>
<Emissions>
<Emission>
<Gas>CH4</Gas>
<Not_Applicable_Indicator>1</Not_Applicable_Indicator>
<Methodology/>
<Emission_Quantity/>
<Emission_Calculated_Quantity>0.0000</Emission_Calculated_Quantity>
</Emission>
</Emissions>
<SectionTitle>(e) flares and other control devices</SectionTitle>
<Emissions>
<Emission>
<Gas>CH4</Gas>
<Not_Applicable_Indicator>0</Not_Applicable_Indicator>
<Methodology>ON.203(e)</Methodology>
<Emission_Quantity>5.1580</Emission_Quantity>
<Emission_Calculated_Quantity>108.3180</Emission_Calculated_Quantity>
</Emission>
</Emissions>
</Petroleum_Refining>
</SQM>
</Sources>
</Report_Detail>
</Report>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks again.
welcome
You need to cast to number and filter out the empty ones
<xsl:when test="/Report/Report_Detai
<xsl:value-of select="sum(/Report/Report
</xsl:when>