drj826 / SML

This is the Perl 5 implementation of the SML code library. SML is a minimalistic plain text descriptive markup language which is human readable, enables continuous integration of documentation, expresses and validates semantic relationships, is easy to edit, is easy to generate automatically, and publishes professional documentation from plain text manuscripts.
GNU General Public License v3.0
2 stars 2 forks source link

No Warning of Disallowed Element 'version' in Document #69

Closed drj826 closed 8 years ago

drj826 commented 8 years ago

I started to work on #64 -- I commented out the document property declaration that said a document can have a 'version' property and then re-published the library expecting to see warnings or errors about an unknown property. To my surprise, I didn't get any warnings or errors. It appears something may be wrong with the parser's validation logic.

drj826 commented 8 years ago

I inspected the code and didn't find any logic to validate that an element is allowed within the division in which it appears. That's odd, I thought I checked for this error condition. I guess not. It's easy enough to add.

The SML::Ontology class has a public method 'allows_property_name_in_division_name' which returns 1 if the ontology allows the specified property in the specified division. The parser should invoke this method to perform the required validation.

The question is, "When should this validation take place?" I think it should take place at the earliest possible time during parsing, and that is during '_parse_lines' when the parser encounters the first line of the element and calls the '_process_start_element' method. At that point in time the parser has all the information it needs to validate the element is allowed to appear within the division currently being parsed.