Java 类org.w3c.dom.DOMErrorHandler 实例源码

项目:OpenJSharp    文件:DOMNormalizer.java   
/**
 * Reports a DOM error to the user handler.
 *
 * If the error is fatal, the processing will be always aborted.
 */
public static final void reportDOMError(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
                    String message, short severity, String type ) {
    if( errorHandler!=null ) {
        error.reset();
        error.fMessage = message;
        error.fSeverity = severity;
        error.fLocator = locator;
        error.fType = type;
        error.fRelatedData = locator.fRelatedNode;

        if(!errorHandler.handleError(error))
            throw abort;
    }
    if( severity==DOMError.SEVERITY_FATAL_ERROR )
        throw abort;
}
项目:openjdk-jdk10    文件:DOMNormalizer.java   
/**
 * Reports a DOM error to the user handler.
 *
 * If the error is fatal, the processing will be always aborted.
 */
public static final void reportDOMError(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
                    String message, short severity, String type ) {
    if( errorHandler!=null ) {
        error.reset();
        error.fMessage = message;
        error.fSeverity = severity;
        error.fLocator = locator;
        error.fType = type;
        error.fRelatedData = locator.fRelatedNode;

        if(!errorHandler.handleError(error))
            throw new AbortException();
    }
    if( severity==DOMError.SEVERITY_FATAL_ERROR )
        throw new AbortException();
}
项目:openjdk-jdk10    文件:DOM3TreeWalker.java   
/**
 * Constructor.
 * @param   contentHandler serialHandler The implemention of the SerializationHandler interface
 */
DOM3TreeWalker(
    SerializationHandler serialHandler,
    DOMErrorHandler errHandler,
    LSSerializerFilter filter,
    String newLine) {
    fSerializer = serialHandler;
    //fErrorHandler = errHandler == null ? new DOMErrorHandlerImpl() : errHandler; // Should we be using the default?
    fErrorHandler = errHandler;
    fFilter = filter;
    fLexicalHandler = null;
    fNewLine = newLine;

    fNSBinder = new NamespaceSupport();
    fLocalNSBinder = new NamespaceSupport();

    fDOMConfigProperties = fSerializer.getOutputFormat();
    fSerializer.setDocumentLocator(fLocator);
    initProperties(fDOMConfigProperties);
}
项目:openjdk9    文件:DOMNormalizer.java   
/**
 * Reports a DOM error to the user handler.
 *
 * If the error is fatal, the processing will be always aborted.
 */
public static final void reportDOMError(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
                    String message, short severity, String type ) {
    if( errorHandler!=null ) {
        error.reset();
        error.fMessage = message;
        error.fSeverity = severity;
        error.fLocator = locator;
        error.fType = type;
        error.fRelatedData = locator.fRelatedNode;

        if(!errorHandler.handleError(error))
            throw abort;
    }
    if( severity==DOMError.SEVERITY_FATAL_ERROR )
        throw abort;
}
项目:openjdk9    文件:DOM3TreeWalker.java   
/**
 * Constructor.
 * @param   contentHandler serialHandler The implemention of the SerializationHandler interface
 */
DOM3TreeWalker(
    SerializationHandler serialHandler,
    DOMErrorHandler errHandler,
    LSSerializerFilter filter,
    String newLine) {
    fSerializer = serialHandler;
    //fErrorHandler = errHandler == null ? new DOMErrorHandlerImpl() : errHandler; // Should we be using the default?
    fErrorHandler = errHandler;
    fFilter = filter;
    fLexicalHandler = null;
    fNewLine = newLine;

    fNSBinder = new NamespaceSupport();
    fLocalNSBinder = new NamespaceSupport();

    fDOMConfigProperties = fSerializer.getOutputFormat();
    fSerializer.setDocumentLocator(fLocator);
    initProperties(fDOMConfigProperties);
}
项目:lookaside_java-1.8.0-openjdk    文件:DOMNormalizer.java   
/**
 * Reports a DOM error to the user handler.
 *
 * If the error is fatal, the processing will be always aborted.
 */
public static final void reportDOMError(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
                    String message, short severity, String type ) {
    if( errorHandler!=null ) {
        error.reset();
        error.fMessage = message;
        error.fSeverity = severity;
        error.fLocator = locator;
        error.fType = type;
        error.fRelatedData = locator.fRelatedNode;

        if(!errorHandler.handleError(error))
            throw abort;
    }
    if( severity==DOMError.SEVERITY_FATAL_ERROR )
        throw abort;
}
项目:infobip-open-jdk-8    文件:DOMNormalizer.java   
/**
 * Reports a DOM error to the user handler.
 *
 * If the error is fatal, the processing will be always aborted.
 */
