Package org.codehaus.stax2

Examples of org.codehaus.stax2.XMLStreamReader2


                }
                return;
               
            case DTD:
                {
                    DTDInfo info = sr.getDTDInfo();
                    if (info == null) {
                        // Hmmmh. It is legal for this to happen, for
                        // non-DTD-aware readers. But what is the right
                        // thing to do here?
                        throwOutputError("Current state DOCTYPE, but not DTDInfo Object returned -- reader doesn't support DTDs?");
View Full Code Here


                    char c = (text.length() == 0) ? ' ': text.charAt(text.length()-1);
                    if (c != '\r' && c != '\n') {
                        System.out.println();
                    }
                } else if (type == DTD) {
                    DTDInfo info = sr.getDTDInfo();
                    System.out.println(" DTD (root "
                                       +getNullOrStr(info.getDTDRootName())
                                       +", sysid "+getNullOrStr(info.getDTDSystemId())
                                       +", pubid "+getNullOrStr(info.getDTDPublicId())
                                       +");");
                    List<?> entities = (List<?>) sr.getProperty("javax.xml.stream.entities");
                    List<?> notations = (List<?>) sr.getProperty("javax.xml.stream.notations");
                    int entCount = (entities == null) ? -1 : entities.size();
                    int notCount = (notations == null) ? -1 : notations.size();
View Full Code Here

            +"<!NOTATION not PUBLIC 'some-public-id'>\n"
            +"]>"
            +"<root/>";
 
        // Need to disable coalescing though for test to work:
        XMLEventReader2 er = getReader(XML, false);
        // Need to set Base URI; can do it for factory or instance
        er.setProperty(WstxInputProperties.P_BASE_URL, new URL(URI));
        assertTrue(er.nextEvent().isStartDocument());
        XMLEvent evt = er.nextEvent(); // DTD
        assertTokenType(DTD, evt.getEventType());

        DTD dtd = (DTD) evt;
        List<?> nots = dtd.getNotations();
        assertEquals(1, nots.size());
View Full Code Here

    ///////////////////////////////////////////////////////////////////////
    */
   
    XMLStreamReader2 getReader(String contents) throws XMLStreamException
    {
        XMLInputFactory2 f = getInputFactory();
        setValidating(f, false);
        return constructStreamReader(f, contents);
    }
View Full Code Here

  public void testWsdlValidation() throws Exception {
    String runMe = System.getProperty("testWsdlValidation");
    if (runMe == null || "".equals(runMe)) {
      return;
    }
    XMLInputFactory2 factory = getInputFactory();
    XMLStreamReader2 reader = (XMLStreamReader2) factory.createXMLStreamReader(getClass().getResourceAsStream("test-message.xml"), "utf-8");
    QName msgQName = new QName("http://server.hw.demo/", "sayHi");
    while (true) {
      int what = reader.nextTag();
      if (what == XMLStreamConstants.START_ELEMENT) {
        if (reader.getName().equals(msgQName)) {
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 XMLStreamReader2 getReader(String contents, boolean nsAware)
        throws XMLStreamException
    {
        XMLInputFactory2 f = getInputFactory();
        setCoalescing(f, true);
        setSupportDTD(f, true);
        setNamespaceAware(f, nsAware);
        setValidating(f, false);
        return constructStreamReader(f, contents);
View Full Code Here

        sw.writeEmptyElement("root");
        sw.writeEndDocument();
        sw.close();

        // plus let's read and check it
        XMLInputFactory2 inf = getInputFactory();
        XMLStreamReader sr = inf.createXMLStreamReader(tmpF);
        assertTokenType(START_ELEMENT, sr.next());
        assertTokenType(END_ELEMENT, sr.next());
        sr.close();
    }
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.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(XMLInputFactory2.P_LAZY_PARSING, Boolean.FALSE);

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

TOP

Related Classes of org.codehaus.stax2.XMLStreamReader2

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.