Skip to content

Commit

Permalink
Add subMessage and severity to XML output.
Browse files Browse the repository at this point in the history
As per suggestion of @tofi86, we add the subMessage and severity
attributes to message to get the exact code.
Refactor the unit tests to check the error code instead of the message
to be more robust on locales.

Fixes w3c#486.
  • Loading branch information
tledoux committed Feb 19, 2016
1 parent 5aa6beb commit 981aa18
Show file tree
Hide file tree
Showing 14 changed files with 216 additions and 208 deletions.
12 changes: 8 additions & 4 deletions src/main/java/com/adobe/epubcheck/util/XmlReportImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public int generateReport()
if (ml.getLine() > 0 || ml.getColumn() > 0) {
loc = " (" + ml.getLine() + "-" + ml.getColumn() + ")";
}
generateElement("message", m + PathUtil.removeWorkingDirectory(ml.getPath()) + loc);
generateElement("message", m + PathUtil.removeWorkingDirectory(ml.getPath()) + loc,
KeyValue.with("subMessage", c.getID()), KeyValue.with("severity", "error"));
}
}
for (CheckMessage c : errors) {
Expand All @@ -76,7 +77,8 @@ public int generateReport()
if (ml.getLine() > 0 || ml.getColumn() > 0) {
loc = " (" + ml.getLine() + "-" + ml.getColumn() + ")";
}
generateElement("message", m + PathUtil.removeWorkingDirectory(ml.getPath()) + loc);
generateElement("message", m + PathUtil.removeWorkingDirectory(ml.getPath()) + loc,
KeyValue.with("subMessage", c.getID()), KeyValue.with("severity", "error"));
}
}
for (CheckMessage c : warns) {
Expand All @@ -86,7 +88,8 @@ public int generateReport()
if (ml.getLine() > 0 || ml.getColumn() > 0) {
loc = " (" + ml.getLine() + "-" + ml.getColumn() + ")";
}
generateElement("message", m + PathUtil.removeWorkingDirectory(ml.getPath()) + loc);
generateElement("message", m + PathUtil.removeWorkingDirectory(ml.getPath()) + loc,
KeyValue.with("subMessage", c.getID()), KeyValue.with("severity", "error"));
}
}
for (CheckMessage c : hints) {
Expand All @@ -96,7 +99,8 @@ public int generateReport()
if (ml.getLine() > 0 || ml.getColumn() > 0) {
loc = " (" + ml.getLine() + "-" + ml.getColumn() + ")";
}
generateElement("message", m + PathUtil.removeWorkingDirectory(ml.getPath()) + loc);
generateElement("message", m + PathUtil.removeWorkingDirectory(ml.getPath()) + loc,
KeyValue.with("subMessage", c.getID()), KeyValue.with("severity", "info"));
}
}
endElement("messages");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,17 @@ public int differenceFound(Difference difference)
|| expectedXPath.equals("/jhove[1]/date[1]/text()[1]")
|| expectedXPath.equals("/jhove[1]/repInfo[1]/@uri")
|| expectedXPath.equals("/jhove[1]/repInfo[1]/version[1]/text()[1]")
|| expectedXPath.equals("/jhove[1]/repInfo[1]/messages[1]/message[7]/text()[1]")
|| expectedXPath.equals("/xmpmeta[1]/RDF[1]/Description[1]/hasEvent[1]/hasEventDateTime[1]/text()[1]")
|| expectedXPath.equals("/xmpmeta[1]/RDF[1]/Description[1]/hasEvent[1]/hasEventRelatedAgent[1]/hasAgentName[1]/text()[1]")
)
{
return DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR;
}
// Be more robust to the modification/locale of the text of the messages (the associated code is already tested)
if (expectedXPath.startsWith("/jhove[1]/repInfo[1]/messages[1]/message[") && expectedXPath.endsWith("]/text()[1]"))
{
return DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR;
}

