C++ tool to generate random XML files from XML Schema? - c++

I think there should be a tool to do so ? is anyone here aware of any ?
I saw other posts related to this but found none for C++, I am aware that I can do that with JAVA and C#.

If you use XML Spy or oXygen, you can generate sample XML files based on a schema. Both tools accept commandline options and can be run in batch mode so that'll probably fit in your unit tests, if that's what you're after. Wrap your own C++ code around it and you're in business.
If you need quality XML, with tons of tweakable options, you might want to check out http://www.code-generator.com/XML-Sample-Generator.aspx. No C++ here, just a tool that works, and rises beyond the default "lorem ipsum..." output.
HTH,
~Rob

Related

Force Visual C++ to generate XML comments solely for my files?

having an issue that I can't seem to find a direct answer to. I'm in the late stages of building a game engine with a few friends and at this point, we're looking to streamline the comments to make them more readable and useful for any developers that may wish to join the team. Since we use Visual Studio 2010, the embedded XML commenting seemed like the perfect tool, and it is! The only issue we are having is that the graphics library our engine is based upon seemed to have the same idea, and also uses XML-like commenting schema. Unfortunately, the syntax of whatever tool they used to compile their XML comments is dissimilar to the one used in Visual Studio so when Visual Studio attempts to render their comments to the projects XML output file, all we get is a huge string of errors that really tie up the process and are completely unneeded anyway since we only want documentation for our code. So, in short, is there some compiler parameter or option I can set in Visual Studio/VC++ that will force it to only generate an XML-comments output file for our classes and documentation? Thank you so much.
Forget Visual Studio and use a real documentation generation tool like doxygen. It handles the MS XML based documentation and you can configure it to only search certain files or directories.
EDIT Doxygen has it's own documentation tag format described here but it also handles JavaDoc style comments. XML style comments are described here.

Testing Code in iTextSharp

Is it possible to perform TDD when creating code with iTextSharp? If not, is there any kind of testing to check your outputs?
I don't have a full .Net solution for you but there is an open source Java version called JpdfUnit that may or may not be helpful. It uses Apache's PDFBox behind the scenes to do the actual PDF reading. The good news is that there is a .Net wrapper for PDFBox. You'll have to roll your own unit tests but hopefully it will be helpful. Here's a link to someone that gives a little more information on how to use PDFBox.net.
PDF is mostly a visual medium, however, so if you want to test if things "look right", you'll have to manually so that unfortunately.

Should I use XML in my c++ game

Is XML something required to use in modern games? Sense I'm trying to make game that will be programmed like a professional programmer did it, So should i use XML in my game or it is just an optional thing, Why and Why not?
There's nothing wrong with using XML if it solves your problem. There's nothing wrong with not using XML if it isn't the best option for solving your problem.
If you want to store data in an a format which is easy to query, then XML is not a bad option. If you're look for space efficiency, XML is not a good option. If you are looking for cross-platform features, XML is a no-brainer compared to binary formats.
JSON is another option which is very simple and very lightweight.
In short, it depends on your requirements. If you want more direction you'll have to give more information.
Use whatever works for you. Don't judge your tools based on whether something is considered "uncool". If it works for you and helps you create maintainable and flexible code and data, use it.
Now specifically for XML - that's definitely a format that is widely used and has libraries for virtually every platform. I've worked on a recent Xbox 360 and PlayStation 3 title that made use of XML.

Where can I find static/dynamic code analysis tools for XSLT?

Are there any static or dynamic code analysis tools that analyze XSLT/XSL code?
The resources I have been able to find so far are:
1. Oxygen xml editor
2. http://gandhimukul.tripod.com/xslt/xslquality.html which looks faily basic in its capabilities
There are quite a few testing tools and verifiers at Tony Graham's XSLT Testing Tools page. If you haven't looked there, it's a fairly comprehensive list.
Using Saxon in schema-aware mode will catch many common errors.
You've already discovered Mukul Gandhi's XSL Quality tools, which support user-added extensions. On the xsl-list run by Mulberry Technologies a while back, several other people contributed ideas for new rules also. You might also get help asking there.
Stylus Studio, Oxygen and xmlspy have profilers for run-time performance.
XML Spy includes an XSLT profiler. That should fulfil your dynamic analysis needs if you can afford it.
There is also StylusStudio, a plugin for VisualStudio and CatchXSL (which is free).

XMLUnit for C++

Does anyone know if there exists something like XMLUnit for C++? I'm looking for an easy way to check nodes, values, etc in a XML output. We are using Google test in Visual Studio but I suppose any library that makes the work easier will be enough.
I'm using Xerces as an XML parser but XMLUnit (http://xmlunit.sourceforge.net/) has some features wrapped over the XML parser that are very useful for unit testing. For example, asserts using XPath expressions, functions to compare two "similar" XMLs, etc.
I have used a combination of Xerces and CPPUnit to accomplish this in the past. In my test cases I would create a DOM object with the Xerces API in the setUp() function. This DOM would represent my expected results. In the test case itself I would then read the XML file and the class under test would populate a DOM object representing the contents of the file. To check equality I would walk through the two DOM trees via the Xerces API (DOMTreeWalker) and use CPPUnit assertions as I compared the contents of the DOM nodes. It was a bit tedious but there were no frameworks available at the time that could mimic XmlUnit. I would imagine that Google Test would work just as well as CPPUnit for accomplishing this task.
The Xerces API has some support for XPath expressions:
http://xerces.apache.org/xerces-c/faq-parse-3.html#faq-2
For validation you would need to set up an error handler as mentioned here and incorporate it into your test case:
Validating document in Xerces C++
For XSLT transform checking you would need to use Xalan. It works with Xerces so I wouldn't anticipate any major difficulties:
http://xalan.apache.org/old/xalan-c/index.html
I was not able to locate any obvious products that packaged XMLUnit-like operations in C++. So the answer is I think you will have to roll your own. Good luck.
I really like http://pugixml.org/
It:
is stable
is extremely fast
has great documentation and sample code
is licensed under the MIT license
is very STL friendly
is still quite an active project
has great support for xpath
You can use tinyxml package here: tinyxml
I'm working with it and it's quite friendly and bug free.
It's an xml handling.
I guess it wasn't designed for unit testing, but you can use it to check/test your xml files.
It as expected loads the xml into a DOM object and supplies a nice API to run on the nodes.
Gal
Xerces at http://xerces.apache.org/xerces-c/i pretty full featured, has a C++ interface and produces good error messages, which several other XML parsers don't do so well. Having said that, it's pretty big & I've wound up using my own wrapper round the C parser Expat.
I'm currently using libxml++ for a personal project of mine.
I use Boost property_tree for xml, easy to use, pretty robust and works well with Boost unit test framework.