CPSC 421-020 Object-Oriented Programming (OOP) Spring 2025

Project 4 Posted: Apr 08

Project 4 continues the work on srcFacts. It is due at 11:59:59 pm Tuesday, Apr 22, and involves the following stages which must be performed in order:

Tag v4a Correct the issues in XMLParser that affect srcfacts, xmlstats, identity, class diagram, and sequence diagram.

Tag template Redesign XMLParser to use the Template Design Pattern. In this design pattern, extension points are virtual methods. This means new classes that inherit from XMLParser:

The pull request template adds these new files to your repository and updates the CMakeLists.txt so that they are part of the build. Update your class and sequence diagrams to show this new design.

As before, our XML parser needs to provide access to all parts of XMLvia the following extension points from [XML notes slide 33]

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  

Tag handler Extract a handler from XMLParser called XMLParserHandler, a new class that only handles the user-defined processing (what we previously had as callbacks). Put the entire XMLParserHandler class in the file XMLParserHandler.hpp.

Then change srcFactsParser, IdentityParser, and XMLStatsParser to inherit from XMLParserHandler instead of XMLParser, and rename them by replacing "Parser" in the name with "Handler". You can rename the srcFacts files using git:

Note you will have to commit and push these changes.

You will also have to rename these files in your CMakeLists.txt. Update your class and sequence diagrams to show this new design.

Also make sure to update the class names and header comments.

Warning Once you tag template and move on to handler, you will not be able to change anything for template. So carefully check that you are done with the template part before you tag it and move on to handler

One prevalent issue in these conversions is that changing XMLParser and srcfacts will cause identity and xmlstats to break until they are converted. To avoid this, understand that make uses the default target all and means make all. So instead of building all executable targets, build them separately as needed, e.g., make srcfacts, make xmlstats, or make identity.

Keep in mind: