Examples of TransformerFactory


Examples of javax.xml.transform.TransformerFactory

  public RDFaParserFactory()
    throws TransformerConfigurationException
  {
    executor = Executors.newCachedThreadPool();
    TransformerFactory transFact = TransformerFactory.newInstance();
    ClassLoader cl = RDFaParser.class.getClassLoader();
    InputStream xslt = cl.getResourceAsStream(RDFaParser.XSLT);
    transformer = transFact.newTransformer(new StreamSource(xslt));
  }
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

  public RDFaParser()
    throws TransformerConfigurationException
  {
    executor = Executors.newSingleThreadExecutor();
    TransformerFactory transFact = TransformerFactory.newInstance();
    ClassLoader cl = RDFaParser.class.getClassLoader();
    transformer = transFact.newTransformer(new StreamSource(cl.getResourceAsStream(XSLT)));
  }
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

      throws TransformerFactoryConfigurationError {
      if (factoryName == null || factoryName.length() < 1) {
         return newTransformerFactory();
      }
      try {
         TransformerFactory tf = (TransformerFactory) factory.getClass().getClassLoader().loadClass(factoryName).newInstance();
         return tf;
      } catch (Exception e) {
         throw new TransformerFactoryConfigurationError(e,e.getMessage());
      } // end of try-catch
   }
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

    * @param props Map<String, String>
    * @return
    * @throws Exception
    */
   private static Transformer newTransformer(String systemId, String xslString, URIResolver uriResolver, Map props) throws Exception {
      TransformerFactory transformerFactory = TransformerFactory.newInstance();
      if (uriResolver != null)
         transformerFactory.setURIResolver(uriResolver);
      StreamSource xslStreamSource = null;
      if(systemId != null)
          xslStreamSource = new StreamSource(new StringReader(xslString), systemId);
      else
          xslStreamSource = new StreamSource(new StringReader(xslString));

      Transformer transformer = transformerFactory.newTransformer(xslStreamSource);
      if(props != null) {
          Iterator iter = props.entrySet().iterator();
          while(iter.hasNext()) {
              Entry entry = (Entry)iter.next();
              transformer.setParameter((String)entry.getKey(), (String)entry.getValue());
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

  static private Transformer getSerializer(String systemID) throws XException
  {
    setTransformerProperties();

    Transformer serializer;
    TransformerFactory tfactory = TransformerFactory.newInstance();
    // This creates a transformer that does a simple identity transform,
    // and thus can be used for all intents and purposes as a serializer.
    try
    {
      serializer = tfactory.newTransformer();
      serializer.setOutputProperty(OutputKeys.INDENT, "yes");
      serializer.setOutputProperty(OutputKeys.METHOD, "xml");
      serializer.setOutputProperty(OutputKeys.ENCODING, Constants
          .getXMLEncoding());
      if ((systemID != null) && (systemID.length() > 0))
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

        try
        {
            if (StringUtils.isNotBlank(xmlDocument))
            {
                final Source xmlSource = new DOMSource(this.urlToDocument(xmlDocument));
                final TransformerFactory factory = TransformerFactory.newInstance();
                if (xslt != null)
                {
                    final Source xsltSource = new StreamSource(xslt.openStream());
                    final javax.xml.transform.Transformer transformer = factory.newTransformer(xsltSource);
                    final ByteArrayOutputStream output = new ByteArrayOutputStream();
                    final Result result = new StreamResult(output);
                    transformer.transform(
                        xmlSource,
                        result);
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

    {
        InputStream xmlstream = null;
        InputStream xslstream = null;
        try
        {
            TransformerFactory factory = TransformerFactory.newInstance(  );

            /* XSL */
            xslstream = openXslInputStream( request );
            if ( xslstream == null )
            {
                throw new PortletException( "No XSL" );
            }

            StreamSource xsl = new StreamSource( xslstream );

            /* XML */
            xmlstream = openXmlInputStream( request );
            if ( xslstream == null )
            {
                throw new PortletException( "No XML" );
            }

            StreamSource xml = new StreamSource( xmlstream );

            /* Transform */
            StreamResult output = new StreamResult( response.getWriter(  ) );
            Transformer  transformer = factory.newTransformer( xsl );
            Map          params = getXslParameters( request, response );
            if ( params != null )
            {
                Iterator it = params.keySet(  ).iterator(  );
                while ( it.hasNext(  ) )
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

            Object exArgs[] = { "xslt:stylesheet", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
         }

         TransformerFactory tFactory = TransformerFactory.newInstance();
   // Process XSLT stylesheets in a secure manner
   tFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);

         /*
          * This transform requires an octet stream as input. If the actual
          * input is an XPath node-set, then the signature application should
          * attempt to convert it to octets (apply Canonical XML]) as described
          * in the Reference Processing Model (section 4.3.3.2).
          */
         Source xmlSource =
            new StreamSource(new ByteArrayInputStream(input.getBytes()));
         Source stylesheet;

         /*
          * This complicated transformation of the stylesheet itself is necessary
          * because of the need to get the pure style sheet. If we simply say
          * Source stylesheet = new DOMSource(this._xsltElement);
          * whereby this._xsltElement is not the rootElement of the Document,
          * this causes problems;
          * so we convert the stylesheet to byte[] and use this as input stream
          */
         {
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            Transformer transformer = tFactory.newTransformer();
            DOMSource source = new DOMSource(_xsltElement);
            StreamResult result = new StreamResult(os);

            transformer.transform(source, result);

            stylesheet =
               new StreamSource(new ByteArrayInputStream(os.toByteArray()));
         }

         Transformer transformer = tFactory.newTransformer(stylesheet);
         if (baos==null) {
               ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
               StreamResult outputTarget = new StreamResult(baos1);
               transformer.transform(xmlSource, outputTarget);
               return new XMLSignatureInput(baos1.toByteArray());
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

        }

        StringWriter stringWriter = new StringWriter();
        StreamResult streamResult = new StreamResult(stringWriter);

        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        Transformer transformer;
        try {
            transformer = transformerFactory.newTransformer();
        } catch (TransformerConfigurationException e) {
            throw new IllegalStateException("Unable to get a new transformer", e);
        }

        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
View Full Code Here

Examples of javax.xml.transform.TransformerFactory

    StreamResult result = new StreamResult(ps);

    // Once again we are using a factory of some sort,
    // this time for getting a Transformer instance,
    // which we use to output the XML
    TransformerFactory transformerFactory = TransformerFactory
        .newInstance();
    Transformer transformer = transformerFactory.newTransformer();

    // Indenting the XML
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");

    // The actual output to a file goes here
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.