/**
   * Runs the test case.
   *
   * @throws Throwable Any uncaught exception causes test to fail
   */
  public void runTest() throws Throwable {
    DOMImplementation domImpl;
    Document doc;
    DOMConfiguration domConfig;
    DocumentType nullDocType = null;

    boolean canSet;
    boolean state;
    String parameter = "nAmEspace-declarations";
    domImpl = getImplementation();
    doc = domImpl.createDocument("http://www.w3.org/1999/xhtml", "html", nullDocType);
    domConfig = doc.getDomConfig();
    state = ((Boolean) domConfig.getParameter(parameter)).booleanValue();
    assertTrue("defaultFalse", state);
    canSet = domConfig.canSetParameter(parameter, Boolean.FALSE);
    assertTrue("canSetFalse", canSet);
    canSet = domConfig.canSetParameter(parameter, Boolean.TRUE);
    assertTrue("canSetTrue", canSet);
    domConfig.setParameter(parameter, Boolean.FALSE);
    state = ((Boolean) domConfig.getParameter(parameter)).booleanValue();
    assertFalse("setFalseEffective", state);
    domConfig.setParameter(parameter, Boolean.TRUE);
    state = ((Boolean) domConfig.getParameter(parameter)).booleanValue();
    assertTrue("setTrueEffective", state);
  }
Ejemplo n.º 2
0
 public static void validate(Document d, String schema, DOMErrorHandler handler) {
   DOMConfiguration config = d.getDomConfig();
   config.setParameter("schema-type", "http://www.w3.org/2001/XMLSchema");
   config.setParameter("validate", true);
   config.setParameter("schema-location", schema);
   config.setParameter("resource-resolver", new ClasspathResourceResolver());
   config.setParameter("error-handler", handler);
   d.normalizeDocument();
 }
Ejemplo n.º 3
0
  /**
   * Runs the test case.
   *
   * @throws Throwable Any uncaught exception causes test to fail
   */
  public void runTest() throws Throwable {
    DOMImplementation domImpl;
    Document doc;
    DOMConfiguration domConfig;
    DocumentType nullDocType = null;

    boolean canSet;
    DOMErrorHandler errorHandler = null;

    String parameter = "error-handler";
    DOMErrorHandler state;
    domImpl = getImplementation();
    doc = domImpl.createDocument("http://www.w3.org/1999/xhtml", "html", nullDocType);
    domConfig = doc.getDomConfig();
    canSet = domConfig.canSetParameter(parameter, ((Object) /*DOMErrorHandler */ errorHandler));
    assertTrue("canSetNull", canSet);
    domConfig.setParameter(parameter, ((Object) /*DOMErrorHandler */ errorHandler));
    state = (DOMErrorHandler) domConfig.getParameter(parameter);
    assertNull("errorHandlerIsNull", state);
  }
  /**
   * Runs the test case.
   *
   * @throws Throwable Any uncaught exception causes test to fail
   */
  public void runTest() throws Throwable {
    DOMImplementation domImpl;
    Document doc;
    DOMConfiguration domConfig;
    DocumentType nullDocType = null;

    boolean canSet;
    boolean state;
    String parameter = "datatype-normalization";
    domImpl = getImplementation();
    doc = domImpl.createDocument("http://www.w3.org/1999/xhtml", "html", nullDocType);
    domConfig = doc.getDomConfig();
    domConfig.setParameter("validate", Boolean.FALSE);
    canSet = domConfig.canSetParameter(parameter, Boolean.TRUE);

    if (canSet) {
      domConfig.setParameter(parameter, Boolean.TRUE);
      state = ((Boolean) domConfig.getParameter("validate")).booleanValue();
      assertTrue("validateSet", state);
    }
  }
 /**
  * DOM3 method: Normalize the document with namespaces
  *
  * @param doc
  * @return
  */
 public static Document normalizeNamespaces(Document doc) {
   DOMConfiguration docConfig = doc.getDomConfig();
   docConfig.setParameter("namespaces", Boolean.TRUE);
   doc.normalizeDocument();
   return doc;
 }