Package javax.xml.stream

Examples of javax.xml.stream.XMLEventFactory.createAttribute()


            writer.add(event);
            final XMLEventFactory eventFactory = XMLEventFactory.newInstance();
            for (final Tag tag : toAdd.get(start.getName().getLocalPart())) {
              List<Attribute> attrs = new ArrayList<Attribute>();
              for (final AttributeEntry entry : tag) {
                attrs.add(eventFactory.createAttribute(entry.getKey(), entry.getValue()));
              }
              StartElement newStart = eventFactory.createStartElement(QName.valueOf(tag.getName()), attrs.iterator(),
                      null);
              EndElement newEnd = eventFactory.createEndElement(newStart.getName(), null);
View Full Code Here


   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

        eventWriter.add(end);
       
        ArrayList<Namespace> ns = new ArrayList<Namespace>();
       
        ArrayList<Attribute> atts = new ArrayList<Attribute>();
        atts.add(eventFactory.createAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"));
        atts.add(eventFactory.createAttribute("xsi:schemaLocation", "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"));
        atts.add(eventFactory.createAttribute("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9"));
        StartElement urlSetStartElement = eventFactory.createStartElement("", "", "urlset", atts.iterator(), ns.iterator());
       
        eventWriter.add(urlSetStartElement);
View Full Code Here

       
        ArrayList<Namespace> ns = new ArrayList<Namespace>();
       
        ArrayList<Attribute> atts = new ArrayList<Attribute>();
        atts.add(eventFactory.createAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"));
        atts.add(eventFactory.createAttribute("xsi:schemaLocation", "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"));
        atts.add(eventFactory.createAttribute("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9"));
        StartElement urlSetStartElement = eventFactory.createStartElement("", "", "urlset", atts.iterator(), ns.iterator());
       
        eventWriter.add(urlSetStartElement);
        eventWriter.add(end);
View Full Code Here

        ArrayList<Namespace> ns = new ArrayList<Namespace>();
       
        ArrayList<Attribute> atts = new ArrayList<Attribute>();
        atts.add(eventFactory.createAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"));
        atts.add(eventFactory.createAttribute("xsi:schemaLocation", "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"));
        atts.add(eventFactory.createAttribute("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9"));
        StartElement urlSetStartElement = eventFactory.createStartElement("", "", "urlset", atts.iterator(), ns.iterator());
       
        eventWriter.add(urlSetStartElement);
        eventWriter.add(end);
        findFiles(request, getServletConfig().getServletContext(), eventWriter);
View Full Code Here

      final StartElement startElement = _event.asStartElement();
      if (startElement.getName().equals( XMLConstants.Manifest.FILE_ENTRY )) {
        final Attribute fullPathAttribute = startElement.getAttributeByName( XMLConstants.Manifest.FULL_PATH );
        if (fullPathAttribute != null && "/".equals( fullPathAttribute.getValue() )) {
          final XMLEventFactory xmlEventFactory = XMLEventFactory.newInstance();
          final Attribute mediaTypeAttribute = xmlEventFactory.createAttribute( XMLConstants.Manifest.MEDIA_TYPE, OpenDocumentSpreadsheetSaver.MIME_TYPE );
          final List<Attribute> attributes = Arrays.asList( mediaTypeAttribute, fullPathAttribute );
          final StartElement newStartElement = xmlEventFactory.createStartElement( XMLConstants.Manifest.FILE_ENTRY, attributes.iterator(), null );
          super.process( newStartElement );
          return;
        }
View Full Code Here

        Pipeline<StAXPipelineComponent> pipe = new NonCachingPipeline<StAXPipelineComponent>();
        pipe.addComponent(new XMLGenerator(input));
        XMLEventFactory factory = XMLEventFactory.newInstance();
        List<Attribute> atts = new ArrayList<Attribute>();
        atts.add(factory.createAttribute("attribute", "bad"));
        StartEndElementPairModificationTransformer modifier = new StartEndElementPairModificationTransformer(
                "anyelement", atts, "somethingdifferent", new ArrayList<Attribute>());
        pipe.addComponent(modifier);
        pipe.addComponent(new XMLSerializer());
        pipe.setup(out);
View Full Code Here

        Pipeline<StAXPipelineComponent> pipe = new NonCachingPipeline<StAXPipelineComponent>();
        pipe.addComponent(new XMLGenerator(input));
        XMLEventFactory factory = XMLEventFactory.newInstance();
        List<Attribute> atts = new ArrayList<Attribute>();
        atts.add(factory.createAttribute("attribute", "bad"));
        atts.add(factory.createAttribute("attribute", "good"));
        StartEndElementPairModificationTransformer modifier = new StartEndElementPairModificationTransformer(
                "anyelement", atts, "somethingdifferent", new ArrayList<Attribute>());
        pipe.addComponent(modifier);
        pipe.addComponent(new XMLSerializer());
View Full Code Here

        Pipeline<StAXPipelineComponent> pipe = new NonCachingPipeline<StAXPipelineComponent>();
        pipe.addComponent(new XMLGenerator(input));
        XMLEventFactory factory = XMLEventFactory.newInstance();
        List<Attribute> atts = new ArrayList<Attribute>();
        atts.add(factory.createAttribute("attribute", "bad"));
        atts.add(factory.createAttribute("attribute", "good"));
        StartEndElementPairModificationTransformer modifier = new StartEndElementPairModificationTransformer(
                "anyelement", atts, "somethingdifferent", new ArrayList<Attribute>());
        pipe.addComponent(modifier);
        pipe.addComponent(new XMLSerializer());
        pipe.setup(out);
View Full Code Here

        Pipeline<StAXPipelineComponent> pipe = new NonCachingPipeline<StAXPipelineComponent>();
        pipe.addComponent(new XMLGenerator(input));
        XMLEventFactory factory = XMLEventFactory.newInstance();
        List<Attribute> atts = new ArrayList<Attribute>();
        atts.add(factory.createAttribute("attribute", "bad"));
        StartEndElementPairModificationTransformer modifier = new StartEndElementPairModificationTransformer(
                "anyelement", atts, "somethingdifferent", new ArrayList<Attribute>());
        pipe.addComponent(modifier);
        pipe.addComponent(new XMLSerializer());
        pipe.setup(out);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.