Java 类javax.xml.parsers.FactoryConfigurationError 实例源码

项目:incubator-netbeans    文件:DefaultAttributes.java   
/**
 * Reads itself from XML format
 * New added - for Sandwich project (XML format instead of serialization) .
 * @param is input stream (which is parsed)
 * @return Table
 */
public void readFromXML(InputStream is, boolean validate)
throws SAXException {
    StringBuffer fileName = new StringBuffer();
    ElementHandler[] elmKeyService = { parseFirstLevel(), parseSecondLevel(fileName), parseThirdLevel(fileName) }; //
    String dtd = getClass().getClassLoader().getResource(DTD_PATH).toExternalForm();
    InnerParser parser = new InnerParser(PUBLIC_ID, dtd, elmKeyService);

    try {
        parser.parseXML(is, validate);
    } catch (Exception ioe) {
        throw (SAXException) ExternalUtil.copyAnnotation(
            new SAXException(NbBundle.getMessage(DefaultAttributes.class, "EXC_DefAttrReadErr")), ioe
        );
    } catch (FactoryConfigurationError fce) {
        // ??? see http://openide.netbeans.org/servlets/ReadMsg?msgId=340881&listName=dev
        throw (SAXException) ExternalUtil.copyAnnotation(
            new SAXException(NbBundle.getMessage(DefaultAttributes.class, "EXC_DefAttrReadErr")), fce
        );
    }
}
项目:incubator-netbeans    文件:XMLUtil.java   
/** Creates a SAX parser.
 *
 * <p>See {@link #parse} for hints on setting an entity resolver.
 *
 * @param validate if true, a validating parser is returned
 * @param namespaceAware if true, a namespace aware parser is returned
 *
 * @throws FactoryConfigurationError Application developers should never need to directly catch errors of this type.
 * @throws SAXException if a parser fulfilling given parameters can not be created
 *
 * @return XMLReader configured according to passed parameters
 */
public static synchronized XMLReader createXMLReader(boolean validate, boolean namespaceAware)
throws SAXException {
    SAXParserFactory factory = saxes[validate ? 0 : 1][namespaceAware ? 0 : 1];
    if (factory == null) {
        try {
            factory = SAXParserFactory.newInstance();
        } catch (FactoryConfigurationError err) {
            Exceptions.attachMessage(
                err, 
                "Info about thread context classloader: " + // NOI18N
                Thread.currentThread().getContextClassLoader()
            );
            throw err;
        }
        factory.setValidating(validate);
        factory.setNamespaceAware(namespaceAware);
        saxes[validate ? 0 : 1][namespaceAware ? 0 : 1] = factory;
    }

    try {
        return factory.newSAXParser().getXMLReader();
    } catch (ParserConfigurationException ex) {
        throw new SAXException("Cannot create parser satisfying configuration parameters", ex); //NOI18N                        
    }
}
项目:jmt    文件:Measure.java   
/**
 * Creates a DOM (Document Object Model) <code>Document<code>.
 */
private void createDOM() {
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();

        //data is a Document
        Document data = builder.newDocument();
        Element root = data.createElement("measure");
        root.setAttribute("name", name);
        root.setAttribute("meanValue", "null");
        root.setAttribute("upperBound", "null");
        root.setAttribute("lowerBound", "null");
        root.setAttribute("progress", Double.toString(getSamplesAnalyzedPercentage()));
        root.setAttribute("data", "null");
        root.setAttribute("finished", "false");
        root.setAttribute("discarded", "0");
        root.setAttribute("precision", Double.toString(analyzer.getPrecision()));
        root.setAttribute("maxSamples", Double.toString(getMaxSamples()));
        data.appendChild(root);
    } catch (FactoryConfigurationError factoryConfigurationError) {
        factoryConfigurationError.printStackTrace();
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    }
}
项目:mytracks    文件:TrackWriterTest.java   
/**
 * Parses the given XML contents and returns a DOM {@link Document} for it.
 */
protected Document parseXmlDocument(String contents)
    throws FactoryConfigurationError, ParserConfigurationException,
        SAXException, IOException {
  DocumentBuilderFactory builderFactory =
      DocumentBuilderFactory.newInstance();
  builderFactory.setCoalescing(true);
  // TODO: Somehow do XML validation on Android
  // builderFactory.setValidating(true);
  builderFactory.setNamespaceAware(true);
  builderFactory.setIgnoringComments(true);
  builderFactory.setIgnoringElementContentWhitespace(true);
  DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder();
  Document doc = documentBuilder.parse(
      new InputSource(new StringReader(contents)));
  return doc;
}
项目:javify    文件:DomDocumentBuilderFactory.java   
public DomDocumentBuilderFactory()
{
  try
    {
      DOMImplementationRegistry reg =
        DOMImplementationRegistry.newInstance();
      impl = reg.getDOMImplementation("LS 3.0");
      if (impl == null)
        {
          throw new FactoryConfigurationError("no LS implementations found");
        }
      ls = (DOMImplementationLS) impl;
    }
  catch (Exception e)
    {
      throw new FactoryConfigurationError(e);
    }
}
项目:Smack    文件:PacketParserUtilsTest.java   
@Test
public void parseElementMultipleNamespace()
                throws ParserConfigurationException,
                FactoryConfigurationError, XmlPullParserException,
                IOException, TransformerException, SAXException {
    // @formatter:off
    final String stanza = XMLBuilder.create("outer", "outerNamespace").a("outerAttribute", "outerValue")
                    .element("inner", "innerNamespace").a("innverAttribute", "innerValue")
                        .element("innermost")
                            .t("some text")
                    .asString();
    // @formatter:on
    XmlPullParser parser = TestUtils.getParser(stanza, "outer");
    CharSequence result = PacketParserUtils.parseElement(parser, true);
    assertXMLEqual(stanza, result.toString());
}
项目:Smack    文件:PacketParserUtilsTest.java   
@Test
public void parseSASLFailureExtended() throws FactoryConfigurationError, TransformerException,
                ParserConfigurationException, XmlPullParserException, IOException, SAXException {
    // @formatter:off
    final String saslFailureString = XMLBuilder.create(SASLFailure.ELEMENT, SaslStreamElements.NAMESPACE)
                    .e(SASLError.account_disabled.toString())
                    .up()
                    .e("text").a("xml:lang", "en")
                        .t("Call 212-555-1212 for assistance.")
                    .up()
                    .e("text").a("xml:lang", "de")
                        .t("Bitte wenden sie sich an (04321) 123-4444")
                    .up()
                    .e("text")
                        .t("Wusel dusel")
                    .asString();
    // @formatter:on
    XmlPullParser parser = TestUtils.getParser(saslFailureString, SASLFailure.ELEMENT);
    SASLFailure saslFailure = PacketParserUtils.parseSASLFailure(parser);
    XmlUnitUtils.assertSimilar(saslFailureString, saslFailure.toXML());
}
项目:java-aci-api-ng    文件:DocumentProcessorTest.java   
@Test(expected = FactoryConfigurationError.class)
public void testConvertACIResponseToDOMInvalidDocumentBuilderFactory() throws AciErrorException, IOException, ProcessorException {
    // Set a duff property for the DocumentBuilderFactory...
    System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.autonomy.DuffDocumentBuilderFactory");

    try {
        // Setup with a proper XML response file...
        final BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.setEntity(new InputStreamEntity(getClass().getResourceAsStream("/GetVersion.xml"), -1));

        // Set the AciResponseInputStream...
        final AciResponseInputStream stream = new AciResponseInputStreamImpl(response);

        // Process...
        processor.process(stream);
        fail("Should have raised an ProcessorException.");
    } finally {
        // Remove the duff system property...
        System.clearProperty("javax.xml.parsers.DocumentBuilderFactory");
    }
}
项目:openxds    文件:Util.java   
public static OMElement parse_xml(InputStream is) throws FactoryConfigurationError, XdsInternalException {

        //      create the parser
        XMLStreamReader parser=null;

        try {
            parser = XMLInputFactory.newInstance().createXMLStreamReader(is);
        } catch (XMLStreamException e) {
            throw new XdsInternalException("Could not create XMLStreamReader from InputStream");
        } 

        //      create the builder
        StAXOMBuilder builder = new StAXOMBuilder(parser);

        //      get the root element (in this case the envelope)
        OMElement documentElement =  builder.getDocumentElement();  
        if (documentElement == null)
            throw new XdsInternalException("No document element");
        return documentElement;
    }
