diff --git a/src/main/java/org/jpeek/Report.java b/src/main/java/org/jpeek/Report.java index 1513a4ac..edb15d09 100644 --- a/src/main/java/org/jpeek/Report.java +++ b/src/main/java/org/jpeek/Report.java @@ -28,6 +28,7 @@ import com.jcabi.xml.Sources; import com.jcabi.xml.StrictXML; import com.jcabi.xml.XML; +import com.jcabi.xml.XMLDocument; import com.jcabi.xml.XSD; import com.jcabi.xml.XSDDocument; import com.jcabi.xml.XSL; @@ -39,13 +40,11 @@ import java.util.HashMap; import java.util.Map; import org.cactoos.collection.CollectionOf; -import org.cactoos.io.InputOf; import org.cactoos.io.LengthOf; import org.cactoos.io.TeeInput; -import org.cactoos.map.MapEntry; -import org.cactoos.map.MapOf; import org.cactoos.text.TextOf; -import org.cactoos.text.UncheckedText; +import org.xembly.Directives; +import org.xembly.Xembler; /** * Single report. @@ -139,11 +138,6 @@ final class Report { * @param mean Mean * @param sigma Sigma * @checkstyle ParameterNumberCheck (10 lines) - * @todo #135:30min The current solution to add the reference to - * 'metric.xsd' in the generated 'metric.xml' is too complex for - * the task at hand. Refactor towards a simpler solution that - * ideally would just require one or two Xembly instructions to - * add the required attribute. */ @SuppressWarnings("unchecked") Report(final XML xml, final String name, @@ -151,25 +145,9 @@ final class Report { final double mean, final double sigma) { this.skeleton = xml; this.metric = name; - this.params = new MapOf<>( - args, - new MapEntry<>("schemaLocation", Report.SCHEMA_FILE) - ); + this.params = args; this.post = new XSLChain( new CollectionOf<>( - new XSLDocument( - new UncheckedText( - new TextOf( - new InputOf( - Report.class.getResourceAsStream( - "xsl/metric-post-schemaloc.xsl" - ) - ) - ) - ).asString(), - Sources.DUMMY, - this.params - ), new XSLDocument( Report.class.getResourceAsStream( "xsl/metric-post-colors.xsl" @@ -237,11 +215,23 @@ private XML xml() throws IOException { String.format("XSL not found: %s", name) ); } - return new XSLDocument( - new TextOf(res).asString(), - Sources.DUMMY, - this.params - ).transform(this.skeleton); + return new XMLDocument( + new Xembler( + new Directives().xpath("metric").attr( + "xmlns:xsi", + "http://www.w3.org/2001/XMLSchema-instance" + ).attr( + "xsi:noNamespaceSchemaLocation", + Report.SCHEMA_FILE + ) + ).applyQuietly( + new XSLDocument( + new TextOf(res).asString(), + Sources.DUMMY, + this.params + ).transform(this.skeleton).node() + ) + ); } } diff --git a/src/main/resources/org/jpeek/xsl/metric-post-schemaloc.xsl b/src/main/resources/org/jpeek/xsl/metric-post-schemaloc.xsl deleted file mode 100644 index ca04f0c7..00000000 --- a/src/main/resources/org/jpeek/xsl/metric-post-schemaloc.xsl +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - -