Package javax.xml.transform.sax

Examples of javax.xml.transform.sax.TemplatesHandler


        }

        try
        {
            // Create a ContentHandler to handle parsing of the stylesheet.
            TemplatesHandler templatesHandler = transformerFactory.newTemplatesHandler();

            // Create an XMLReader and set its ContentHandler.
            XMLReader reader = XMLReaderFactory.createXMLReader();
            reader.setContentHandler(templatesHandler);

            // Set it to solve Entities via cache
            reader.setEntityResolver(new TransformDTDEntityResolver(dtds));

            //
            // Get the stylesheet's content from the deployment
            //                        
            java.io.FileInputStream is = new java.io.FileInputStream(xslt);
            InputStreamReader ssreader = new InputStreamReader(is);

            // Parse the stylesheet.
            final InputSource xstyle = new InputSource(ssreader);
            xstyle.setSystemId(xslt);
            reader.parse(xstyle);

            //Get the Templates object from the ContentHandler.
            Templates templates = templatesHandler.getTemplates();

            // Create a ContentHandler to handle parsing of the XML source.
            TransformerHandler handler = transformerFactory.newTransformerHandler(templates);

            // Reset the XMLReader's ContentHandler.
View Full Code Here


        }

        try
        {
            // Create a ContentHandler to handle parsing of the stylesheet.
            TemplatesHandler templatesHandler = transformerFactory.newTemplatesHandler();

            // Create an XMLReader and set its ContentHandler.
            XMLReader reader = XMLReaderFactory.createXMLReader();
            reader.setContentHandler(templatesHandler);

            // Set it to solve Entities via cache
            reader.setEntityResolver(new TransformDTDEntityResolver(dtds));

            //
            // Get the stylesheet's content from the deployment
            //                        
            java.io.FileInputStream is = new java.io.FileInputStream(xslt);
            InputStreamReader ssreader = new InputStreamReader(is);

            // Parse the stylesheet.
            final InputSource xstyle = new InputSource(ssreader);
            xstyle.setSystemId(xslt);
            reader.parse(xstyle);

            //Get the Templates object from the ContentHandler.
            Templates templates = templatesHandler.getTemplates();

            // Create a ContentHandler to handle parsing of the XML source.
            TransformerHandler handler = transformerFactory.newTransformerHandler(templates);

            // Reset the XMLReader's ContentHandler.
View Full Code Here

        }

        try
        {
            // Create a ContentHandler to handle parsing of the stylesheet.
            TemplatesHandler templatesHandler = transformerFactory.newTemplatesHandler();

            // Create an XMLReader and set its ContentHandler.
            XMLReader reader = XMLReaderFactory.createXMLReader();
            reader.setContentHandler(templatesHandler);

            // Set it to solve Entities via cache
            reader.setEntityResolver(new TransformDTDEntityResolver(dtds));

            //
            // Get the stylesheet's content from the deployment
            //                        
            java.io.FileInputStream is = new java.io.FileInputStream(xslt);
            InputStreamReader ssreader = new InputStreamReader(is);

            // Parse the stylesheet.
            final InputSource xstyle = new InputSource(ssreader);
            xstyle.setSystemId(xslt);
            reader.parse(xstyle);

            //Get the Templates object from the ContentHandler.
            Templates templates = templatesHandler.getTemplates();

            // Create a ContentHandler to handle parsing of the XML source.
            TransformerHandler handler = transformerFactory.newTransformerHandler(templates);

            // Reset the XMLReader's ContentHandler.
View Full Code Here

            factory.setErrorListener(errorListener);

            // Create a Templates ContentHandler to handle parsing of the
            // stylesheet.
            TemplatesHandler templatesHandler = factory.newTemplatesHandler();

            // Set the system ID for the template handler since some
            // TrAX implementations (XSLTC) rely on this in order to obtain
            // a meaningful identifier for the Templates instances.
            templatesHandler.setSystemId(id);
            if (filter != null) {
                filter.setContentHandler(templatesHandler);
            }

            if (getLogger().isDebugEnabled()) {
                getLogger().debug("Source = " + stylesheet + ", templatesHandler = " + templatesHandler);
            }

            // Initialize List for included validities
            SourceValidity validity = stylesheet.getValidity();
            if (validity != null && checkIncludes) {
                includesMap.put(id, new ArrayList());
            }

            try {
                // Process the stylesheet.
                sourceToSAX(stylesheet, filter != null ? (ContentHandler) filter : (ContentHandler) templatesHandler);

                // Get the Templates object (generated during the parsing of
                // the stylesheet) from the TemplatesHandler.
                final Templates template = templatesHandler.getTemplates();

                if (null == template) {
                    throw new XSLTProcessorException("Unable to create templates for stylesheet: " + stylesheet.getURI());
                }
View Full Code Here

            m_factory.setErrorListener(errorListener);

            // Create a Templates ContentHandler to handle parsing of the
            // stylesheet.
            TemplatesHandler templatesHandler = m_factory.newTemplatesHandler();

            // Set the system ID for the template handler since some
            // TrAX implementations (XSLTC) rely on this in order to obtain
            // a meaningful identifier for the Templates instances.
            templatesHandler.setSystemId(id);
            if (filter != null) {
                filter.setContentHandler(templatesHandler);
            }

            if (getLogger().isDebugEnabled()) {
                getLogger().debug("Source = " + stylesheet + ", templatesHandler = " + templatesHandler);
            }

            // Initialize List for included validities
            SourceValidity validity = stylesheet.getValidity();
            if (validity != null && m_checkIncludes) {
                m_includesMap.put(id, new ArrayList());
            }

            try {
                // Process the stylesheet.
                sourceToSAX(stylesheet, filter != null ? (ContentHandler) filter : (ContentHandler) templatesHandler);

                // Get the Templates object (generated during the parsing of
                // the stylesheet) from the TemplatesHandler.
                final Templates template = templatesHandler.getTemplates();

                if (null == template) {
                    throw new XSLTProcessorException("Unable to create templates for stylesheet: " + stylesheet.getURI());
                }
View Full Code Here

        private Templates getSource(DBBroker broker, DocumentImpl stylesheet)
                throws ServletException {
            factory.setURIResolver(new DatabaseResolver(broker, stylesheet));
            try {
                final TemplatesHandler handler = factory.newTemplatesHandler();
                handler.startDocument();

                final Serializer serializer = broker.getSerializer();
                serializer.reset();
                serializer.setSAXHandlers(handler, null);
                serializer.toSAX(stylesheet);

                handler.endDocument();      
                return handler.getTemplates();

            } catch (final SAXException e) {
                throw new ServletException("A SAX exception occurred while compiling the stylesheet: "
                        + e.getMessage(), e);
View Full Code Here

    }
  }
 
  private Templates getSource(SAXTransformerFactory factory, NodeValue stylesheetRoot) throws XPathException, TransformerConfigurationException
  {
    final TemplatesHandler handler = factory.newTemplatesHandler();
    try {
      handler.startDocument();
      stylesheetRoot.toSAX(context.getBroker(), handler, null);
      handler.endDocument();
      return handler.getTemplates();
    } catch (final SAXException e) {
      throw new XPathException(this,
        "A SAX exception occurred while compiling the stylesheet: " + e.getMessage(), e);
    }
  }
View Full Code Here

          /*
           * TODO: the code in this try statement (apart from the WSDLFilter use) was mostly extracted from
           * transform:stream-transform(), it would be better to be able to share that code somehow
           */
          final SAXTransformerFactory factory = TransformerFactoryAllocator.getTransformerFactory(broker.getBrokerPool());
      final TemplatesHandler templatesHandler = factory.newTemplatesHandler();
      templatesHandler.startDocument();
      final Serializer serializer = broker.getSerializer();
      serializer.reset();
      final WSDLFilter wsdlfilter = new WSDLFilter(templatesHandler, HttpServletRequestURL);
      serializer.setSAXHandlers(wsdlfilter, null);
      serializer.toSAX(docStyleSheet);
      templatesHandler.endDocument();
     
      final TransformerHandler handler = factory.newTransformerHandler(templatesHandler.getTemplates());
     
      //set parameters, if any
      if(parameters != null)
      {
        final Transformer transformer = handler.getTransformer();
View Full Code Here

    private Templates getSource(DocumentImpl stylesheet)
    throws XPathException, TransformerConfigurationException {
      factory.setURIResolver(new EXistURIResolver(stylesheet.getCollection().getURI().toString()));
            final TransformErrorListener errorListener = new TransformErrorListener();
            factory.setErrorListener(errorListener);
      final TemplatesHandler handler = factory.newTemplatesHandler();
      try {
        handler.startDocument();
        final Serializer serializer = context.getBroker().getSerializer();
        serializer.reset();
        serializer.setSAXHandlers(handler, null);
        serializer.toSAX(stylesheet);
        handler.endDocument();
        final Templates t = handler.getTemplates();
                errorListener.checkForErrors();
                return t;
      } catch (final Exception e) {
                if (e instanceof XPathException)
                    {throw (XPathException) e;}
View Full Code Here

            // save handlers
            Receiver oldReceiver = receiver;

            // compile stylesheet
            factory.setErrorListener(new ErrorListener());
            final TemplatesHandler handler = factory.newTemplatesHandler();
            receiver = new ReceiverToSAX(handler);
            try {
                this.serializeToReceiver(xsl, true);
                templates = handler.getTemplates();
            } catch (final SAXException e) {
                throw new TransformerConfigurationException(e.getMessage(), e);
            }

            // restore handlers
View Full Code Here

TOP

Related Classes of javax.xml.transform.sax.TemplatesHandler

Copyright © 2018 www.massapicom. 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.