Package org.codehaus.stax2

Examples of org.codehaus.stax2.XMLInputFactory2


    }

    protected int test(File file)
        throws Exception
    {
        XMLInputFactory2 f = getFactory();

        //f.setProperty(WstxInputProperties.P_BASE_URL, "file:///tmp/");

        System.out.print("Coalesce: "+f.getProperty(XMLInputFactory.IS_COALESCING));
        System.out.println("NS-aware: "+f.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE));
        System.out.print("Entity-expanding: "+f.getProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES));
        System.out.println("Validating: "+f.getProperty(XMLInputFactory.IS_VALIDATING));
        System.out.println("Xml-id support: "+f.getProperty(XMLInputFactory2.XSP_SUPPORT_XMLID));

        int total = 0;
        XMLStreamReader2 sr;

        // Let's deal with gzipped files too?
        if (file.getName().endsWith(".gz")) {
            System.out.println("[gzipped input file!]");
            sr = (XMLStreamReader2) f.createXMLStreamReader
                (new InputStreamReader(new GZIPInputStream
                                       (new FileInputStream(file)), "UTF-8"));
        } else {
            sr = f.createXMLStreamReader(file);
            //sr = (XMLStreamReader2) f.createXMLStreamReader(new InputStreamReader(new FileInputStream(file), "IBM500"));
            //sr = (XMLStreamReader2) f.createXMLStreamReader(new StreamSource(file));
        }

        //sr.setProperty(WstxInputProperties.P_BASE_URL, "file:///tmp");
View Full Code Here


public class RunValidation
    extends RunStreamReader
{
    protected XMLInputFactory2 getFactory()
    {
        XMLInputFactory2 f = super.getFactory();

        f.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.TRUE);
        f.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.TRUE);

        // Usually we don't care about full stress testing...
        if (f.isPropertySupported(WstxInputProperties.P_INPUT_BUFFER_LENGTH)) {
            f.setProperty(WstxInputProperties.P_INPUT_BUFFER_LENGTH,
                          new Integer(2000));
        }

        // Do we want to handle validation problems gracefully?
        //f.setProperty(XMLInputFactory.REPORTER, new TestReporter());
View Full Code Here

    }

    protected int test3(byte[] bdata, char[] cdata, File file)
        throws Exception
    {
        XMLInputFactory2 f = (XMLInputFactory2) mInputFactory;
        XMLStreamReader2 sr;

        if (bdata != null) {
            //sr = (XMLStreamReader2) f.createXMLStreamReader(new ByteArrayInputStream(bdata));
            sr = (XMLStreamReader2) f.createXMLStreamReader(new org.codehaus.stax2.io.Stax2ByteArraySource(bdata, 0, bdata.length));
        } else {
            sr = (XMLStreamReader2) f.createXMLStreamReader(new CharArrayReader(cdata));
        }
        //sr = (XMLStreamReader2) f.createXMLStreamReader(file);

        int result = 0;
View Full Code Here

    protected XMLInputFactory2 getFactory()
    {
        System.setProperty("javax.xml.stream.XMLInputFactory",
                           "com.ctc.wstx.stax.WstxInputFactory");

        XMLInputFactory2 f =  (XMLInputFactory2) XMLInputFactory.newInstance();
        System.out.println("Factory instance: "+f.getClass());

        //f.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE);
        f.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
        f.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE);
        //f.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE);
        f.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES,
                      //Boolean.FALSE
                      Boolean.TRUE
                      );

        f.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.TRUE);
        //f.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);

        f.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
        //f.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.TRUE);

        f.setProperty(XMLInputFactory.REPORTER, new TestReporter());
        f.setProperty(XMLInputFactory.RESOLVER, new TestResolver1());
        if (f.isPropertySupported(XMLInputFactory2.P_REPORT_PROLOG_WHITESPACE)) {
            f.setProperty(XMLInputFactory2.P_REPORT_PROLOG_WHITESPACE,
                          Boolean.FALSE
                          //Boolean.TRUE
            );
        }

        f.setProperty(XMLInputFactory2.XSP_SUPPORT_XMLID,
                      XMLInputFactory2.XSP_V_XMLID_TYPING
                      //XMLInputFactory2.XSP_V_XMLID_NONE
                      );

        if (f.isPropertySupported(WstxInputProperties.P_MIN_TEXT_SEGMENT)) {
            f.setProperty(WstxInputProperties.P_MIN_TEXT_SEGMENT,
                          new Integer(1));
            //new Integer(23));
        }

        /*
        f.setProperty(WstxInputProperties.P_LAZY_PARSING,
                      //Boolean.FALSE);
                      Boolean.TRUE);
        */

        /*
        if (f.isPropertySupported(WstxInputProperties.P_CUSTOM_INTERNAL_ENTITIES)) {
            java.util.Map m = new java.util.HashMap();
            m.put("myent", "foobar");
            m.put("myent2", "<tag>R&amp;B + &myent;</tag>");
            f.setProperty(WstxInputProperties.P_CUSTOM_INTERNAL_ENTITIES, m);
        }
        */

        if (f.isPropertySupported(WstxInputProperties.P_DTD_RESOLVER)) {
            f.setProperty(WstxInputProperties.P_DTD_RESOLVER,
                          new TestResolver2());
        }
        if (f.isPropertySupported(WstxInputProperties.P_ENTITY_RESOLVER)) {
            f.setProperty(WstxInputProperties.P_ENTITY_RESOLVER,
                          new TestResolver2());
        }

        /* Uncomment for boundary-condition stress tests; should be ok to
         * use some fairly small (but not tiny) number...
         */
        if (f.isPropertySupported(WstxInputProperties.P_INPUT_BUFFER_LENGTH)) {
            f.setProperty(WstxInputProperties.P_INPUT_BUFFER_LENGTH,
                          new Integer(32));
        }

        /*
        if (f.isPropertySupported(WstxInputProperties.P_TEXT_BUFFER_LENGTH)) {
            f.setProperty(WstxInputProperties.P_TEXT_BUFFER_LENGTH,
                          new Integer(17));
        }
        */

        f.setProperty(WstxInputProperties.P_INPUT_PARSING_MODE,
                      //WstxInputProperties.PARSING_MODE_FRAGMENT
                      //WstxInputProperties.PARSING_MODE_DOCUMENTS
                      WstxInputProperties.PARSING_MODE_DOCUMENT
                      );