public static final void reportDOMError(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
                    String message, short severity, String type ) {
    if( errorHandler!=null ) {
        error.reset();
        error.fMessage = message;
        error.fSeverity = severity;
        error.fLocator = locator;
        error.fType = type;
        error.fRelatedData = locator.fRelatedNode;

        if(!errorHandler.handleError(error))
            throw abort;
    }
    if( severity==DOMError.SEVERITY_FATAL_ERROR )
        throw abort;
}
项目:jlibs    文件:XSParser.java   
public XSParser(LSResourceResolver entityResolver, DOMErrorHandler errorHandler){
    System.setProperty(DOMImplementationRegistry.PROPERTY, DOMXSImplementationSourceImpl.class.getName());
    DOMImplementationRegistry registry;
    try{
        registry = DOMImplementationRegistry.newInstance();
    }catch(Exception ex){
        throw new ImpossibleException(ex);
    }
    XSImplementationImpl xsImpl = (XSImplementationImpl)registry.getDOMImplementation("XS-Loader");

    xsLoader = xsImpl.createXSLoader(null);
    DOMConfiguration config = xsLoader.getConfig();
    config.setParameter(Constants.DOM_VALIDATE, Boolean.TRUE);

    if(entityResolver!=null)
        config.setParameter(Constants.DOM_RESOURCE_RESOLVER, entityResolver);

    if(errorHandler!=null)
        config.setParameter(Constants.DOM_ERROR_HANDLER, errorHandler);
}
项目:OLD-OpenJDK8    文件:DOMNormalizer.java   
/**
 * Reports a DOM error to the user handler.
 *
 * If the error is fatal, the processing will be always aborted.
 */
public static final void reportDOMError(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
                    String message, short severity, String type ) {
    if( errorHandler!=null ) {
        error.reset();
        error.fMessage = message;
        error.fSeverity = severity;
        error.fLocator = locator;
        error.fType = type;
        error.fRelatedData = locator.fRelatedNode;

        if(!errorHandler.handleError(error))
            throw abort;
    }
    if( severity==DOMError.SEVERITY_FATAL_ERROR )
        throw abort;
}
项目:SplitCharater    文件:DOMNormalizer.java   
/**
 * Reports a DOM error to the user handler.
 * 
 * If the error is fatal, the processing will be always aborted.
 */
public static final void reportDOMError(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator, 
                    String message, short severity, String type ) {
    if( errorHandler!=null ) {
        error.reset();
        error.fMessage = message;
        error.fSeverity = severity;
        error.fLocator = locator;
        error.fType = type;
        error.fRelatedData = locator.fRelatedNode;

        if(!errorHandler.handleError(error))
            throw abort;
    }
    if( severity==DOMError.SEVERITY_FATAL_ERROR )
        throw abort;
}
项目:openjdk-icedtea7    文件:DOMNormalizer.java   
/**
 * Reports a DOM error to the user handler.
 *
 * If the error is fatal, the processing will be always aborted.
 */
public static final void reportDOMError(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
                    String message, short severity, String type ) {
    if( errorHandler!=null ) {
        error.reset();
        error.fMessage = message;
        error.fSeverity = severity;
        error.fLocator = locator;
        error.fType = type;
        error.fRelatedData = locator.fRelatedNode;

        if(!errorHandler.handleError(error))
            throw abort;
    }
    if( severity==DOMError.SEVERITY_FATAL_ERROR )
        throw abort;
}
项目:openjdk-jdk10    文件:LSSerializerImpl.java   
/**
 * Checks if setting a parameter to a specific value is supported.
 *
 * @see org.w3c.dom.DOMConfiguration#canSetParameter(java.lang.String, java.lang.Object)
 * @since DOM Level 3
 * @param name A String containing the DOMConfiguration parameter name.
 * @param value An Object specifying the value of the corresponding parameter.
 */
