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


Java TransformerConfigurationException类代码示例

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


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

示例1: createTransformerFactory

import javax.xml.transform.TransformerConfigurationException; //导入依赖的package包/类
/**
 * Returns properly configured (e.g. security features) factory
 * - securityProcessing == is set based on security processing property, default is true
 */
public static TransformerFactory createTransformerFactory(boolean disableSecureProcessing) throws IllegalStateException {
    try {
        TransformerFactory factory = TransformerFactory.newInstance();
        if (LOGGER.isLoggable(Level.FINE)) {
            LOGGER.log(Level.FINE, "TransformerFactory instance: {0}", factory);
        }
        factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !isXMLSecurityDisabled(disableSecureProcessing));
        return factory;
    } catch (TransformerConfigurationException ex) {
        LOGGER.log(Level.SEVERE, null, ex);
        throw new IllegalStateException( ex);
    } catch (AbstractMethodError er) {
        LOGGER.log(Level.SEVERE, null, er);
        throw new IllegalStateException(Messages.INVALID_JAXP_IMPLEMENTATION.format(), er);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:XmlFactory.java

示例2: xsltprocess

import javax.xml.transform.TransformerConfigurationException; //导入依赖的package包/类
public void xsltprocess(String[] args) throws TransformerException, TransformerConfigurationException, FileNotFoundException, IOException {
    // 1. Instantiate a TransformerFactory.
    SAXTransformerFactory tFactory = (SAXTransformerFactory) TransformerFactory.newInstance();
    
    // 2. Use the TransformerFactory to process the stylesheet Source and
    //    generate a Transformer.
    InputStream is = getClass().getResourceAsStream("xmg2pol.xsl");
    Transformer transformer = tFactory.newTransformer (new StreamSource(is));
    transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "polarities.dtd,xml");
    transformer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
    
    // 3. Use the Transformer to transform an XML Source and send the
    //    output to a Result object.
    try {
	    String input = args[0];
	    String output= args[1];
	    SAXSource saxs = new SAXSource(new InputSource(input));
		XMLReader saxReader = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
		saxReader.setEntityResolver(new MyEntityResolver());
		saxs.setXMLReader(saxReader);
	    transformer.transform(saxs, new StreamResult(new OutputStreamWriter(new FileOutputStream(output), "utf-8")));
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
}
 
开发者ID:spetitjean,项目名称:TuLiPA-frames,代码行数:26,代码来源:TransformPolarity.java

示例3: getTransformerHandler

import javax.xml.transform.TransformerConfigurationException; //导入依赖的package包/类
@Override
protected TransformerHandler getTransformerHandler(String xslFileName) throws SAXException, ParserConfigurationException,
        TransformerConfigurationException, IOException {
    SAXTransformerFactory factory = (SAXTransformerFactory) TransformerFactory.newInstance();
    factory.setURIResolver(uriResolver);

    TemplatesHandler templatesHandler = factory.newTemplatesHandler();

    SAXParserFactory pFactory = SAXParserFactory.newInstance();
    pFactory.setNamespaceAware(true);

    XMLReader xmlreader = pFactory.newSAXParser().getXMLReader();

    // create the stylesheet input source
    InputSource xslSrc = new InputSource(xslFileName);

    xslSrc.setSystemId(filenameToURL(xslFileName));
    // hook up the templates handler as the xsl content handler
    xmlreader.setContentHandler(templatesHandler);
    // call parse on the xsl input source

    xmlreader.parse(xslSrc);

    // extract the Templates object created from the xsl input source
    return factory.newTransformerHandler(templatesHandler.getTemplates());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:TemplatesFilterFactoryImpl.java

示例4: getSerializer

import javax.xml.transform.TransformerConfigurationException; //导入依赖的package包/类
@Override
public TransformerHandler getSerializer()
{
	try
	{
		SAXTransformerFactory transformerFactory = buildTransformerFactory();
		configure(transformerFactory);
		TransformerHandler transformer = buildTransformer(transformerFactory);
		configure(transformer.getTransformer());
		return transformer;
	}
	catch (TransformerConfigurationException ex)
	{
		throw new FluentXmlConfigurationException(ex);
	}
}
 
开发者ID:fluentxml4j,项目名称:fluentxml4j,代码行数:17,代码来源:SerializerConfigurerAdapter.java

示例5: buildSingleTransformerPipeline

import javax.xml.transform.TransformerConfigurationException; //导入依赖的package包/类
private Result buildSingleTransformerPipeline(Result result)
{
	try
	{
		SAXTransformerFactory saxTransformerFactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
		TransformerHandler transformerHandler = saxTransformerFactory.newTransformerHandler();
		if (result != null)
		{
			transformerHandler.setResult(result);
		}
		return new SAXResult(transformerHandler);
	}
	catch (TransformerConfigurationException ex)
	{
		throw new FluentXmlConfigurationException(ex);
	}
}
 
开发者ID:fluentxml4j,项目名称:fluentxml4j,代码行数:18,代码来源:TransformationChain.java

示例6: toSAXResult

import javax.xml.transform.TransformerConfigurationException; //导入依赖的package包/类
private SAXResult toSAXResult(Result result)
{
	if (result instanceof SAXResult)
	{
		return (SAXResult) result;
	}

	try
	{
		SAXTransformerFactory transformerFactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
		TransformerHandler transformerHandler = transformerFactory.newTransformerHandler();
		transformerHandler.setResult(result);
		return new SAXResult(transformerHandler);
	}
	catch (TransformerConfigurationException ex)
	{
		throw new FluentXmlConfigurationException(ex);
	}
}
 
开发者ID:fluentxml4j,项目名称:fluentxml4j,代码行数:20,代码来源:AbstractSAXFilter.java

示例7: SchemaToXML

import javax.xml.transform.TransformerConfigurationException; //导入依赖的package包/类
public SchemaToXML(Schema schema, StreamResult streamResult)
{
    final SAXTransformerFactory stf = (SAXTransformerFactory) TransformerFactory.newInstance();
    try
    {
        xmlOut = stf.newTransformerHandler();
    }
    catch (TransformerConfigurationException error)
    {
        throw new RuntimeException("Unable to create TransformerHandler.", error);
    }
    final Transformer t = xmlOut.getTransformer();
    try
    {
        t.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "2");
    }
    catch (final IllegalArgumentException e)
    {
        // It was worth a try
    }
    t.setOutputProperty(OutputKeys.INDENT, "yes");
    t.setOutputProperty(OutputKeys.ENCODING, SchemaComparator.CHAR_SET);
    xmlOut.setResult(streamResult);
    
    this.schema = schema;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:SchemaToXML.java

示例8: colorizeXML

import javax.xml.transform.TransformerConfigurationException; //导入依赖的package包/类
String colorizeXML(String xml, String xsltFilename) throws TransformerConfigurationException, TransformerException {

       // Get the XSLT file as a resource
       InputStream xslt = getClass().getResourceAsStream(xsltFilename);
       
       // Create and configure XSLT Transformer 
       TransformerFactory factory = TransformerFactory.newInstance();
       Transformer transformer = factory.newTransformer(new StreamSource(xslt));
       transformer.setParameter("indent-elements", "yes");
       
       OutputStream outputStream = new ByteArrayOutputStream();
       InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
       
       // Convert the XML into HTML per the XSLT file
       transformer.transform(new StreamSource(inputStream), new StreamResult(outputStream));
       
       return new String(((ByteArrayOutputStream)outputStream).toByteArray());
   }
 
开发者ID:will-gilbert,项目名称:OSWf-OSWorkflow-fork,代码行数:19,代码来源:WfDefinitionServiceImpl.java

示例9: testXMLStackOverflowBug

import javax.xml.transform.TransformerConfigurationException; //导入依赖的package包/类
@Test
public final void testXMLStackOverflowBug() throws TransformerConfigurationException, IOException, SAXException {
    try {
        SAXTransformerFactory stf = (SAXTransformerFactory) TransformerFactory.newInstance();
        TransformerHandler ser = stf.newTransformerHandler();
        ser.setResult(new StreamResult(System.out));

        StringBuilder sb = new StringBuilder(4096);
        for (int x = 4096; x > 0; x--) {
            sb.append((char) x);
        }
        ser.characters(sb.toString().toCharArray(), 0, sb.toString().toCharArray().length);
        ser.endDocument();
    } catch (StackOverflowError se) {
        se.printStackTrace();
        Assert.fail("StackOverflow");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:OpenJDK100017Test.java

示例10: passWarningsToListener

import javax.xml.transform.TransformerConfigurationException; //导入依赖的package包/类
/**
 * Pass warning messages from the compiler to the error listener
 */
private void passWarningsToListener(ArrayList<ErrorMsg> messages)
    throws TransformerException
{
    if (_errorListener == null || messages == null) {
        return;
    }
    // Pass messages to listener, one by one
    final int count = messages.size();
    for (int pos = 0; pos < count; pos++) {
        ErrorMsg msg = messages.get(pos);
        // Workaround for the TCK failure ErrorListener.errorTests.error001.
        if (msg.isWarningError())
            _errorListener.error(
                new TransformerConfigurationException(msg.toString()));
        else
            _errorListener.warning(
                new TransformerConfigurationException(msg.toString()));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:TransformerFactoryImpl.java

示例11: newTransformer

import javax.xml.transform.TransformerConfigurationException; //导入依赖的package包/类
/**
 * Implements JAXP's Templates.newTransformer()
 *
 * @throws TransformerConfigurationException
 */
public synchronized Transformer newTransformer()
    throws TransformerConfigurationException
{
    TransformerImpl transformer;

    transformer = new TransformerImpl(getTransletInstance(), _outputProperties,
        _indentNumber, _tfactory);

    if (_uriResolver != null) {
        transformer.setURIResolver(_uriResolver);
    }

    if (_tfactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING)) {
        transformer.setSecureProcessing(true);
    }
    return transformer;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:TemplatesImpl.java

示例12: toString

import javax.xml.transform.TransformerConfigurationException; //导入依赖的package包/类
public static String toString(SOAPMessage soapMessage, String encoding) throws TransformerConfigurationException, TransformerException, SOAPException, IOException, ParserConfigurationException, SAXException {	
soapMessage.saveChanges();

if (encoding == null) { // #3803
	Engine.logEngine.warn("(SOAPUtils) encoding is null. Set encoding to UTF-8 for toString.");
	encoding = "UTF-8";
}

ByteArrayOutputStream out = new ByteArrayOutputStream();
soapMessage.writeTo(out);
      String s = new String(out.toByteArray(), encoding); 

      s = XMLUtils.prettyPrintDOMWithEncoding(s, encoding);
      
// Ticket #2678: fix empty "xmlns"
s = s.replaceAll("\\sxmlns=\"\"", "");

return s;
  }
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:20,代码来源:SOAPUtils.java

示例13: newTransformer

import javax.xml.transform.TransformerConfigurationException; //导入依赖的package包/类
/**
 * 获取一个Transformer对象,由于使用时都做相同的初始化,所以提取出来作为公共方法。
 *
 * @return a Transformer encoding gb2312
 */

public static Transformer newTransformer() {
	try {
		Transformer transformer = TransformerFactory.newInstance()
				.newTransformer();
		Properties properties = transformer.getOutputProperties();
		properties.setProperty(OutputKeys.ENCODING, "gb2312");
		properties.setProperty(OutputKeys.METHOD, "xml");
		properties.setProperty(OutputKeys.VERSION, "1.0");
		properties.setProperty(OutputKeys.INDENT, "no");
		transformer.setOutputProperties(properties);
		return transformer;
	} catch (TransformerConfigurationException tce) {
		throw new RuntimeException(tce.getMessage());
	}
}
 
开发者ID:DataAgg,项目名称:DAFramework,代码行数:22,代码来源:DomXmlUtils.java

示例14: PomModifier

import javax.xml.transform.TransformerConfigurationException; //导入依赖的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

示例15: passWarningsToListener

import javax.xml.transform.TransformerConfigurationException; //导入依赖的package包/类
/**
 * Pass warning messages from the compiler to the error listener
 */
private void passWarningsToListener(Vector messages)
    throws TransformerException
{
    if (_errorListener == null || messages == null) {
        return;
    }
    // Pass messages to listener, one by one
    final int count = messages.size();
    for (int pos = 0; pos < count; pos++) {
        ErrorMsg msg = (ErrorMsg)messages.elementAt(pos);
        // Workaround for the TCK failure ErrorListener.errorTests.error001.
        if (msg.isWarningError())
            _errorListener.error(
                new TransformerConfigurationException(msg.toString()));
        else
            _errorListener.warning(
                new TransformerConfigurationException(msg.toString()));
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:TransformerFactoryImpl.java


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