项目:cacheonix-core    文件:DOMConfigurator.java   
/**
   Configure log4j by reading in a log4j.dtd compliant XML
   configuration file.

*/
public
void doConfigure(final InputStream inputStream, LoggerRepository repository) 
                                        throws FactoryConfigurationError {
    ParseAction action = new ParseAction() {
        public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
            InputSource inputSource = new InputSource(inputStream);
            inputSource.setSystemId("dummy://log4j.dtd");
            return parser.parse(inputSource);
        }
        public String toString() { 
            return "input stream [" + inputStream.toString() + "]"; 
        }
    };
    doConfigure(action, repository);
}
项目:cacheonix-core    文件:DOMConfigurator.java   
/**
   Configure log4j by reading in a log4j.dtd compliant XML
   configuration file.

*/
public
void doConfigure(final Reader reader, LoggerRepository repository) 
                                        throws FactoryConfigurationError {
    ParseAction action = new ParseAction() {
        public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
            InputSource inputSource = new InputSource(reader);
            inputSource.setSystemId("dummy://log4j.dtd");
            return parser.parse(inputSource);
        }
        public String toString() { 
            return "reader [" + reader.toString() + "]"; 
        }
    };
  doConfigure(action, repository);
}
项目:cacheonix-core    文件:DOMConfigurator.java   
/**
   Configure log4j by reading in a log4j.dtd compliant XML
   configuration file.

*/
protected
void doConfigure(final InputSource inputSource, LoggerRepository repository) 
                                        throws FactoryConfigurationError {
    if (inputSource.getSystemId() == null) {
        inputSource.setSystemId("dummy://log4j.dtd");
    }
    ParseAction action = new ParseAction() {
        public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
            return parser.parse(inputSource);
        }
        public String toString() { 
            return "input source [" + inputSource.toString() + "]"; 
        }
    };
    doConfigure(action, repository);
  }
项目:cacheonix-core    文件:DOMConfigurator.java   
/**
 * Configure log4j by reading in a log4j.dtd compliant XML configuration file.
 */
public void doConfigure(final InputStream inputStream, final LoggerRepository repository)
        throws FactoryConfigurationError {

   final ParseAction action = new ParseAction() {

      public Document parse(final DocumentBuilder parser) throws SAXException, IOException {

         final InputSource inputSource = new InputSource(inputStream);
         inputSource.setSystemId("dummy://log4j.dtd");
         return parser.parse(inputSource);
      }


      public String toString() {

         //noinspection ObjectToString
         return "input stream [" + inputStream + ']';
      }
   };
   doConfigure(action, repository);
}
项目:cacheonix-core    文件:DOMConfigurator.java   
/**
 * Configure log4j by reading in a log4j.dtd compliant XML configuration file.
 */
public void doConfigure(final Reader reader, final LoggerRepository repository)
        throws FactoryConfigurationError {

   final ParseAction action = new ParseAction() {

      public Document parse(final DocumentBuilder parser) throws SAXException, IOException {

         final InputSource inputSource = new InputSource(reader);
         inputSource.setSystemId("dummy://log4j.dtd");
         return parser.parse(inputSource);
      }


      public String toString() {

         //noinspection ObjectToString
         return "reader [" + reader + ']';
      }
   };
   doConfigure(action, repository);
}
项目:cacheonix-core    文件:DOMConfigurator.java   
/**
 * Configure log4j by reading in a log4j.dtd compliant XML configuration file.
 */