if (isDate(expectedValue))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<version>2.0.1</version>
<status>Well-formed</status>
<messages>
<message>OPF-021, WARN, [Use of non-registered URI scheme type in href: 'waka://barnesandnoble.com'.], OPS/AreYouReadyV3.xml (25-69)</message>
<message>HTM-010, HINT, [Namespace uri 'http://www.daisy.org/z3986/2005/ncx/' was found.], OPS/toc.ncx (2-68)</message>
<message severity="error" subMessage="OPF-021">OPF-021, WARN, [Use of non-registered URI scheme type in href: 'waka://barnesandnoble.com'.], OPS/AreYouReadyV3.xml (25-69)</message>
<message severity="info" subMessage="HTM-010">HTM-010, HINT, [Namespace uri 'http://www.daisy.org/z3986/2005/ncx/' was found.], OPS/toc.ncx (2-68)</message>
</messages>
<mimeType>application/epub+zip</mimeType>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
<version>3.0.1</version>
<status>Well-formed</status>
<messages>
<message>HTM-010, HINT, [Namespace uri 'http://www.daisy.org/z3986/2005/ncx/' was found.], OPS/toc.ncx (2-68)</message>
<message>OPF-059, HINT, [Spine item has no NCX entry reference.], OPS/toc.ncx</message>
<message>OPF-059, HINT, [Spine item has no NCX entry reference.], OPS/toc.ncx</message>
<message>ACC-008, HINT, [Navigation Document has no 'landmarks nav' element.], xmlfile.epub</message>
<message>CSS-009, HINT, [Use of certain CSS such as Columns, Transforms, Transitions, box-sizing or KeyFrames can cause pagination issues.], OPS/style.css (3-23)</message>
<message>CSS-009, HINT, [Use of certain CSS such as Columns, Transforms, Transitions, box-sizing or KeyFrames can cause pagination issues.], OPS/style.css (8-23)</message>
<message>CSS-009, HINT, [Use of certain CSS such as Columns, Transforms, Transitions, box-sizing or KeyFrames can cause pagination issues.], OPS/style_tag_css.xhtml (8-31)</message>
<message>CSS-009, HINT, [Use of certain CSS such as Columns, Transforms, Transitions, box-sizing or KeyFrames can cause pagination issues.], OPS/style_tag_css.xhtml (13-31)</message>
<message>CSS-009, HINT, [Use of certain CSS such as Columns, Transforms, Transitions, box-sizing or KeyFrames can cause pagination issues.], OPS/style_tag_css.xhtml (5-28)</message>
<message>ACC-013, HINT, [Content file contains at least one inline style declaration.], OPS/inline_css.xhtml (14-116)</message>
<message>ACC-013, HINT, [Content file contains at least one inline style declaration.], OPS/inline_css.xhtml (10-119)</message>
<message>ACC-013, HINT, [Content file contains at least one inline style declaration.], OPS/inline_css.xhtml (15-114)</message>
<message>ACC-013, HINT, [Content file contains at least one inline style declaration.], OPS/inline_css.xhtml (11-115)</message>
<message>ACC-007, HINT, [Content Documents do not use 'epub:type' attributes for semantic inflection.], OPS/external_css.xhtml</message>
<message>ACC-007, HINT, [Content Documents do not use 'epub:type' attributes for semantic inflection.], OPS/style_tag_css.xhtml</message>
<message>ACC-007, HINT, [Content Documents do not use 'epub:type' attributes for semantic inflection.], OPS/inline_css.xhtml</message>
<message severity="info" subMessage="HTM-010">HTM-010, HINT, [Namespace uri 'http://www.daisy.org/z3986/2005/ncx/' was found.], OPS/toc.ncx (2-68)</message>
<message severity="info" subMessage="OPF-059">OPF-059, HINT, [Spine item has no NCX entry reference.], OPS/toc.ncx</message>
<message severity="info" subMessage="OPF-059">OPF-059, HINT, [Spine item has no NCX entry reference.], OPS/toc.ncx</message>
<message severity="info" subMessage="ACC-008">ACC-008, HINT, [Navigation Document has no 'landmarks nav' element.], xmlfile.epub</message>
<message severity="info" subMessage="CSS-009">CSS-009, HINT, [Use of certain CSS such as Columns, Transforms, Transitions, box-sizing or KeyFrames can cause pagination issues.], OPS/style.css (3-23)</message>
<message severity="info" subMessage="CSS-009">CSS-009, HINT, [Use of certain CSS such as Columns, Transforms, Transitions, box-sizing or KeyFrames can cause pagination issues.], OPS/style.css (8-23)</message>
<message severity="info" subMessage="CSS-009">CSS-009, HINT, [Use of certain CSS such as Columns, Transforms, Transitions, box-sizing or KeyFrames can cause pagination issues.], OPS/style_tag_css.xhtml (8-31)</message>
<message severity="info" subMessage="CSS-009">CSS-009, HINT, [Use of certain CSS such as Columns, Transforms, Transitions, box-sizing or KeyFrames can cause pagination issues.], OPS/style_tag_css.xhtml (13-31)</message>
<message severity="info" subMessage="CSS-009">CSS-009, HINT, [Use of certain CSS such as Columns, Transforms, Transitions, box-sizing or KeyFrames can cause pagination issues.], OPS/style_tag_css.xhtml (5-28)</message>
<message severity="info" subMessage="ACC-013">ACC-013, HINT, [Content file contains at least one inline style declaration.], OPS/inline_css.xhtml (14-116)</message>
<message severity="info" subMessage="ACC-013">ACC-013, HINT, [Content file contains at least one inline style declaration.], OPS/inline_css.xhtml (10-119)</message>
<message severity="info" subMessage="ACC-013">ACC-013, HINT, [Content file contains at least one inline style declaration.], OPS/inline_css.xhtml (15-114)</message>
<message severity="info" subMessage="ACC-013">ACC-013, HINT, [Content file contains at least one inline style declaration.], OPS/inline_css.xhtml (11-115)</message>
<message severity="info" subMessage="ACC-007">ACC-007, HINT, [Content Documents do not use 'epub:type' attributes for semantic inflection.], OPS/external_css.xhtml</message>
<message severity="info" subMessage="ACC-007">ACC-007, HINT, [Content Documents do not use 'epub:type' attributes for semantic inflection.], OPS/style_tag_css.xhtml</message>
<message severity="info" subMessage="ACC-007">ACC-007, HINT, [Content Documents do not use 'epub:type' attributes for semantic inflection.], OPS/inline_css.xhtml</message>
</messages>
<mimeType>application/epub+zip</mimeType>
<properties>
Expand Down
Loading

0 comments on commit 981aa18

Please sign in to comment.