Documentation
¶
Overview ¶
Package qt3 runs the W3C QT3 (FOTS) test suite against this engine.
The suite is not vendored: it is ~78MB and belongs to the W3C. Point GOXSLT_QT3 at a checkout of https://github.com/w3c/qt3tests and the tests in this package run; without it they skip. That keeps `go test ./...` fast and dependency-free for everyone else while making the conformance run reproducible for anyone who wants it.
Index ¶
- Variables
- func SuiteRoot() string
- type Assertion
- type Catalog
- type Collation
- type Collection
- type CollectionQuery
- type ContextItem
- type DecimalFormatDecl
- type Dependency
- type Environment
- type Namespace
- type Outcome
- type Param
- type Report
- type Resource
- type Result
- type Runner
- type Schema
- type Source
- type StaticBaseURI
- type TargetVersion
- type TestCase
- type TestSet
- type TestSetRef
Constants ¶
This section is empty.
Variables ¶
var SuiteClock = time.Date(2024, 1, 15, 9, 30, 0, 0, time.FixedZone("", -5*3600))
SuiteClock is the fixed value fn:current-dateTime returns during a run. It carries a non-UTC offset because a UTC-only clock would let a timezone bug pass unnoticed.
Functions ¶
Types ¶
type Assertion ¶
type Assertion struct {
// Kind is the element name: "assert-eq", "all-of", "error", and so on.
Kind string
// Value is the character data, which for most kinds is the expected value.
Value string
// Code is the @code of an <error>, and @type of an assert-type.
Code string
// Flags is the @flags of a serialization-matches: the regular expression
// flags fn:matches would be given. It is a field of its own rather than
// another use of Code because a serialization-matches carries both — the
// suite writes flags="q" beside no code at all, and folding them together
// would make a literal-match assertion look like an error assertion.
Flags string
// File is the @file of an assert-xml whose expected value is held in a
// separate document rather than inline. Without it the comparison ran
// against an empty string, which reported every such case as a mismatch
// against "".
File string
// Children are the operands of all-of / any-of / not.
Children []Assertion
}
Assertion is one node of the result tree.
func ParseAssert ¶
ParseAssert parses the raw result XML into an assertion tree.
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.
func LoadCatalog ¶
LoadCatalog reads catalog.xml from the suite root.
type Collection ¶
type Collection struct {
URI string `xml:"uri,attr"`
Sources []Source `xml:"source"`
Queries []CollectionQuery `xml:"query"`
}
Collection is a named set of documents an environment supplies to fn:collection.
The sources carry the same role/file/uri attributes as a context source, but role is unused: membership in the collection is the point, not the name it is bound to. A collection may instead name its members by a query rather than by files. The catalog schema allows <collection> to hold either <source> children or <query> children, and the query form is how the suite builds collections whose members are not documents at all: "integer-collection" is <query>1 to 10</query> and "atomic-collection" is <query>(1, "hello", 1e0) </query>. The engine's CollectionResolver already returns an xdm.Sequence rather than a node list precisely so that such a collection can be expressed, so honouring <query> here costs nothing on the engine side.
type CollectionQuery ¶ added in v1.2.1
type CollectionQuery struct {
URI string `xml:"uri,attr"`
Expr string `xml:",chardata"`
// contains filtered or unexported fields
}
CollectionQuery is one <query> child of a <collection>: an XQuery expression whose result is contributed to the collection.
The optional uri attribute is the document URI of the item the query produces, which UseCaseR31's "users-json" collection uses so that a collection member can be named. It is recorded for completeness; a member that is not a node has no document URI to stamp.
type ContextItem ¶ added in v1.2.0
type ContextItem struct {
Select string `xml:"select,attr"`
}
ContextItem is an environment's "context-item", whose select attribute is an XPath expression evaluated to produce the item.
type DecimalFormatDecl ¶ added in v1.1.0
type DecimalFormatDecl struct {
// Name is the lexical QName the declaration carries. Its prefix may be
// declared on the decimal-format element itself, so the namespace it
// binds to is recovered from Attrs rather than from the environment.
Name string `xml:"name,attr"`
Attrs []xml.Attr `xml:",any,attr"`
DecimalSeparator string `xml:"decimal-separator,attr"`
GroupingSeparator string `xml:"grouping-separator,attr"`
Percent string `xml:"percent,attr"`
PerMille string `xml:"per-mille,attr"`
ZeroDigit string `xml:"zero-digit,attr"`
Digit string `xml:"digit,attr"`
PatternSeparator string `xml:"pattern-separator,attr"`
MinusSign string `xml:"minus-sign,attr"`
Infinity string `xml:"infinity,attr"`
NaN string `xml:"NaN,attr"`
ExponentSeparator string `xml:"exponent-separator,attr"`
}
DecimalFormatDecl is one <decimal-format> declaration. Every attribute is optional and defaults to the standard symbol, so each is a pointer-free string tested for emptiness rather than a value with its own default.
type Dependency ¶
type Environment ¶
type Environment struct {
Name string `xml:"name,attr"`
Ref string `xml:"ref,attr"`
Sources []Source `xml:"source"`
Params []Param `xml:"param"`
// ContextItem supplies the context item as an expression to evaluate,
// rather than as a document to load the way a "." source does. A handful
// of environments set an atomic or an array this way — "declare context
// item as xs:integer external" against a supplied 'London' is how
// contextDecl-020 asks for XPTY0004 — and without it the item is absent
// and the case gets XPDY0002 instead.
ContextItem []ContextItem `xml:"context-item"`
Namespaces []Namespace `xml:"namespace"`
Schemas []Schema `xml:"schema"`
// Collations and a declared default collation appear on a few
// environments; a test needing a non-codepoint one is unsupported here.
Collations []Collation `xml:"collation"`
// StaticBaseURI supplies the base URI of the expression itself, which is
// what fn:static-base-uri returns and what fn:resolve-uri resolves
// against.
StaticBaseURI []StaticBaseURI `xml:"static-base-uri"`
// Collections are the document sets fn:collection returns.
Collections []Collection `xml:"collection"`
// Resources are the non-XML files fn:unparsed-text reads, mapping the URI
// a case names to the file in the checkout that holds it.
Resources []Resource `xml:"resource"`
// DecimalFormats are the decimal formats fn:format-number reads. Only the
// unnamed (default) one is used by these cases.
DecimalFormats []DecimalFormatDecl `xml:"decimal-format"`
}
type Outcome ¶
type Outcome int
Outcome is what happened to one test case.
const ( Pass Outcome = iota Fail // Skip covers a test this engine is not in scope for — an XQuery-only // construct, a 3.0/3.1 feature, or a schema-aware environment. A skip is // not a pass and is reported separately, because counting them as passes // is how a conformance number becomes meaningless. Skip )
type Param ¶
type Param struct {
Name string `xml:"name,attr"`
Select string `xml:"select,attr"`
As string `xml:"as,attr"`
// A param's name may carry a prefix, and the binding for it is declared
// on the param element rather than on the environment — extvardeclwithtype-24
// writes xmlns:test on the <param> and names "test:x". Capturing the
// element's own attributes is the only way to see it, since the
// environment's <namespace> children do not mention it.
Attrs []xml.Attr `xml:",any,attr"`
}
type Report ¶
type Report struct {
Set, Case string
Outcome Outcome
Reason string
// Expr is the expression the case evaluated. A failure line naming only
// the case means opening the catalog to find out what it ran; carrying it
// here makes the report reproducible by hand.
Expr string
}
Report is the result of one case.
type Resource ¶ added in v1.1.0
type Resource struct {
File string `xml:"file,attr"`
URI string `xml:"uri,attr"`
MediaType string `xml:"media-type,attr"`
Encoding string `xml:"encoding,attr"`
}
Resource is one <resource> declaration: a file in the checkout published under the URI a test case uses to reach it.
type Result ¶
type Result struct {
Raw []byte `xml:",innerxml"`
}
Result is the assertion tree, kept as raw XML and parsed by ParseAssert.
The nesting is arbitrary — all-of and any-of contain further assertions to any depth — and struct tags cannot express that, so it is walked with the token stream instead.
type Runner ¶
type Runner struct {
Root string
// Target is the language version the run is scoped to. The zero value is
// XPath20, so an existing caller that does not set it keeps the 2.0 run
// it had before.
Target TargetVersion
// contains filtered or unexported fields
}
Runner executes cases from a suite checkout.
type StaticBaseURI ¶
type StaticBaseURI struct {
URI string `xml:"uri,attr"`
}
type TargetVersion ¶ added in v1.1.0
type TargetVersion int
TargetVersion selects the language version the run is scoped to.
The suite is FOTS 3.1 and every case declares the versions it applies to, so which cases are in scope is a property of the run rather than of the engine. Scoping to 2.0 and to 3.0 are two measurements of the same suite, and both are reported: the 2.0 figure must not move as 3.0 is implemented, which is what makes it a regression check rather than just a headline.
const ( // XPath20 scopes the run to cases that apply to XPath 2.0. XPath20 TargetVersion = iota // XPath30 scopes the run to cases that apply to XPath 2.0 or 3.0. XPath30 // XPath31 scopes the run to cases that apply to 2.0, 3.0 or 3.1. XPath31 // XQuery31 scopes the run to XQuery cases rather than XPath ones. // // It is not a fourth point on the same scale: an XQuery case holds a whole // query where an XPath case holds an expression, and the two are evaluated // by different packages. Every XPath 3.1 expression is an XQuery // expression, so the XQuery run also admits the cases written for XP31. XQuery31 )
func (TargetVersion) String ¶ added in v1.1.0
func (v TargetVersion) String() string
type TestCase ¶
type TestCase struct {
Name string `xml:"name,attr"`
Description string `xml:"description"`
Environments []Environment `xml:"environment"`
Dependencies []Dependency `xml:"dependency"`
// Test carries the <test> element both ways it can be written: the query
// inline as character data, or a "file" attribute naming a file beside
// the test set that holds it. LoadTestSet reads the file form in, so
// everything downstream reads Test.Query whichever way the case was
// written.
//
// One field rather than two because the decoder refuses to map two struct
// fields onto the same element name.
Test struct {
Query string `xml:",chardata"`
File string `xml:"file,attr"`
} `xml:"test"`
Modules []struct {
URI string `xml:"uri,attr"`
File string `xml:"file,attr"`
} `xml:"module"`
Result Result `xml:"result"`
}
type TestSet ¶
type TestSet struct {
XMLName xml.Name `xml:"test-set"`
Name string `xml:"name,attr"`
Environments []Environment `xml:"environment"`
Dependencies []Dependency `xml:"dependency"`
Cases []TestCase `xml:"test-case"`
// Dir is the test-set file's directory, relative to the suite root.
//
// Source paths are relative to the test-set file, not to the root:
// fn/collection.xml names "../docs/bib.xml". Joining those against the
// root walks above it and the file is not found, so the directory has to
// travel with the parsed set.
Dir string `xml:"-"`
// File is the test-set file itself, relative to the suite root.
//
// Dir is not enough for the one thing this is for: §2.1.2 defaults the
// static base URI to the URI of the resource holding the expression, and
// K2-BaseURIProlog-5 declares the relative base URI "" and then requires
// fn:static-base-uri() to end with "prod/BaseURIDecl.xml" -- the file, not
// the directory that contains it.
File string `xml:"-"`
}
TestSet is one test-set file, e.g. fn/abs.xml.
func LoadTestSet ¶
LoadTestSet reads one test-set file named relative to the suite root.