private void doConfigure(final InputSource inputSource, final LoggerRepository repository)
        throws FactoryConfigurationError {

   if (inputSource.getSystemId() == null) {
      inputSource.setSystemId("dummy://log4j.dtd");
   }
   final ParseAction action = new ParseAction() {

      public Document parse(final DocumentBuilder parser) throws SAXException, IOException {

         return parser.parse(inputSource);
      }


      public String toString() {

         //noinspection ObjectToString
         return "input source [" + inputSource + ']';
      }
   };
   doConfigure(action, repository);
}
项目:jvm-stm    文件:DomDocumentBuilderFactory.java   
public DomDocumentBuilderFactory()
{
  try
    {
      DOMImplementationRegistry reg =
        DOMImplementationRegistry.newInstance();
      impl = reg.getDOMImplementation("LS 3.0");
      if (impl == null)
        {
          throw new FactoryConfigurationError("no LS implementations found");
        }
      ls = (DOMImplementationLS) impl;
    }
  catch (Exception e)
    {
      throw new FactoryConfigurationError(e);
    }
}
项目:scientific-publishing    文件:ArxivImporter.java   
@VisibleForTesting
List<Publication> extractPublications(InputStream inputStream, LocalDateTime lastImport, int total) throws FactoryConfigurationError {
    final List<Publication> publications = new ArrayList<>(total);
    final  SAXParserFactory parserFactory = SAXParserFactory.newInstance();
    parserFactory.setNamespaceAware(true);
    try {
        SAXParser parser = parserFactory.newSAXParser();
        parser.parse(inputStream, new ArxivSaxHandler(new PublicationCallbackHandler() {
            @Override
            public void onNewPublication(Publication publication) {
                publications.add(publication);
            }
        }, dao, lastImport));
    } catch (StopParsing ex) {
        logger.info("Stopped parsing because entries were before the last import date");
    } catch (SAXException | ParserConfigurationException | IOException e) {
        throw new IllegalStateException("Failed to parse input", e);
    }

    return publications;
}
项目:daq-eclipse    文件:DOMConfigurator.java   
/**
   Configure log4j by reading in a log4j.dtd compliant XML
   configuration file.

*/
public
void doConfigure(final InputStream inputStream, LoggerRepository repository) 
                                        throws FactoryConfigurationError {
    ParseAction action = new ParseAction() {
        public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
            InputSource inputSource = new InputSource(inputStream);
            inputSource.setSystemId("dummy://log4j.dtd");
            return parser.parse(inputSource);
        }
        public String toString() { 
            return "input stream [" + inputStream.toString() + "]"; 
        }
    };
    doConfigure(action, repository);
}
项目:daq-eclipse    文件:DOMConfigurator.java   
/**
   Configure log4j by reading in a log4j.dtd compliant XML
   configuration file.

*/
public
void doConfigure(final Reader reader, LoggerRepository repository) 
                                        throws FactoryConfigurationError {
    ParseAction action = new ParseAction() {
        public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
            InputSource inputSource = new InputSource(reader);
            inputSource.setSystemId("dummy://log4j.dtd");
            return parser.parse(inputSource);
        }
        public String toString() { 
            return "reader [" + reader.toString() + "]"; 
        }
    };
  doConfigure(action, repository);
}
项目:daq-eclipse    文件:DOMConfigurator.java   
/**
   Configure log4j by reading in a log4j.dtd compliant XML
   configuration file.

*/
protected
void doConfigure(final InputSource inputSource, LoggerRepository repository) 
                                        throws FactoryConfigurationError {
    if (inputSource.getSystemId() == null) {
        inputSource.setSystemId("dummy://log4j.dtd");
    }
    ParseAction action = new ParseAction() {
        public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
            return parser.parse(inputSource);
        }
        public String toString() { 
            return "input source [" + inputSource.toString() + "]"; 
        }
    };
    doConfigure(action, repository);
  }
项目:settings4j    文件:SettingsManager.java   
private static void initializeRepository(final String configurationFile) throws FactoryConfigurationError {
    LOG.debug("Using URL [{}] for automatic settings4j configuration.", configurationFile);

    final URL url = ClasspathContentResolver.getResource(configurationFile);

    // If we have a non-null url, then delegate the rest of the
    // configuration to the DOMConfigurator.configure method.
    if (url != null) {
        LOG.info("The settings4j will be configured with the config: {}", url);
        try {
            DOMConfigurator.configure(url, getSettingsRepository());
        } catch (final NoClassDefFoundError e) {
            LOG.warn("Error during initialization {}", configurationFile, e);
        }
    } else {
        if (SettingsManager.DEFAULT_FALLBACK_CONFIGURATION_FILE.equals(configurationFile)) {
            LOG.error("Could not find resource: [{}].", configurationFile);
        } else {
            LOG.debug("Could not find resource: [{}]. Use default fallback.", configurationFile);
        }
    }
}
项目:cxf-plus    文件:JAXBContextImpl.java   
/**
 * Creates a new DOM document.
 */
static Document createDom() {
    synchronized(JAXBContextImpl.class) {
        if(db==null) {
            try {
                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                dbf.setNamespaceAware(true);
                db = dbf.newDocumentBuilder();
            } catch (ParserConfigurationException e) {
                // impossible
                throw new FactoryConfigurationError(e);
            }
        }
        return db.newDocument();
    }
}
项目:In-the-Box-Fork    文件:FactoryConfigurationErrorTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getMessage",
    args = {}
)
public void test_getMessage() {
    assertNull(new FactoryConfigurationError().getMessage());
    assertEquals("msg1",
            new FactoryConfigurationError("msg1").getMessage());
    assertEquals(new Exception("msg2").toString(),
            new FactoryConfigurationError(
                    new Exception("msg2")).getMessage());
    assertEquals(new NullPointerException().toString(),
            new FactoryConfigurationError(
                    new NullPointerException()).getMessage());
}
项目:nabs    文件:DOMConfigurator.java   
/**
   Configure log4j by reading in a log4j.dtd compliant XML
   configuration file.

*/
public
void doConfigure(final InputStream inputStream, LoggerRepository repository) 
                                        throws FactoryConfigurationError {
    ParseAction action = new ParseAction() {
        public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
            InputSource inputSource = new InputSource(inputStream);
            inputSource.setSystemId("dummy://log4j.dtd");
            return parser.parse(inputSource);
        }
        public String toString() { 
            return "input stream [" + inputStream.toString() + "]"; 
        }
    };
    doConfigure(action, repository);
}
项目:nabs    文件:DOMConfigurator.java   
/**
   Configure log4j by reading in a log4j.dtd compliant XML
   configuration file.

*/
public
void doConfigure(final Reader reader, LoggerRepository repository) 
                                        throws FactoryConfigurationError {
    ParseAction action = new ParseAction() {
        public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
            InputSource inputSource = new InputSource(reader);
            inputSource.setSystemId("dummy://log4j.dtd");
            return parser.parse(inputSource);
        }
        public String toString() { 
            return "reader [" + reader.toString() + "]"; 
        }
    };
  doConfigure(action, repository);
}
项目:nabs    文件:DOMConfigurator.java   
/**
   Configure log4j by reading in a log4j.dtd compliant XML
   configuration file.

*/
protected
void doConfigure(final InputSource inputSource, LoggerRepository repository) 
                                        throws FactoryConfigurationError {
    if (inputSource.getSystemId() == null) {
        inputSource.setSystemId("dummy://log4j.dtd");
    }
    ParseAction action = new ParseAction() {
        public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
            return parser.parse(inputSource);
        }
        public String toString() { 
            return "input source [" + inputSource.toString() + "]"; 
        }
    };
    doConfigure(action, repository);
  }
项目:AugmentedOxford    文件:GeoUtils.java   
@Deprecated
private Document getDocumentFromUrl(String url) throws IOException,
        MalformedURLException, ProtocolException,
        FactoryConfigurationError, ParserConfigurationException,
        SAXException {
    HttpURLConnection urlConnection = (HttpURLConnection) new URL(url)
            .openConnection();
    urlConnection.setRequestMethod("GET");
    urlConnection.setDoOutput(true);
    urlConnection.setDoInput(true);
    urlConnection.connect();

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    // get the kml file. And parse it to get the coordinates(direction
    // route):
    Document doc = db.parse(urlConnection.getInputStream());
    return doc;
}
项目:JamVM-PH    文件:DomDocumentBuilderFactory.java   
public DomDocumentBuilderFactory()
{
  try
    {
      DOMImplementationRegistry reg =
        DOMImplementationRegistry.newInstance();
      impl = reg.getDOMImplementation("LS 3.0");
      if (impl == null)
        {
          throw new FactoryConfigurationError("no LS implementations found");
        }
      ls = (DOMImplementationLS) impl;
    }
  catch (Exception e)
    {
      throw new FactoryConfigurationError(e);
    }
}
项目:jets3t-aws-roles    文件:GSAccessControlList.java   
@Override
public XMLBuilder toXMLBuilder() throws ServiceException, ParserConfigurationException,
    FactoryConfigurationError, TransformerException
{
    XMLBuilder builder = XMLBuilder.create("AccessControlList");

    // Owner
    if (owner != null) {
        XMLBuilder ownerBuilder = builder.elem("Owner");
        ownerBuilder.elem("ID").text(owner.getId()).up();
        if (owner.getDisplayName() != null) {
            ownerBuilder.elem("Name").text(owner.getDisplayName());
        }
    }

    XMLBuilder accessControlList = builder.elem("Entries");
    for (GrantAndPermission gap: grants) {
        GranteeInterface grantee = gap.getGrantee();
        Permission permission = gap.getPermission();
        accessControlList
            .elem("Entry")
                .importXMLBuilder(grantee.toXMLBuilder())
                .elem("Permission").text(permission.toString());
    }
    return builder;
}
项目:jets3t-aws-roles    文件:AccessControlList.java   
public XMLBuilder toXMLBuilder() throws ServiceException, ParserConfigurationException,
    FactoryConfigurationError, TransformerException
{
    if (owner == null) {
        throw new ServiceException("Invalid AccessControlList: missing an owner");
    }
    XMLBuilder builder = XMLBuilder.create("AccessControlPolicy")
        .attr("xmlns", Constants.XML_NAMESPACE)
        .elem("Owner")
            .elem("ID").text(owner.getId()).up()
            .elem("DisplayName").text(owner.getDisplayName()).up()
        .up();

    XMLBuilder accessControlList = builder.elem("AccessControlList");
    for (GrantAndPermission gap: grants) {
        GranteeInterface grantee = gap.getGrantee();
        Permission permission = gap.getPermission();
        accessControlList
            .elem("Grant")
                .importXMLBuilder(grantee.toXMLBuilder())
                .elem("Permission").text(permission.toString());
    }
    return builder;
}
项目:jets3t-aws-roles    文件:S3BucketLoggingStatus.java   
public XMLBuilder toXMLBuilder() throws ParserConfigurationException,
    FactoryConfigurationError, TransformerException
{
    XMLBuilder builder = XMLBuilder.create("BucketLoggingStatus")
        .attr("xmlns", Constants.XML_NAMESPACE);

    if (isLoggingEnabled()) {
        XMLBuilder enabledBuilder = builder.elem("LoggingEnabled")
            .elem("TargetBucket").text(getTargetBucketName()).up()
            .elem("TargetPrefix").text(getLogfilePrefix()).up();
        if (targetGrantsList.size() > 0) {
            Iterator<GrantAndPermission> targetGrantsIter = targetGrantsList.iterator();
            XMLBuilder grantsBuilder = enabledBuilder.elem("TargetGrants");
            while (targetGrantsIter.hasNext()) {
                GrantAndPermission gap = targetGrantsIter.next();
                grantsBuilder.elem("Grant")
                    .importXMLBuilder(gap.getGrantee().toXMLBuilder())
                    .elem("Permission").text(gap.getPermission().toString());
            }
        }
    }
    return builder;
}
项目:bazel    文件:DensitySpecificManifestProcessor.java   
private static DocumentBuilder getSecureDocumentBuilder() throws ParserConfigurationException {
  DocumentBuilderFactory factory =
      DocumentBuilderFactory.newInstance(
          "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl", null);
  factory.setValidating(false);
  factory.setXIncludeAware(false);
  for (Map.Entry<String, Boolean> featureAndValue : SECURE_XML_FEATURES.entrySet()) {
    try {
      factory.setFeature(featureAndValue.getKey(), featureAndValue.getValue());
    } catch (ParserConfigurationException e) {
      throw new FactoryConfigurationError(
          e,
          "Xerces DocumentBuilderFactory doesn't support the required security features: "
              + e.getMessage());
    }
  }
  return factory.newDocumentBuilder();
}
项目:incubator-blur    文件:TableAdmin.java   
private void reloadConfig() throws MalformedURLException, FactoryConfigurationError, BException {
  String blurHome = System.getenv("BLUR_HOME");
  if (blurHome != null) {
    File blurHomeFile = new File(blurHome);
    if (blurHomeFile.exists()) {
      File log4jFile = new File(new File(blurHomeFile, "conf"), "log4j.xml");
      if (log4jFile.exists()) {
        LOG.info("Reseting log4j config from [{0}]", log4jFile);
        LogManager.resetConfiguration();
        DOMConfigurator.configure(log4jFile.toURI().toURL());
        return;
      }
    }
  }
  URL url = TableAdmin.class.getResource("/log4j.xml");
  if (url != null) {
    LOG.info("Reseting log4j config from classpath resource [{0}]", url);
    LogManager.resetConfiguration();
    DOMConfigurator.configure(url);
    return;
  }
  throw new BException("Could not locate log4j file to reload, doing nothing.");
}
项目:birt    文件:FontConfigReaderTest.java   
public void testFontMapWhenAllFontsDefined( ) throws IOException,
        FactoryConfigurationError, ParserConfigurationException,
        SAXException
{
    fontMappingManager = getFontMappingManager( "fontsConfig1.xml" );

    // alias defined, composite font defined, block defined, and character
    // is defined by the block font.
    assertTrue( isMappedTo( '1', "alias1", "Courier" ) );
    // alias defined, composite font not defined, and character
    // is defined by the logical font.
    assertTrue( isMappedTo( '1', "alias2", "Helvetica" ) );

    // alias not defined, composite font defined, and character
    // is defined by the block font.
    assertTrue( isMappedTo( '1', "Symbol", "Courier" ) );
    // alias not defined, composite font not defined, and character
    // is defined by the logical font.
    assertTrue( isMappedTo( '1', "Helvetica", "Helvetica" ) );

    // alias: defined; composite-font: defined; block: defined;
    assertTrue( isMappedTo( (char) 0xe81, "Symbol", "Courier" ) );
    // alias: defined; composite-font: defined; block: not defined;
    // all-fonts:not define the block
    assertTrue( isMappedTo( (char) 0xff01, "Symbol", "Times Roman" ) );
}
项目:birt    文件:FontConfigReaderTest.java   
public void testFontConfigParser( ) throws IOException,
        FactoryConfigurationError, ParserConfigurationException,
        SAXException
{
    fontMappingManager = getFontMappingManager( "fontsConfigParser.xml" );
    Map fontAliases = fontMappingManager.getFontAliases( );
    assertEquals( 1, fontAliases.size( ) );
    assertEquals( "Times-Roman", fontAliases.get( "test alias" ) );

    Map compositeFonts = fontMappingManager.getCompositeFonts( );
    assertEquals( 1, compositeFonts.size( ) );
    CompositeFont testFont = (CompositeFont) compositeFonts
            .get( "test font" );
    assertEquals( "Symbol", testFont.getUsedFont( (char) 0 ) );
    assertEquals( "Symbol", testFont.getUsedFont( (char) 0x7F ) );
    assertEquals( "Helvetica", testFont.getDefaultFont( ) );
}
项目:mulgara    文件:TqlSession.java   
/**
 * Loads the embedded logging configuration (from the JAR file).
 */
