itsallcode / openfasttrace

Open source requirement tracing suite
GNU General Public License v3.0
101 stars 21 forks source link

Detect ReqM2 preamble #197

Open redcatbear opened 5 years ago

redcatbear commented 5 years ago

Is your feature request related to a problem? Please describe. OFT auto-detects files by extension. Unfortunately ReqM2's extension is to generic (.xml) this leads to other XML files unnecessarily being scanned, which has two consequences:

  1. The import is slower than necessary because it could skip files which are do not contain ReqM2 content.
  2. Lots of error messages about unknown XML content are dumped to STDERR

Describe the solution you'd like When an XML file is about to be imported, OFT should check whether it really contains ReqM2 content. This comes in two variants at the moment:

  1. Plain ReqM2 file
  2. DocBook file with embedded ReqM2 content (supported but not really recommended)

Describe alternatives you've considered

Additional context This is an excerpt of example error output:

Nov 17, 2018 1:11:57 PM org.itsallcode.openfasttrace.importer.specobject.handler.SpecDocumentHandlerBuilder lambda$0
INFO: Found unknown root element TreeElement [element=StartElementEvent [qName=testsuite, attributeMap={tests=Attribute [qName=tests, value=5], failures=Attribute [qName=failures, value=0], xsi:noNamespaceSchemaLocation=Attribute [qName=xsi:noNamespaceSchemaLocation, value=https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd], name=Attribute [qName=name, value=org.itsallcode.openfasttrace.importer.input.TestStreamInput], xmlns:xsi=Attribute [qName=xmlns:xsi, value=http://www.w3.org/2001/XMLSchema-instance], time=Attribute [qName=time, value=0.001], errors=Attribute [qName=errors, value=0], skipped=Attribute [qName=skipped, value=0]}, location=/home/johndoe/git/openfasttrace/target/surefire-reports/TEST-org.itsallcode.openfasttrace.importer.input.TestStreamInput.xml:2:309], characterData=, endElementListeners=[]]: skip file
redcatbear commented 5 years ago

@kaklakariada, could you please take care of this one?

kaklakariada commented 1 year ago

Detection of ReqM2 is already implemented. If the root element of an XML file is not <specdocument>, the observed log message is printed and further processing is stopped. However the XML file is parsed until the end without processing any events. We can fix this by throwing an exception (and catching it later) as described in the documentation of XMLReader.parse().