Repository navigation
Conversation
Users reading a ReqIF file did not find how to go from a SPEC-HIERARCHY node to the requirement text: the hierarchy only holds a SPEC-OBJECT-REF, the attribute names live on the SPEC-OBJECT-TYPE, and the text of XHTML attributes is an XHTML fragment. Add the integration example 05_extract_requirement_text. It looks up the SPEC-OBJECT with ReqIFBundle.get_spec_object_by_ref(), names each attribute through the SPEC-OBJECT-TYPE's attribute_map, and converts value_stripped_xhtml to plain text with lxml. The test checks the script's output with FileCheck, including that no XHTML tag is left. Add a "Retrieving the requirement text" section to the README with the same code. Closes strictdoc-project#143
Contributor
Author
|
Friendly ping @stanislaw: this is ready for review whenever you have time (addresses #143); happy to change the approach. This was investigated and written with an AI coding agent (Claude) working on my behalf. |
This was referenced Nov 12, 2026
stanislaw
force-pushed
the
docs/extract-requirement-text-example
branch
from
November 12, 2026 22:31
efb0265 to
53e8c50
Compare
Contributor
Author
|
Thanks @stanislaw for merging. This was investigated and written with an AI coding agent (Claude) working on my behalf. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #143.
The README showed how to iterate a specification's hierarchy, but not how to get from a SPEC-HIERARCHY node to the requirement text. That takes three steps that are hard to find: look up the SPEC-OBJECT by the SPEC-OBJECT-REF (
ReqIFBundle.get_spec_object_by_ref()), get the attribute names such asReqIF.Textfrom the SPEC-OBJECT-TYPE (get_spec_object_type_by_ref()andattribute_map), and turn the XHTML value into plain text.This adds the integration example
tests/integration/examples/05_extract_requirement_textwith a small ReqIF input (a section and two requirements with nested XHTML). Its script prints each SPEC-OBJECT's identifier, LONG-NAME, and attribute values, and converts XHTML attributes withlxml.html.fromstring(attribute.value_stripped_xhtml).text_content(). lxml is already a dependency. The test checks every output line with FileCheck and fails if any XHTML tag is left in the output. The README gets a "Retrieving the requirement text" section with the same code.The input file passes
reqif validate --use-reqif-schema, andreqif passthroughreproduces it unchanged. No library code changes.Locally,
invoke lintpasses, andinvoke testpasses 76 unit tests plus 79 of 80 integration tests (1 pre-existing unsupported). One note: lit 23.x, the current PyPI release, rejectsShTest("0")intests/integration/lit.cfg, so I ran the integration tests with lit 18.1.8. CI might hit this independently of this PR.