stax

StAX Writer Implementation for C/C++

两盒软妹~` 提交于 2019-12-30 16:18:29
问题 Are there any other STaX Writer implementation for C/C++ except libxml2? 回答1: LLamaXML Its one of the few C++ pull parsers. 回答2: The article about STaX in Wikipedia mentiones Expat in the list of implementations. 回答3: You can look at the Genx library. 回答4: Qt has QXmlStreamWriter and QXmlStreamReader Irrlicht Engine contain IXMLWriter that use StAX model 来源: https://stackoverflow.com/questions/1693523/stax-writer-implementation-for-c-c

How to write unescaped XML to XMLStreamWriter?

心已入冬 提交于 2019-12-30 06:50:47
问题 I have a number of small XML chunks, that should be embedded in one big XML as child elements. Is there any way to write these chunks to XMLStreamWriter without escaping them? 回答1: Below are a couple of options for handling this: Option #1 - Use javax.xml.transform.Transformer You could use a javax.xml.transform.Transformer to transform a StreamSource representing your XML fragment onto your StAXResult which is wrapping your XMLStreamWriter . Option #2 - Interact Directly with the OuputStream

Reading Huge XML File using StAX and XPath

穿精又带淫゛_ 提交于 2019-12-30 03:11:07
问题 The input file contains thousands of transactions in XML format which is around 10GB of size. The requirement is to pick each transaction XML based on the user input and send it to processing system. The sample content of the file <transactions> <txn id="1"> <name> product 1</name> <price>29.99</price> </txn> <txn id="2"> <name> product 2</name> <price>59.59</price> </txn> </transactions> The (technical)user is expected to give the input tag name like <txn> . We would like to provide this

How to create Dom objects parsing an XML with Stax

一笑奈何 提交于 2019-12-25 03:54:05
问题 I have some difficulties to parse an XML using Stax in order to create org.w3c.dom.Document objects for parts of the XML tree. Ex.: <root> <children> <child>child 1</child> <child>child 2</child> <child>child 3</child> </children> </root> => I would like to create 3 DOM objects for each <child> node. I tried to do this using Staxmate and DomConverter but I have a problem ... My test project only depends on : stax2-api-3.0.3.jar staxmate-2.0.0.jar jdk 1.6.0_21 2 tests : Test 1 that works

How to add a schema location with StAX

烂漫一生 提交于 2019-12-23 08:57:10
问题 I am using StAX and I want to add a schema location to my xml file. What is the best way to achieve this? 回答1: If you use XMLStreamWriter , you can just use writeNamespace() and writeAttribute() (or just writeAttribute() ). XMLStreamWriter xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out); xmlStreamWriter.writeStartDocument(); xmlStreamWriter.writeStartElement("YourRootElement"); xmlStreamWriter.writeNamespace("xsi", "http://www.w3.org/2000/10/XMLSchema

How do I keep track of parsing progress of large files in StAX?

↘锁芯ラ 提交于 2019-12-22 17:58:08
问题 I'm processing large (1TB) XML files using the StAX API. Let's assume we have a loop handling some elements: XMLInputFactory fac = XMLInputFactory.newInstance(); XMLStreamReader reader = fac.createXMLStreamReader(new FileReader(inputFile)); while (true) { if (reader.nextTag() == XMLStreamConstants.START_ELEMENT){ // handle contents } } How do I keep track of overall progress within the large XML file? Fetching the offset from reader works fine for smaller files: int offset = reader

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

自作多情 提交于 2019-12-21 21:48:46
问题 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

Java - XML parser performance : Sun Java Streaming XML Parser (SJSXP) vs Woodstox

落花浮王杯 提交于 2019-12-21 17:03:15
问题 I am looking for latest, memory efficient and high-performance java XML parsing API. I need to parse 3 MB to 5 MB XML files. I did google on this and come to know about Sun Java Streaming XML Parser (SJSXP) and Woodstox is much faster than DOM & SAX. Both are using StAX API. *schema validation is not supported by these technologies. Aalto XML processor is also implements StAX API. I have not found concrete findings on performance on these technologies. Which one will be best in context of

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

℡╲_俬逩灬. 提交于 2019-12-21 16:53:46
问题 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>

How do I format and read XML processing instructions using Java StAX?

北城以北 提交于 2019-12-20 03:14:12
问题 First, how do I format the XML processing instruction, is it: <?processingInstructionName attribute="value" attribute2="value2"?> Using StAX, I then want to read it by handling the XMLStreamConstants.PROCESSING_INSTRUCTION (javadoc) event, but it only provides two methods to then retrieve information about the processing instruction from the XMLStreamReader : getPITarget() getPIData() The javadoc for these two methods isn't very helpful. Is the XML formatting correct? Is this the proper way