Given a list of functions that take a Jimfs instance and return a MockFile, create the mockfiles in the given file system and delete them after running the specification.
Given a list of functions that take a Jimfs instance and return a MockFile, create the mockfiles in the given file system and delete them after running the specification.
The mock files are then available for parsing during the test. Any relative URIs and URIs that use Jimfs.URI_SCHEME as the scheme will be resolved against the given Jimfs file system.
Functions for converting an XSLT stylesheet into a Source.
Functions for converting an XSLT stylesheet into a Source.
Apply the XSLT template for the node selected by the given XPath query, using the input Node as the context node.
Apply the XSLT template for the node selected by the given XPath query, using the input Node as the context node.
Equivalent to <xsl:apply-templates/>
.
Apply the XSLT template for the given Node in the stylesheet defined in this specification.
Apply the XSLT template for the given Node in the stylesheet defined in this specification.
Equivalent to <xsl:apply-templates/>
.
Convert a sequence of tuples into a Map of parameters that Saxon understands.
Create an XdmNode attribute()
node.
Create an XdmNode attribute()
node.
If your template or function expects an attribute, use this function.
A specs2 matcher that tests whether a node matches an XPath expression.
A specs2 matcher that tests whether a node matches an XPath expression.
Example:
applying { <foo>x</foo> } must beMatching("bar[. eq 'x']")
A Saxon DocumentBuilder instance for converting DOM nodes into XML Data Model (XDM) instances
A Saxon DocumentBuilder instance for converting DOM nodes into XML Data Model (XDM) instances
Call an XSLT function, using the namespace URI defined implicitly in the XsltSpecification instance.
Call an XSLT function with the given parameters.
Call a named XSLT template and supply a context node (as Node) for the transformation.
Call a named XSLT template and supply a context node (as XdmNode) for the transformation.
Call a named XSLT template
An extensible Saxon Configuration instance.
An extensible Saxon Configuration instance.
Overriding is prevented to make it more difficult to accidentally lose the support for reading from and writing to an in-memory Jimfs file system.
The default matcher for comparing two XML element or document nodes.
Convert an Elem into an XdmNode document-node()
node.
Convert an Elem into an XdmNode element()
node.
Convert an Elem into an XdmNode element()
node.
By default, any Elem instance you create and give as a parameter is a document node. If your template or function expects an element, use this function.
The in-memory file system that stores MockFile instances and documents generated with <xsl:result-document>
.
The in-memory file system that stores MockFile instances and documents generated with <xsl:result-document>
.
Every specification uses its own in-memory file system. If you need every test to have its own in-memory file system, use the specs2 isolation argument.
Note, however, that if you enable isolation, the stylesheet will currently also be compiled per-test rather than per-specification, because the file system needs to be instantiated before the stylesheet is compiled.
Create a function that takes a Source and returns a CompareMatcher that filters attributes according to the given predicate.
Create a function that takes a Source and returns a CompareMatcher that filters attributes according to the given predicate.
For filtering elements and other node types, use filterNode.
Example:
// Apply templates for x, ignore differences in the @id attribute. applying(<x/>) must produce(<y/>)(filterAttr(!XPath.matches("@id", _))
Create a function that takes a Source and returns a CompareMatcher that filters nodes according to the given predicate.
Create a function that takes a Source and returns a CompareMatcher that filters nodes according to the given predicate.
For filtering attributes, use filterAttr.
Example:
// Apply templates for a, ignore differences in the d children of c. applying(<a><b/></a>) must produce(<c/>)(filterNode(!XPath.matches("c/d", _))
The XML Schema to use for validating the input XML and loading default attributes
The XML Schema to use for validating the input XML and loading default attributes
Example:
import org.xmlunit.builder.Input override val inputSchema = Some(Input.fromFile("schema.xsd"))
A function that takes a Source and returns a CompareMatcher that compares the given Source to an XML fragment.
A function that takes a Source and returns a CompareMatcher that compares the given Source to an XML fragment.
You can extend the default matcher by by overriding it in your specification:
class MySpecification extends mutable.Specification with XsltSpecification { ... // A matcher that ignores @id attributes when comparing elements. override implicit def matcher = (s: Source) => defaultMatcher(s).withAttributeFilter( filter[Attr](a => a.getName != "id") ) ... }
You can also use a different matcher for a single test:
"Ignore an attribute" in { // Define a custom matcher for this test only. val m = (s: Source) => defaultMatcher(s).withAttributeFilter( // Ignore any attribute called "ignore-me". filter[Attr](a => a.getName != "ignore-me") ) // Pass in the custom matcher. applying(<x/>) must produce(<y/>)(m) }
Global stylesheet parameters.
Global stylesheet parameters.
You can either supply a Map[QName, XdmValue]
or call asMap on a sequence of tuples:
scala> asMap("string" -> "foo", "int" -> 1, "uri" -> new URI("http://www.google.com")) res2: Map[QName, XdmItem] = Map(string -> foo, int -> 1, uri -> http://www.google.com)
Convert a ProcInstr into an XdmNode processing-instruction()
node.
The Saxon Processor to use for running the stylesheet.
The Saxon Processor to use for running the stylesheet.
By default, it is configured to use the in-memory file system and an XML parser that can use XML catalogs.
Create a matcher that compares the supplied arguments against the result of an XML transformation.
Create a matcher that compares the supplied arguments against the result of an XML transformation.
Example use:
class MySpecification extends mutable.Specification with XsltSpecification { val stylesheet = XSLT.file("my-stylesheet.xsl") "Convert a into b" in { // Apply the templates for the element in the XSLT stylesheet and check the result. applying { <a>foo</a> } must produce { <b>foo</b> } } }
Convert a String into an XdmNode text()
node.
Convert a String into an XdmNode text()
node.
If you have a function that expects a text node parameter, call this method with a string argument to create a text node, then pass it to your function.
Get a new Xslt30Transformer instance for the compiled stylesheet.
Get a new Xslt30Transformer instance for the compiled stylesheet.
Any global parameters you set are set when this method is called.
A specification for testing an XSLT stylesheet.
Classes that mix in this trait must define stylesheet, which is a File instance that points to the stylesheet that you want to test.