View Full Code Here

    }

    protected int test(File file)
        throws Exception
    {
        XMLInputFactory2 f = getFactory();


        System.out.print("Coalesce: "+f.getProperty(XMLInputFactory.IS_COALESCING));
        System.out.println("NS-aware: "+f.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE));
        System.out.print("Entity-expanding: "+f.getProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES));
        System.out.println("Validating: "+f.getProperty(XMLInputFactory.IS_VALIDATING));
        System.out.println("Xml-id support: "+f.getProperty(XMLInputFactory2.XSP_SUPPORT_XMLID));

        /*
        if (f.isPropertySupported(WstxInputProperties.P_BASE_URL)) {
            f.setProperty(WstxInputProperties.P_BASE_URL, file.toURL());
        }
        */

        int total = 0;
        XMLStreamReader2 sr;

        // Let's deal with gzipped files too?
        if (file.getName().endsWith(".gz")) {
            System.out.println("[gzipped input file!]");
            sr = (XMLStreamReader2) f.createXMLStreamReader
                (new InputStreamReader(new GZIPInputStream
                                       (new FileInputStream(file)), "UTF-8"));
        } else {
            sr = (XMLStreamReader2) f.createXMLStreamReader(file);
            //sr = (XMLStreamReader2) f.createXMLStreamReader(new StreamSource(file));
        }

        int type = sr.getEventType();

View Full Code Here

    private TestValidation() {
    }

    protected XMLInputFactory2 getFactory()
    {
        XMLInputFactory2 f = super.getFactory();

        f.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.TRUE);
        f.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.TRUE);

        // Usually we don't care about full stress testing...
        if (f.isPropertySupported(WstxInputProperties.P_INPUT_BUFFER_LENGTH)) {
            f.setProperty(WstxInputProperties.P_INPUT_BUFFER_LENGTH,
                          new Integer(2000));
        }

        return f;
    }
View Full Code Here

    }

    protected int test3(byte[] bdata, char[] cdata, File file)
        throws Exception
    {
        XMLInputFactory2 f = (XMLInputFactory2) mInputFactory;
        XMLStreamReader2 sr;

        /*
        if (bdata != null) {
            sr = (XMLStreamReader2) f.createXMLStreamReader
                (new ByteArrayInputStream(bdata)
                 //,"ISO-8859-1"
                 //,"UTF-8"
                 );
        } else {
            sr = (XMLStreamReader2) f.createXMLStreamReader(new CharArrayReader(cdata));
        }
        */
        sr = (XMLStreamReader2) f.createXMLStreamReader(file);

        int result = 0;

        while (sr.hasNext()) {
            int type = sr.next();
View Full Code Here

    private XMLStreamReader2 getReader(String contents,
                                      boolean xmlidEnabled,
                                      boolean nsAware, boolean coal)
        throws XMLStreamException
    {
        XMLInputFactory2 f = getInputFactory();
        setSupportDTD(f, true);
        setValidating(f, false);
        setCoalescing(f, coal);
        setNamespaceAware(f, nsAware);
        f.setProperty(XMLInputFactory2.XSP_SUPPORT_XMLID,
                      xmlidEnabled
                      ? XMLInputFactory2.XSP_V_XMLID_TYPING
                      : XMLInputFactory2.XSP_V_XMLID_NONE);
        return constructStreamReader(f, contents);
    }
View Full Code Here

    private XMLStreamReader2 getValidatingReader(String contents,
                                                boolean nsAware, boolean coal)
        throws XMLStreamException
    {
        XMLInputFactory2 f = getInputFactory();
        setSupportDTD(f, true);
        setValidating(f, true);
        setCoalescing(f, coal);
        setNamespaceAware(f, nsAware);
        f.setProperty(XMLInputFactory2.XSP_SUPPORT_XMLID,
                      XMLInputFactory2.XSP_V_XMLID_TYPING);
        return constructStreamReader(f, contents);
    }
View Full Code Here

    private static String getName(XMLStreamReader2 xmlr) {
        return xmlr.getName().toString();
    }

    private static XMLInputFactory2 createFactory() {
        XMLInputFactory2 xmlif = (XMLInputFactory2) XMLInputFactory2.newInstance();
        xmlif.configureForConvenience();
        return xmlif;
    }
View Full Code Here

TOP

Related Classes of org.codehaus.stax2.XMLInputFactory2

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.