|
Lines 6-20
Link Here
|
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
7 |
* |
| 8 |
* Contributors: |
8 |
* Contributors: |
| 9 |
* Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 |
9 |
* Andrea Bittau - initial API and implementation from the PsychoPath XPath 2.0 |
|
|
10 |
* Mukul Gandhi - bug 276134 - improvements to schema aware support for attribute nodes |
| 10 |
*******************************************************************************/ |
11 |
*******************************************************************************/ |
| 11 |
|
12 |
|
| 12 |
package org.eclipse.wst.xml.xpath2.processor.internal.types; |
13 |
package org.eclipse.wst.xml.xpath2.processor.internal.types; |
| 13 |
|
14 |
|
| 14 |
import org.w3c.dom.*; |
15 |
import java.math.BigInteger; |
|
|
16 |
|
| 17 |
import org.apache.xerces.dom.PSVIAttrNSImpl; |
| 18 |
import org.apache.xerces.xs.XSTypeDefinition; |
| 15 |
import org.eclipse.wst.xml.xpath2.processor.ResultSequence; |
19 |
import org.eclipse.wst.xml.xpath2.processor.ResultSequence; |
| 16 |
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory; |
20 |
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory; |
| 17 |
import org.eclipse.wst.xml.xpath2.processor.internal.*; |
21 |
import org.w3c.dom.Attr; |
| 18 |
|
22 |
|
| 19 |
/** |
23 |
/** |
| 20 |
* A representation of the AttributeType datatype |
24 |
* A representation of the AttributeType datatype |
|
Lines 72-81
Link Here
|
| 72 |
@Override |
76 |
@Override |
| 73 |
public ResultSequence typed_value() { |
77 |
public ResultSequence typed_value() { |
| 74 |
ResultSequence rs = ResultSequenceFactory.create_new(); |
78 |
ResultSequence rs = ResultSequenceFactory.create_new(); |
| 75 |
|
79 |
|
| 76 |
// XXX with no PSVI |
80 |
PSVIAttrNSImpl psviAttr = (PSVIAttrNSImpl)_value; |
| 77 |
rs.add(new UntypedAtomic(string_value())); |
81 |
XSTypeDefinition typeDef = psviAttr.getTypeDefinition(); |
| 78 |
|
82 |
|
|
|
83 |
if (typeDef != null) { |
| 84 |
if (typeDef.getName().equals("date")) { |
| 85 |
rs.add(XSDate.parse_date(string_value())); |
| 86 |
} |
| 87 |
else if (typeDef.getName().equals("int")) { |
| 88 |
rs.add(new XSInt(new BigInteger(string_value()))); |
| 89 |
} |
| 90 |
else if (typeDef.getName().equals("long")) { |
| 91 |
rs.add(new XSLong(new BigInteger(string_value()))); |
| 92 |
} |
| 93 |
else if (typeDef.getName().equals("integer")) { |
| 94 |
rs.add(new XSInteger(new BigInteger(string_value()))); |
| 95 |
} |
| 96 |
else if (typeDef.getName().equals("double")) { |
| 97 |
rs.add(new XSDouble(Double.parseDouble(string_value()))); |
| 98 |
} |
| 99 |
else if (typeDef.getName().equals("float")) { |
| 100 |
rs.add(new XSFloat(Float.parseFloat(string_value()))); |
| 101 |
} |
| 102 |
else if (typeDef.getName().equals("decimal")) { |
| 103 |
rs.add(new XSDecimal(Double.parseDouble(string_value()))); |
| 104 |
} |
| 105 |
} else { |
| 106 |
// construct an 'untypedatomic' value |
| 107 |
rs.add(new UntypedAtomic(string_value())); |
| 108 |
} |
| 109 |
|
| 79 |
return rs; |
110 |
return rs; |
| 80 |
} |
111 |
} |
| 81 |
|
112 |
|