XVRL provides a unified format for expressing possibly multiple validation methods, applied to possibly multiple documents. The need arises because not every validation language has a standardized report format, making it difficult to render the results of multiple validations in a single report.
XVRL elements are in the namespace http://www.xproc.org/ns/xvrl. XVRL documents may contain
      elements in other namespaces at certain locations. The XVRL elements and attributes and their semantics are given
      in the following lists. More details about the XVRL grammar are encoded in the Relax NG Compact Syntax version of
      the XVRL schema, which is also normative.
- detectionelement
- A single finding, typically with an associated error code and/or message(s). A - reportelement primarily contains- detectionelements. See Section 2.2, “Detection” for details.
- digestelement
- A - reportmay contain a- digestelement in order to provide a summary of the- detectionelements. For the distinct severity levels, counts of the- detectionelements for a given level may be specified on- digest, for example in an- @error-countattribute. In addition, the- @worstattribute may give the highest severity level that occurs in the- detectionelements that are contained by the- digest’s parent element.- A - digestelement may occur in addition to or instead of- detectionelements. If no- detectionelement is included, a- digestelement must be included.- All information in digest is understood to be aggregated at some point from the actual detection elements. It is the responsibility of an XVRL creating/processing application to keep them up to date or to remove them when the underlying detection information is changed. A digest may be inserted either before or after the detection elements. 
- metadataelement
- Information about the time of validation, the validator used, the document(s) under test, etc. See Section 2.3, “Metadata” for details. - A single - metadataelement need not contain all relevant metadata. Metadata infomation will be inherited from surrounding- reports/metadataelements, that is, if a given- metadatadoes not provide- validatorinformation but the parent- reports/metadatadoes, the parent’s- metadata/validatorwill also pertain to the current- metadataelement’s siblings and their descendants, unless overridden further down.
- reportelement
- The result of a single validation method, typically using a single schema, typically applied to a single document (also referred to as the source document). The individual errors (or other findings) are included as - detectionelements.- Naming things…- Previously, what is called “detection” here was called “report”, while a collection of detections was called “validation-report”. Now this collection ist called “report”, while a collection of (new-terminology) reports is now called “reports” (previously: “validation-reports”). I changed the names because I didn’t think that both an individual finding and a collection of individual findings should both be called a “report”, with the prefix “validation-” discerning between both. Since the individual finding is also the result of a validation, there is no reason it couldn’t have been called “validation-report” in the first place. It took quite some time to come up with a term for the individual findings. Candidates were: “finding”, “observation”, “detection”, “incidence”, and “incident”. I’m willing to rename it to something that seems more fitting. 
- reportselement
- A collection of - reportelements. It may contain the same- metadatainformation as a single- reportin order to denote common information, for example if all validations have been applied to the same document or if all validations use the same schema or validation engine.- reportselements may nest in order to group- reportelements with common sets of metadata.
As described in Section 2.1, “Document Structure”, detection is the main container for individual
        validation findings. It contains optional severity and 
        code attributes, and the following elements in arbitrary order:
- categoryelement(s)
- In order to filter or group messages for a formatted report, individual - detections may be categorized according to arbitrary category systems, using the repeatable- categoryelement. Its optional attribute- vocabularycan hold a string that designates the category system. There are no pre-defined values to choose from.- Categorization that applies to all - detections in a- reportcan be included in the- report’s- metadata.
- codeattribute
- An error code. The term “error code” is used in a colloquial sense here. It need not relate to an error, but to any kind of message that has a distinctive identifying string. 
- contextelement
- The purpose of this element is to present a piece of content that surrounds the element that the detection pertains to. It contains an optional - locationelement, followed by (optional) arbitrary text or non-XVRL element content.
- locationelement
- Within a single - detectionelement, the location in the source document that the validation error, warning, etc. pertains to is given by the- locationelement’s attributes.- If not present, - hrefis taken from the closest ancestor’s- metadata/document/@hrefattribute. If there are multiple- document/@hrefattributes in the closest ancestor’s metadata, the- hrefattribute should not be omitted on- location, or at least a disambiguating relative URI should be given in the- location/@hrefattribute.- The attribute - xpathcontains an XPath expression that gives the location within the document. The in-scope value of the attribute- xpath-default-namespacethat is permitted on any element may give a namespace for the element names in this XPath expression. Apart from that, the- Q{namespace-uri}local-namesyntax should be used, but in-scope namespace prefixes or XPath predicates like- [namespace-uri() = 'uri']may also be used.- The attributes - lineand- columnmay also be used to point at lines and columns in a textual representation of the source document.- The attribute - octet-positionmay be used to give the byte position (1-offset) of the error. This may be useful for binary documents.- In order to support JSON document validations, the attributes - jsonpathand- jsonpointermay be used.- Giving multiple alternative pointers is not forbidden. However, it is beyond the scope of this specification to define mechanisms to enforce or check consistency between the attribute values. It is evident that - jsonpointeror- jsonpathare meaningless in the context of XML documents.- Other attributes are permitted if they are in a non-XVRL namespace. 
- messageelement
- An error message that pertains to a - detection. There may be multiple- messageelements in a single- detectionelement, typically to convey localized versions of essentially the same message. A message may contain arbitrary markup in non-XVRL namespaces. Messages are typically generated for consumption by humans.- Note- Whenever the term “error message” is used in a colloquial sense (that is, not highlighted as the severity level “ - error” or as the XVRL element “- message”) throughout this specification, a- detectionelement with any- @severitylevel, not necessarily “- error”, and any number of localized- messages is implied. Likewise, the term “error code” does not imply the severity level “- error”.
- provenanceelement
- In multi-step conversion pipelines it is sometimes required to save a common origin location that a portion of the validated document is derived from. This may be necessary in order to patch back error messages of later conversion stages into the source document. - The optional - provenanceelement within a- detectionconveys exactly this information, in a contained- locationelement that points to the provenance location in the original source document. A- provenanceelement may contain multiple- locationelements; it is up to processing applications to discern between different roles that they may have.- Although it is possible to omit the - @hrefattribute in the contained- locationelements, this URI is not inherited from a containing element’s- metadata/document/@hrefattribute.
- severityattribute
- The - severityattribute is permitted on a- detectionelement. XVRL establishes a finite set of error levels that correspond to the impact of a detected issue. Each- detectionelement may have a severity level, from highest (worst impact) to lowest, of “- fatal-error”, “- error”, “- warning”, or “- info”. In addition, the- severityattribute may have the value “- unspecified” which is equivalent to omitting the attribute.- Note- Which severity level is attached to a given error code depends on, among other things, the audience that the validation report is prepared for. For Schematron’s SVRL output, the values of - @rolewill typically translate to XVRL- @severityattributes, but this mapping may be configured, see below.
- summaryelement(s)
- An abstract of a - report, a- reportscollection, or an individual- detection. This element is repeatable, for example, in order to support multiple natural languages. In the context of- detection, it can serve as an abridged version of a full message that contains lengthy lists and the like.
- supplementalelement(s)
- This repeatable element may contain arbitrary textual or non-XVRL element content. It may appear in - metadataand in- detection. Its- roleattribute may be used to further classify the purpose of its content. Like any other XVRL element, it may be localized using the- xml:langattribute.- Purposes can be, but are not limited to, conveying the SVRL source that the XVRL report was created from, or a disclaimer, a confidentiality statement, or introductory content that should be included in a rendered report. 
All elements in this section are optional within metadata.
      The order in which they appear is arbitrary. Some are repeatable.
- creatorelement
- Information about the tool that created the source document. There are the optional attributes - @name,- @version, and the optional element- invocation. The- invocationelement is meant to hold a command line that contains the invocation of the program that was responsible for generating the source document. This information can be useful for later diagnosing dependencies between errors and command line options.
- categoryelement(s)
- documentelement(s)
- The URI of a source document may be specified in the - hrefattribute. In addition or instead, the document may be given as the element content. See also- locationelement about inheritance of- href.
- schemaelement(s)
- The URI of a schema document may be specified in the - hrefattribute. In addition or instead, the document may be given as the element content.- For schema languages that have a distinct XML namespace, the namespace of the schema may be given in the attribute - schematypens.- Some schema languages have a distinct content type. This can be conveyed in the attribute - content-type.- In addition or alternatively to the aforementioned attributes, the schema language may be specified by a distinct token in the attribute - language. Tokens for well-known schema languages are listed in Appendix B, Well-known Schema Languages. Schema languages that do not appear in Appendix B, Well-known Schema Languages should be referred to by a- languagetoken that is prefixed with- x-and that contains a reasonably recognizable identifier for the given schema language.- The version of the schema language may be given in the attribute - version.
- summaryelement(s)
- See - summaryelement(s).
- supplementalelement(s)
- timestampelement
- >The content needs to be an - xsd:dateTimevalue, for example “- 2017-12-04T12:21:37.381+01:00”.
- titleelement(s)
- The title of a - report, a- reportscollection, or an individual- detection. This element is repeatable, for example, in order to support multiple natural languages.
- validatorelement
- Information about the validation program that generated the report(s) or the underlying messages (if XVRL was not generated natively by the program). There are optional attributes - @nameand- @version, both are arbitrary strings. Arbitrary text or element (in a non-XVRL namespace) content may be contained, for example to describe a configuration or to include an actual configuration file.
A. The XVRL Schema
# Schema for XML Validation Report Language; adapted from a proposal
# by Matthieu Ricaud incorporating some suggestions by Gerrit Imsieke
# See https://github.com/xproc/3.0-steps/issues/15
namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0"
namespace local = ""
default namespace xvrl = "http://www.xproc.org/ns/xvrl"
start = reports | report
xmllang.attr = attribute xml:lang { xsd:language }
xmlid.attr = attribute xml:id { xsd:ID }
xmlbase.attr = attribute xml:base { xsd:anyURI }
# Default namespace URI for location XPaths:
xpdns.attr = attribute xpath-default-namespace { xsd:anyURI }
anyother.attr = attribute * - (local:* | xvrl:* | xml:*) { text }
any.attr = attribute * - xvrl:* { text }
message.attr  = attribute (* - (xvrl:* | xml:*)) { text }
common.attr =
  xmllang.attr?
  & xmlid.attr?
  & xmlbase.attr?
  & xpdns.attr?
  & anyother.attr*
href.attr =
  attribute href { xsd:anyURI }
  
any.element = 
  element * - xvrl:* { (any.attr | text | any.element)* }
reports =
  element reports {
    common.attr,
    report.metadata,
    (report | reports | digest)+
  }
report =
  element report {
    common.attr,
    report.metadata,
    ((digest?, detection+) | (detection+, digest) | digest)
  }
## All information in digest is understood to be aggregated at some point from the actual detection elements. 
## It is the responsibility of an XVRL creating/processing application to keep them up to date or to remove them 
## when the underlying detection information is changed. If the individual detections are omitted, a digest must be present. 
## A digest may be inserted either before or after the detection elements.
digest =
  element digest {
    common.attr,
    attribute valid { "true" | "false" | "partial" | "undetermined" }?,
    attribute fatal-error-count { xsd:integer }?,
    attribute error-count { xsd:integer }?,
    attribute warning-count { xsd:integer }?,
    attribute info-count { xsd:integer }?,
    attribute unspecified-count { xsd:integer }?,
    attribute fatal-error-codes { list { token* } }?,
    attribute error-codes { list { token* } }?,
    attribute warning-codes { list { token* } }?,
    attribute info-codes { list { token* } }?,
    attribute unspecified-codes { list { token* } }?,
    attribute worst { "fatal-error" | "error" | "warning" | "info" | "nothing" | "unspecified" }?
  }
report.metadata =
  element metadata {
    common.attr,
    (timestamp?
     & validator?
     & creator?
     & document*
     & title*
     & summary*
     & category*
     & schema*
     & supplemental*)
  }
document = 
  element document {
    common.attr,
    href.attr?,
    (text | any.element)
  }
  
detection =
  element detection {
    common.attr,
    attribute severity { "info" | "warning" | "error" | "fatal-error" | "unspecified" }?,
    attribute code { text }?,
    (location?
     & provenance?
     & title*
     & summary*
     & category*
     & (let*, message*)
     & supplemental*
     & context?)
  }
let =
    element let {
        common.attr,
        attribute name { xsd:QName },
        (attribute value {xsd:string} | (text | any.element))*
    }
value-of =
    element value-of {
        attribute name { xsd:QName }
    }
location = element location { location.model }
location.model =
  xpdns.attr?,
  # XPaths may use the Q{namespace-uri}local-name notation.
  attribute xpath { text }?,
  # These are different syntaxes to address JSON documents.
  # JSON docs may be represented as XPath maps and arrays
  # and then addressed via, e.g., xpath=".(3)('foo')"
  # for the 3rd array item, which is a map, and then the map’s
  # value for the 'foo' key.
  attribute jsonpointer { text }?,
  attribute jsonpath { text }?,
  attribute href { xsd:anyURI }?,
  attribute line { xsd:positiveInteger }?,
  attribute column { xsd:positiveInteger }?,
  # For binary data:
  attribute octet-position { xsd:positiveInteger }?,
  anyother.attr*
provenance = element provenance { location+ }
message =
  element message {
    common.attr,
    (text | message.element)*
  }
message.element =
    element (* - (xvrl:* - xvrl:value-of)) {
      (message.attr | text | message.element | value-of)*
  }
supplemental =
  element supplemental { common.attr, (text | any.element)* }
context =
  element context {
  common.attr, location?, (text | any.element)* }
validator =
  element validator {
    common.attr,
    attribute name { text },
    attribute version { text }?,
    (text | any.element)*
  }
creator =
  element creator {
    common.attr,
    attribute name { text },
    attribute version { text }?,
    element invocation { text }?
  }
schema =
  element schema {
    common.attr,
    attribute href { xsd:anyURI }?,
    attribute language {  list {
        (("DTD" | "XSD" | "RNG" | "RNC" | "Schematron" | "NVDL" | "JSON" )
         | xsd:token { pattern = "x-[\-._/\w]+" } )} }?,
    attribute content-type { xsd:token { pattern = "\w+/[\-.\w]+(\+[\-.\w]+)?" } }?,
    attribute schematypens { xsd:anyURI }?,
    attribute version { text }?,
    (text | any.element)?
  }
title = element title { common.attr, (text | any.element)* }
summary = element summary { common.attr, (text | any.element)* }
category =
  element category {
    common.attr,
    attribute vocabulary { xsd:token }?,
    (text | any.element)*
  }
timestamp = element timestamp { common.attr, xsd:dateTime }B. Well-known Schema Languages
The following schema languages can be referred to by language token in the schema/@language
    attribute:
| Token ( @language) | Content Type ( @content-type) | Namespace ( @schematypens) | Specification | 
|---|---|---|---|
| DTD | application/xml-dtd | [XML 1.0] | |
| XSD | application/xml | http://www.w3.org/2001/XMLSchema | [W3C XML Schema: Part 1] | 
| RNG | application/xml | http://relaxng.org/ns/structure/1.0 | [RELAX NG] | 
| RNC | application/relax-ng-compact-syntax | [RELAX NG Compact Syntax] | |
| Schematron | application/xml | http://purl.oclc.org/dsdl/schematron (ISO Schematron), http://xml.ascc.net/schematron/ (legacy Schematron up to version 1.5) | [Schematron] (ISO Schematron) | 
| NVDL | application/xml | http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0 | [NVDL] | 
| JSON | application/schema+json | [JSON schema] | 
Appearance of a schema language in this list does not imply that an XVRL-producing validation application is required to support validation with this language.
Applications that generate XVRL should choose appropriate schema attribute(s) to unambiguously convey the 
      applied Schema language and its version.
      They may use the namespace URI in order to identify an XML-syntax Schema language, or the content type for DTD, Relax NG Compact Syntax 
      or JSON Schema, but they may also use the corresponding language token.
Schema languages that do not appear in this list should be referred to by a language 
      attribute that is prefixed with x-, for example, x-jsontron.
C. Parameters for Controlling XVRL Generation
The following parameters should be understood by XVRL report generators when converting underlying validation
      reports, for example, from SVRL or from the XProc error vocabulary, c:errors etc.
- xvrl:default-severity
- 
          When no severity is associated with a source vocabulary element that is mapped to detection, this property can be specified in order to assign a default severity to any of these source vocabulary constructs. It can be argued that the XProc error vocabulary,c:error, already conveys the severity levelerror. The view that this specification takes is to regard these messages as generic findings of severity “error”, but that thexvrl:default-severitymay be given to override this.Implementations are free to provide other parameters, in a different namespace, that permit a more detailed mapping, for example from error code to severity. 
- xvrl:serialization-format
- 
          Anticipates future alternative serialization If no value is given, xmlis assumed. Other possible values may be, but are not limited to,json,rdf/xml,turtle.
- xvrl:language
- 
          A space separated list of language abbreviations, typically according to ISO 639-1. The preferred language is given first, followed by fallback languages. The result is that localized elements within a detectionwill be reduced to messages, categories, or summaries in the preferred language. Example:de eninstructs the XVRL generator to include German messages only and to use an English message when no German message is present. If no language matches for a given localizable element in adetectioncontext, a corresponding element with the same attributes, but with noxml:langattribute, should be included. Localizable elements with anxml:langattribute that is not listed in this property should be ignored.
- xvrl:map-to-severity
- 
          This parameter contains space-separated QNames that correspond to elements or attributes of an underlying reporting language, in particular SVRL attributes. A value of flag roleinstructs an SVRL to XVRL converter to preferentially map the SVRLflagattribute to the XVRLseverityattribute. If it is not present or its value cannot be mapped, it should try to map the SVRLrolevalue to XVRL’sseverity.The following attribute values are considered mappable, after folding the source value to lower case: “information”, “informational” map to “info”; “warn” maps to “warning”; “fatal” maps to ”fatal-error”. A conversion tool may consider other variants, including translations that correspond to the natural language of the corresponding error message, for mapping. If the content of an (for example) SVRL attribute cannot be mapped, it should be attached to the corresponding XVRL detectioneither as a category or as a namespaced attribute (that is,role="foo"in SVRL may becomesvrl:role="foo"in XVRL, withxmlns:svrl="http://purl.oclc.org/dsdl/svrl").
- xvrl:xpath-notation
- 
          This parameter controls how XPath attributes given in locationelements should be structured. Possible values are “Q”, “namespace-uri“, and “name”.Example: The path /TEI/text[1]in the namespacehttp://www.tei-c.org/ns/1.0will be represented in these notations as follows:- Q
- 
                /Q{http://www.tei-c.org/ns/1.0}TEI/Q{http://www.tei-c.org/ns/1.0}text[1]
- namespace-uri
- 
                /*:TEI[namespace-uri()='http://www.tei-c.org/ns/1.0']/*:text[namespace-uri()='http://www.tei-c.org/ns/1.0'][1]This corresponds to the parameter setting full-path-notation=1in the SVRL output of the Schematron skeleton implementation.
- name
- 
                /tei:TEI/tei:text[1]This corresponds to the parameter setting full-path-notation=2in the SVRL output of the Schematron skeleton implementation. It takes namespace prefix declarations from the source document and it needs to copy these declarations to an appropriate location in the resulting XVRL document.
 If the XVRL attribute xpath-default-namespaceis present on an ancestor element, the namespace URI given in this attribute on the closest ancestor should be used to omit this namespace from the resulting XPath. Ifxpath-default-uri="http://www.tei-c.org/ns/1.0"is in force in a given context, the paths in any of the three notations should reduce to/TEI/text[1].If an XVRL-generating application is unable to generate the preferred notation, any XPath notation that it can produce is acceptable. 
D. XSLT Stylesheets (Non-Normative)
As a convenience, XSLT stylesheets will be made available for the following purposes:
- SVRL → XVRL conversion
- 
          It is recommended that XProc processor vendors make this XSLT available under the import URI http://xproc.org/xvrl/xsl/svrl2xvrl.xsl.
- c:errors→ XVRL conversion
- 
          It is recommended that XProc processor vendors make this XSLT available under the import URI http://xproc.org/xvrl/xsl/c-errors2xvrl.xsl.
- Filter/transform XVRL
- 
          It is recommended that XProc processor vendors make this XSLT available under the import URI http://xproc.org/xvrl/xsl/xvrl2xvrl.xsl.
All stylesheets accept the parameters given in Appendix C, Parameters for Controlling XVRL Generation.
E. References
[XML 1.0] Extensible Markup Language (XML) 1.0 (Fifth Edition). Tim Bray, Jean Paoli, C. M. Sperberg-McQueen, et. al. editors. W3C Recommendation 26 November 2008.
[W3C XML Schema: Part 1] XML Schema Part 1: Structures Second Edition. Henry S. Thompson, David Beech, Murray Maloney, et. al., editors. World Wide Web Consortium, 28 October 2004.
[RELAX NG] ISO/IEC JTC 1/SC 34. ISO/IEC 19757-2:2008(E) Document Schema Definition Language (DSDL) — Part 2: Regular-grammar-based validation — RELAX NG 2008.
[RELAX NG Compact Syntax] ISO/IEC JTC 1/SC 34. ISO/IEC 19757-2:2003/Amd 1:2006 Document Schema Definition Languages (DSDL) — Part 2: Grammar-based validation — RELAX NG AMENDMENT 1 Compact Syntax 2006.
[Schematron] ISO/IEC JTC 1/SC 34. ISO/IEC 19757-3:2016(E) Document Schema Definition Languages (DSDL) — Part 3: Rule-based validation — Schematron 2016.
[NVDL] ISO/IEC JTC 1/SC 34. ISO/IEC 19757-4:2006(E) Document Schema Definition Languages (DSDL) — Part 4: Namespace-based Validation Dispatching Language (NVDL) 2006.
[JSON schema] JSON Schema Validation: A Vocabulary for Structural Validation of JSON. A.Wright, H. Andrews and B. Hutton, editors. Internet Engineering Task Force. June, 2022.