public boolean canSetParameter(String name, Object value) {
    if (value instanceof Boolean){
        if ( name.equalsIgnoreCase(DOMConstants.DOM_CDATA_SECTIONS)
                || name.equalsIgnoreCase(DOMConstants.DOM_COMMENTS)
                || name.equalsIgnoreCase(DOMConstants.DOM_ENTITIES)
                || name.equalsIgnoreCase(DOMConstants.DOM_INFOSET)
                || name.equalsIgnoreCase(DOMConstants.DOM_ELEMENT_CONTENT_WHITESPACE)
                || name.equalsIgnoreCase(DOMConstants.DOM_NAMESPACES)
                || name.equalsIgnoreCase(DOMConstants.DOM_NAMESPACE_DECLARATIONS)
                || name.equalsIgnoreCase(DOMConstants.DOM_SPLIT_CDATA)
                || name.equalsIgnoreCase(DOMConstants.DOM_WELLFORMED)
                || name.equalsIgnoreCase(DOMConstants.DOM_DISCARD_DEFAULT_CONTENT)
                || name.equalsIgnoreCase(DOMConstants.DOM_FORMAT_PRETTY_PRINT)
                || name.equalsIgnoreCase(DOMConstants.DOM_XMLDECL)){
            // both values supported
            return true;
        }
        else if (name.equalsIgnoreCase(DOMConstants.DOM_CANONICAL_FORM)
                || name.equalsIgnoreCase(DOMConstants.DOM_CHECK_CHAR_NORMALIZATION)
                || name.equalsIgnoreCase(DOMConstants.DOM_DATATYPE_NORMALIZATION)
                || name.equalsIgnoreCase(DOMConstants.DOM_VALIDATE_IF_SCHEMA)
                || name.equalsIgnoreCase(DOMConstants.DOM_VALIDATE)
                // || name.equalsIgnoreCase(DOMConstants.DOM_NORMALIZE_CHARACTERS)
                ) {
            // true is not supported
            return !((Boolean)value).booleanValue();
        }
        else if (name.equalsIgnoreCase(DOMConstants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)) {
            // false is not supported
            return ((Boolean)value).booleanValue();
        }
    }
    else if (name.equalsIgnoreCase(DOMConstants.DOM_ERROR_HANDLER) &&
            value == null || value instanceof DOMErrorHandler){
        return true;
    }
    return false;
}
项目:openjdk-jdk10    文件:Bug4915748.java   
@Test
public void testMain() throws Exception {

    final boolean[] hadError = new boolean[1];

    DocumentBuilderFactory docBF = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docBF.newDocumentBuilder();

    Document doc = docBuilder.getDOMImplementation().createDocument("namespaceURI", "ns:root", null);

    CDATASection cdata = doc.createCDATASection("text1]]>text2");
    doc.getDocumentElement().appendChild(cdata);

    DOMConfiguration config = doc.getDomConfig();
    DOMErrorHandler erroHandler = new DOMErrorHandler() {
        public boolean handleError(DOMError error) {
            System.out.println(error.getMessage());
            Assert.assertEquals(error.getType(), "cdata-sections-splitted");
            Assert.assertFalse(hadError[0], "two errors were reported");
            hadError[0] = true;
            return false;
        }
    };
    config.setParameter("error-handler", erroHandler);
    doc.normalizeDocument();
    Assert.assertTrue(hadError[0]);
}
项目:openjdk9    文件:LSSerializerImpl.java   
/**
 * Checks if setting a parameter to a specific value is supported.
 *
 * @see org.w3c.dom.DOMConfiguration#canSetParameter(java.lang.String, java.lang.Object)
 * @since DOM Level 3
 * @param name A String containing the DOMConfiguration parameter name.
 * @param value An Object specifying the value of the corresponding parameter.
 */
public boolean canSetParameter(String name, Object value) {
    if (value instanceof Boolean){
        if ( name.equalsIgnoreCase(DOMConstants.DOM_CDATA_SECTIONS)
                || name.equalsIgnoreCase(DOMConstants.DOM_COMMENTS)
                || name.equalsIgnoreCase(DOMConstants.DOM_ENTITIES)
                || name.equalsIgnoreCase(DOMConstants.DOM_INFOSET)
                || name.equalsIgnoreCase(DOMConstants.DOM_ELEMENT_CONTENT_WHITESPACE)
                || name.equalsIgnoreCase(DOMConstants.DOM_NAMESPACES)
                || name.equalsIgnoreCase(DOMConstants.DOM_NAMESPACE_DECLARATIONS)
                || name.equalsIgnoreCase(DOMConstants.DOM_SPLIT_CDATA)
                || name.equalsIgnoreCase(DOMConstants.DOM_WELLFORMED)
                || name.equalsIgnoreCase(DOMConstants.DOM_DISCARD_DEFAULT_CONTENT)
                || name.equalsIgnoreCase(DOMConstants.DOM_FORMAT_PRETTY_PRINT)
                || name.equalsIgnoreCase(DOMConstants.DOM_XMLDECL)){
            // both values supported
            return true;
        }
        else if (name.equalsIgnoreCase(DOMConstants.DOM_CANONICAL_FORM)
                || name.equalsIgnoreCase(DOMConstants.DOM_CHECK_CHAR_NORMALIZATION)
                || name.equalsIgnoreCase(DOMConstants.DOM_DATATYPE_NORMALIZATION)
                || name.equalsIgnoreCase(DOMConstants.DOM_VALIDATE_IF_SCHEMA)
                || name.equalsIgnoreCase(DOMConstants.DOM_VALIDATE)
                // || name.equalsIgnoreCase(DOMConstants.DOM_NORMALIZE_CHARACTERS)
                ) {
            // true is not supported
            return !((Boolean)value).booleanValue();
        }
        else if (name.equalsIgnoreCase(DOMConstants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)) {
            // false is not supported
            return ((Boolean)value).booleanValue();
        }
    }
    else if (name.equalsIgnoreCase(DOMConstants.DOM_ERROR_HANDLER) &&
            value == null || value instanceof DOMErrorHandler){
        return true;
    }
    return false;
}
项目:openjdk9    文件:Bug4915748.java   
@Test
public void testMain() throws Exception {

    final boolean[] hadError = new boolean[1];

    DocumentBuilderFactory docBF = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docBF.newDocumentBuilder();

    Document doc = docBuilder.getDOMImplementation().createDocument("namespaceURI", "ns:root", null);

    CDATASection cdata = doc.createCDATASection("text1]]>text2");
    doc.getDocumentElement().appendChild(cdata);

    DOMConfiguration config = doc.getDomConfig();
    DOMErrorHandler erroHandler = new DOMErrorHandler() {
        public boolean handleError(DOMError error) {
            System.out.println(error.getMessage());
            Assert.assertEquals(error.getType(), "cdata-sections-splitted");
            Assert.assertFalse(hadError[0], "two errors were reported");
            hadError[0] = true;
            return false;
        }
    };
    config.setParameter("error-handler", erroHandler);
    doc.normalizeDocument();
    Assert.assertTrue(hadError[0]);
}
项目:Push2Display    文件:AbstractDocument.java   
/**
 * <b>DOM</b>: Implements {@link org.w3c.dom.Document#normalizeDocument()}.
 * XXX Does not handle the 'entities' parameter yet.
 */
