当前位置: 首页>>代码示例>>Java>>正文


Java ParserConfigurationException类代码示例

本文整理汇总了Java中javax.xml.parsers.ParserConfigurationException的典型用法代码示例。如果您正苦于以下问题:Java ParserConfigurationException类的具体用法?Java ParserConfigurationException怎么用?Java ParserConfigurationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ParserConfigurationException类属于javax.xml.parsers包,在下文中一共展示了ParserConfigurationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureOldXerces

import javax.xml.parsers.ParserConfigurationException; //导入依赖的package包/类
/**
 * Configure schema validation as recommended by the JAXP 1.2 spec.
 * The <code>properties</code> object may contains information about
 * the schema local and language. 
 * @param properties parser optional info
 */
private static void configureOldXerces(SAXParser parser, 
                                       Properties properties) 
        throws ParserConfigurationException, 
               SAXNotSupportedException {

    String schemaLocation = (String)properties.get("schemaLocation");
    String schemaLanguage = (String)properties.get("schemaLanguage");

    try{
        if (schemaLocation != null) {
            parser.setProperty(JAXP_SCHEMA_LANGUAGE, schemaLanguage);
            parser.setProperty(JAXP_SCHEMA_SOURCE, schemaLocation);
        }
    } catch (SAXNotRecognizedException e){
        log.info(parser.getClass().getName() + ": " 
                                    + e.getMessage() + " not supported."); 
    }

}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:26,代码来源:XercesParser.java

示例2: getSessionId

import javax.xml.parsers.ParserConfigurationException; //导入依赖的package包/类
private String getSessionId() throws IOException, ParserConfigurationException, SAXException, NoSuchAlgorithmException {

    HttpURLConnection con = createConnection(SID_REQUEST_URL);

    handleResponseCode(con.getResponseCode());

    Document doc = xmlFactory.newDocumentBuilder().parse(con.getInputStream());
    logger.trace("response:\n{}", XmlUtils.docToString(doc, true));
    if (doc == null) {
      throw new IOException("SessionInfo element not available");
    }
    String sid = XmlUtils.getValue(doc.getDocumentElement(), "SID");

    if (EMPTY_SID.equals(sid)) {
      String challenge = XmlUtils.getValue(doc.getDocumentElement(), "Challenge");
      sid = getSessionId(challenge);
    }

    if (sid == null || EMPTY_SID.equals(sid)) {
      throw new IOException("sid request failed: " + sid);
    }
    return sid;

  }
 
开发者ID:comtel2000,项目名称:fritz-home-skill,代码行数:25,代码来源:SwitchService.java

示例3: compareDocumentWithGold

import javax.xml.parsers.ParserConfigurationException; //导入依赖的package包/类
/**
 * Compare contents of golden file with test output file by their document
 * representation.
 * Here we ignore the white space and comments. return true if they're
 * lexical identical.
 * @param goldfile Golden output file name.
 * @param resultFile Test output file name.
 * @return true if two file's document representation are identical.
 *         false if two file's document representation are not identical.
 * @throws javax.xml.parsers.ParserConfigurationException if the
 *         implementation is not available or cannot be instantiated.
 * @throws SAXException If any parse errors occur.
 * @throws IOException if an I/O error occurs reading from the file or a
 *         malformed or unmappable byte sequence is read .
 */
public static boolean compareDocumentWithGold(String goldfile, String resultFile)
        throws ParserConfigurationException, SAXException, IOException {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    factory.setCoalescing(true);
    factory.setIgnoringElementContentWhitespace(true);
    factory.setIgnoringComments(true);
    DocumentBuilder db = factory.newDocumentBuilder();

    Document goldD = db.parse(Paths.get(goldfile).toFile());
    goldD.normalizeDocument();
    Document resultD = db.parse(Paths.get(resultFile).toFile());
    resultD.normalizeDocument();
    return goldD.isEqualNode(resultD);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:JAXPTestUtilities.java

示例4: PomModifier

import javax.xml.parsers.ParserConfigurationException; //导入依赖的package包/类
public PomModifier(final Path projectDirectory, final Path gitDirectory) {
	if (builderFactory == null) {
		builderFactory = DocumentBuilderFactory.newInstance();
		transformerFactory = TransformerFactory.newInstance();
		try {
			builder = builderFactory.newDocumentBuilder();
			transformer = transformerFactory.newTransformer();
			transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
			transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
			transformer.setOutputProperty(OutputKeys.INDENT, "yes");
			transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
		} catch (ParserConfigurationException | TransformerConfigurationException e) {
			throw new IllegalStateException(e);
		}
	}
	this.projectPomFile = gitDirectory.resolve("pom.xml");
	this.projectDirectory = projectDirectory;
	this.gitDirectory = gitDirectory;
}
 
开发者ID:xtf-cz,项目名称:xtf,代码行数:20,代码来源:PomModifier.java

示例5: PepXMLParser

import javax.xml.parsers.ParserConfigurationException; //导入依赖的package包/类
public PepXMLParser(LCMSID singleLCMSID, String FileName, float threshold, boolean CorrectMassDiff) throws ParserConfigurationException, SAXException, IOException, XmlPullParserException {
    this.singleLCMSID = singleLCMSID;
    this.CorrectMassDiff = CorrectMassDiff;
    this.FileName = FileName;
    this.threshold = threshold;
    Logger.getRootLogger().info("Parsing pepXML: " + FileName + "....");
    try {
        ParseSAX();
    } catch (Exception e) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(e));
        Logger.getRootLogger().info("Parsing pepXML: " + FileName + " failed. Trying to fix the file...");
        insert_msms_run_summary(new File(FileName));
        ParseSAX();
    }
    //System.out.print("done\n");
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:17,代码来源:PepXMLParser.java

