Package org.apache.xmlbeans.xml.stream

Examples of org.apache.xmlbeans.xml.stream.XMLInputStream


                "<any " + ns + " xsi:type='kindaPrime'>100</any>",
                null, null );

        // Make sure the unvalidated stream is OK

        XMLInputStream xis = x.newXMLInputStream();

        while ( xis.hasNext() )
            xis.next();

        // Make sure the validated stream fails

        boolean blewChunks = false;

        xis =
            stl.newValidatingXMLInputStream(
                x.newXMLInputStream(), null, null );

        try
        {
            while ( xis.hasNext() )
                xis.next();
        }
        catch ( XMLStreamValidationException e )
        {
            blewChunks = true;
        }
View Full Code Here


    private void doXmlStreamTest ( String xml )
        throws Exception
    {
        XmlCursor c = XmlObject.Factory.parse( xml ).newCursor();
        XMLInputStream xmlStream = c.newXMLInputStream();
        XmlObject o = XmlObject.Factory.parse( xmlStream );
        Assert.assertTrue( o.xmlText().equals( xml ) );
    }
View Full Code Here

       
        c.insertElement( "bar", "bar.com" );
       
        c.toStartDoc();

        XMLInputStream xis = c.newXMLInputStream();

        XMLEvent xev;
        StartDocument startDocument;
        EndDocument endDocument;
        StartElement startElement;
        AttributeIterator attributeIterator;
        StartPrefixMapping startPrefixMapping;
        EndPrefixMapping endPrefixMapping;
        ChangePrefixMapping cpm;
        EndElement endElement;
        Attribute attribute;
        Comment comment;
        CharacterData characterData;
        XMLName name;
        String str;
        Map map;
       
        xev = startDocument = (StartDocument) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.START_DOCUMENT );
        Assert.assertTrue( !xev.hasName() );
        Assert.assertTrue( startDocument.isStartDocument() );
       
        xev = startPrefixMapping = (StartPrefixMapping) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.START_PREFIX_MAPPING );
        Assert.assertTrue( !xev.hasName() );
        Assert.assertTrue( xev.isStartPrefixMapping() );
        str = startPrefixMapping.getNamespaceUri();
        Assert.assertTrue( str.equals( "default.com" ) );
        Assert.assertTrue( startPrefixMapping.getPrefix().length() == 0 );
       
        xev = startElement = (StartElement) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.START_ELEMENT );
        Assert.assertTrue( xev.hasName() );
        Assert.assertTrue( xev.isStartElement() );
        assertName( startElement.getName(), "default.com", "foo", null );
        attributeIterator = startElement.getAttributes();
        attribute = attributeIterator.next();
        assertName( attribute.getName(), null, "x", null );
        Assert.assertTrue( attribute.getValue().equals( "y" ) );
        Assert.assertTrue( attributeIterator.next() == null );
        attributeIterator = startElement.getNamespaces();
        attribute = attributeIterator.next();
        assertName( attribute.getName(), null, "xmlns", null );
        Assert.assertTrue( attribute.getValue().equals( "default.com" ) );
        Assert.assertTrue( attributeIterator.next() == null );
        attributeIterator = startElement.getAttributesAndNamespaces();
        Assert.assertTrue( attributeIterator.next() != null );
        Assert.assertTrue( attributeIterator.next() != null );
        Assert.assertTrue( attributeIterator.next() == null );
        name = new XmlNameImpl( null, "x", null );
        attribute = startElement.getAttributeByName( name );
        Assert.assertTrue( attribute != null );
        Assert.assertTrue( attribute.getValue().equals( "y" ) );
        name = new XmlNameImpl( null, "xmlns", null );
        attribute = startElement.getAttributeByName( name );
        Assert.assertTrue( attribute == null );
        str = startElement.getNamespaceUri( null );
        Assert.assertTrue( str.equals( "default.com" ) );

        xev = startPrefixMapping = (StartPrefixMapping) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.START_PREFIX_MAPPING );
        Assert.assertTrue( !xev.hasName() );
        Assert.assertTrue( xev.isStartPrefixMapping() );
        str = startPrefixMapping.getNamespaceUri();
        Assert.assertTrue( str.equals( "bar.com" ) );
        Assert.assertTrue( startPrefixMapping.getPrefix().equals( "bar" ) );
       
        xev = startElement = (StartElement) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.START_ELEMENT );
        Assert.assertTrue( xev.hasName() );
        Assert.assertTrue( xev.isStartElement() );
        assertName( startElement.getName(), "bar.com", "bar", "bar" );
        attributeIterator = startElement.getAttributes();
        Assert.assertTrue( attributeIterator.next() == null );
        attributeIterator = startElement.getNamespaces();
        attribute = attributeIterator.next();
        assertName( attribute.getName(), null, "bar", "xmlns" );
        Assert.assertTrue( attribute.getValue().equals( "bar.com" ) );
        Assert.assertTrue( attributeIterator.next() == null );
        attributeIterator = startElement.getAttributesAndNamespaces();
        Assert.assertTrue( attributeIterator.next() != null );
        Assert.assertTrue( attributeIterator.next() == null );
        str = startElement.getNamespaceUri( "bar" );
        Assert.assertTrue( str.equals( "bar.com" ) );
        map = startElement.getNamespaceMap();
        Assert.assertTrue( map.get( "bar" ).equals( "bar.com" ) );
       
        xev = endElement = (EndElement) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.END_ELEMENT );
        Assert.assertTrue( xev.hasName() );
        Assert.assertTrue( xev.isEndElement() );
        assertName( endElement.getName(), "bar.com", "bar", "bar" );

        xev = endPrefixMapping = (EndPrefixMapping) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.END_PREFIX_MAPPING );
        Assert.assertTrue( !xev.hasName() );
        Assert.assertTrue( xev.isEndPrefixMapping() );
        Assert.assertTrue( endPrefixMapping.getPrefix().equals( "bar" ) );

        xev = comment = (Comment) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.COMMENT );
        Assert.assertTrue( !xev.hasName() );
        Assert.assertTrue( comment.hasContent() );
        Assert.assertTrue( comment.getContent().equals( " x " ) );
       
        xev = characterData = (CharacterData) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.CHARACTER_DATA );
        Assert.assertTrue( !xev.hasName() );
        Assert.assertTrue( xev.isCharacterData() );
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "bar" ) );

        xev = endElement = (EndElement) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.END_ELEMENT );
        Assert.assertTrue( xev.hasName() );
        Assert.assertTrue( xev.isEndElement() );
        assertName( endElement.getName(), "default.com", "foo", null );

        xev = cpm = (ChangePrefixMapping) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.CHANGE_PREFIX_MAPPING );
        Assert.assertTrue( !xev.hasName() );
        Assert.assertTrue( xev.isChangePrefixMapping() );
        Assert.assertTrue( cpm.getPrefix().length() == 0 );
        Assert.assertTrue( cpm.getOldNamespaceUri().equals( "default.com" ) );
        Assert.assertTrue( cpm.getNewNamespaceUri().equals( "" ) );

        xev = endDocument = (EndDocument) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.END_DOCUMENT );
        Assert.assertTrue( !xev.hasName() );
        Assert.assertTrue( xev.isEndDocument() );
       
        xev = xis.next();
        Assert.assertTrue( xev == null );

        //
        // Test ChangePrefixMapping event
        //

        o = XmlObject.Factory.parse( "<foo xmlns:x=\"y\"><bar xmlns:x=\"z\"/></foo>" );
        c = o.newCursor();
        xis = c.newXMLInputStream();
       
        startDocument = (StartDocument) xis.next();
       
        startPrefixMapping = (StartPrefixMapping) xis.next();
        str = startPrefixMapping.getNamespaceUri();
        Assert.assertTrue( str.equals( "y" ) );
        Assert.assertTrue( startPrefixMapping.getPrefix().equals( "x" ) );
       
        startElement = (StartElement) xis.next();

        startPrefixMapping = (StartPrefixMapping) xis.next();
        str = startPrefixMapping.getNamespaceUri();
        Assert.assertTrue( str.equals( "z" ) );
        Assert.assertTrue( startPrefixMapping.getPrefix().equals( "x" ) );
       
        startElement = (StartElement) xis.next();
       
        endElement = (EndElement) xis.next();

        cpm = (ChangePrefixMapping) xis.next();
        str = cpm.getOldNamespaceUri();
        Assert.assertTrue( str.equals( "z" ) );
        str = cpm.getNewNamespaceUri();
        Assert.assertTrue( str.equals( "y" ) );
        str = cpm.getPrefix();
        Assert.assertTrue( str.equals( "x" ) );

        endElement = (EndElement) xis.next();
       
        endPrefixMapping = (EndPrefixMapping) xis.next();
        Assert.assertTrue( endPrefixMapping.getPrefix().equals( "x" ) );

        endDocument = (EndDocument) xis.next();
       
        xev = xis.next();
        Assert.assertTrue( xev == null );

        //
        // Test CharacterData events
        //

        o = XmlObject.Factory.parse( "<foo>a<bar>b<baz>c</baz>d</bar>e</foo>" );
        c = o.newCursor();
        xis = c.newXMLInputStream();
       
        startDocument = (StartDocument) xis.next();

        startElement = (StartElement) xis.next();

        characterData = (CharacterData) xis.next();
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "a" ) );

        startElement = (StartElement) xis.next();
       
        characterData = (CharacterData) xis.next();
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "b" ) );

        startElement = (StartElement) xis.next();
       
        characterData = (CharacterData) xis.next();
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "c" ) );

        endElement = (EndElement) xis.next();
       
        characterData = (CharacterData) xis.next();
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "d" ) );

        endElement = (EndElement) xis.next();

        characterData = (CharacterData) xis.next();
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "e" ) );

        endElement = (EndElement) xis.next();
       
        endDocument = (EndDocument) xis.next();
       
        xev = xis.next();
        Assert.assertTrue( xev == null );

        //
        // Test SubStreams
        //

        o = XmlObject.Factory.parse( "<foo>a<bar>b<baz>c</baz>d</bar>e</foo>" );
        c = o.newCursor();
        xis = c.newXMLInputStream();
       
        startDocument = (StartDocument) xis.next();

        startElement = (StartElement) xis.next();

        characterData = (CharacterData) xis.next();
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "a" ) );

        startElement = (StartElement) xis.next();
       
        characterData = (CharacterData) xis.next();
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "b" ) );

            XMLInputStream xis2 = xis.getSubStream();

        startElement = (StartElement) xis.next();
       
        characterData = (CharacterData) xis.next();
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "c" ) );

        endElement = (EndElement) xis.next();
       
        characterData = (CharacterData) xis.next();
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "d" ) );

            startElement = (StartElement) xis2.next();

            characterData = (CharacterData) xis2.next();
            Assert.assertTrue( characterData.hasContent() );
            Assert.assertTrue( characterData.getContent().equals( "c" ) );

            endElement = (EndElement) xis2.next();
           
            xev = xis2.next();
            Assert.assertTrue( xev == null );
           
        endElement = (EndElement) xis.next();

        characterData = (CharacterData) xis.next();
View Full Code Here

        XmlObject x = XmlObject.Factory.parse(xml);

        // get an XMLInputStream and move to XMLEvent.START_ELEMENT for 'b'
        XmlCursor c = x.newCursor();
        XMLInputStream xis = c.newXMLInputStream();
        c.dispose();
        while (xis.hasNext() && xis.next().getType() != XMLEvent.START_ELEMENT) {
        }

        // reparse from 'b' element using an sub-XMLInputStream
        XMLInputStream xis1 = xis.getSubStream();
        XmlObject x1 = XmlObject.Factory.parse(xis1);

        // CR135193: namespaces including default are set on the 'b' child
        String expect = "<b xmlns=\"aNS\" xmlns:b=\"bNS\"><c/></b>";
        Assert.assertEquals( expect, x1.xmlText() );
View Full Code Here

    private void doXmlStreamTest ( String xml )
        throws Exception
    {
        XmlCursor c = XmlObject.Factory.parse( xml ).newCursor();
        XMLInputStream xmlStream = c.newXMLInputStream();
        XmlObject o = XmlObject.Factory.parse( xmlStream );
        Assert.assertTrue( o.xmlText().equals( xml ) );
    }
View Full Code Here

       
        c.insertElement( "bar", "bar.com" );
       
        c.toStartDoc();

        XMLInputStream xis = c.newXMLInputStream();

        XMLEvent xev;
        StartDocument startDocument;
        EndDocument endDocument;
        StartElement startElement;
        AttributeIterator attributeIterator;
        StartPrefixMapping startPrefixMapping;
        EndPrefixMapping endPrefixMapping;
        ChangePrefixMapping cpm;
        EndElement endElement;
        Attribute attribute;
        Comment comment;
        CharacterData characterData;
        XMLName name;
        String str;
        Map map;
       
        xev = startDocument = (StartDocument) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.START_DOCUMENT );
        Assert.assertTrue( !xev.hasName() );
        Assert.assertTrue( startDocument.isStartDocument() );
       
        xev = startPrefixMapping = (StartPrefixMapping) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.START_PREFIX_MAPPING );
        Assert.assertTrue( !xev.hasName() );
        Assert.assertTrue( xev.isStartPrefixMapping() );
        str = startPrefixMapping.getNamespaceUri();
        Assert.assertTrue( str.equals( "default.com" ) );
        Assert.assertTrue( startPrefixMapping.getPrefix().length() == 0 );
       
        xev = startElement = (StartElement) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.START_ELEMENT );
        Assert.assertTrue( xev.hasName() );
        Assert.assertTrue( xev.isStartElement() );
        assertName( startElement.getName(), "default.com", "foo", null );
        attributeIterator = startElement.getAttributes();
        attribute = attributeIterator.next();
        assertName( attribute.getName(), null, "x", null );
        Assert.assertTrue( attribute.getValue().equals( "y" ) );
        Assert.assertTrue( attributeIterator.next() == null );
        attributeIterator = startElement.getNamespaces();
        attribute = attributeIterator.next();
        assertName( attribute.getName(), null, "xmlns", null );
        Assert.assertTrue( attribute.getValue().equals( "default.com" ) );
        Assert.assertTrue( attributeIterator.next() == null );
        attributeIterator = startElement.getAttributesAndNamespaces();
        Assert.assertTrue( attributeIterator.next() != null );
        Assert.assertTrue( attributeIterator.next() != null );
        Assert.assertTrue( attributeIterator.next() == null );
        name = new XmlNameImpl( null, "x", null );
        attribute = startElement.getAttributeByName( name );
        Assert.assertTrue( attribute != null );
        Assert.assertTrue( attribute.getValue().equals( "y" ) );
        name = new XmlNameImpl( null, "xmlns", null );
        attribute = startElement.getAttributeByName( name );
        Assert.assertTrue( attribute == null );
        str = startElement.getNamespaceUri( null );
        Assert.assertTrue( str.equals( "default.com" ) );

        xev = startPrefixMapping = (StartPrefixMapping) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.START_PREFIX_MAPPING );
        Assert.assertTrue( !xev.hasName() );
        Assert.assertTrue( xev.isStartPrefixMapping() );
        str = startPrefixMapping.getNamespaceUri();
        Assert.assertTrue( str.equals( "bar.com" ) );
        Assert.assertTrue( startPrefixMapping.getPrefix().equals( "bar" ) );
       
        xev = startElement = (StartElement) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.START_ELEMENT );
        Assert.assertTrue( xev.hasName() );
        Assert.assertTrue( xev.isStartElement() );
        assertName( startElement.getName(), "bar.com", "bar", "bar" );
        attributeIterator = startElement.getAttributes();
        Assert.assertTrue( attributeIterator.next() == null );
        attributeIterator = startElement.getNamespaces();
        attribute = attributeIterator.next();
        assertName( attribute.getName(), null, "bar", "xmlns" );
        Assert.assertTrue( attribute.getValue().equals( "bar.com" ) );
        Assert.assertTrue( attributeIterator.next() == null );
        attributeIterator = startElement.getAttributesAndNamespaces();
        Assert.assertTrue( attributeIterator.next() != null );
        Assert.assertTrue( attributeIterator.next() == null );
        str = startElement.getNamespaceUri( "bar" );
        Assert.assertTrue( str.equals( "bar.com" ) );
        map = startElement.getNamespaceMap();
        Assert.assertTrue( map.get( "bar" ).equals( "bar.com" ) );
       
        xev = endElement = (EndElement) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.END_ELEMENT );
        Assert.assertTrue( xev.hasName() );
        Assert.assertTrue( xev.isEndElement() );
        assertName( endElement.getName(), "bar.com", "bar", "bar" );

        xev = endPrefixMapping = (EndPrefixMapping) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.END_PREFIX_MAPPING );
        Assert.assertTrue( !xev.hasName() );
        Assert.assertTrue( xev.isEndPrefixMapping() );
        Assert.assertTrue( endPrefixMapping.getPrefix().equals( "bar" ) );

        xev = comment = (Comment) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.COMMENT );
        Assert.assertTrue( !xev.hasName() );
        Assert.assertTrue( comment.hasContent() );
        Assert.assertTrue( comment.getContent().equals( " x " ) );
       
        xev = characterData = (CharacterData) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.CHARACTER_DATA );
        Assert.assertTrue( !xev.hasName() );
        Assert.assertTrue( xev.isCharacterData() );
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "bar" ) );

        xev = endElement = (EndElement) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.END_ELEMENT );
        Assert.assertTrue( xev.hasName() );
        Assert.assertTrue( xev.isEndElement() );
        assertName( endElement.getName(), "default.com", "foo", null );

        xev = cpm = (ChangePrefixMapping) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.CHANGE_PREFIX_MAPPING );
        Assert.assertTrue( !xev.hasName() );
        Assert.assertTrue( xev.isChangePrefixMapping() );
        Assert.assertTrue( cpm.getPrefix().length() == 0 );
        Assert.assertTrue( cpm.getOldNamespaceUri().equals( "default.com" ) );
        Assert.assertTrue( cpm.getNewNamespaceUri().equals( "" ) );

        xev = endDocument = (EndDocument) xis.next();
        Assert.assertTrue( xev.getType() == XMLEvent.END_DOCUMENT );
        Assert.assertTrue( !xev.hasName() );
        Assert.assertTrue( xev.isEndDocument() );
       
        xev = xis.next();
        Assert.assertTrue( xev == null );

        //
        // Test ChangePrefixMapping event
        //

        o = XmlObject.Factory.parse( "<foo xmlns:x=\"y\"><bar xmlns:x=\"z\"/></foo>" );
        c = o.newCursor();
        xis = c.newXMLInputStream();
       
        startDocument = (StartDocument) xis.next();
       
        startPrefixMapping = (StartPrefixMapping) xis.next();
        str = startPrefixMapping.getNamespaceUri();
        Assert.assertTrue( str.equals( "y" ) );
        Assert.assertTrue( startPrefixMapping.getPrefix().equals( "x" ) );
       
        startElement = (StartElement) xis.next();

        startPrefixMapping = (StartPrefixMapping) xis.next();
        str = startPrefixMapping.getNamespaceUri();
        Assert.assertTrue( str.equals( "z" ) );
        Assert.assertTrue( startPrefixMapping.getPrefix().equals( "x" ) );
       
        startElement = (StartElement) xis.next();
       
        endElement = (EndElement) xis.next();

        cpm = (ChangePrefixMapping) xis.next();
        str = cpm.getOldNamespaceUri();
        Assert.assertTrue( str.equals( "z" ) );
        str = cpm.getNewNamespaceUri();
        Assert.assertTrue( str.equals( "y" ) );
        str = cpm.getPrefix();
        Assert.assertTrue( str.equals( "x" ) );

        endElement = (EndElement) xis.next();
       
        endPrefixMapping = (EndPrefixMapping) xis.next();
        Assert.assertTrue( endPrefixMapping.getPrefix().equals( "x" ) );

        endDocument = (EndDocument) xis.next();
       
        xev = xis.next();
        Assert.assertTrue( xev == null );

        //
        // Test CharacterData events
        //

        o = XmlObject.Factory.parse( "<foo>a<bar>b<baz>c</baz>d</bar>e</foo>" );
        c = o.newCursor();
        xis = c.newXMLInputStream();
       
        startDocument = (StartDocument) xis.next();

        startElement = (StartElement) xis.next();

        characterData = (CharacterData) xis.next();
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "a" ) );

        startElement = (StartElement) xis.next();
       
        characterData = (CharacterData) xis.next();
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "b" ) );

        startElement = (StartElement) xis.next();
       
        characterData = (CharacterData) xis.next();
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "c" ) );

        endElement = (EndElement) xis.next();
       
        characterData = (CharacterData) xis.next();
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "d" ) );

        endElement = (EndElement) xis.next();

        characterData = (CharacterData) xis.next();
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "e" ) );

        endElement = (EndElement) xis.next();
       
        endDocument = (EndDocument) xis.next();
       
        xev = xis.next();
        Assert.assertTrue( xev == null );

        //
        // Test SubStreams
        //

        o = XmlObject.Factory.parse( "<foo>a<bar>b<baz>c</baz>d</bar>e</foo>" );
        c = o.newCursor();
        xis = c.newXMLInputStream();
       
        startDocument = (StartDocument) xis.next();

        startElement = (StartElement) xis.next();

        characterData = (CharacterData) xis.next();
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "a" ) );

        startElement = (StartElement) xis.next();
       
        characterData = (CharacterData) xis.next();
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "b" ) );

            XMLInputStream xis2 = xis.getSubStream();

        startElement = (StartElement) xis.next();
       
        characterData = (CharacterData) xis.next();
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "c" ) );

        endElement = (EndElement) xis.next();
       
        characterData = (CharacterData) xis.next();
        Assert.assertTrue( characterData.hasContent() );
        Assert.assertTrue( characterData.getContent().equals( "d" ) );

            startElement = (StartElement) xis2.next();

            characterData = (CharacterData) xis2.next();
            Assert.assertTrue( characterData.hasContent() );
            Assert.assertTrue( characterData.getContent().equals( "c" ) );

            endElement = (EndElement) xis2.next();
           
            xev = xis2.next();
            Assert.assertTrue( xev == null );
           
        endElement = (EndElement) xis.next();

        characterData = (CharacterData) xis.next();
