protected Expression makeExpression() {
final RELAXNGReader reader = (RELAXNGReader)this.reader;
String typeName = startTag.getCollapsedAttribute("type");
Datatype type;
StringPair typeFullName;
if(typeName==null) {
try {
// defaults to built-in token type.
type = reader.resolveDataTypeLibrary("").createDatatype("token");
typeFullName = new StringPair("","token");
} catch( DatatypeException e ) {
// since token is the built-in datatype,
// this can't happen
e.printStackTrace();
throw new InternalError();
}
} else {
type = reader.resolveDataType(typeName);
typeFullName = new StringPair(reader.datatypeLibURI,typeName);
}
Object value = type.createValue(text.toString(),reader);
if( value==null ) {
// this is not a good value for this type.
reader.reportError( RELAXNGReader.ERR_BAD_DATA_VALUE, typeName, text.toString().trim() );
return Expression.nullSet; // recover by returning something.
}