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:com.predic8.membrane.core.config.Proxy.java

@Override
public void write(XMLStreamWriter out) throws XMLStreamException {
    out.writeStartElement(ELEMENT_NAME);

    out.writeAttribute(ATTRIBUTE_ACTIVE, Boolean.toString(useProxy));

    out.writeAttribute(ATTRIBUTE_AUTHENTICATION, Boolean.toString(useAuthentication));

    new ProxyHost(proxyHost).write(out);

    new ProxyPort(Integer.toString(proxyPort)).write(out);

    new ProxyUsername(proxyUsername).write(out);

    new ProxyPassword(proxyPassword).write(out);

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

From source file:com.norconex.collector.http.sitemap.impl.StandardSitemapResolverFactory.java

@Override
public void saveToXML(Writer out) throws IOException {
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    try {/*  ww w .j  av a 2 s .c  o m*/
        XMLStreamWriter writer = factory.createXMLStreamWriter(out);
        writer.writeStartElement("sitemapResolverFactory");
        writer.writeAttribute("class", getClass().getCanonicalName());
        writer.writeAttribute("lenient", Boolean.toString(lenient));
        if (sitemapLocations != null) {
            for (String location : sitemapLocations) {
                writer.writeStartElement("location");
                writer.writeCharacters(location);
                writer.writeEndElement();
            }
        }
        writer.writeEndElement();
        writer.flush();
        writer.close();
    } catch (XMLStreamException e) {
        throw new IOException("Cannot save as XML.", e);
    }
}

From source file:com.norconex.committer.gsa.GsaCommitter.java

@Override
protected void saveToXML(XMLStreamWriter writer) throws XMLStreamException {
    writer.writeStartElement("feedUrl");
    writer.writeCharacters(getFeedUrl());
    writer.writeEndElement();/*from   ww  w .j a  v  a2 s .c om*/
}

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

@Override
public void saveToXML(Writer out) throws IOException {
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    try {/*w w w.j  a v  a 2s .  c o  m*/
        XMLStreamWriter writer = factory.createXMLStreamWriter(out);
        writer.writeStartElement("httpHeadersFetcher");
        writer.writeAttribute("class", getClass().getCanonicalName());
        writer.writeStartElement("validStatusCodes");
        writer.writeCharacters(StringUtils.join(validStatusCodes, ","));
        writer.writeEndElement();
        writer.writeStartElement("headersPrefix");
        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.flexive.extractor.audio.FxAudioMetaDataImpl.java

/**
 * {@inheritDoc}/*w  w  w  .j  av a  2 s .c  om*/
 */
@Override
protected void writeXMLTags(XMLStreamWriter writer) throws XMLStreamException {
    // remaining audio data (sample rate, etc): FxMetadataItems
    writer.writeStartElement("audioData");
    writeSimpleTag(writer, "length", getLengthAsTimeString(), false);
    writeSimpleTag(writer, "durationmicros", getLength(), false);
    writer.writeEndElement();
}

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

@Override
public void saveToXML(Writer out) throws IOException {
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    try {//from   w  w  w . j  a  v  a  2 s.c o m
        XMLStreamWriter writer = factory.createXMLStreamWriter(out);
        writer.writeStartElement("filter");
        writer.writeAttribute("class", getClass().getCanonicalName());
        super.saveToXML(writer);
        writer.writeAttribute("caseSensitive", Boolean.toString(caseSensitive));
        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:de.qucosa.webapi.v1.RelationResource.java

@RequestMapping(value = "/relation/urn/{URN}", method = RequestMethod.GET)
public ResponseEntity<String> describeRelationships(@PathVariable String URN)
        throws XMLStreamException, IOException, FedoraClientException {
    String pid = fedoraRepository.getPIDByIdentifier(URN);
    List<Tuple<String>> constituentPredecessorPids = fedoraRepository.getPredecessorPIDs(pid,
            FedoraRepository.RELATION_CONSTITUENT);
    List<Tuple<String>> derivativePredecessorPIDs = fedoraRepository.getPredecessorPIDs(pid,
            FedoraRepository.RELATION_DERIVATIVE);
    List<Tuple<String>> constituentSuccessorPids = fedoraRepository.getSuccessorPIDs(pid,
            FedoraRepository.RELATION_CONSTITUENT);
    List<Tuple<String>> derivativeSuccessorPids = fedoraRepository.getSuccessorPIDs(pid,
            FedoraRepository.RELATION_DERIVATIVE);

    XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newFactory();
    StringWriter sw = new StringWriter();
    XMLStreamWriter w = xmlOutputFactory.createXMLStreamWriter(sw);
    w.writeStartDocument("UTF-8", "1.0");
    w.writeStartElement("Opus");
    w.writeStartElement("Opus_Document");
    w.writeStartElement("DocumentId");
    w.writeCharacters(stripPrefix(pid));
    w.writeEndElement();//from w w  w .  j  a  v a2s  .c  o  m
    w.writeStartElement("Relations");
    writeRelationElement(constituentPredecessorPids, w, "PredecessorRelation", "journal");
    writeRelationElement(derivativePredecessorPIDs, w, "PredecessorRelation", "predecessor");
    writeRelationElement(constituentSuccessorPids, w, "SuccessorRelation", "issue");
    writeRelationElement(derivativeSuccessorPids, w, "SuccessorRelation", "predecessor");
    w.writeEndElement();
    w.writeEndElement();
    w.writeEndElement();
    w.writeEndDocument();
    w.flush();

    return new ResponseEntity<>(sw.toString(), HttpStatus.OK);
}

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

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

From source file:com.norconex.committer.core.impl.MultiCommitter.java

@Override
public void saveToXML(Writer out) throws IOException {
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    try {/*from  w  w w .  j a va2s  .com*/
        XMLStreamWriter writer = factory.createXMLStreamWriter(out);
        writer.writeStartElement("committer");
        writer.writeAttribute("class", getClass().getCanonicalName());
        for (ICommitter committer : committers) {
            writer.flush();
            if (!(committer instanceof IXMLConfigurable)) {
                LOG.error("Cannot save committer to XML as it does not " + "implement IXMLConfigurable: "
                        + committer);
            }
            ((IXMLConfigurable) committer).saveToXML(out);
        }
        writer.writeEndElement();
        writer.flush();
        writer.close();
    } catch (XMLStreamException e) {
        throw new IOException("Cannot save as XML.", e);
    }
}

From source file:de.shadowhunt.subversion.internal.httpv1.CheckoutOperation.java

@Override
protected HttpUriRequest createRequest() {
    final Writer body = new StringBuilderWriter();
    try {//from  w  w w.  j  a  v a  2s. co m
        final XMLStreamWriter writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(body);
        writer.writeStartDocument(XmlConstants.ENCODING, XmlConstants.VERSION_1_0);
        writer.writeStartElement("checkout");
        writer.writeDefaultNamespace(XmlConstants.DAV_NAMESPACE);
        writer.writeStartElement("activity-set");
        writer.writeStartElement("href");
        final URI transactionURI = URIUtils.createURI(repository, transaction);
        writer.writeCData(transactionURI.toString());
        writer.writeEndElement(); // href
        writer.writeEndElement(); // activity-set
        writer.writeEmptyElement("apply-to-version");
        writer.writeEndElement(); //checkout
        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("CHECKOUT", uri);
    request.setEntity(new StringEntity(body.toString(), CONTENT_TYPE_XML));
    return request;
}