示例6: saveUserDefinedProperties

import javax.xml.parsers.ParserConfigurationException; //导入依赖的package包/类
public static void saveUserDefinedProperties() throws XMLException {
    Document doc;
    try {
        doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    } catch (ParserConfigurationException var4) {
        throw new XMLException("Failed to create document: " + var4, var4);
    }

    Element root = doc.createElement("drivers");
    doc.appendChild(root);
    Iterator var2 = getJDBCProperties().iterator();

    while(var2.hasNext()) {
        JDBCProperties props = (JDBCProperties)var2.next();
        if(props.isUserDefined()) {
            root.appendChild(props.getXML(doc));
        }
    }

    XMLTools.stream(doc, getUserJDBCPropertiesFile(), StandardCharsets.UTF_8);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:22,代码来源:DatabaseService.java

示例7: parse

import javax.xml.parsers.ParserConfigurationException; //导入依赖的package包/类
public static void parse(
        URL xmlURL, URL schema, DefaultHandler handler)
        throws SAXException, IOException, ParserConfigurationException {
    InputStream xmlStream = URLHandlerRegistry.getDefault().openStream(xmlURL);
    try {
        InputSource inSrc = new InputSource(xmlStream);
        inSrc.setSystemId(xmlURL.toExternalForm());
        parse(inSrc, schema, handler);
    } finally {
        try {
            xmlStream.close();
        } catch (IOException e) {
            // ignored
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:IvyXmlModuleDescriptorParser.java

示例8: start

import javax.xml.parsers.ParserConfigurationException; //导入依赖的package包/类
/**
    * Starts preview lesson on LAMS server. Launches it.
    */
   private void start(HttpServletRequest request, HttpServletResponse response, Context ctx) throws IOException, ServletException, PersistenceException, ParseException, ValidationException, ParserConfigurationException, SAXException {

   	BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager();

//store newly created LAMS lesson
User user = ctx.getUser();
BlackboardUtil.storeBlackboardContent(request, response, user);

// constuct strReturnUrl
String courseIdStr = request.getParameter("course_id");
String contentIdStr = request.getParameter("content_id");
// internal Blackboard IDs for the course and parent content item
Id courseId = bbPm.generateId(Course.DATA_TYPE, courseIdStr);
Id folderId = bbPm.generateId(CourseDocument.DATA_TYPE, contentIdStr);
String returnUrl = PlugInUtil.getEditableContentReturnURL(folderId, courseId);
request.setAttribute("returnUrl", returnUrl);

request.getRequestDispatcher("/modules/startLessonSuccess.jsp").forward(request, response);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:LessonManagerServlet.java

示例9: parseMavenMetadataInto

import javax.xml.parsers.ParserConfigurationException; //导入依赖的package包/类
private void parseMavenMetadataInto(ExternalResource metadataResource, final MavenMetadata mavenMetadata) {
    LOGGER.debug("parsing maven-metadata: {}", metadataResource);
    metadataResource.withContent(new ErroringAction<InputStream>() {
        public void doExecute(InputStream inputStream) throws ParserConfigurationException, SAXException, IOException {
            XMLHelper.parse(inputStream, null, new ContextualSAXHandler() {
                public void endElement(String uri, String localName, String qName)
                        throws SAXException {
                    if ("metadata/versioning/snapshot/timestamp".equals(getContext())) {
                        mavenMetadata.timestamp = getText();
                    }
                    if ("metadata/versioning/snapshot/buildNumber".equals(getContext())) {
                        mavenMetadata.buildNumber = getText();
                    }
                    if ("metadata/versioning/versions/version".equals(getContext())) {
                        mavenMetadata.versions.add(getText().trim());
                    }
                    super.endElement(uri, localName, qName);
                }
            }, null);
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:23,代码来源:MavenMetadataLoader.java

示例10: buildDOMderivation

import javax.xml.parsers.ParserConfigurationException; //导入依赖的package包/类
public static Document buildDOMderivation(ArrayList<ParseTreeCollection> all, String sentence) {
	try {
		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		DocumentBuilder constructor    = factory.newDocumentBuilder();
		derivDoc                       = constructor.newDocument();
		derivDoc.setXmlVersion("1.0");
		derivDoc.setXmlStandalone(false);
		
		Element root = derivDoc.createElement("parses");
		root.setAttribute("sentence", sentence);
           for (ParseTreeCollection ptc : all)
           {
           	buildOne(root, ptc.getDerivationTree().getDomNodes().get(0), ptc.getDerivedTree().getDomNodes().get(0), ptc.getSemantics(), ptc.getSpecifiedSemantics());
           }
		// finally we do not forget the root
		derivDoc.appendChild(root);
		return derivDoc;
		
	} catch (ParserConfigurationException e) {
		System.err.println(e);
		return null;
	}		
}
 
开发者ID:spetitjean,项目名称:TuLiPA-frames,代码行数:24,代码来源:DOMderivationBuilder.java

示例11: createDOM

import javax.xml.parsers.ParserConfigurationException; //导入依赖的package包/类
/**
 * 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();
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:29,代码来源:Measure.java

示例12: saveOperatorDocBundle

import javax.xml.parsers.ParserConfigurationException; //导入依赖的package包/类
private static void saveOperatorDocBundle(File file) {
    try {
        Document document = DocumentBuilderFactory
                .newInstance()
                .newDocumentBuilder()
                .newDocument();

        document.setXmlVersion("1.0");
        document.setXmlStandalone(false);
        Attr attr = document.createAttribute("encoding");
        attr.setValue("UTF-8");

        Element operatorHelp = document.createElement("operatorHelp");
        for (OperatorDescription deac: getAllUserDefinedOperators()) {
            addOperatorDoc(document, operatorHelp, deac.getName(), deac.getKey());
        }
        document.appendChild(operatorHelp);

        XMLTools.stream(document, file, Charset.forName("UTF-8"));
    } catch (ParserConfigurationException | XMLException e) {
        SwingTools.showSimpleErrorMessage(ioErrorKey, e);
    }
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:24,代码来源:UserDefinedOperatorService.java

示例13: processFile

import javax.xml.parsers.ParserConfigurationException; //导入依赖的package包/类
/**
 * Process the xmlfile named <code>fileName</code> with the given system
 * ID.
 * 
 * @param fileName
 *          meta data file name.
 * @param systemId
 *          system ID.
 */
protected void processFile(String fileName, String systemId)
    throws ValidationException, ParserConfigurationException,
        SAXException, IOException, SchedulerException,
        ClassNotFoundException, ParseException, XPathException {

    prepForProcessing();
    
    log.info("Parsing XML file: " + fileName + 
            " with systemId: " + systemId);
    InputSource is = new InputSource(getInputStream(fileName));
    is.setSystemId(systemId);
    
    process(is);
    
    maybeThrowValidationException();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:XMLSchedulingDataProcessor.java

示例14: get_node_list

import javax.xml.parsers.ParserConfigurationException; //导入依赖的package包/类
private static NodeList get_node_list(List<String> xml_lines, String addition) {
    StringBuilder sb = new StringBuilder();

    for(String line : xml_lines) { sb.append(line); }
    String xml_string = sb.toString();

    try {
        DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        InputSource is = new InputSource();
        is.setCharacterStream(new StringReader(xml_string));

        Document doc = db.parse(is);

        if(!addition.equals("")) {
            addition = addition + ":";
        }
        return doc.getElementsByTagName(addition + "infoTable");

    } catch (ParserConfigurationException | IOException | SAXException e) {
        e.printStackTrace();
    }

    return null;
}
 
开发者ID:bws0013,项目名称:read_13f,代码行数:25,代码来源:file_processor_new.java

示例15: migrateBillingResultXml

import javax.xml.parsers.ParserConfigurationException; //导入依赖的package包/类
protected String migrateBillingResultXml(String billingXml)
        throws ParserConfigurationException, SAXException, IOException,
        XPathExpressionException, TransformerException {

    // create a document from the xml file
    Document document = XMLConverter.convertToDocument(billingXml, false);

    // iterate over all stepped prices elements, if any
    NodeList steppedPrices = XMLConverter.getNodeListByXPath(document,
            XPATH_STEPPEDPRICES);
    for (int i = 0; i < steppedPrices.getLength(); i++) {
        Node steppedPricesElement = steppedPrices.item(i);

        // proceed only if amount attribute is not present
        if (!isAmountAttributeAlreadyPresent(steppedPricesElement)) {
            long value = getValue(steppedPricesElement);
            StepData relevantStep = getStepData(steppedPricesElement, value);
            BigDecimal price = calculateStepPrice(relevantStep);
            createAttribute(steppedPricesElement, price);
        }
    }

    return XMLConverter.convertToString(document, false);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:25,代码来源:MigrationBillingResultSteppedPrices.java


注:本文中的javax.xml.parsers.ParserConfigurationException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。