openfasttrace icon indicating copy to clipboard operation
openfasttrace copied to clipboard

Detect ReqM2 preamble

Open redcatbear opened this issue 7 years ago • 2 comments

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

  • Enforcing a strict extension (e.g. .reqm2): While being perfect for OFT this has the downside that it breaks compatibility and also that XML Editors don't know this extensions by default.
  • Enforcing a compound extension (.reqm2.xml): Works for OFT and XML editors. Downsides are that it is clunky and still breaks compatibility.

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 avatar Nov 17 '18 12:11 redcatbear

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

redcatbear avatar Nov 17 '18 12:11 redcatbear

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().

kaklakariada avatar Jan 04 '23 12:01 kaklakariada