public void normalizeDocument() {
    if (domConfig == null) {
        domConfig = new DocumentConfiguration();
    }
    boolean cdataSections = domConfig.getBooleanParameter
        (DOMConstants.DOM_CDATA_SECTIONS_PARAM);
    boolean comments = domConfig.getBooleanParameter
        (DOMConstants.DOM_COMMENTS_PARAM);
    boolean elementContentWhitespace = domConfig.getBooleanParameter
        (DOMConstants.DOM_ELEMENT_CONTENT_WHITESPACE_PARAM);
    boolean namespaceDeclarations = domConfig.getBooleanParameter
        (DOMConstants.DOM_NAMESPACE_DECLARATIONS_PARAM);
    boolean namespaces = domConfig.getBooleanParameter
        (DOMConstants.DOM_NAMESPACES_PARAM);
    boolean splitCdataSections = domConfig.getBooleanParameter
        (DOMConstants.DOM_SPLIT_CDATA_SECTIONS_PARAM);
    DOMErrorHandler errorHandler = (DOMErrorHandler) domConfig.getParameter
        (DOMConstants.DOM_ERROR_HANDLER_PARAM);
    normalizeDocument(getDocumentElement(),
                      cdataSections,
                      comments,
                      elementContentWhitespace,
                      namespaceDeclarations,
                      namespaces,
                      splitCdataSections,
                      errorHandler);
}
项目:Push2Display    文件:AbstractDocument.java   
/**
 * Splits the given CDATA node if required.
 */
protected boolean splitCdata(Element e,
                             Node n,
                             DOMErrorHandler errorHandler) {
    String s2 = n.getNodeValue();
    int index = s2.indexOf(XMLConstants.XML_CDATA_END);
    if (index != -1) {
        String before = s2.substring(0, index + 2);
        String after = s2.substring(index + 2);
        n.setNodeValue(before);
        Node next = n.getNextSibling();
        if (next == null) {
            e.appendChild(createCDATASection(after));
        } else {
            e.insertBefore(createCDATASection(after),
                           next);
        }
        if (errorHandler != null) {
            if (!errorHandler.handleError(createDOMError(
                DOMConstants.DOM_CDATA_SECTIONS_SPLITTED_ERROR,
                DOMError.SEVERITY_WARNING,
                "cdata.section.split",
                new Object[] {},
                n,
                null))) {
                return false;
            }
        }
    }
    return true;
}
项目:Push2Display    文件:AbstractDocument.java   
/**
 * Returns whether the given parameter can be set to the given value.
 */
