private XPathException checkAgainstFacets(String lexicalValue) {
Iterator iter = typeLabel.getFacets();
StringValue normalizedValue = null;
while (iter.hasNext()) {
Facet f = (Facet)iter.next();
if (f.getName().equals(Facet.PATTERN)) {
if (normalizedValue == null) {
if (lexicalValue == null) {
normalizedValue = new StringValue(primitiveValue.getStringValue());
} else {
normalizedValue = new StringValue(typeLabel.applyWhitespaceNormalization(lexicalValue));
}
}
if (!f.testAtomicValue(normalizedValue)) {
return new DynamicError(
"Value " + Err.wrap(normalizedValue.toString(), Err.VALUE) + " violates the pattern facet " +
(f.getValue()==null ? "" : Err.wrap(f.getValue(), Err.VALUE) + " ") +
"of the type "
+ typeLabel.getDescription());
}
} else {
if (!f.testAtomicValue(primitiveValue)) {
return new DynamicError(
"Value " + Err.wrap(displayValue(), Err.VALUE) + " violates the " +
f.getName() + " facet " +
(f.getValue()==null ? "" : Err.wrap(f.getValue(), Err.VALUE) + " ") +
"of the type "
+ typeLabel.getDescription());
}
}
}