stax

Parsing multiple XML fragments with STaX

本小妞迷上赌 提交于 2019-12-06 01:24:07
I was hoping the following would be parseable in StAX, <something a="b"/> <something a="b"/> But it chokes when you reach the second element. As there is no common root element. (I'm not too sure why a pull parser cares about this particular issue... anyway...) I can fake a root element, e.g. Guava: InputSupplier<Reader> join = CharStreams.join( newReaderSupplier("<root>"), newReaderSupplier(new File("...")), newReaderSupplier("</root>")); XMLInputFactory xif = XMLInputFactory.newInstance(); XMLStreamReader xsr = xif.createXMLStreamReader(join.getInput()); xsr.nextTag(); // Skip the fake root

Can a part of XML be marshalled using JAXB (or JAXB + StAX)?

≡放荡痞女 提交于 2019-12-05 14:40:16
I have an XML structure which is very huge. I want to update the parts of this XML, by unmarshalling one element and then applying business logic. I am able to unmarshal a child element into a POJO. I want to make changes to this POJO in Java and then update it back to the XML at the same location. Is this possible in JAXB? Or by using the combination of JAXB + StAX. Example Structure : <folder id="c5718b36-bab1-4c08-8f75-8e2f9aee42c5" name="Folder-1"> <description> folder Desc</description> <createdBy>User2</createdBy> <hidden>false</hidden> <file id="4f2efb42-0604-4878-9e1e-ae90d66fb836"

StAX XML all content between two required tags

无人久伴 提交于 2019-12-05 03:29:37
Starting learning the StAX, using XMLStreamReader, I faced with some problem. How can I get ALL content between tags as Text? I mean, I know name of needed tag, and when I find it, I must go to the close tag, and everything I found between them I must append at some string. For example, we have something like <rootTag> ... <someTag> Some text content and other tags here… </someTag > <tagINeed> <someinternalTag1> <someinternalTag11> Some text content.. </someinternalTag11> ... </someinternalTag1> <someinternalTag2> Something here </someinternalTag2> </tagINeed> ... <somethingAnother> ... <

Do I need stax-api-1.0.x in my web app when using JDK 1.6?

风格不统一 提交于 2019-12-04 18:03:54
问题 I am currently developing a web app that uses Jersey for REST. I use maven, and both stax-api-1.0.1 and 1.0.2 are pulled into my web-inf/lib. I thought the stax api were a aprt of JDK1.6? Why are those JARS included in my web application? Here is my pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion>

Spring Batch Stax XML reading job is not ending when out of input

…衆ロ難τιáo~ 提交于 2019-12-04 16:42:38
I'm using Spring Batch to set up a job that will process a potentially very large XML file. I think I've set it up appropriately, but at runtime I'm finding that the job runs, processes its input, and then just hangs in an executing state (I can confirm by viewing the JobExecution's status in the JobRepository). I've read through the Batch documentation several times but I don't see any obvious "make the job stop when out of input" configuration that I'm missing. Here's the relevant portion of my application context: <batch:job id="processPartnerUploads" restartable="true"> <batch:step id=

Unable to check CDATA in XML using XMLEventReader in Stax

倖福魔咒の 提交于 2019-12-04 02:16:10
问题 I am unable to check for CDATA in XML and read it using XMLEventReader. The following is the sample: <name>HEADERS</name> <data> <![CDATA[ Sat Nov 19 18:50:15 2016 (1672822) ]]> <![CDATA[Sat, 19 Nov 2016 18:50:14 -0800 (PST) ]]> </data> The XMLEventReader of Stax api which i am using is as follows: while (eventReader.hasNext()) { XMLEvent event = eventReader.nextEvent(); if (event.isCharacters()) { System.out.println(event.asCharacters().isCData()); System.out.println(event.asCharacters()

How to catch Attribute-events with a StAX XML-parser?

左心房为你撑大大i 提交于 2019-12-03 14:44:22
I try to parse an XML file with a StAX XML-parser. It give me START_ELEMENT and END_DOCUMENT events but no ATTRIBUTE events. How can I receive ATTRIBUTE events with the StAX parser? My XML: <?xml version="1.0" encoding="utf-8"?> <posts> <row name="Jonas"/> <row name="John"/> </posts> My StAX XML-parser: public class XMLParser { public void parseFile(String filename) { XMLInputFactory2 xmlif = (XMLInputFactory2) XMLInputFactory2.newInstance(); xmlif.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE); xmlif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES,

Do I need stax-api-1.0.x in my web app when using JDK 1.6?

假如想象 提交于 2019-12-03 11:50:43
I am currently developing a web app that uses Jersey for REST. I use maven, and both stax-api-1.0.1 and 1.0.2 are pulled into my web-inf/lib. I thought the stax api were a aprt of JDK1.6? Why are those JARS included in my web application? Here is my pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.glennbech</groupId> <artifactId>simplerest</artifactId> <packaging>war</packaging> <version

which .jar file has javax.xml.stream.*?

淺唱寂寞╮ 提交于 2019-12-03 07:06:31
问题 I have problems again with my Mac running Java 1.5.... where do I get a .jar file that has javax.xml.stream.XMLInputFactory ? I want to use StAX but don't know how to get it set up right. I can't seem to get this setup. I've now downloaded jaxp-api.jar, jsr173_1.0_api.jar, sjsxp.jar, stax-api-1.0.1.jar, stax2-api-3.0.1.jar, and woodstox-core-asl-4.0.5.jar; put them all into my java/lib/ext directory, made sure they're on my eclipse build path, removed the Mac com.apple.quarantine extended

which .jar file has javax.xml.stream.*?

左心房为你撑大大i 提交于 2019-12-02 20:41:15
I have problems again with my Mac running Java 1.5.... where do I get a .jar file that has javax.xml.stream.XMLInputFactory ? I want to use StAX but don't know how to get it set up right. I can't seem to get this setup. I've now downloaded jaxp-api.jar, jsr173_1.0_api.jar, sjsxp.jar, stax-api-1.0.1.jar, stax2-api-3.0.1.jar, and woodstox-core-asl-4.0.5.jar; put them all into my java/lib/ext directory, made sure they're on my eclipse build path, removed the Mac com.apple.quarantine extended attribute, did a "chmod a+x" on the .jar files, and I still get the following error trying to import javax