CPSC 421-010 Object-Oriented Programming (OOP) Spring 2024

Project 3 Posted: Mar 12

The main problem with the design for the srcFacts project is the complicated section of code (large while loop with nested-if) surrounding the srcFacts concerns. We have moved much of the low-level parsing details out of srcfacts.cpp (and into XMLParser), but that overall code structure remains.

Change the design of XMLParser to use full IoC (Inversion of Control). IoC lets you move the large while loop with nested-if entirely into an XMLParser method parse(). The only things that srcFacts will have to do (and the only public methods of the new XMLParser) are the parse() method and (depending on your implementation) methods to register handlers.

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 34

XML Extension Point Attributes
Start Document  
XML Declaration version, encoding, standalone
Element Start Tag qName, prefix, localName
Element End Tag qName, prefix, localName
Characters characters
Attribute qName, prefix, localName, value
XML Namespace prefix, uri
XML Comment value
CDATA characters
Processing Instruction target, data
End Document  

There is no explicit stage to fix the code from the Project 2 feedback. Fix any style issues in XMLParser or any issues that will cause a problem with Project 3.

Tag v3a: Redesign XMLParser to use IoC with lambda handlers 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. Update your Class Diagram and Sequence Diagram to reflect this new design. Rules apply:

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.

Tag v3identity: Create the application identity which is an identity transformation. A transformation is a program that converts data in one format to data in 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 Character and CDATA content.

Note: Any changes to XMLParser must work with srcfacts, xmlstats, and identity:

All tags for Project 3 are due Tuesday, Apr 2 Thursday, Apr 4.

Keep in mind: