Documentation
¶
Overview ¶
Package xslts runs the W3C XSLT test suite against this engine, filtered to the tests an XSLT 2.0 processor is expected to pass.
There is no maintained XSLT 2.0 suite. The original XSLTS was frozen at 1.1.0, was distributed from w3.org behind a click-through licence rather than a repository, and has had no maintenance since XSLT 2.0 reached Recommendation in 2007. What replaced it is the XSLT 3.0 suite, which carried most of those tests forward and records a version dependency on each one — so a 2.0-conformance run is a filtered run of the 3.0 suite rather than a separate corpus.
The suite is not vendored: it is ~470MB and belongs to the W3C. Point GOXSLT_XSLTS at a checkout of https://github.com/w3c/xslt30-test and the tests in this package run; without it they skip.
git clone --depth 1 https://github.com/w3c/xslt30-test.git GOXSLT_XSLTS=xslt30-test go test ./xslts/
Index ¶
- type Assertion
- type Catalog
- type Collection
- type Dependencies
- type EnvPackage
- type Environment
- type Feature
- type NamedThing
- type Other
- type Outcome
- type OutputRef
- type PackageRef
- type Param
- type Resource
- type Result
- type Runner
- type Schema
- type SetStats
- type Source
- type Spec
- type StylesheetRef
- type Summary
- type Target
- type Test
- type TestCase
- type TestSet
- type TestSetRef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Assertion ¶
type Assertion struct {
// Kind is the element name: "assert", "assert-xml", "error", "all-of".
Kind string
// Value is the character data, which for most kinds is the expected
// result or the XPath expression to evaluate against it.
Value string
// Code is the @error-code of an <error>.
Code string
// File names a document holding the expected value, used where it is too
// large to sit inline.
File string
// Normalize records @normalize-space on an assert-xml, which says
// whitespace differences do not count.
Normalize bool
// URI is the @uri of an assert-result-document, naming which secondary
// output the nested assertions apply to.
URI string
// Flags is the @flags of a serialization-matches, in the XPath regular
// expression flag vocabulary: i, s, m and x.
Flags string
// Encoding is the @encoding of an assert-serialization, naming the
// character encoding the expected-result file is written in. Without it
// the file is UTF-8, which is what almost every one of them is.
Encoding string
// NS holds the prefix-to-URI bindings in scope where the assertion was
// written. The suite declares them on the assertion element or on an
// enclosing combinator — an XPath assertion that names a prefix cannot be
// evaluated without them.
NS map[string]string
// Children are the operands of all-of, any-of and not.
Children []Assertion
}
Assertion is one node of a result tree.
The suite nests all-of, any-of and not to arbitrary depth, so the result is walked with the token stream rather than described with struct tags.
func ParseAssert ¶
ParseAssert parses the raw result XML into an assertion tree.
outer holds the namespace bindings in scope at the element raw was taken from the inside of — the suite declares the XHTML prefix on <result> itself, and innerxml does not carry it.
type Catalog ¶
type Catalog struct {
XMLName xml.Name `xml:"catalog"`
TestSets []TestSetRef `xml:"test-set"`
Environments []Environment `xml:"environment"`
}
Catalog is the top-level catalog.xml.
type Collection ¶
Collection is a named set of documents fn:collection returns.
An empty uri names the *default* collection — the one collection() with no argument returns — which is why the attribute is not treated as missing when it is present and blank.
type Dependencies ¶
type Dependencies struct {
Specs []Spec `xml:"spec"`
Features []Feature `xml:"feature"`
Others []Other `xml:",any"`
}
Dependencies is the set of conditions a test needs.
Only the ones that decide whether a test is in scope here are modelled. Everything else — the many feature and implementation-defined flags — is read as a raw name so that an unrecognised one excludes the test rather than being silently ignored.
type EnvPackage ¶ added in v1.1.0
type EnvPackage struct {
File string `xml:"file,attr"`
Role string `xml:"role,attr"`
URI string `xml:"uri,attr"`
Version string `xml:"package-version,attr"`
}
EnvPackage is a <package> declared in an environment.
type Environment ¶
type Environment struct {
Name string `xml:"name,attr"`
Ref string `xml:"ref,attr"`
Sources []Source `xml:"source"`
Params []Param `xml:"param"`
Schemas []Schema `xml:"schema"`
// Collections are the document sets fn:collection resolves. An
// environment declaring one is what makes collection() answer at all:
// without it the engine refuses, correctly, because a collection URI it
// was never told about is not a document set it can invent.
Collections []Collection `xml:"collection"`
// Packages are the library packages xsl:use-package may name. A package
// is addressed by name and version rather than by location, so the
// environment states all three and the resolver matches on the first two.
Packages []EnvPackage `xml:"package"`
// Stylesheets declared here are shared by every case referencing the
// environment. A test-set built that way states no stylesheet on its
// cases at all, so a runner reading only the case-level ones finds none
// and reports the whole set as unrunnable.
Stylesheets []StylesheetRef `xml:"stylesheet"`
// Resources are the non-XML documents fn:unparsed-text and friends may
// read. Most name a file shipped beside the test set, which the engine
// resolves as an ordinary relative reference and which needs no modelling
// here. The ones that matter for scope are those whose @file is itself an
// absolute http(s) URI: they say the environment is only complete when
// the network is. See remoteResource in deps.go.
Resources []Resource `xml:"resource"`
}
Environment supplies the source documents, parameters and settings a test runs against.
type NamedThing ¶
type NamedThing struct {
// Params are the arguments of this one invocation. Both
// <initial-template> and <initial-mode> may carry them.
Params []Param `xml:"param"`
// Name is the lexical QName exactly as the catalog wrote it.
Name string `xml:"name,attr"`
// Select is the initial match selection, which only <initial-mode>
// carries. It is an XPath expression evaluated with no context, and the
// package tests use it to start an initial mode with no source document
// at all -- which is the only way those cases can avoid XTDE0044.
Select string `xml:"select,attr"`
// URI is the namespace the catalog's own declarations bind Name's prefix
// to. It is filled in by resolveInitialTemplateNames rather than by
// encoding/xml, which never resolves a QName held in an attribute value.
// Empty means the name has no prefix, or the prefix was unbound.
URI string `xml:"-"`
}
type Other ¶
type Other struct {
XMLName xml.Name
Value string `xml:"value,attr"`
Satisfied string `xml:"satisfied,attr"`
}
Other is any dependency element this runner does not model.
type Outcome ¶
type Outcome struct {
Set, Name string
Pass bool
Skipped bool
// Why explains a skip or a failure.
Why string
}
Outcome is what happened to one test.
type OutputRef ¶
type OutputRef struct {
File string `xml:"file,attr"`
Serialize string `xml:"serialize,attr"`
// Tree="no" asks the driver not to wrap the transformation's result in a
// document node, so the assertions see 2.3.5's raw result sequence
// instead. That is what lets a test assert about a sequence of atomic
// values, which no tree can represent: initial-template-004 returns
// eight xs:decimal values and compares them with deep-equal, which a
// tree would have turned into one text node, and initial-function-100b
// asserts its result is an xs:integer, which a tree makes a text node.
//
// ResultVar names the variable to bind it to. It is the suite's own
// spelling in one case and absent everywhere else; the reference driver
// does not read it at all — "result-var" appears nowhere in
// runner/run-tests.xsl — so an absent one means the ordinary name.
Tree string `xml:"tree,attr"`
ResultVar string `xml:"result-var,attr"`
}
type PackageRef ¶
type PackageRef struct {
File string `xml:"file,attr"`
Role string `xml:"role,attr"`
// A secondary package is addressed by name and version, exactly as one
// declared in an environment is; only the principal is addressed by file.
URI string `xml:"uri,attr"`
Version string `xml:"package-version,attr"`
}
type Param ¶
type Param struct {
Name string `xml:"name,attr"`
Select string `xml:"select,attr"`
As string `xml:"as,attr"`
Static string `xml:"static,attr"`
Tunnel string `xml:"tunnel,attr"`
// URI is the namespace Name's prefix is bound to by the catalog's own
// declarations, filled in by resolveInitialTemplateNames the same way a
// NamedThing's is. encoding/xml never resolves a QName held in an
// attribute value.
URI string `xml:"-"`
}
type Result ¶
type Result struct {
Inner string `xml:",innerxml"`
// NS holds the prefix-to-URI bindings in scope at the <result> element
// itself. encoding/xml's innerxml keeps only what is *inside* the
// element, so a declaration written on <result> — which is where the
// suite puts the XHTML binding an assertion's XPath needs — is not in
// Inner and cannot be recovered by parsing it. Filled in by
// resolveResultNamespaces.
NS map[string]string `xml:"-"`
}
Result is the assertion tree, kept as raw XML.
The nesting is arbitrary — all-of and any-of contain further assertions to any depth — so it is walked with the token stream rather than described with struct tags.
type Runner ¶
type Runner struct {
// Root is the suite checkout.
Root string
// Target is the version measured. The zero value is XSLT 2.0, so an
// existing caller keeps the run it had.
Target Target
// Timeout bounds one transform. A stylesheet that does not terminate is a
// failure of that test rather than of the run.
Timeout time.Duration
}
type Source ¶
type Source struct {
Role string `xml:"role,attr"`
File string `xml:"file,attr"`
URI string `xml:"uri,attr"`
Content string `xml:"content"`
// Select is an XPath expression that picks the initial context node out
// of the loaded document -- or, with no file and no inline content,
// constructs it outright (parse-xml('<root/>')). The initial context
// item need not be a document node, and three cases in the suite name an
// element or a text node this way.
Select string `xml:"select,attr"`
// XInclude is the environment's xinclude="true", which asks that the
// document be XInclude-processed before the transform sees it. Only
// base-uri-052 sets it, and it is what that case exists to test: the
// xml:base fixup XInclude 1.0 section 4.5.5 requires.
XInclude string `xml:"xinclude,attr"`
// Validation is "strict", "lax" or "skip". A source declared strict is
// meant to reach the transform carrying type annotations from the
// environment's schema, which is what makes "instance of my:type"
// answer true for a value read out of it.
Validation string `xml:"validation,attr"`
}
Source is one input document, either named by file or given inline.
role="." marks the principal input — the document the transform starts on. Any other role names a secondary document reachable through fn:doc.
type StylesheetRef ¶
type Summary ¶
type Summary struct {
Total, Passed, Failed, Skipped int
// Failures holds the failing outcomes, for reporting.
Failures []Outcome
// SkipReasons counts why tests were left out, so that the scope of a run
// is visible rather than implied by the total.
SkipReasons map[string]int
// SkippedOutOfScope and SkippedUnimplemented split Skipped by class --
// see skipReasonClasses. A reason with no class is counted in neither,
// so the two summing to Skipped is what the suite tests assert.
SkippedOutOfScope, SkippedUnimplemented int
// BySet counts each test-set separately. A single percentage hides which
// features work: a set failing 96 of 100 is an unimplemented feature,
// while one failing 5 of 300 is a handful of edge cases, and the two want
// entirely different work.
BySet map[string]*SetStats
}
Summary counts a run.
type Target ¶ added in v1.1.0
type Target int
Runner executes the suite against this engine. Target is the version of XSLT a run measures conformance against.
The suite is one catalog covering every version, so which cases are in scope is a property of the run rather than of the suite: a case declaring XSLT30+ is out of scope for a 2.0 run and is the point of a 3.0 one. Two runs over the same catalog is how a change is shown not to have cost ground at 2.0 while gaining it at 3.0.
type Test ¶
type Test struct {
Stylesheets []StylesheetRef `xml:"stylesheet"`
Packages []PackageRef `xml:"package"`
InitialTemplate *NamedThing `xml:"initial-template"`
InitialMode *NamedThing `xml:"initial-mode"`
InitialFunction *NamedThing `xml:"initial-function"`
Params []Param `xml:"param"`
Output *OutputRef `xml:"output"`
// PostureAndSweep marks a streamability test, which is XSLT 3.0 only.
PostureAndSweep *struct{} `xml:"posture-and-sweep"`
XPath string `xml:"xpath"`
}
Test says what to run.
type TestCase ¶
type TestCase struct {
Name string `xml:"name,attr"`
Description string `xml:"description"`
Environments []Environment `xml:"environment"`
Dependencies Dependencies `xml:"dependencies"`
Test Test `xml:"test"`
Result Result `xml:"result"`
}
TestCase is one test.
type TestSet ¶
type TestSet struct {
XMLName xml.Name `xml:"test-set"`
Name string `xml:"name,attr"`
Environments []Environment `xml:"environment"`
// Dependencies declared here apply to every case in the set unless the
// case states its own. Seven thousand cases inherit rather than declare,
// so a runner that reads only the case-level ones admits tests that need
// XSLT 3.0 and reports them as failures of this engine.
Dependencies Dependencies `xml:"dependencies"`
Cases []TestCase `xml:"test-case"`
// Dir is the test-set file's directory, relative to the suite root.
// Stylesheet and source paths are relative to it rather than to the root.
Dir string `xml:"-"`
// Path is the test-set file itself. An inline <source><content> is a part
// of this file, so this -- not a synthesised name in Dir -- is the base
// URI the XML spec gives the element the content becomes.
Path string `xml:"-"`
}
TestSet is one test-set file.