Package org.apache.xmlbeans.xml.stream

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


               
                AttributeIterator attrs = se.getAttributes();

                while ( attrs.hasNext() )
                {
                    Attribute attr = attrs.next();

                    XMLName attrName = attr.getName();

                    if ("http://www.w3.org/2001/XMLSchema-instance".equals(
                            attrName.getNamespaceUri() ))
                    {
                        String local = attrName.getLocalName();

                        if (local.equals( "type" ))
                            _xsiType = attr.getValue();
                        else if (local.equals( "nil" ))
                            _xsiNil = attr.getValue();
                        else if (local.equals( "schemaLocation" ))
                            _xsiLoc = attr.getValue();
                        else if (local.equals( "noNamespaceSchemaLocation" ))
                            _xsiNoLoc = attr.getValue();
                    }
                }

                // Emit the START

                // TODO - should delay the aquisition of the name
                _name = e.getName();

                nextEvent( ValidatorListener.BEGIN );
               
                // Emit the attrs
               
                attrs = se.getAttributes();

                while ( attrs.hasNext() )
                {
                    Attribute attr = attrs.next();

                    XMLName attrName = attr.getName();

                    if ("http://www.w3.org/2001/XMLSchema-instance".equals(
                            attrName.getNamespaceUri() ))
                    {
                        String local = attrName.getLocalName();

                        if (local.equals( "type" ))
                            continue;
                        else if (local.equals( "nil" ))
                            continue;
                        else if (local.equals( "schemaLocation" ))
                            continue;
                        else if (local.equals( "noNamespaceSchemaLocation" ))
                            continue;
                    }

                    // TODO - God, this is lame :-)

                    _text.append( attr.getValue() );
                    _name = attr.getName();
                   
                    nextEvent( ValidatorListener.ATTR );
                }

                clearText();
View Full Code Here


                    context.lineNumberAnnotation( xe );

                for ( AttributeIterator ai = ((StartElement) xe).getAttributes()
                      ; ai.hasNext() ; )
                {
                    Attribute attr = ai.next();

                    context.attr(
                        XMLNameHelper.getQName( attr.getName() ),
                        attr.getValue() );
                }

                for ( AttributeIterator ai = ((StartElement) xe).getNamespaces()
                      ; ai.hasNext() ; )
                {
                    Attribute attr = ai.next();

                    XMLName name = attr.getName();
                    String local = name.getLocalName();

                    if (name.getPrefix() == null && local.equals( "xmlns" ))
                        local = "";

                    context.xmlns( local, attr.getValue() );
                }

                break;

            case XMLEvent.END_ELEMENT :
View Full Code Here

        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" );
View Full Code Here

               
                AttributeIterator attrs = se.getAttributes();

                while ( attrs.hasNext() )
                {
                    Attribute attr = attrs.next();

                    XMLName attrName = attr.getName();

                    if ("http://www.w3.org/2001/XMLSchema-instance".equals(
                            attrName.getNamespaceUri() ))
                    {
                        String local = attrName.getLocalName();

                        if (local.equals( "type" ))
                            _xsiType = attr.getValue();
                        else if (local.equals( "nil" ))
                            _xsiNil = attr.getValue();
                        else if (local.equals( "schemaLocation" ))
                            _xsiLoc = attr.getValue();
                        else if (local.equals( "noNamespaceSchemaLocation" ))
                            _xsiNoLoc = attr.getValue();
                    }
                }

                // Emit the START

                // TODO - should delay the aquisition of the name
                _name = e.getName();

                nextEvent( ValidatorListener.BEGIN );
               
                // Emit the attrs
               
                attrs = se.getAttributes();

                while ( attrs.hasNext() )
                {
                    Attribute attr = attrs.next();

                    XMLName attrName = attr.getName();

                    if ("http://www.w3.org/2001/XMLSchema-instance".equals(
                            attrName.getNamespaceUri() ))
                    {
                        String local = attrName.getLocalName();

                        if (local.equals( "type" ))
                            continue;
                        else if (local.equals( "nil" ))
                            continue;
                        else if (local.equals( "schemaLocation" ))
                            continue;
                        else if (local.equals( "noNamespaceSchemaLocation" ))
                            continue;
                    }

                    // TODO - God, this is lame :-)

                    _text.append( attr.getValue() );
                    _name = attr.getName();
                   
                    nextEvent( ValidatorListener.ATTR );
                }

                clearText();
View Full Code Here

                if (lineNums)
                    lineNumber( xe, context );

                for ( AttributeIterator ai = ((StartElement) xe).getAttributes() ; ai.hasNext() ; )
                {
                    Attribute attr = ai.next();

                    context.attr(
                        XMLNameHelper.getQName( attr.getName() ),
                        attr.getValue() );
                }

                for ( AttributeIterator ai = ((StartElement) xe).getNamespaces()
                      ; ai.hasNext() ; )
                {
                    Attribute attr = ai.next();

                    XMLName name = attr.getName();
                    String local = name.getLocalName();

                    if (name.getPrefix() == null && local.equals( "xmlns" ))
                        local = "";

                    context.xmlns( local, attr.getValue() );
                }

                break;

            case XMLEvent.END_ELEMENT :
View Full Code Here

TOP

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

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.