List of usage examples for javax.xml.stream XMLStreamWriter writeAttribute
public void writeAttribute(String localName, String value) throws XMLStreamException;
From source file:Main.java
/** * Adds the provided object id to the {@code XMLStreamWriter} that has been provided.<br> The object id is * added as the attribute "objid"./* w w w. j a v a 2 s . c om*/ * * @param writer The {@code XMLStreamWriter} object to add the attribute to. * @param objId The object id to add. * @throws XMLStreamException Thrown in case of an xml stream error. */ public static void addObjectId(final XMLStreamWriter writer, final String objId) throws XMLStreamException { writer.writeAttribute("objid", objId); }
From source file:gdv.xport.util.HtmlFormatter.java
private static void writeTo(final XMLStreamWriter xmlStreamWriter, final Satz satz, final int zeile) throws XMLStreamException { xmlStreamWriter.writeStartElement("div"); xmlStreamWriter.writeAttribute("class", "Satz"); if (satz instanceof Datensatz) { Datensatz datensatz = (Datensatz) satz; xmlStreamWriter.writeAttribute("title", "Satzart " + datensatz.getSatzartFeld().getInhalt() + "." + datensatz.getSparteFeld().getInhalt()); } else {/* w ww .j a va 2s . com*/ xmlStreamWriter.writeAttribute("title", "Satzart " + satz.getSatzartFeld().getInhalt()); } int n = zeile; for (Iterator<Teildatensatz> iterator = satz.getTeildatensaetze().iterator(); iterator.hasNext();) { Teildatensatz teildatensatz = iterator.next(); writeTo(xmlStreamWriter, teildatensatz, n); if (iterator.hasNext()) { xmlStreamWriter.writeCharacters("\n"); } n++; } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.flush(); }
From source file:gdv.xport.util.HtmlFormatter.java
private static void writeTo(final XMLStreamWriter xmlStreamWriter, final Teildatensatz teildatensatz, final int zeile) throws XMLStreamException { xmlStreamWriter.writeStartElement("span"); xmlStreamWriter.writeAttribute("class", "Teildatensatz"); xmlStreamWriter.writeAttribute("title", "Nr. " + teildatensatz.getNummer().getInhalt()); int endAdresse = 1; for (Iterator<Feld> iterator = teildatensatz.getFelder().iterator(); iterator.hasNext();) { Feld feld = iterator.next();//www .ja v a2 s. co m int gap = feld.getByteAdresse() - endAdresse; if (gap > 1) { Feld undefiniert = new Undefiniert(gap - 1, endAdresse + 1); writeTo(xmlStreamWriter, undefiniert, zeile); } writeTo(xmlStreamWriter, feld, zeile); endAdresse = feld.getEndAdresse(); } if (endAdresse < 256) { Feld undefiniert = new Undefiniert(256 - endAdresse, endAdresse + 1); writeTo(xmlStreamWriter, undefiniert, zeile); } xmlStreamWriter.writeEndElement(); }
From source file:com.hdsfed.cometapi.XMLHelper.java
public static XMLStreamWriter CreateTagListTuplet(XMLStreamWriter serializer, int i, String key, String value) throws XMLStreamException { if (value == null || key == null) return serializer; serializer.writeCharacters("\t"); serializer.writeStartElement("tag"); serializer.writeAttribute("id", String.valueOf(i)); serializer.writeCharacters("\n\t\t"); serializer = XMLHelper.CreateSimpleTagAndContent(serializer, "name", key); serializer.writeCharacters("\n\t\t"); serializer = XMLHelper.CreateSimpleTagAndContent(serializer, "value", value); serializer.writeCharacters("\n\t"); serializer.writeEndElement(); //end tag serializer.writeCharacters("\n"); return serializer; }
From source file:gdv.xport.util.HtmlFormatter.java
private static void writeTo(final XMLStreamWriter xmlStreamWriter, final Feld feld, final int zeile) throws XMLStreamException { String feldType = feld.getClass().getSimpleName(); xmlStreamWriter.writeStartElement("a"); xmlStreamWriter.writeAttribute("class", feldType); xmlStreamWriter.writeAttribute("title", "Byte " + feld.getByteAdresse() + "-" + feld.getEndAdresse() + ": " + feld.getBezeichnung()); xmlStreamWriter.writeAttribute("href", "#" + getAnchorFor(zeile, feld)); writeInhaltTo(xmlStreamWriter, feld); xmlStreamWriter.writeEndElement();/* w w w.j a va 2 s.c om*/ }
From source file:gdv.xport.util.HtmlFormatter.java
private static void writeDetailsTo(final XMLStreamWriter xmlStreamWriter, final Feld feld, final int zeile, final int nr) throws XMLStreamException { String typ = feld.getClass().getSimpleName(); xmlStreamWriter.writeStartElement("tr"); xmlStreamWriter.writeAttribute("class", typ); writeTagTo(xmlStreamWriter, "td", Integer.toString(nr)); xmlStreamWriter.writeStartElement("td"); xmlStreamWriter.writeStartElement("a"); xmlStreamWriter.writeAttribute("name", getAnchorFor(zeile, feld)); xmlStreamWriter.writeEndElement();//from ww w.j a v a2 s.c o m if (feld.getAnzahlBytes() == 1) { xmlStreamWriter.writeCharacters(Integer.toString(feld.getByteAdresse())); } else { xmlStreamWriter.writeCharacters(feld.getByteAdresse() + " - " + feld.getEndAdresse()); } xmlStreamWriter.writeEndElement(); writeTagTo(xmlStreamWriter, "td", feld.getBezeichnung()); writeTagTo(xmlStreamWriter, "td", typ); xmlStreamWriter.writeStartElement("td"); writeInhaltTo(xmlStreamWriter, feld); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); }
From source file:eu.scape_project.planning.xml.ProjectExportAction.java
/** * Dumps binary data to provided file. It results in an XML file with a * single element: data.//from w w w . jav a 2 s . c o m * * @param id * @param data * @param f * @param encoder * @throws IOException */ private static void writeBinaryData(int id, InputStream data, File f) throws IOException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); try { XMLStreamWriter writer = factory.createXMLStreamWriter(new FileWriter(f)); writer.writeStartDocument(PlanXMLConstants.ENCODING, "1.0"); writer.writeStartElement("data"); writer.writeAttribute("id", "" + id); Base64InputStream base64EncodingIn = new Base64InputStream(data, true, PlanXMLConstants.BASE64_LINE_LENGTH, PlanXMLConstants.BASE64_LINE_BREAK); OutputStream out = new WriterOutputStream(new XMLStreamContentWriter(writer), PlanXMLConstants.ENCODING); // read the binary data and encode it on the fly IOUtils.copy(base64EncodingIn, out); out.flush(); // all data is written - end writer.writeEndElement(); writer.writeEndDocument(); writer.flush(); writer.close(); } catch (XMLStreamException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.fiorano.openesb.application.DmiObject.java
protected static void writeAttribute(XMLStreamWriter writer, String attribute, int value) throws XMLStreamException { writer.writeAttribute(attribute, String.valueOf(value)); }
From source file:com.fiorano.openesb.application.DmiObject.java
protected static void writeAttribute(XMLStreamWriter writer, String attribute, long value) throws XMLStreamException { writer.writeAttribute(attribute, String.valueOf(value)); }
From source file:com.fiorano.openesb.application.DmiObject.java
protected static void writeAttribute(XMLStreamWriter writer, String attribute, float value) throws XMLStreamException { writer.writeAttribute(attribute, String.valueOf(value)); }