private void loadLoggingConfig() {
  // get a URL from the classloader for the logging configuration
  URL log4jConfigUrl = ClassLoader.getSystemResource(LOG4J_CONFIG_PATH);

  // if we didn't get a URL, tell the user that something went wrong
  if (log4jConfigUrl == null) {
    System.err.println("Unable to find logging configuration file in JAR " +
        "with " + LOG4J_CONFIG_PATH + ", reverting to default configuration.");
    BasicConfigurator.configure();
  } else {
    try {
      // configure the logging service
      DOMConfigurator.configure(log4jConfigUrl);
      log.info("Using logging configuration from " + log4jConfigUrl);
    } catch (FactoryConfigurationError e) {
      System.err.println("Unable to configure logging service");
    }
  }
}
项目:java-xmlbuilder    文件:BaseXMLBuilder.java   
/**
 * Construct an XML Document with a default namespace with the given
 * root element.
 *
 * @param name
 * the name of the document's root element.
 * @param namespaceURI
 * default namespace URI for document, ignored if null or empty.
 * @param enableExternalEntities
 * enable external entities; beware of XML External Entity (XXE) injection.
 * @param isNamespaceAware
 * enable or disable namespace awareness in the underlying
 * {@link DocumentBuilderFactory}
 * @return
 * an XML Document.
 *
 * @throws FactoryConfigurationError
 * @throws ParserConfigurationException
 */
