Project 3

Change the design of XMLParser to use IoC (Inversion of Control). Using IoC allows you to move the large while loop with nested-if entirely into an XMLParser method parse().

Your XML parser needs to provide access to all parts of XML, even if srcFacts does not use it, via the following extension points from XML notes slide 35

Perform all work on the new branch ioc. To create the new branch:

Change to the main branch git checkout main
Make sure you are up to date git pull
Create and checkout a new branch git checkout -b ioc
Make sure you are on the correct branch git branch
Push the new branch to GitHub (first time) git push --set-upstream origin ioc
View all your branches, including remotes git branch --all

After you create a new branch, verify it at GitHub. Your default branch is main, so if you clone the repository again, you will have to checkout the branch ioc.

Tag v3a: Redesign XMLParser to use IoC with lambda callbacks for the extension points. For srcFacts, this means that the lambda functions in srcFacts.cpp contains all the processing of the XML data results, e.g., tag names with none of the XML parsing. Due Thursday, Mar 18 Monday, Mar 22

Before working on these applications, merge the pull request that adds these files to your repository and build.

You should not need to make any changes to your XMLParser to write the following applications. If you do, for example you forgot to allow an application to create a callback for a part of XML that srcFacts does not use, then you need to add this to the XMLParser and fix srcFacts so that it still works.

Tag v3xmlstats: Create the application xmlstats that produces a markdown report (similar to what srcFacts does) that indicates the number of each part of XML. E.g., the number of start tags, end tags, attributes, character sections, etc. A rough count of the demo.xml example, i.e., what you get by running the command make runxmlstats, is one XML declaration, 1,941,807 start tags, 1,940,854 end tags, 160,905 attributes, 2,035,029 character sections (not the same as the number of characters), 66,696 entity references, 185 XML namespaces, with no XML comments and no CDATA.

Due Thursday, Mar 25 Thursday, Apr 1

Tag v3identity: Create the application identity which is an identity transformation. A transformation is a program that converts from one format to a related format, typically the same format. In this case, it converts from XML to XML. It is an identity transformation because the output XML should be the same (as much as possible) as the input XML. The XMLParser will parse the input, and your callbacks will output the XML format. You can assume that there are no CDATA parts, but you must escape all >, <, and & in Characters’ content. Due Thursday, Mar 25 Thursday, Apr 1

Note: The command make runidentity is like the previous run commands, however the standard output (std::cout) is redirected to the file democopy.xml. You can then compare the two, diff demo.xml democopy.xml.

Note: Identity programs are the best way to find deficiencies in the interface (e.g., XMLParser methods) and bugs in the underlying, low-level XML parsing code.

There is a bug in the low-level parsing code (my responsibility) where the prefix for namespaces is always empty, i.e., all of them are in the form xmlns="...". To fix this, make the easy change show in the Fix Namespace Prefix

The other issue is for empty elements, e.g., <block_content/>. To parse those correctly, you will need to make the changes described in the guide Parsing Empty Elements.

Keep in mind: