Skip to content

Diagnostics ​

No entry point of go-xslt panics. Every problem, including an internal panic, comes back as an engine.Diagnostic in the result.

go
type Diagnostic struct {
	Severity string // "error" or "warning"
	Line     int    // 1-based; 0 means unknown
	Col      int    // 1-based; 0 means unknown
	Code     string // W3C error code where known, e.g. "XPST0003"
	Message  string
	Phase    string // "parse", "compile" or "run"

	// Only set by XSD validation:
	Rule     string // msg:message/@rule of a failed assertion
	Path     string // e.g. /Doc[1]/Item[2]
	Particle string // {namespace}local of a content-model error
	Kind     string // "missing", "too-many", "unexpected" or "order"
}

engine.SeverityError and engine.SeverityWarning hold the two severity values. Result.HasErrors() and XPathResult.HasErrors() tell whether any diagnostic is an error.

Where Line and Col point ​

PhasePosition
parseIn the document that could not be parsed.
compileIn the stylesheet.
runAt the innermost stylesheet instruction the error passed through.
validationIn the instance document. Schema compile errors may have no position.

Error codes ​

Code is the error code defined by the W3C specification, for example:

PrefixDefined byExample
XTSEXSLT, static errorXTSE0010 unknown XSLT element
XTDE, XTTEXSLT, dynamic and type errorsXTTE0570 value does not match as
XPST, XPTY, XPDYXPathXPST0008 undeclared variable
FO…Functions & OperatorsFORG0001 invalid cast

An xsl:message terminate="yes" and fn:error produce the code they were given.

Released under the Apache License 2.0.