View Full Code Here

        XmlObject x = XmlObject.Factory.parse(xml);

        // get an XMLInputStream and move to XMLEvent.START_ELEMENT for 'b'
        XmlCursor c = x.newCursor();
        XMLInputStream xis = c.newXMLInputStream();
        c.dispose();
        while (xis.hasNext() && xis.next().getType() != XMLEvent.START_ELEMENT) {
        }

        // reparse from 'b' element using an sub-XMLInputStream
        XMLInputStream xis1 = xis.getSubStream();
        XmlObject x1 = XmlObject.Factory.parse(xis1);

        // CR135193: namespaces including default are set on the 'b' child
        String expect = "<b xmlns=\"aNS\" xmlns:b=\"bNS\"><c/></b>";
        Assert.assertEquals( expect, x1.xmlText() );
View Full Code Here

                "<any " + ns + " xsi:type='kindaPrime'>100</any>",
                null, null );

        // Make sure the unvalidated stream is OK

        XMLInputStream xis = x.newXMLInputStream();

        while ( xis.hasNext() )
            xis.next();

        // Make sure the validated stream fails

        boolean blewChunks = false;

        xis =
            stl.newValidatingXMLInputStream(
                x.newXMLInputStream(), null, null );

        try
        {
            while ( xis.hasNext() )
                xis.next();
        }
        catch ( XMLStreamValidationException e )
        {
            blewChunks = true;
        }
View Full Code Here

    private void xmlInputStream ( ) throws Exception
    {
        if (rnd( 5 ) != 0)
            return;
       
        XMLInputStream xis;
       
        try
        {
            xis = getCursor().newXMLInputStream();
        }
        catch ( IllegalStateException e )
        {
            return;
        }

        while ( xis.next() != null )
            ;
    }
View Full Code Here

            reader2 = new FileReader(args[0]);
        }

        System.out.println("reader ...");
        XmlStreamSource source = new XppXmlStreamImpl(reader1);
        XMLInputStream myStream = XmlStreamFactory.
                createXmlInputStream( source );

        XMLInputStream babelStream = XMLInputStreamFactory.newInstance().
            newInputStream(reader2);

        System.out.println("myStream ...");
        for(int i=0; myStream.hasNext() && i<3; i++)
        {
            System.out.println( "my: " + myStream.hasNext() + " '" +
                myStream.next() + "'");
            System.out.println( "bb: " + babelStream.hasNext() + " '" +
                    babelStream.next() + "'");
        }

        XMLInputStream myss = myStream.getSubStream();
        XMLInputStream bbss = babelStream.getSubStream();

        for(int i=0; (myss.hasNext() || bbss.hasNext()) && i<3; i++)
        {
            System.out.println( "my SUBStream: " + myss.hasNext() + " '" +
                    myss.next() + "'");
            System.out.println( "bb SUBStream: " + bbss.hasNext() + " '" +
                    bbss.next() + "'");
        }

        XMLInputStream myss2 = myss.getSubStream();
        XMLInputStream bbss2 = myss.getSubStream();
        for(; myss2.hasNext() || bbss2.hasNext() ;)
        {
            System.out.println( "my SubSUBStream 2: " + myss2.hasNext() +
                    " '" + myss2.next() + "'");
            System.out.println( "bb SubSUBStream 2: " + bbss2.hasNext() +
                    " '" + bbss2.next() + "'");
        }
        myss2.close();
        bbss2.close();

        for(; myss.hasNext() || bbss.hasNext() ;)
        {
            System.out.println( "my SUBStream: " + myss.hasNext() + " '" +
                    myss.next() + "'");
View Full Code Here

TOP

Related Classes of org.apache.xmlbeans.xml.stream.XMLInputStream

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.