Examples of XmlFilter


Examples of org.xml.sax.XMLFilter

      // --TransformerFactory actually returns a SAXTransformerFactory instance
      // --We didn't care about that before, because we didn't use the
      // --SAXTransformerFactory extensions. But now we do, so we cast the result.
      SAXTransformerFactory stf =
        (SAXTransformerFactory) TransformerFactory.newInstance();
      XMLFilter filter1 = stf.newXMLFilter(new StreamSource(stylesheet1));
      XMLFilter filter2 = stf.newXMLFilter(new StreamSource(stylesheet2));

      // Wire the output of the reader to filter1
      // and the output of filter1 to filter2
      // --A filter is a kind of reader
      // --Setting the parent sets the input reader
      // --Since a filter is a reader, the "parent" could be another filter
      filter1.setParent(reader);
      filter2.setParent(filter1);

      // Set up the output stream
      StreamResult result = new StreamResult(System.out);
     
      // Set up the transformer to process the SAX events generated
View Full Code Here

Examples of org.xml.sax.XMLFilter

  protected void logSummary(boolean bHasErrors, Logger aLogger) {
  }

  protected boolean validateEntry(Logger aParentLogger, String aEntryName, String aLocalElementName, OdfVersion aVersion) throws IOException, ZipException, IllegalStateException, ODFValidatorException {
    Logger aLogger = new Logger(aEntryName, aParentLogger);
    XMLFilter aFilter = new ContentFilter(aLogger, aLocalElementName);
    if ((m_eMode == OdfValidatorMode.CONFORMANCE && aVersion.compareTo(OdfVersion.V1_1) <= 0)
        || m_eMode == OdfValidatorMode.EXTENDED_CONFORMANCE) {
      XMLFilter aAlienFilter = new ForeignContentFilter(aLogger, aVersion, m_aResult);
      aAlienFilter.setParent(aFilter);
      aFilter = aAlienFilter;
    }
    Validator aValidator = null;
    if (m_eMode == OdfValidatorMode.VALIDATE_STRICT) {
      aValidator = m_aValidatorProvider.getStrictValidator(aParentLogger.getOutputStream(), aVersion);
View Full Code Here

Examples of org.xml.sax.XMLFilter

    return validateEntry(aFilter, aValidator, aLogger, aEntryName);
  }

  private boolean validateMeta(Logger aParentLogger, String aEntryName, OdfVersion aVersion, boolean bIsRoot) throws IOException, ZipException, IllegalStateException, ODFValidatorException {
    Logger aLogger = new Logger(aEntryName, aParentLogger);
    XMLFilter aFilter = new MetaFilter(aLogger, m_aResult);
    if ((m_eMode == OdfValidatorMode.CONFORMANCE && aVersion.compareTo(OdfVersion.V1_1) <= 0)
        || m_eMode == OdfValidatorMode.EXTENDED_CONFORMANCE) {
      XMLFilter aAlienFilter = new ForeignContentFilter(aLogger, aVersion, m_aResult);
      aAlienFilter.setParent(aFilter);
      aFilter = aAlienFilter;
    }

    Validator aValidator = null;
    if (m_eMode == OdfValidatorMode.VALIDATE_STRICT) {
View Full Code Here

Examples of org.xml.sax.XMLFilter

       
        // In general, a filter may violate the constraints of XML 1.0.
        // However, I specifically trust Norm Walsh not to do that, so
        // if his filters are being used we look at the parent instead.
        if (parserName.equals("org.apache.xml.resolver.tools.ResolvingXMLFilter")) {
            XMLFilter filter = (XMLFilter) parser;
            parserName = filter.getParent().getClass().getName();
        }
       
        // These parsers are known to not make all the checks
        // they're supposed to. :-(
        if (parserName.equals("gnu.xml.aelfred2.XmlReader")) return false;
View Full Code Here

Examples of org.xml.sax.XMLFilter

        // Make sure we can count the actual numbers of elements etc. that
        // are created
        builder.setFactory(factory);

        // Count specific attributes and elements for some of the tests
        XMLFilter filter = new XMLFilterImpl() {
            public void startElement(String namespaceURI,
                                     String localName,
                                     String qName,
                                     Attributes attributes)
                throws SAXException {
View Full Code Here

Examples of org.xml.sax.XMLFilter

        ScriptFilter filter = createScriptFilter(
            contentType,
            "org.xml.sax.helpers.XMLFilterImpl");

        module.putScriptFilter(filter);
        final XMLFilter xmlFilter = module.selectScriptFilter(contentType);
        assertNotNull("Should be found", xmlFilter);
        assertTrue("Value should match", xmlFilter instanceof XMLFilterImpl);
    }
View Full Code Here

Examples of org.xml.sax.XMLFilter

            ParserConfigurationException,
            IOException,
            SAXException {

        // Get an XMLFilter that will apply the transform.
        XMLFilter filter = saxTransformerFactory.newXMLFilter(templates);

        // Parse the input, pass it through the filter and create a DOM.
        XMLReader parser = new SAXParser();

        parser.setFeature("http://xml.org/sax/features/validation", true);
        parser.setFeature("http://apache.org/xml/features/validation/schema", true);

        filter.setParent(parser);

//        // todo validate input and output.
//        final PrintWriter writer = new PrintWriter(System.out);
//        filter.setContentHandler(new MyContentHandler(writer));
//        filter.setErrorHandler(new MyErrorHandler());
View Full Code Here

Examples of org.xml.sax.XMLFilter

        File deviceRepositoryFile = new File(deviceRepository);
        if (!deviceRepositoryFile.canRead()) {
            throw new IOException("Cannot read file: " + deviceRepository);
        }

        XMLFilter xmlFilter = isAdminProject ?
                EclipseDeviceRepository.STANDARD_ELEMENT_FILTER : null;

        accessor = new EclipseDeviceRepository(deviceRepository,
                transformerMetaFactory, jdomFactory, false, false, xmlFilter);
View Full Code Here

Examples of org.xml.sax.XMLFilter

        final String[] nodeNames = new String[]{
            "complexType", "sequence", "all", "choice"
        };

        XMLFilter filter = new GroupFilter(new DeletionFilter(
                filteredElements,
                new ExposeChildrenFilter(nodeNames,
                                         parser)));

        // Set up the features that we need
        try {
            parser.setFeature("http://xml.org/sax/features/namespaces",
                              true);
        } catch (SAXNotSupportedException e) {
            throw new IllegalStateException(
                    "The parser should support all required features (" +
                    e.getMessage() + ")");
        } catch (SAXNotRecognizedException e) {
            throw new IllegalStateException(
                    "The parser should support all required features (" +
                    e.getMessage() + ")");
        }

        // Set up the schema configurator needed to populate the schema
        // definition.
        filter.setContentHandler(new SchemaConfigurator(schema));

        // Now parse the schema file itself to populate the schema definition
        filter.parse(systemID);
    }
View Full Code Here

Examples of org.xml.sax.XMLFilter

    public static XMLReader createXMLReader(boolean fragment) {

        XMLReader reader = new com.volantis.xml.xerces.parsers.SAXParser();

        if (fragment) {
            XMLFilter filter = new DocumentFragmentFilter();
            filter.setParent(reader);
            reader = filter;
        }
        return reader;
    }
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.