Package org.xml.sax

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


       
        // 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

        // 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

        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

            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

        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

        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

    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

        // create an actual reader that will perfom the parsing
        XMLReader reader = createXMLReader(fragment);
        // create Filter that will fix up elements that are not associated
        // with a namespace.
        XMLFilter namespaceFilter =
                new NamespaceFilter(defaultNamespacePrefix,
                                    defaultNamespaceURI);
        namespaceFilter.setParent(reader);
        return namespaceFilter;
    }
View Full Code Here

        String data = "<?xml version=\"1.0\"?>\n"
          + "<!DOCTYPE root [\n" +
                "  <!--comment-->\n  <!ELEMENT test (#PCDATA)>" +
            "\n  <!--comment-->\n]>"
          + "\n<test />\n"
        XMLFilter filter = new XMLFilterImpl();
        filter.setParent(XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser"));
        Document doc = (new Builder(filter)).build(data, null);
        String result = doc.toXML();
        assertEquals(data, result);   
       
   
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.