public boolean canSetParameter(String name, Object value) {
    if (name.equals(DOMConstants.DOM_ERROR_HANDLER_PARAM)) {
        return value == null || value instanceof DOMErrorHandler;
    }
    Integer i = (Integer) booleanParamIndexes.get(name);
    if (i == null || value == null || !(value instanceof Boolean)) {
        return false;
    }
    int index = i.intValue();
    boolean val = ((Boolean) value).booleanValue();
    return !booleanParamReadOnly[index]
        || booleanParamValues[index] == val;
}
项目:javify    文件:GnomeDocument.java   
public boolean canSetParameter(String name, Object value)
{
  name = name.toLowerCase();
  if ("error-handler".equals(name))
    {
      return (value == null || value instanceof DOMErrorHandler);
    }
  return ("cdata-sections".equals(name) ||
          "comments".equals(name) ||
          "entities".equals(name) ||
          "namespace-declarations".equals(name) ||
          "split-cdata-sections".equals(name));
}
项目:javify    文件:DomDocumentConfiguration.java   
public boolean canSetParameter(String name, Object value)
{
  name = name.toLowerCase();
  if ("error-handler".equals(name))
    {
      return (value == null || value instanceof DOMErrorHandler);
    }
  else if (contains(name))
    {
      return true;
    }
  else if ("canonical-form".equals(name) ||
           "check-character-normalization".equals(name) ||
           "datatype-normalization".equals(name) ||
           "normalize-characters".equals(name) ||
           "validate".equals(name) ||
           "validate-if-schema".equals(name))
    {
      return "false".equals(value.toString());
    }
  else if ("namespaces".equals(name) ||
           "well-formed".equals(name))
    {
      return "true".equals(value.toString());
    }
  return false;
}
项目:jvm-stm    文件:GnomeDocument.java   
public boolean canSetParameter(String name, Object value)
{
  name = name.toLowerCase();
  if ("error-handler".equals(name))
    {
      return (value == null || value instanceof DOMErrorHandler);
    }
  return ("cdata-sections".equals(name) ||
          "comments".equals(name) ||
          "entities".equals(name) ||
          "namespace-declarations".equals(name) ||
          "split-cdata-sections".equals(name));
}
项目:jvm-stm    文件:DomDocumentConfiguration.java   
public boolean canSetParameter(String name, Object value)
{
  name = name.toLowerCase();
  if ("error-handler".equals(name))
    {
      return (value == null || value instanceof DOMErrorHandler);
    }
  else if (contains(name))
    {
      return true;
    }
  else if ("canonical-form".equals(name) ||
           "check-character-normalization".equals(name) ||
           "datatype-normalization".equals(name) ||
           "normalize-characters".equals(name) ||
           "validate".equals(name) ||
           "validate-if-schema".equals(name))
    {
      return "false".equals(value.toString());
    }
  else if ("namespaces".equals(name) ||
           "well-formed".equals(name))
    {
      return "true".equals(value.toString());
    }
  return false;
}
项目:Push2Display    文件:AbstractDocument.java   
/**
 * <b>DOM</b>: Implements {@link org.w3c.dom.Document#normalizeDocument()}.
 * XXX Does not handle the 'entities' parameter yet.
 */
public void normalizeDocument() {
    if (domConfig == null) {
        domConfig = new DocumentConfiguration();
    }
    boolean cdataSections = domConfig.getBooleanParameter
        (DOMConstants.DOM_CDATA_SECTIONS_PARAM);
    boolean comments = domConfig.getBooleanParameter
        (DOMConstants.DOM_COMMENTS_PARAM);
    boolean elementContentWhitespace = domConfig.getBooleanParameter
        (DOMConstants.DOM_ELEMENT_CONTENT_WHITESPACE_PARAM);
    boolean namespaceDeclarations = domConfig.getBooleanParameter
        (DOMConstants.DOM_NAMESPACE_DECLARATIONS_PARAM);
    boolean namespaces = domConfig.getBooleanParameter
        (DOMConstants.DOM_NAMESPACES_PARAM);
    boolean splitCdataSections = domConfig.getBooleanParameter
        (DOMConstants.DOM_SPLIT_CDATA_SECTIONS_PARAM);
    DOMErrorHandler errorHandler = (DOMErrorHandler) domConfig.getParameter
        (DOMConstants.DOM_ERROR_HANDLER_PARAM);
    normalizeDocument(getDocumentElement(),
                      cdataSections,
                      comments,
                      elementContentWhitespace,
                      namespaceDeclarations,
                      namespaces,
                      splitCdataSections,
                      errorHandler);
}
项目:Push2Display    文件:AbstractDocument.java   
/**
 * Splits the given CDATA node if required.
 */
protected boolean splitCdata(Element e,
                             Node n,
                             DOMErrorHandler errorHandler) {
    String s2 = n.getNodeValue();
    int index = s2.indexOf(XMLConstants.XML_CDATA_END);
    if (index != -1) {
        String before = s2.substring(0, index + 2);
        String after = s2.substring(index + 2);
        n.setNodeValue(before);
        Node next = n.getNextSibling();
        if (next == null) {
            e.appendChild(createCDATASection(after));
        } else {
            e.insertBefore(createCDATASection(after),
                           next);
        }
        if (errorHandler != null) {
            if (!errorHandler.handleError(createDOMError(
                DOMConstants.DOM_CDATA_SECTIONS_SPLITTED_ERROR,
                DOMError.SEVERITY_WARNING,
                "cdata.section.split",
                new Object[] {},
                n,
                null))) {
                return false;
            }
        }
    }
    return true;
}
项目:Push2Display    文件:AbstractDocument.java   
/**
 * Returns whether the given parameter can be set to the given value.
 */