protected static Document createDocumentImpl(
    String name, String namespaceURI, boolean enableExternalEntities,
    boolean isNamespaceAware)
    throws ParserConfigurationException, FactoryConfigurationError
{
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(isNamespaceAware);
    enableOrDisableExternalEntityParsing(factory, enableExternalEntities);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.newDocument();
    Element rootElement = null;
    if (namespaceURI != null && namespaceURI.length() > 0) {
        rootElement = document.createElementNS(namespaceURI, name);
    } else {
        rootElement = document.createElement(name);
    }
    document.appendChild(rootElement);
    return document;
}
项目:spring-rich-client    文件:XmlSettingsTests.java   
public void testSave() throws ParserConfigurationException, FactoryConfigurationError, IOException {
    Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    Element parentElement = doc.createElement("settings");
    parentElement.setAttribute("name", "parent-settings");
    doc.appendChild(parentElement);
    Element childElement = doc.createElement("settings");
    childElement.setAttribute("name", "child-settings");
    parentElement.appendChild(childElement);

    TestableXmlSettingsReaderWriter readerWriter = new TestableXmlSettingsReaderWriter();
    RootXmlSettings parentSettings = new RootXmlSettings(doc, readerWriter);
    Settings childSettings = parentSettings.getSettings("child-settings");
    childSettings.save();

    assertEquals(parentSettings, readerWriter.lastWritten);
}
项目:spring-rich-client    文件:XmlSettingsTests.java   
public void testChildSettings() throws ParserConfigurationException, FactoryConfigurationError, SAXException, IOException {
    StringBuffer sb = new StringBuffer();
    sb.append("<?xml version=\"1.0\"?>");
    sb.append("<settings name=\"test-settings\">");
    sb.append("  <entry key=\"key-1\" value=\"value-1\" />");
    sb.append("  <entry key=\"key-2\" value=\"false\" />");
    sb.append("  <entry key=\"key-3\" value=\"1.5\" />");
    sb.append("  <settings name=\"child-settings\">");
    sb.append("    <entry key=\"child-key\" value=\"value\" />");
    sb.append("  </settings>");
    sb.append("</settings>");

    XmlSettings settings = new XmlSettings(createElement(sb.toString()));

    assertEquals(Arrays.asList(new String[] {"child-settings"}), Arrays.asList(settings.getChildSettings()));
}
项目:classpath    文件:DomDocumentBuilderFactory.java   
public DomDocumentBuilderFactory()
{
  try
    {
      DOMImplementationRegistry reg =
        DOMImplementationRegistry.newInstance();
      impl = reg.getDOMImplementation("LS 3.0");
      if (impl == null)
        {
          throw new FactoryConfigurationError("no LS implementations found");
        }
      ls = (DOMImplementationLS) impl;
    }
  catch (Exception e)
    {
      throw new FactoryConfigurationError(e);
    }
}