Example #1
0
  public void testSchema() {
    String name = "name";
    String uri = "uri";
    String prefix = "prefix";
    Schema schema = new SchemaImpl(name, new Namespace(uri, prefix));

    assertEquals(schema.getName(), name);
    assertEquals(schema.getNamespace().uri, uri);
    assertEquals(schema.getNamespace().prefix, prefix);
  }
Example #2
0
 /**
  * Validate an XmlObject against the contained inferred schemas. Upon validation errors, the
  * ConflictHandler is used to determine if a schema should be adjusted, or if validation should
  * fail.
  *
  * @param xmlo An XmlObject containing the document to be validated.
  * @param handler A ConflictHandler to use on validation errors.
  * @throws XmlException On unresolvable validation error.
  */
 public void validate(XmlObject xmlo, ConflictHandler handler) throws XmlException {
   XmlCursor cursor = xmlo.newCursor();
   cursor.toFirstChild();
   Schema s = getSchemaForNamespace(cursor.getName().getNamespaceURI());
   boolean created = false;
   if (s == null) {
     s = newSchema(cursor.getName().getNamespaceURI());
     created = true;
   }
   Context context = new Context(this, handler, cursor);
   try {
     s.validate(context);
   } catch (XmlException e) {
     if (created) schemas.remove(s.getNamespace());
     throw e;
   }
 }