コード例 #1
0
ファイル: ValidationUtils.java プロジェクト: RayPlante/junx
 private static void setForSchemaCacheXerces(DocumentBuilderFactory df, SchemaLocation sl) {
   try {
     df.setAttribute(NAMESPACES_FEATURE_ID, Boolean.TRUE);
     df.setAttribute(VALIDATION_FEATURE_ID, Boolean.TRUE);
     df.setAttribute(SCHEMA_VALIDATION_FEATURE_ID, Boolean.TRUE);
     df.setAttribute(SCHEMA_FULL_CHECKING_FEATURE_ID, Boolean.TRUE);
     if (sl != null) df.setAttribute(EXTERNAL_SCHEMA_LOCATION, sl.getSchemaLocation());
   } catch (IllegalArgumentException ex) {
     throw new InternalError(
         "Configuration error: Xerces features not supported"
             + " (you probably need Java 1.5 or later)");
   }
 }
コード例 #2
0
ファイル: ValidationUtils.java プロジェクト: RayPlante/junx
  /** 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?)");
    }
  }