public boolean canSetParameter(String name, Object value) {
    if (name.equals(DOMConstants.DOM_ERROR_HANDLER_PARAM)) {
        return value == null || value instanceof DOMErrorHandler;
    }
    Integer i = (Integer) booleanParamIndexes.get(name);
    if (i == null || value == null || !(value instanceof Boolean)) {
        return false;
    }
    int index = i.intValue();
    boolean val = ((Boolean) value).booleanValue();
    return !booleanParamReadOnly[index]
        || booleanParamValues[index] == val;
}
项目:FHIR-Server    文件:XMLUtils.java   
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();
}
项目:feathers-sdk    文件:AbstractDocument.java   
/**
 * <b>DOM</b>: Implements {@link org.w3c.dom.Document#normalizeDocument()}.
 * XXX Does not handle the 'entities' parameter yet.
 */
public void normalizeDocument() {
    if (domConfig == null) {
        domConfig = new DocumentConfiguration();
    }
    boolean cdataSections = domConfig.getBooleanParameter
        (DOMConstants.DOM_CDATA_SECTIONS_PARAM);
    boolean comments = domConfig.getBooleanParameter
        (DOMConstants.DOM_COMMENTS_PARAM);
    boolean elementContentWhitespace = domConfig.getBooleanParameter
        (DOMConstants.DOM_ELEMENT_CONTENT_WHITESPACE_PARAM);
    boolean namespaceDeclarations = domConfig.getBooleanParameter
        (DOMConstants.DOM_NAMESPACE_DECLARATIONS_PARAM);
    boolean namespaces = domConfig.getBooleanParameter
        (DOMConstants.DOM_NAMESPACES_PARAM);
    boolean splitCdataSections = domConfig.getBooleanParameter
        (DOMConstants.DOM_SPLIT_CDATA_SECTIONS_PARAM);
    DOMErrorHandler errorHandler = (DOMErrorHandler) domConfig.getParameter
        (DOMConstants.DOM_ERROR_HANDLER_PARAM);
    normalizeDocument(getDocumentElement(),
                      cdataSections,
                      comments,
                      elementContentWhitespace,
                      namespaceDeclarations,
                      namespaces,
                      splitCdataSections,
                      errorHandler);
}
项目:feathers-sdk    文件:AbstractDocument.java   
/**
 * Splits the given CDATA node if required.
 */
protected boolean splitCdata(Element e,
                             Node n,
                             DOMErrorHandler errorHandler) {
    String s2 = n.getNodeValue();
    int index = s2.indexOf(XMLConstants.XML_CDATA_END);
    if (index != -1) {
        String before = s2.substring(0, index + 2);
        String after = s2.substring(index + 2);
        n.setNodeValue(before);
        Node next = n.getNextSibling();
        if (next == null) {
            e.appendChild(createCDATASection(after));
        } else {
            e.insertBefore(createCDATASection(after),
                           next);
        }
        if (errorHandler != null) {
            if (!errorHandler.handleError(createDOMError(
                DOMConstants.DOM_CDATA_SECTIONS_SPLITTED_ERROR,
                DOMError.SEVERITY_WARNING,
                "cdata.section.split",
                new Object[] {},
                n,
                null))) {
                return false;
            }
        }
    }
    return true;
}
项目:feathers-sdk    文件:AbstractDocument.java   
/**
 * Returns whether the given parameter can be set to the given value.
 */
public boolean canSetParameter(String name, Object value) {
    if (name.equals(DOMConstants.DOM_ERROR_HANDLER_PARAM)) {
        return value == null || value instanceof DOMErrorHandler;
    }
    Integer i = (Integer) booleanParamIndexes.get(name);
    if (i == null || value == null || !(value instanceof Boolean)) {
        return false;
    }
    int index = i.intValue();
    boolean val = ((Boolean) value).booleanValue();
    return !booleanParamReadOnly[index]
        || booleanParamValues[index] == val;
}
项目:In-the-Box-Fork    文件:LSSerializerImpl.java   
/** 
 * Checks if setting a parameter to a specific value is supported.    
 *  
 * @see org.w3c.dom.DOMConfiguration#canSetParameter(java.lang.String, java.lang.Object)
 * @since DOM Level 3
 * @param name A String containing the DOMConfiguration parameter name.
 * @param value An Object specifying the value of the corresponding parameter. 
 */
public boolean canSetParameter(String name, Object value) {
    if (value instanceof Boolean){
        if ( name.equalsIgnoreCase(DOMConstants.DOM_CDATA_SECTIONS)
                || name.equalsIgnoreCase(DOMConstants.DOM_COMMENTS)
                || name.equalsIgnoreCase(DOMConstants.DOM_ENTITIES)
                || name.equalsIgnoreCase(DOMConstants.DOM_INFOSET)
                || name.equalsIgnoreCase(DOMConstants.DOM_ELEMENT_CONTENT_WHITESPACE)
                || name.equalsIgnoreCase(DOMConstants.DOM_NAMESPACES)    
                || name.equalsIgnoreCase(DOMConstants.DOM_NAMESPACE_DECLARATIONS)
                || name.equalsIgnoreCase(DOMConstants.DOM_SPLIT_CDATA)
                || name.equalsIgnoreCase(DOMConstants.DOM_WELLFORMED)    
                || name.equalsIgnoreCase(DOMConstants.DOM_DISCARD_DEFAULT_CONTENT)
                || name.equalsIgnoreCase(DOMConstants.DOM_FORMAT_PRETTY_PRINT)                
                || name.equalsIgnoreCase(DOMConstants.DOM_XMLDECL)){
            // both values supported
            return true;
        }
        else if (name.equalsIgnoreCase(DOMConstants.DOM_CANONICAL_FORM)
                || name.equalsIgnoreCase(DOMConstants.DOM_CHECK_CHAR_NORMALIZATION)
                || name.equalsIgnoreCase(DOMConstants.DOM_DATATYPE_NORMALIZATION)
                || name.equalsIgnoreCase(DOMConstants.DOM_VALIDATE_IF_SCHEMA)
                || name.equalsIgnoreCase(DOMConstants.DOM_VALIDATE)
                // || name.equalsIgnoreCase(DOMConstants.DOM_NORMALIZE_CHARACTERS)
                ) {
            // true is not supported
            return !((Boolean)value).booleanValue();
        }
        else if (name.equalsIgnoreCase(DOMConstants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)) {
            // false is not supported
            return ((Boolean)value).booleanValue();
        }
    }
    else if (name.equalsIgnoreCase(DOMConstants.DOM_ERROR_HANDLER) &&
            value == null || value instanceof DOMErrorHandler){
        return true;
    }
    return false;
}
项目:In-the-Box-Fork    文件:DOM3TreeWalker.java   
/**
 * Constructor.
 * @param   contentHandler serialHandler The implemention of the SerializationHandler interface
 */
