Author: knoaman
Date: Mon Apr 12 18:49:51 2010
New Revision: 933357
URL: http://svn.apache.org/viewvc?rev=933357&view=rev
Log:
Allow "+INF" for double and float in XML Schema 1.1. Patch by Kun Xu with a
slight modification. Jira bug:
https://issues.apache.org/jira/browse/XERCESJ-1436
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/DoubleDV.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/FloatDV.java
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/DoubleDV.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/DoubleDV.java?rev=933357&r1=933356&r2=933357&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/DoubleDV.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/DoubleDV.java
Mon Apr 12 18:49:51 2010
@@ -19,6 +19,7 @@ package org.apache.xerces.impl.dv.xs;
import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
import org.apache.xerces.impl.dv.ValidationContext;
+import org.apache.xerces.impl.dv.xs.TypeValidatorHelper.TypeValidatorHelper1_1;
import org.apache.xerces.xs.datatypes.XSDouble;
/**
@@ -35,8 +36,8 @@ public class DoubleDV extends TypeValida
//convert a String to Double form, we have to take care of cases specified
in spec like INF, -INF and NaN
public Object getActualValue(String content, ValidationContext context)
throws InvalidDatatypeValueException {
- try{
- return new XDouble(content);
+ try {
+ return new XDouble(content, context.getTypeValidatorHelper()
instanceof TypeValidatorHelper1_1);
} catch (NumberFormatException ex){
throw new
InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content,
"double"});
}
@@ -75,11 +76,11 @@ public class DoubleDV extends TypeValida
private static final class XDouble implements XSDouble {
private final double value;
- public XDouble(String s) throws NumberFormatException {
+ public XDouble(String s, boolean isSchema11) throws
NumberFormatException {
if (isPossibleFP(s)) {
value = Double.parseDouble(s);
}
- else if ( s.equals("INF") ) {
+ else if ( s.equals("INF") || (isSchema11 && s.equals("+INF"))) {
value = Double.POSITIVE_INFINITY;
}
else if ( s.equals("-INF") ) {
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/FloatDV.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/FloatDV.java?rev=933357&r1=933356&r2=933357&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/FloatDV.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/FloatDV.java
Mon Apr 12 18:49:51 2010
@@ -19,6 +19,7 @@ package org.apache.xerces.impl.dv.xs;
import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
import org.apache.xerces.impl.dv.ValidationContext;
+import org.apache.xerces.impl.dv.xs.TypeValidatorHelper.TypeValidatorHelper1_1;
import org.apache.xerces.xs.datatypes.XSFloat;
/**
@@ -35,8 +36,8 @@ public class FloatDV extends TypeValidat
//convert a String to Float form, we have to take care of cases specified
in spec like INF, -INF and NaN
public Object getActualValue(String content, ValidationContext context)
throws InvalidDatatypeValueException {
- try{
- return new XFloat(content);
+ try {
+ return new XFloat(content, context.getTypeValidatorHelper()
instanceof TypeValidatorHelper1_1);
} catch (NumberFormatException ex){
throw new
InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content,
"float"});
}
@@ -59,11 +60,11 @@ public class FloatDV extends TypeValidat
private static final class XFloat implements XSFloat {
private final float value;
- public XFloat(String s) throws NumberFormatException {
+ public XFloat(String s, boolean isSchema11) throws
NumberFormatException {
if (DoubleDV.isPossibleFP(s)) {
value = Float.parseFloat(s);
}
- else if ( s.equals("INF") ) {
+ else if ( s.equals("INF") || (isSchema11 && s.equals("+INF"))) {
value = Float.POSITIVE_INFINITY;
}
else if ( s.equals("-INF") ) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]