Package org.xml.sax

Examples of org.xml.sax.XMLFilter


            Templates t = createTemplates(getInTemplates(mt), inParamsMap, inProperties);
            if (t == null && supportJaxbOnly) {
                return super.unmarshalFromInputStream(unmarshaller, is, mt);
            }
            XMLFilter filter = factory.newXMLFilter(t);
            SAXSource source = new SAXSource(filter, new InputSource(is));
            if (systemId != null) {
                source.setSystemId(systemId);
            }
            return unmarshaller.unmarshal(source);
View Full Code Here


        Document doc = output.getDocument();

        if (doc != null) return;

        // XMLFilter
        XMLFilter xmlFilter = output.getXMLFilter();
        if (xmlFilter != null) {
            handler.fatalError(new TranscoderException("" + ERROR_INCOMPATIBLE_OUTPUT_TYPE));
        }

        try {
View Full Code Here

      // arquivo onde vai ser gerado o FO
          ByteArrayOutputStream outFo = new ByteArrayOutputStream();

      //java.io.PrintWriter out = response.getWriter();
      StreamResult result = new StreamResult(outFo);
      XMLFilter style = null;
      SAXTransformerFactory stf = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
      try{
        StreamSource ss = new StreamSource(stylesheet);
        style = stf.newXMLFilter(ss);
      }catch(javax.xml.transform.TransformerConfigurationException ex){
View Full Code Here

    Assert.isNotNull(input, "input"); //$NON-NLS-1$
    Assert.isNotNull(collector, "collector"); //$NON-NLS-1$
    try {
      InputStream eventSetIS = getClass().getResourceAsStream(FILENAME_EVENTSET_XML);
      XMLReader reader = XMLReaderFactory.createXMLReader();
      XMLFilter filter = new Log4JXMLFilter(collector);
      filter.setParent(reader);
      filter.setEntityResolver(new EntityResolver() {
       
        @Override
        public InputSource resolveEntity(String publicId, String systemId)
            throws SAXException, IOException {
          if ((systemId != null) && systemId.toLowerCase().endsWith(FILENAME_LOG4J_DTD)) {
            // Looking for the Log4J DTD?
            InputStream is = getClass().getResourceAsStream(FILENAME_LOG4J_DTD);
            return new InputSource(is);
          }
          if ((systemId != null) && systemId.equals("%file%")) { //$NON-NLS-1$
            // Loading the log file
            InputSource src = new InputSource(input);
            // Apply the passed encoding
            IHasEncoding enc = (IHasEncoding) log.getAdapter(IHasEncoding.class);
            src.setEncoding(enc.getEncoding());
            return src;
          }
          return null;
        }
      });
      filter.parse(new InputSource(eventSetIS));
    } catch (OperationCanceledException e) {
      // Thrown by Log4JXMLFilter to cancel parsing
    } catch (Exception e) {
      throw new CoreException(new Status(IStatus.ERROR, Log4JDialectPlugin.PLUGIN_ID,
          NLS.bind(Messages.Log4JDialect_error_parsingFailed,
View Full Code Here

      TransformerHandler handler = getSAXTransformer().getSaxTransformerHandler().newTransformerHandler();
      handler.setResult(result);
 
      XMLReader reader = XMLReaderFactory.createXMLReader();
 
        XMLFilter xhtmlFilter = new XObjectFilter(reader, getSAXTransformer(), getListableBeanFactory(), Protocol.XSL);
        xhtmlFilter.setParent(reader);
        xhtmlFilter.setContentHandler(handler);
   
        InputSource is = SAXSource.sourceToInputSource(sourceXslt);
 
        xhtmlFilter.parse(is);
    } else {
      Transformer transformer = getSAXTransformer().getSaxTransformerHandler().newTransformer();
      transformer.transform(sourceXslt, result);
    }
  }
View Full Code Here

            // If the Source object is not changed, the
            // getTransformerHandler() of XSLTProcessor will simply return
            // the old template object. If the Source is unchanged, the
            // namespaces are not modified either.
            XMLFilter saveNSFilter = new SaveNamespaceFilter(namespaceURIs);
            return xsltProcessor.getTransformerHandler(source, saveNSFilter);

        } catch (ComponentException e) {
            throw new ProcessingException("Could not obtain XSLT processor", e);
        } catch (MalformedURLException e) {
View Full Code Here

                    tFactory.getFeature(SAXResult.FEATURE)) {
                // Cast the TransformerFactory to SAXTransformerFactory.
                SAXTransformerFactory saxTFactory =
                  ((SAXTransformerFactory) tFactory);
                // Create an XMLFilter for each stylesheet.
                XMLFilter xmlfilter = saxTFactory.newXMLFilter(
                                        new StreamSource(xsltfile));

                // Create an XMLReader.
                XMLReader parser = createParser();
                if (parser == null) {
                    throw new FOPException("Unable to create SAX parser");
                }

                // xmlFilter1 uses the XMLReader as its reader.
                xmlfilter.setParent(parser);
                return xmlfilter;
            } else {
                throw new FOPException(
                  "Your parser doesn't support the features SAXSource and SAXResult." +
                  "\nMake sure you are using a xsl parser which supports TrAX");
View Full Code Here

            Templates t = createTemplates(getInTemplates(mt), inParamsMap, inProperties);
            if (t == null && supportJaxbOnly) {
                return super.unmarshalFromInputStream(unmarshaller, is, mt);
            }
            XMLFilter filter = factory.newXMLFilter(t);
            SAXSource source = new SAXSource(filter, new InputSource(is));
            if (systemId != null) {
                source.setSystemId(systemId);
            }
            return unmarshaller.unmarshal(source);
View Full Code Here

        if (filterChain == null) {
            this.xmlReader = new SaxWriter();
        } else {
            if (filterChain instanceof XMLFilter) {
                // Connect the filter chain to a document reader.
                XMLFilter filter = (XMLFilter)filterChain;
                while (filter.getParent() instanceof XMLFilter) {
                    filter = (XMLFilter)(filter.getParent());
                }
                if (!(filter.getParent() instanceof SaxWriter)) {
                    filter.setParent(new SaxWriter());
                }

                // Read XML data from filter chain.
                this.xmlReader = filterChain;
            } else {
View Full Code Here

  Path p = s.expression();

  // construct the appropriate SAX chain
  // (reader -> us -> serializer)
  XMLReader r = XMLReaderFactory.createXMLReader();
  XMLFilter f1 = new SPathFilter(p);
  XMLFilter f2 = new XMLFilterImpl();
  f1.setParent(r);
  f2.setParent(f1);
  Serializer sz = SerializerFactory.getSerializer
      (OutputProperties.getDefaultMethodProperties("xml"));
  sz.setOutputStream(System.out);
  f2.setContentHandler(sz.asContentHandler());

  // go!
  f2.parse(new InputSource(System.in));
  System.out.println();
    }
View Full Code Here

TOP

Related Classes of org.xml.sax.XMLFilter

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.