Example usage for javax.xml.stream XMLStreamWriter writeStartElement

List of usage examples for javax.xml.stream XMLStreamWriter writeStartElement

Introduction

In this page you can find the example usage for javax.xml.stream XMLStreamWriter writeStartElement.

Prototype

public void writeStartElement(String localName) throws XMLStreamException;

Source Link

Document

Writes a start tag to the output.

Usage

From source file:de.qucosa.webapi.v1.RelationResource.java

private void writeRelationElement(List<Tuple<String>> tuples, XMLStreamWriter w, String name, String type)
        throws XMLStreamException {
    for (Tuple<String> t : tuples) {
        w.writeStartElement(name);

        w.writeStartElement("DocumentId");
        w.writeCharacters(t.get(0));/*from ww  w  . jav a2s .  c o m*/
        w.writeEndElement();

        w.writeStartElement("Value");
        w.writeCharacters(t.get(1));
        w.writeEndElement();

        w.writeStartElement("Relation");
        w.writeCharacters(type);
        w.writeEndElement();

        w.writeStartElement("TitleMain");
        w.writeCharacters(t.get(2));
        w.writeEndElement();

        w.writeEmptyElement("Label");
        w.writeEmptyElement("SortOrder");
        w.writeEmptyElement("Issue");

        w.writeEndElement();
    }
}

From source file:de.shadowhunt.subversion.internal.CommitMessageOperation.java

@Override
protected HttpUriRequest createRequest() {
    final Writer body = new StringBuilderWriter();
    try {//from w  ww. j a  va2 s.  c om
        final XMLStreamWriter writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(body);
        writer.writeStartDocument(XmlConstants.ENCODING, XmlConstants.VERSION_1_0);
        writer.writeStartElement("propertyupdate");
        writer.writeDefaultNamespace(XmlConstants.DAV_NAMESPACE);
        writer.writeStartElement("set");
        writer.writeStartElement("prop");
        writer.setPrefix(XmlConstants.SUBVERSION_DAV_PREFIX, XmlConstants.SUBVERSION_DAV_NAMESPACE);
        writer.writeStartElement(XmlConstants.SUBVERSION_DAV_NAMESPACE, "log");
        writer.writeNamespace(XmlConstants.SUBVERSION_DAV_PREFIX, XmlConstants.SUBVERSION_DAV_NAMESPACE);
        writer.writeCharacters(message);
        writer.writeEndElement(); // log
        writer.writeEndElement(); // prop
        writer.writeEndElement(); // set
        writer.writeEndElement(); // propertyupdate
        writer.writeEndDocument();
        writer.close();
    } catch (final XMLStreamException e) {
        throw new SubversionException("could not create request body", e);
    }

    final URI uri = URIUtils.createURI(repository, resource);
    final DavTemplateRequest request = new DavTemplateRequest("PROPPATCH", uri);
    request.setEntity(new StringEntity(body.toString(), CONTENT_TYPE_XML));
    return request;
}

From source file:de.shadowhunt.subversion.internal.LockOperation.java

@Override
protected HttpUriRequest createRequest() {
    final URI uri = URIUtils.createURI(repository, resource);
    final DavTemplateRequest request = new DavTemplateRequest("LOCK", uri);
    if (steal) {//ww  w  .  j a v  a 2  s  .  c  o  m
        request.addHeader("X-SVN-Options", "lock-steal");
    }

    final Writer body = new StringBuilderWriter();
    try {
        final XMLStreamWriter writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(body);
        writer.writeStartDocument(XmlConstants.ENCODING, XmlConstants.VERSION_1_0);
        writer.writeStartElement("lockinfo");
        writer.writeDefaultNamespace(XmlConstants.DAV_NAMESPACE);
        writer.writeStartElement("lockscope");
        writer.writeEmptyElement("exclusive");
        writer.writeEndElement(); // lockscope
        writer.writeStartElement("locktype");
        writer.writeEmptyElement("write");
        writer.writeEndElement(); // locktype
        writer.writeEndElement(); //lockinfo
        writer.writeEndDocument();
        writer.close();
    } catch (final XMLStreamException e) {
        throw new SubversionException("could not create request body", e);
    }

    request.setEntity(new StringEntity(body.toString(), CONTENT_TYPE_XML));
    return request;
}

From source file:com.norconex.collector.core.filter.impl.RegexMetadataFilter.java

