Questions tagged [xmlstreamwriter]

The XMLStreamWriter interface specifies how to write XML.

The XMLStreamWriter interface specifies how to write XML.

The XMLStreamWriter does not perform well formedness checking on its input. However the writeCharacters method is required to escape & , < and > For attribute values the writeAttribute method will escape the above characters plus " to ensure that all character content and attribute values are well formed. Each NAMESPACE and ATTRIBUTE must be individually written. If javax.xml.stream.isPrefixDefaulting is set to false it is a fatal error if an element is written with namespace URI that has not been bound to a prefix. If javax.xml.stream.isPrefixDefaulting is set to true the XMLStreamWriter implementation must write a prefix for each unbound URI that it encounters in the current scope.

Reference: http://docs.oracle.com/javaee/5/api/javax/xml/stream/XMLStreamWriter.html

22 questions
5
votes
2 answers

Instancing XMLStreamWriterFactory failed: unsupported property isRepairingNamespaces

In our application we encounter very sporadic run time exceptions which crash our message processors (which are stand-alone java processes running on Java 8). The processors, at the time of this exception, generally try to execute a web service…
fgysin
  • 11,329
  • 13
  • 61
  • 94
3
votes
0 answers

XMLEventWriter throws javax.xml.stream.XMLStreamException: No open start element, when trying to write end element even though opened

I have a application JSON -> XML converter. This application will take a List of events that are converted to XML one by one. Before conversion, the header for the final XML will be created using the start method, and later converted events are…
BATMAN_2008
  • 2,788
  • 3
  • 31
  • 98
2
votes
0 answers

XMLStreamWriter does not convert "\n" to " " when writing attributes

I am trying to write an XML file using XMLStreamWriter. The problem is that I have an attribute value with "\r\n". Since I am using an XML writer, I was expecting the writer to escape "\n" to and "\r" to , but that does not happen. That…
1
vote
1 answer

XMLStreamWriter write tag containing colon

When I use colon in the tag name like in the example below, it ends up in error (there is no problem with tags without the colon). package test; import java.io.StringReader; import java.io.StringWriter; import…
qraqatit
  • 492
  • 4
  • 14
1
vote
0 answers

Not able to add a XMLStreamWriter variable in execution context of spring batch

I am trying to pass XMLStreamWriter instance to other steps in spring batch. I am doing this via adding the variable in executionContext of a job like this: XMLStreamWriter xmlWriter =…
1
vote
0 answers

How to write " instead of " to XML output with XMLStreamWriter/IndentingXMLStreamWriter

I'm writing data to xml files using com.sun.xml.txw2.output.IndentingXMLStreamWriter: OutputStream os = new FileOutputStream(pOutputFile); XMLOutputFactory xmlof = XMLOutputFactory.newInstance(); XMLStreamWriter xsw = new…
PdM
  • 74
  • 1
  • 7
1
vote
1 answer

Adding standalone=no field to XML declaration using XMLStreamWriter

I'm currently using XMLStreamWriter to parse together an XML document. The only parameters that I'm allowed to pass in are "encoding" and "version", but I would like to have "standalone=no" in the declaration, as well. Here's what my output…
Jason Tu
  • 59
  • 1
  • 1
  • 7
1
vote
0 answers

How to write into CDATA without escape characters

We have a CDataInterceptor in order to include a signed XML file into a soap envelope in a CDATA section. But when we are executing the code we are getting the XML escaped, like & lt;CDATA instead of <[CDATA or & #xd; when a new line. This makes…
user1748166
  • 147
  • 1
  • 2
  • 14
1
vote
0 answers

How to Print the DataHandler Content for SOAP Request

I have the object of "javax.activation.DataHandler.DataHandler" and i saw that it has been added to SOAP request using the below command org.apache.axiom.util.stax.XMLStreamWriterUtils.writeDataHandler() I want to get the content from DataHandler,…
rbhawsar
  • 805
  • 7
  • 25
0
votes
0 answers

XMLStreamWriter writeAttribute method throws exception when a colon ':' is included in the attribute name

I am getting exception "Invalid name character ':' (code 58)) in name ("xmlns:xsi"), index #5" for the following statement. If I'm doing this wrong, what is the correct syntax to get the output like:…
Arun
  • 39
  • 1
  • 3
  • 9
0
votes
1 answer

How to add XML elements from List into XMLEventWriter? Append XML to already created XMLEventWriter/XmlStreamWriter

I have a List which contains the XML events created as a part of the output from the JAXB Marshaling approach. After completion of the JAXB Marshaling process this List can contain large amounts of XML. These XML fragments so are…
BATMAN_2008
  • 2,788
  • 3
  • 31
  • 98
0
votes
1 answer

StAX Parser creates an empty XML file

I'm learning parsers in Java and now I'm trying to write a code for XML-file creation using StAX Parser and XMLStreamWriter and StringWriter. But I forced with a problem that my parser creates an empty XML-file. I think the problem is in using…
Silentdog
  • 11
  • 1
  • 3
0
votes
1 answer

Is it possible to specify the behavior of EOL when using XMLOutputFactory?

I like to write an xml Elem to a file, but I want to set the line separator between each node of the elem, so when opening the file under windows or ubuntu I have the correct format. for example : val lineSep = System.getProperty("line.separator")…
med10
  • 101
  • 7
0
votes
0 answers

XMLStreamReader/Writer, sending/receiving multiply XML files. The processing instruction target matching "[xX][mM][lL]" is not allowed

i'm learning java course and stuck at this problem: trying to make client-server communication protocol based on XML (using XMLStreamReader/Writer) server: import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamConstants; import…
0
votes
1 answer

XMLStreamWriter - Issue writing long string to xml writer

I am working on a gradle project that involves reading from and writing to xml files. I've come across an issue while trying to write a very long string of escaped xml to a file using XMLStreamWriter. This string ends up taking around half an hour…
DarthRitis
  • 352
  • 2
  • 10
1
2