Java Code Examples for javax.xml.transform.TransformerConfigurationException

Following code examples demonstrate how to use javax.xml.transform.TransformerConfigurationExceptionfrom java. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use javax.xml.transform.TransformerConfigurationExceptionand various code implementation of this class.

            public static void main(String[] args) {

             StreamSource xslSourse = new StreamSource(new File("school.xsl"));

             StreamSource xmlSourse = new StreamSource(new File("school.xml"));

             StreamResult htmlOutput = new StreamResult(new File("school.html"));

             try {
             TransformerFactory.newInstance().newTransformer(xslSourse).transform(xmlSourse, htmlOutput);
             } catch (TransformerConfigurationException e) {
             e.printStackTrace();
             } catch (TransformerException e) {
             e.printStackTrace();
             } catch (TransformerFactoryConfigurationError e) {
             e.printStackTrace();
             }

             } 


        }
        catch (TransformerException ex1)
        {
          throw new TransformerConfigurationException(ex1);
        } 

  
  public TemplatesHandler newTemplatesHandler()
          throws TransformerConfigurationException
  {
    return new StylesheetHandler(this);
  } 

  
  public TransformerHandler newTransformerHandler()
          throws TransformerConfigurationException
  {
    return new TransformerIdentityImpl(m_isSecureProcessing);
  } 

    }
    catch (StopParseException spe)
    {

    } 

  
  public XMLFilter newXMLFilter(Templates templates)
          throws TransformerConfigurationException
  {
    try 
    {
      return new TrAXFilter(templates);
    } 
    catch( TransformerConfigurationException ex ) 
    {
      if( m_errorListener != null) 
      {
        try 
        {
          m_errorListener.fatalError( ex );
          return null;
        } 
        catch( TransformerConfigurationException ex1 ) 
        {
          throw ex1;
        }
        catch( TransformerException ex1 ) 
        {
          throw new TransformerConfigurationException(ex1);
        }
      }
      throw ex;
    }
  } 

        }
        catch (TransformerException ex)
        {
          throw new TransformerConfigurationException(ex);
        } 

        } 
        catch( TransformerConfigurationException ex1 ) 
        {
          throw ex1;
        } 

  
  public TransformerFactoryImpl()
  {
  } 

   
    catch (Exception e)
    {
      if (m_errorListener != null)
      {
        try
        {
          m_errorListener.fatalError(new TransformerException(e));
        }
        catch (TransformerConfigurationException ex)
        {
          throw ex;
        }
        catch (TransformerException ex)
        {
          throw new TransformerConfigurationException(ex);
        }

        return null;
      }
      else
      {
      }
    } 

  
  public TransformerHandler newTransformerHandler(Templates templates)
          throws TransformerConfigurationException
  {
    try {
      TransformerImpl transformer =
        (TransformerImpl) templates.newTransformer();
      transformer.setURIResolver(m_uriResolver);
      TransformerHandler th =
        (TransformerHandler) transformer.getInputContentHandler(true);

      return th;
    } 
    catch( TransformerConfigurationException ex ) 
    {
      if( m_errorListener != null ) 
      {
        try 
        {
          m_errorListener.fatalError( ex );
          return null;
        } 
        catch (TransformerConfigurationException ex1 ) 
        {
          throw ex1;
        }
        catch (TransformerException ex1 ) 
        {
          throw new TransformerConfigurationException(ex1);
        }
      }
      
      throw ex;
    }
    
  } 

  
  public Transformer newTransformer(Source source)
          throws TransformerConfigurationException
  {
    try 
    {
      Templates tmpl=newTemplates( source );
      
      if( tmpl==null ) return null;
      Transformer transformer = tmpl.newTransformer();
      transformer.setURIResolver(m_uriResolver);
      return transformer;
    } 
    catch( TransformerConfigurationException ex ) 
    {
      if( m_errorListener != null ) 
      {
        try 
        {
          m_errorListener.fatalError( ex );
          return null;
        } 
        catch( TransformerConfigurationException ex1 ) 
        {
          throw ex1;
        }
        catch( TransformerException ex1 ) 
        {
          throw new TransformerConfigurationException( ex1 );
        }
      }
      throw ex;
    }
  } 

        }
        catch (TransformerConfigurationException ex1)
        {
          throw ex1;
        } 

        } 
        catch (TransformerConfigurationException ex1 ) 
        {
          throw ex1;
        } 

    }
    catch (TransformerConfigurationException tce)
    {
      throw tce;
    } 

        }
        catch( TransformerException ex1 ) 
        {
          throw new TransformerConfigurationException(ex1);
        } 

  
  public TransformerHandler newTransformerHandler(Source src)
          throws TransformerConfigurationException
  {

    Templates templates = newTemplates(src);
    if( templates==null ) return null;
    
    return newTransformerHandler(templates);
  } 

  
  public Transformer newTransformer() throws TransformerConfigurationException
  {
      return new TransformerIdentityImpl(m_isSecureProcessing);
  } 

    }
    catch (IOException ioe)
    {
      throw new TransformerConfigurationException(
        "getAssociatedStylesheets failed", ioe);
    } 

  
  Templates processFromNode(Node node, String systemID)
          throws TransformerConfigurationException
  {

    m_DOMsystemID = systemID;

    return processFromNode(node);
  } 

    } 
    catch( TransformerConfigurationException ex ) 
    {
      if( m_errorListener != null) 
      {
        try 
        {
          m_errorListener.fatalError( ex );
          return null;
        } 
        catch( TransformerConfigurationException ex1 ) 
        {
          throw ex1;
        }
        catch( TransformerException ex1 ) 
        {
          throw new TransformerConfigurationException(ex1);
        }
      }
      throw ex;
    } 

        }
        catch (TransformerException ex1 ) 
        {
          throw new TransformerConfigurationException(ex1);
        } 

        }
        catch (TransformerConfigurationException ex)
        {
          throw ex;
        } 

  
  public XMLFilter newXMLFilter(Source src)
          throws TransformerConfigurationException
  {

    Templates templates = newTemplates(src);
    if( templates==null ) return null;
    
    return newXMLFilter(templates);
  } 

    public static Transformer newTransformer(File xslFile) throws TransformerConfigurationException {
        log.debug(xslFile.getPath() + "|" + xslFile.getName());
        TransformerFactory tFactory = TransformerFactory.newInstance();

        return tFactory.newTransformer(new StreamSource(xslFile));
    } 

    public static Transformer newTransformer(InputStream inputStream) throws TransformerConfigurationException {
        TransformerFactory tFactory = TransformerFactory.newInstance();

        return tFactory.newTransformer(new StreamSource(inputStream));
    } 

    
    public void createRdfs(List<Document> xbrlDocuments, String tdbDirectory, String mappingFile, String steps)
            throws FileNotFoundException, TransformerConfigurationException {
        Mapping mapping = mappingFactory.createInstance(xbrlDocuments, mappingFile, steps);
        if (tdbDirectory != null) {
            generateRdfs(xbrlDocuments, tdbDirectory, mapping);
        }
    } 

    @Test
    public default void verifyGenericType()
    throws Exception {
        final Class<SUT> sut = createNewSUT();
        assertTrue("This j8unit test interface is used with a generic type that is illegaly not assignable to TransformerConfigurationException.class!",
                   TransformerConfigurationException.class.isAssignableFrom(sut));
    } 

    public XSLSearchParameters(File file) throws TransformerConfigurationException {
        StreamSource xsltSource = new StreamSource(file);
        TransformerFactory tf = TransformerFactory.newInstance("net.sf.saxon.TransformerFactoryImpl", null);
        transformer = tf.newTransformer(xsltSource);        
    } 

    

    public Source getAssociatedStylesheet(
            Source source, String media, String title, String charset)
            throws TransformerConfigurationException {
        try {
            XsltCompiler compiler = processor.newXsltCompiler();
            return compiler.getAssociatedStylesheet(source, media, title, charset);
        } catch (SaxonApiException e) {
            throw new TransformerConfigurationException(e);
        }
    } 

    

    public TransformerHandler newTransformerHandler(Source src)
            throws TransformerConfigurationException {
        Templates tmpl = newTemplates(src);
        return newTransformerHandler(tmpl);
    } 

    

    public TemplatesHandler newTemplatesHandler()
            throws TransformerConfigurationException {
        return new TemplatesHandlerImpl(processor);
    } 

    

    public TransformerHandler newTransformerHandler(Templates templates)
            throws TransformerConfigurationException {
        if (!(templates instanceof TemplatesImpl)) {
            throw new TransformerConfigurationException("Templates object was not created by Saxon");
        }
        TransformerImpl transformer = (TransformerImpl) templates.newTransformer();
        return transformer.newTransformerHandler();
    } 

    

    public Transformer newTransformer(Source source)
            throws TransformerConfigurationException {
        Templates templates = newTemplates(source);
        return templates.newTransformer();
    } 

    

    public Transformer newTransformer()
            throws TransformerConfigurationException {

        return new IdentityTransformer(processor.getUnderlyingConfiguration());
    } 

    

    public XMLFilter newXMLFilter(Templates templates)
            throws TransformerConfigurationException {
        if (!(templates instanceof TemplatesImpl)) {
            throw new TransformerConfigurationException("Supplied Templates object was not created using Saxon");
        }
        AbstractTransformerImpl transformer = (AbstractTransformerImpl) templates.newTransformer();
        return transformer.newXMLFilter();
    } 

    

    public TransformerHandler newTransformerHandler()
            throws TransformerConfigurationException {
        IdentityTransformer transformer = new IdentityTransformer(getConfiguration());
        return new IdentityTransformerHandler(transformer);
    } 

    

    public Templates newTemplates(Source source, CompilerInfo info)
            throws TransformerConfigurationException {

        try {
            XsltCompiler compiler = processor.newXsltCompiler();
            compiler.getUnderlyingCompilerInfo().copyFrom(info);
            return new TemplatesImpl(compiler.compile(source));
        } catch (SaxonApiException e) {
            throw new TransformerConfigurationException(e);
        }
    } 

    

    public Templates newTemplates(Source source)
            throws TransformerConfigurationException {

        try {
            XsltCompiler compiler = processor.newXsltCompiler();
            XsltExecutable executable = compiler.compile(source);
            return new TemplatesImpl(executable);
        } catch (SaxonApiException e) {
            throw new TransformerConfigurationException(e);
        }
    } 

    

    public XMLFilter newXMLFilter(Source src)
            throws TransformerConfigurationException {
        Templates tmpl = newTemplates(src);
        return newXMLFilter(tmpl);
    } 

    public void setFeature(String name, boolean value) throws TransformerConfigurationException {
        if (name.equals(FEATURE_SECURE_PROCESSING)) {
            getConfiguration().setBooleanProperty(FeatureKeys.ALLOW_EXTERNAL_FUNCTIONS, !value);
        } else {
            try {
                getConfiguration().setBooleanProperty(name, value);
            } catch (IllegalArgumentException err) {
                throw new TransformerConfigurationException("Unsupported TransformerFactory feature: " + name);
            }
        }
    } 

    @Category(Draft.class)
    public void create_TransformerConfigurationException()
    throws Exception {
        @SuppressWarnings("unused")
        final TransformerConfigurationException sut = new TransformerConfigurationException();
    } 

Advertisement
Javadoc
Indicates a serious configuration error.
Advertisement