@Override
public void saveToXML(Writer out) throws IOException {
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    try {//w  w w . j a  v  a2 s . co  m
        XMLStreamWriter writer = factory.createXMLStreamWriter(out);
        writer.writeStartElement("filter");
        writer.writeAttribute("class", getClass().getCanonicalName());
        super.saveToXML(writer);
        writer.writeAttribute("caseSensitive", Boolean.toString(caseSensitive));
        writer.writeAttribute("field", field);
        writer.writeCharacters(regex == null ? "" : regex);
        writer.writeEndElement();
        writer.flush();
        writer.close();
    } catch (XMLStreamException e) {
        throw new IOException("Cannot save as XML.", e);
    }
}

From source file:com.predic8.membrane.core.interceptor.balancer.Node.java

@Override
public void write(XMLStreamWriter out) throws XMLStreamException {

    out.writeStartElement("node");

    out.writeAttribute("host", host);
    out.writeAttribute("port", "" + port);

    out.writeEndElement();//from w w  w  . ja v  a 2s  .  c o  m
}

From source file:com.norconex.collector.http.robot.impl.DefaultRobotsMetaProvider.java

@Override
public void saveToXML(Writer out) throws IOException {
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    try {/*  w w  w.j a va 2s  .  c om*/
        XMLStreamWriter writer = factory.createXMLStreamWriter(out);
        writer.writeStartElement("robotsMeta");
        writer.writeAttribute("class", getClass().getCanonicalName());
        writer.writeStartElement("headersPrefix");
        if (headersPrefix != null) {
            writer.writeCharacters(headersPrefix);
        }
        writer.writeEndElement();
        writer.writeEndElement();
        writer.flush();
        writer.close();
    } catch (XMLStreamException e) {
        throw new IOException("Cannot save as XML.", e);
    }
}

From source file:com.norconex.collector.http.fetch.impl.DefaultDocumentFetcher.java

@Override
public void saveToXML(Writer out) throws IOException {
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    try {//  w w w .j  av  a  2  s  . c o m
        XMLStreamWriter writer = factory.createXMLStreamWriter(out);
        writer.writeStartElement("httpDocumentFetcher");
        writer.writeAttribute("class", getClass().getCanonicalName());
        writer.writeStartElement("validStatusCodes");
        if (validStatusCodes != null) {
            writer.writeCharacters(StringUtils.join(validStatusCodes));
        }
        writer.writeEndElement();
        writer.writeStartElement("headersPrefix");
        if (headersPrefix != null) {
            writer.writeCharacters(headersPrefix);
        }
        writer.writeEndElement();
        writer.writeEndElement();
        writer.writeEndElement();
        writer.flush();
        writer.close();
    } catch (XMLStreamException e) {
        throw new IOException("Cannot save as XML.", e);
    }
}

From source file:com.norconex.jef4.log.FileLogManager.java

@Override
public void saveToXML(Writer out) throws IOException {
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    try {//w  w  w.  ja  v a  2 s .c  o  m
        XMLStreamWriter writer = factory.createXMLStreamWriter(out);
        writer.writeStartElement("logManager");
        writer.writeAttribute("class", getClass().getCanonicalName());
        writer.writeStartElement("logDir");
        writer.writeCharacters(new File(logdir).getAbsolutePath());
        writer.writeEndElement();
        writer.writeEndElement();
        writer.flush();
        writer.close();
    } catch (XMLStreamException e) {
        throw new IOException("Cannot save as XML.", e);
    }
}

From source file:de.shadowhunt.subversion.internal.ResolveOperation.java

@Override
protected HttpUriRequest createRequest() {
    final Writer body = new StringBuilderWriter();
    try {//from  www.j ava 2s  . c om
        final XMLStreamWriter writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(body);
        writer.writeStartDocument(XmlConstants.ENCODING, XmlConstants.VERSION_1_0);
        writer.writeStartElement("get-locations");
        writer.writeDefaultNamespace(XmlConstants.SVN_NAMESPACE);
        writer.writeEmptyElement("path");
        writer.writeStartElement("peg-revision");
        writer.writeCharacters(revision.toString());
        writer.writeEndElement(); // peg-revision
        writer.writeStartElement("location-revision");
        writer.writeCharacters(expected.toString());
        writer.writeEndElement(); // location-revision
        writer.writeEndElement(); //get-locations
        writer.writeEndDocument();
        writer.close();
    } catch (final XMLStreamException e) {
        throw new SubversionException("could not create request body", e);
    }

    final URI uri = URIUtils.createURI(repository, resource);
    final DavTemplateRequest request = new DavTemplateRequest("REPORT", uri);
    request.setEntity(new StringEntity(body.toString(), CONTENT_TYPE_XML));
    return request;
}