DOM3TreeWalker(
    SerializationHandler serialHandler,
    DOMErrorHandler errHandler,
    LSSerializerFilter filter,
    String newLine) {
    fSerializer = serialHandler;
    //fErrorHandler = errHandler == null ? new DOMErrorHandlerImpl() : errHandler; // Should we be using the default?
    fErrorHandler = errHandler;
    fFilter = filter;
    fLexicalHandler = null;
    fNewLine = newLine;

    fNSBinder = new NamespaceSupport();
    fLocalNSBinder = new NamespaceSupport();

    fDOMConfigProperties = fSerializer.getOutputFormat();
    fSerializer.setDocumentLocator(fLocator);
    initProperties(fDOMConfigProperties);

    try {
        // Bug see Bugzilla  26741
        fLocator.setSystemId(
            System.getProperty("user.dir") + File.separator + "dummy.xsl");
    } catch (SecurityException se) { // user.dir not accessible from applet

    }
}
项目:In-the-Box-Fork    文件:NormalizeTest.java   
public void testErrorHandler() {
    assertEquals(null, domConfiguration.getParameter("error-handler"));
    assertSupported("error-handler", null);
    assertSupported("error-handler", new DOMErrorHandler() {
        public boolean handleError(DOMError error) {
            return true;
        }
    });
}
项目:hapi-fhir    文件:XMLUtils.java   
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();
}
项目:JamVM-PH    文件:GnomeDocument.java   
public boolean canSetParameter(String name, Object value)
{
  name = name.toLowerCase();
  if ("error-handler".equals(name))
    {
      return (value == null || value instanceof DOMErrorHandler);
    }
  return ("cdata-sections".equals(name) ||
          "comments".equals(name) ||
          "entities".equals(name) ||
          "namespace-declarations".equals(name) ||
          "split-cdata-sections".equals(name));
}
项目:JamVM-PH    文件:DomDocumentConfiguration.java   
public boolean canSetParameter(String name, Object value)
{
  name = name.toLowerCase();
  if ("error-handler".equals(name))
    {
      return (value == null || value instanceof DOMErrorHandler);
    }
  else if (contains(name))
    {
      return true;
    }
  else if ("canonical-form".equals(name) ||
           "check-character-normalization".equals(name) ||
           "datatype-normalization".equals(name) ||
           "normalize-characters".equals(name) ||
           "validate".equals(name) ||
           "validate-if-schema".equals(name))
    {
      return "false".equals(value.toString());
    }
  else if ("namespaces".equals(name) ||
           "well-formed".equals(name))
    {
      return "true".equals(value.toString());
    }
  return false;
}
项目:classpath    文件:GnomeDocument.java   
public boolean canSetParameter(String name, Object value)
{
  name = name.toLowerCase();
  if ("error-handler".equals(name))
    {
      return (value == null || value instanceof DOMErrorHandler);
    }
  return ("cdata-sections".equals(name) ||
          "comments".equals(name) ||
          "entities".equals(name) ||
          "namespace-declarations".equals(name) ||
          "split-cdata-sections".equals(name));
}
项目:classpath    文件:DomDocumentConfiguration.java   
public boolean canSetParameter(String name, Object value)
{
  name = name.toLowerCase();
  if ("error-handler".equals(name))
    {
      return (value == null || value instanceof DOMErrorHandler);
    }
  else if (contains(name))
    {
      return true;
    }
  else if ("canonical-form".equals(name) ||
           "check-character-normalization".equals(name) ||
           "datatype-normalization".equals(name) ||
           "normalize-characters".equals(name) ||
           "validate".equals(name) ||
           "validate-if-schema".equals(name))
    {
      return "false".equals(value.toString());
    }
  else if ("namespaces".equals(name) ||
           "well-formed".equals(name))
    {
      return "true".equals(value.toString());
    }
  return false;
}
项目:OpenJSharp    文件:DOMNormalizer.java   
/**
* Normalizes document.
* Note: reset() must be called before this method.
*/
   protected void normalizeDocument(CoreDocumentImpl document, DOMConfigurationImpl config) {

           fDocument = document;
           fConfiguration = config;

           // intialize and reset DOMNormalizer component
           //
           fSymbolTable = (SymbolTable) fConfiguration.getProperty(DOMConfigurationImpl.SYMBOL_TABLE);
           // reset namespace context
           fNamespaceContext.reset();
           fNamespaceContext.declarePrefix(XMLSymbols.EMPTY_STRING, XMLSymbols.EMPTY_STRING);

           if ((fConfiguration.features & DOMConfigurationImpl.VALIDATE) != 0) {
       String schemaLang = (String)fConfiguration.getProperty(DOMConfigurationImpl.JAXP_SCHEMA_LANGUAGE);

       if(schemaLang != null && schemaLang.equals(Constants.NS_XMLSCHEMA)) {
                   fValidationHandler =
                           CoreDOMImplementationImpl.singleton.getValidator(XMLGrammarDescription.XML_SCHEMA);
           fConfiguration.setFeature(DOMConfigurationImpl.SCHEMA, true);
           fConfiguration.setFeature(DOMConfigurationImpl.SCHEMA_FULL_CHECKING, true);
           // report fatal error on DOM Level 1 nodes
           fNamespaceValidation = true;

           // check if we need to fill in PSVI
           fPSVI = ((fConfiguration.features & DOMConfigurationImpl.PSVI) !=0)?true:false;
       }

                   fConfiguration.setFeature(DOMConfigurationImpl.XERCES_VALIDATION, true);

       // reset ID table
       fDocument.clearIdentifiers();

       if(fValidationHandler != null)
       // reset schema validator
           ((XMLComponent) fValidationHandler).reset(fConfiguration);

           }

           fErrorHandler = (DOMErrorHandler) fConfiguration.getParameter(Constants.DOM_ERROR_HANDLER);
           if (fValidationHandler != null) {
                   fValidationHandler.setDocumentHandler(this);
                   fValidationHandler.startDocument(
               new SimpleLocator(fDocument.fDocumentURI, fDocument.fDocumentURI,
                                           -1, -1 ), fDocument.encoding, fNamespaceContext, null);

           }
           try {
                   Node kid, next;
                   for (kid = fDocument.getFirstChild(); kid != null; kid = next) {
                           next = kid.getNextSibling();
                           kid = normalizeNode(kid);
                           if (kid != null) { // don't advance
                                   next = kid;
                           }
                   }

                   // release resources
                   if (fValidationHandler != null) {
                           fValidationHandler.endDocument(null);
                           CoreDOMImplementationImpl.singleton.releaseValidator(
                                   XMLGrammarDescription.XML_SCHEMA, fValidationHandler);
                           fValidationHandler = null;
                   }
           }
           catch (RuntimeException e) {
       if( e==abort )
           return; // processing aborted by the user
       throw e;    // otherwise re-throw.
           }

   }
项目:OpenJSharp    文件:DOMErrorHandlerWrapper.java   
public DOMErrorHandlerWrapper(DOMErrorHandler domErrorHandler) {
    fDomErrorHandler = domErrorHandler;
}
项目:OpenJSharp    文件:DOMErrorHandlerWrapper.java   
/** Sets the DOM error handler. */
public void setErrorHandler(DOMErrorHandler errorHandler) {
    fDomErrorHandler = errorHandler;
}