xml one record per line in c++ - c++

I am writing a large xml file in C++. What i need is the capability to construct dom trees of records in chunks and flush the chunks to disk. So for example,
-----------chunk create-----
<record>data<record>
<record>data<record>
<record>data<record>
<record>data<record>
-----------chunk flush--------
Also, a single line should contain one full record as shown above. what i dont want is printing in format shown below
<record>
data
</record>
Which library would allow both the above functionality?

may be you can try TinyXML : http://sourceforge.net/projects/tinyxml/

i use RapidXml.

Related

Qt5.5 XML processing using QDom

I'm using the QDom classes to process an XML file, I want the attributes to be processed in the order they are defined in the XML file, this is important. However it seems the order of the attributes in the 'QDomNamedNodeMap' is different.
Is there any way to ensure the order is as defined in the XML file?
As far as I know, you can't rely on order of attributes in XML, by specifications. This could be the reason your library read them in a different order that the literal one. Even if you find a way, you should not trust it: what about if someone else generates the XML to feed your program? See here more about the specifications.
Maybe a change in the design can help you: what about nesting some nodes? Nesting nodes sequence is deterministic.
I've written my own classes that read the file and process the nodes and attributes, as per my requirement the attributes are kept in the same order they are presented in the file.

Execute XSLT on an XML-Schema rather than an XML document

I know that the input of an XSLT processor is a source XML document that will be transformed into a target XML document.
In my case, I haven't a source XML document but I have a source XML-SCHEMA and I want to know through the XSLT document information about the mappings between the source XML-SCHEMA and the target one.
Thus, I have the idea of executing or maybe parsing the XSLT on the source XML-SCHEMA in order to get this information.
I'm really confused about the difference between execute and parse an XSLT document.
I think that to execute an XSLT document, an XSLT processor firstly parses it to transform it to another internal representation.
What is this internal representation??
I really need your help
I'm really confused about the difference between execute and parse an
XSLT document.
To parse a language, including XML, is to analyse it into parts.
To execute a language, including XSLT, is to perform the instructions specified by the language.
It does not make sense to talk about executing XML because XML itself specifies no instruction.
It does make sense to talk about validating XML against the grammar given by its XSD.
I think that to execute an XSLT document, an XSLT processor firstly
parses it to transform it to another internal representation. What is
this internal representation??
You do not need to know an XSLT processor's internal representation because that is an implementation detail.
You do need to know that an XSLT processor parses an input XML document, executes an XSLT transformation, and generates output. (It also parses the XML that represents the XSLT, but that's beside the point.)
The input XML document typically is not an XSD. You might want to consider the XSD associated with the input XML document in order to anticipate allowed input variations. In rare circumstances you might want to transform the XSD itself in some way, and you can do so since an XSD is represented in XML. In other rare circumstances, you might want to transform XSLT itself in some way, and you can do so since XSLT is also represented in XML. But, normally, the input to an XSLT transformation is a mundane XML document instance, not an XSD, and not other XSLT.

Modify XML File in C++

I want to modify an XML file which has a very complicated structure something like
<root>
<a></a>
<b></b>
<c></c>
<d>
<e>text</e>
<f>text</f>
<d>
<d>
....
</root>
I tried to use tinyxml and it is good but there are some comments in the source xml file that I want to keep so I thought may be dealing with the file as mere text can be a good idea, however the string functions in c++ are crippling me because I'll have to search and replace, any ideas?
Note:There are no attributes in the XML, just values between the tags.
I don't know if using a third party library is off the table for parsing but I've been using this XSD parser which allows you to serialize XML files to memory. You are then free to edit and/or read the values at their node locations and then write the file back out.
This, to me, at least, is significantly simpler than generating a custom parser for each type of XML input.

Fastest way of parsing XML files for specified Tags using the Qt Framework

As far es I know there a 4 ways of parsing XML files using C++ with Qt.
QDom
QSax
QXMLStreamReader
QXMLQuery
I search in my file for a node with a specific attribute, if I've found it, I abort the parsing save the file name to a list and parse the next file.
I accomplished that using QDom, but since i search up to 10k files with each about 400lines. it takes some time to parse them all.
My question is whether anyone of you knows about the performance of this different approaches?
Or if you have any tips to improve the performance of such a program?
I appreciate any information!
I think, if you don't get tree structure from your xml files, use QXMLStremReader.
QXmlStreamReader is the fastest and easiest way to read XML in Qt.
Because the parser works incrementally, it is particularly useful for
finding all occurrences of a given tag in an XML document, for reading
very large files that may not fit in memory, and for populating custom
data structures to reflect an XML document's contents.

what is the best way to write xslt -fo out of xsl+xml

i have complex xslt that formats xml to html
now i need to be able to create xsl fo out of it
what is the best way to do it ?
Here is some ineresting article for you
http://www-128.ibm.com/developerworks/library/x-xslfo2app/
Also you can try next library (I dont't remember, probably it can creat fo files from xslt+xml):
http://www.codeproject.com/KB/dotnet/nfop.aspx
I had a similar requirement, and I did some research, but didn't find a reliable XHTML to FO transformer. There may be one, but there comes a point in some web searches when you have to give up and roll your own.
Instead I took the XML to HTML transformer I had already written and changed it to output FO.
This is a much simpler proposition that a full blown XHTML to FO transformer.
Whilst your details will differ, most structures in HTML have analogues in FO, so you can normally decide what FO construct to use in replacing HTML in your transform fairly easily.
I did this incrementally. If you start with the transform producing the outline of an FO document, and most of your XML being ignored in the transform, you can then build up the output in a measured fashion.