Exemple #1
0
 /**
  * Check whether a given input string is valid according to this SimpleType
  *
  * @param value the input string to be checked
  * @param nsResolver a namespace resolver used to resolve namespace prefixes if the type is
  *     namespace sensitive. The value supplied may be null; in this case any namespace-sensitive
  *     content will throw an UnsupportedOperationException.
  * @param nameChecker XML 1.0 or 1.1 name checker, for types such as xs:NCName
  * @throws UnsupportedOperationException if the type is namespace-sensitive and no namespace
  *     resolver is supplied
  */
 public ValidationFailure validateContent(
     CharSequence value, NamespaceResolver nsResolver, NameChecker nameChecker) {
   SimpleType base = getItemType();
   StringTokenIterator iter = new StringTokenIterator(value.toString());
   ValidationFailure result = null;
   int count = 0;
   // try {
   while (true) {
     StringValue val = (StringValue) iter.next();
     if (val == null) break;
     count++;
     ValidationFailure v = base.validateContent(val.getStringValue(), nsResolver, nameChecker);
     if (v != null) {
       return v;
     }
   }
   //        } catch (ValidationException err) {
   //            result = err;
   //        } catch (XPathException err) {
   //            result = new ValidationException(err);
   //        }
   if (count == 0) {
     result =
         new ValidationFailure(
             "The built-in list type "
                 + StandardNames.getDisplayName(fingerprint)
                 + " does not allow a zero-length list");
   }
   return result;
 }
Exemple #2
0
 /**
  * Get the typed value of a given input string. This method assumes that the input value is valid
  * according to this SimpleType
  *
  * @param value the string whose typed value is required
  * @param resolver namespace resolver for namespace-sensitive content
  * @param nameChecker name checker for XML-version sensitive content
  */
 public SequenceIterator getTypedValue(
     CharSequence value, NamespaceResolver resolver, NameChecker nameChecker)
     throws ValidationException {
   UnfailingIterator iter = new StringTokenIterator(value.toString());
   ListTypeMappingFunction map = new ListTypeMappingFunction();
   map.resolver = resolver;
   map.atomicType = (AtomicType) getItemType();
   map.nameChecker = nameChecker;
   return new MappingIterator(iter, map);
 }