Package javax.xml.stream.events

Examples of javax.xml.stream.events.Attribute


   public void testEventWriter() throws Exception
   {
      ByteArrayOutputStream stream = new ByteArrayOutputStream();
      XMLEventWriter writer = XMLOutputFactory.newInstance().createXMLEventWriter(stream);
      XMLEventFactory factory = XMLEventFactory.newInstance();
      Attribute att = factory.createAttribute("some-attribute", "10");
      ArrayList list = new ArrayList();
      list.add(att);
      writer.add(factory.createStartDocument());
      writer.add(factory.createComment("hello"));
      writer.add(factory.createStartElement(new QName("root"), list.iterator(), null));
View Full Code Here


    public String getAttributeLocalName(int i)
    {

        if (replay)
        {
            Attribute att = (Attribute) ((StartElementEventX) current).getAttributeList().get(i);
            return att.getName().getLocalPart();
        }
        else
        {
            return super.getAttributeLocalName(i);
        }
View Full Code Here

    public QName getAttributeName(int i)
    {

        if (replay)
        {
            Attribute att = (Attribute) ((StartElementEventX) current).getAttributeList().get(i);
            return att.getName();
        }
        else
        {
            return super.getAttributeName(i);
        }
View Full Code Here

    public String getAttributeNamespace(int i)
    {

        if (replay)
        {
            Attribute att = (Attribute) ((StartElementEventX) current).getAttributeList().get(i);
            return att.getName().getNamespaceURI();
        }
        else
        {
            return super.getAttributeNamespace(i);
        }
View Full Code Here

    public String getAttributePrefix(int i)
    {
        if (replay)
        {
            Attribute att = (Attribute) ((StartElementEventX) current).getAttributeList().get(i);
            return att.getName().getPrefix();
        }
        else
        {
            return super.getAttributePrefix(i);
        }
View Full Code Here

    public String getAttributeType(int i)
    {
        if (replay)
        {
            Attribute att = (Attribute) ((StartElementEventX) current).getAttributeList().get(i);
            return att.getDTDType();
        }
        else
        {
            return super.getAttributeType(i);
        }
View Full Code Here

    public String getAttributeValue(int i)
    {
        if (replay)
        {
            Attribute att = (Attribute) ((StartElementEventX) current).getAttributeList().get(i);
            return att.getValue();
        }
        else
        {
            return super.getAttributeValue(i);
        }
View Full Code Here

    public String getAttributeValue(String ns, String local)
    {
        if (replay)
        {
            Attribute att = ((StartElementEventX) current).getAttributeByName(new QName(ns, local));
            if (att != null)
            {
                return att.getValue();
            }
            else
            {
                return null;
            }
View Full Code Here

    public boolean isAttributeSpecified(int i)
    {
        if (replay)
        {
            Attribute attr = (Attribute) ((StartElementEventX) current).getAttributeList().get(i);
            return attr.isSpecified();
        }
        else
        {
            return super.isAttributeSpecified(i);
        }
View Full Code Here

        // (there's a property to control that, but as far as we are concerned
        // we don't use it.) So don't add xmlns:* to attributes.

        // gather non-namespace attrs
        for (Iterator i = event.getAttributes(); i.hasNext();) {
            Attribute staxAttr = (javax.xml.stream.events.Attribute)i.next();

            String uri = staxAttr.getName().getNamespaceURI();
            if (uri == null) {
                uri = "";
            }
            String localName = staxAttr.getName().getLocalPart();
            String prefix = staxAttr.getName().getPrefix();
            String qName;
            if (prefix == null || prefix.length() == 0) {
                qName = localName;
            } else {
                qName = prefix + ':' + localName;
            }
            String type = staxAttr.getDTDType();
            String value = staxAttr.getValue();

            attrs.addAttribute(uri, localName, qName, type, value);
        }

        return attrs;
View Full Code Here

TOP

Related Classes of javax.xml.stream.events.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.