예제 #1
0
  /** set up local cache of schemas for JAXP */
  private static void setForSchemaCacheJAXP(DocumentBuilderFactory df, SchemaLocation sl) {
    try {

      // Xerce's JAXP implementation is broken: it can only validate
      // properly if the schemas are in proper order.  Doh!
      Object[] schemas = null;
      if (sl != null) schemas = sl.getSchemaList();

      // JAXP style validation
      df.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
      if (schemas != null) df.setAttribute(JAXP_SCHEMA_SOURCE, schemas);

    } catch (IllegalArgumentException ex) {
      throw new InternalError(
          "Configuration error: TrAX features not supported"
              + " (are you using Java 1.5 or later?)");
    }
  }