com.crabshue.commons.xproc.helper.ErrorTranslator Maven / Gradle / Ivy
package com.crabshue.commons.xproc.helper;
import org.apache.commons.lang3.EnumUtils;
import net.sf.saxon.s9api.QName;
public class ErrorTranslator {
private enum XPROC_ERRORS {
XD0001("It is a dynamic error if a non-XML resource is produced on a step output or arrives on a step input.\r\n"
+ "See: Inputs and Outputs"),
XD0002("It is a dynamic error if the processor attempts to retrieve the URI specified on a p:document or p:data and fails.\r\n"
+ "See: Associating Documents with Ports"),
XD0003("It is a dynamic error if the viewport source does not provide exactly one document.\r\n" + "\r\n"
+ "See: p:viewport"),
XD0004("It is a dynamic error if no subpipeline is selected by the p:choose and no default is provided.\r\n"
+ "See: p:choose"),
XD0005("It is a dynamic error if the xpath-context is bound to a sequence of documents.\r\n" + "\r\n"
+ "See: p:xpath-context"),
XD0006("If sequence is not specified, or has the value false, then it is a dynamic error unless exactly one document appears on the declared port.\r\n"
+ "See: Document Inputs, p:viewport-source"),
XD0007("If sequence is not specified on p:output, or has the value false, then it is a dynamic error if the step does not produce exactly one document on the declared port.\r\n"
+ "See: p:output"),
XD0008("It is a dynamic error if a document sequence appears where a document to be used as the context node is expected.\r\n"
+ "\r\n"
+ "See: Processor XPath Context, Processor XPath Context, p:variable, p:with-option, p:with-param"),
XD0009("It is a dynamic error if the element attribute on p:namespaces is specified and it does not identify a single element node.\r\n"
+ "See: Namespaces on variables, options, and parameters"),
XD0010("It is a dynamic error if the match expression on p:viewport does not match an element or document.\r\n"
+ "See: p:viewport"),
XD0011("It is a dynamic error if the document referenced by a p:document element does not exist, cannot be accessed, or is not a well-formed XML document.\r\n"
+ "See: p:document"),
XD0013("It is a dynamic error if the specified namespace bindings are inconsistent; that is, if the same prefix is bound to two different namespace names.\r\n"
+ "See: Namespaces on variables, options, and parameters"),
XD0014("It is a dynamic error for any unqualified attribute names other than “name”, “namespace”, or “value” to appear on a c:param element.\r\n"
+ "See: The c:param element, The c:param-set element"),
XD0015("It is a dynamic error if the specified QName cannot be resolved with the in-scope namespace declarations.\r\n"
+ "See: System Properties"),
XD0016("It is a dynamic error if the select expression on a p:input returns anything other than a possibly empty set of element or document nodes.\r\n"
+ "See: Document Inputs"),
XD0017("It is a dynamic error if the running pipeline attempts to invoke a step which the processor does not know how to perform.\r\n"
+ "See: Extension Steps"),
XD0018("It is a dynamic error if the parameter list contains any elements other than c:param.\r\n" + "\r\n"
+ "See: The c:param-set element"),
XD0019("It is a dynamic error if any option value does not satisfy the type required for that option.\r\n"
+ "See: Syntax Summaries"),
XD0020("It is a dynamic error if the combination of serialization options specified or defaulted is not allowed.\r\n"
+ "See: p:serialization"),
XD0021("It is a dynamic error for a pipeline to attempt to access a resource for which it has insufficient privileges or perform a step which is forbidden.\r\n"
+ "See: Security Considerations"),
XD0022("It is a dynamic error if a pipeline attempts to evaluate a step where the psvi-required attribute is true and the processor does not support passing PSVI annotations between steps.\r\n"
+ "See: Declaring pipelines"),
XD0023("It is a dynamic error if a processor that does not support PSVI annotations attempts to invoke a step which asserts that they are required.\r\n"
+ "See: PSVIs in XProc"),
XD0024("It is a dynamic error if a 2.0 processor encounters an XPath 1.0 expression and it does not support XPath 1.0 compatibility mode.\r\n"
+ "See: XPaths in XProc"),
XD0025("It is a dynamic error if the namespace attribute is specified, the name contains a colon, and the specified namespace is not the same as the in-scope namespace binding for the specified prefix.\r\n"
+ "See: The c:param element"),
XS0001("It is a static error if there are any loops in the connections between steps: no step can be connected to itself nor can there be any sequence of connections through other steps that leads back to itself.\r\n"
+ "See: Connections"),
XS0002("All steps in the same scope must have unique names: it is a static error if two steps with the same name appear in the same scope.\r\n"
+ "See: Scoping of Names"),
XS0003("It is a static error if the port specified by a p:pipe is not in the readable ports of the environment.\r\n"
+ "See: Associating Documents with Ports"),
XS0004("It is a static error to declare two or more options on the same step with the same name.\r\n"
+ "See: p:option, p:with-option"),
XS0006("It is a static error if the primary output port has no binding and the last step in the subpipeline does not have a primary output port.\r\n"
+ "See: p:for-each, p:viewport, Declaring pipelines"),
XS0007("It is a static error if two subpipelines in a p:choose declare different outputs.\r\n"
+ "See: p:choose"),
XS0008("It is a static error if any element in the XProc namespace has attributes not defined by this specification unless they are extension attributes.\r\n"
+ "See: Syntax Summaries"),
XS0009("It is a static error if the p:group and p:catch subpipelines declare different outputs.\r\n"
+ "See: p:try"),
XS0010("It is a static error if a pipeline contains a step whose specified inputs, outputs, and options do not match the signature for steps of that type.\r\n"
+ "See: Extension Steps"),
XS0011("It is a static error to identify two ports with the same name on the same step.\r\n"
+ "See: Document Inputs, Parameter Inputs, p:output"),
XS0012("it is a static error if the port given does not match the name of an input port specified in the step's declaration.\r\n"
+ "See: Document Inputs"),
XS0014("It is a static error to identify more than one output port as primary.\r\n" + "See: p:output"),
XS0015("It is a static error if a compound step has no contained steps.\r\n" + "See: Syntax Summaries"),
XS0016("It is a static error if the select attribute is not specified.\r\n"
+ "See: p:variable, p:with-option, p:with-param"),
XS0017("It is a static error to specify that an option is both required and has a default value.\r\n"
+ "See: p:option"),
XS0018("If an option is required, it is a static error to invoke the step without specifying a value for that option.\r\n"
+ "See: p:option"),
XS0019("it is a static error for a variable's document binding to refer to the output port of any step in the surrounding container's contained steps\r\n"
+ "See: p:variable"),
XS0020("It is a static error if the binding attribute on p:namespaces is specified and its value is not the name of an in-scope binding.\r\n"
+ "See: Namespaces on variables, options, and parameters"),
XS0021("It is a static error if the import references in a pipeline or pipeline library are circular.\r\n"
+ "See: p:library"),
XS0022("In all cases except the p:output of a compound step, it is a static error if the port identified by a p:pipe is not in the readable ports of the step that contains the p:pipe.\r\n"
+ "See: p:pipe"),
XS0024("It is a static error if the content of the p:inline element does not consist of exactly one element, optionally preceded and/or followed by any number of processing instructions, comments or whitespace characters.\r\n"
+ "See: p:inline"),
XS0025("It is a dynamic error if the processor encounters an xpath-version that it does not support.\r\n"
+ "See: XPaths in XProc, p:declare-step"),
XS0026("It is a static error if the port specified on the p:log is not the name of an output port on the step in which it appears or if more than one p:log element is applied to the same port.\r\n"
+ "See: p:log"),
XS0027("It is a static error if an option is specified with both the shortcut form and the long form.\r\n"
+ "See: Syntactic Shortcut for Option Values"),
XS0028("It is a static error to declare an option or variable in the XProc namespace.\r\n"
+ "See: p:variable, p:option, p:with-param"),
XS0029("It is a static error to specify a binding for a p:output inside a p:declare-step for an atomic step.\r\n"
+ "See: p:output"),
XS0030("It is a static error to specify that more than one input port is the primary.\r\n"
+ "See: Document Inputs, Parameter Inputs"),
XS0031("It is a static error to use an option on an atomic step that is not declared on steps of that type.\r\n"
+ "See: Syntactic Shortcut for Option Values, p:with-option"),
XS0032("It is a static error if no binding is provided and the default readable port is undefined.\r\n"
+ "See: Document Inputs, p:variable, p:with-option, p:with-param"),
XS0033("It is a static error to specify any kind of input other than “document” or “parameter”.\r\n"
+ "See: Parameter Inputs"),
XS0034("It is a static error if the specified port is not a parameter input port or if no port is specified and the step does not have a primary parameter input port.\r\n"
+ "See: p:with-param"),
XS0035("It is a static error if the declaration of a parameter input port contains a binding; parameter input port declarations must be empty.\r\n"
+ "See: Parameter Inputs"),
XS0036("All the step types in a pipeline must have unique names: it is a static error if any step type name is built-in and/or declared or defined more than once in the same scope.\r\n"
+ "See: Scoping of Names"),
XS0037("It is a static error if any step directly contains text nodes that do not consist entirely of whitespace.\r\n"
+ "See: Syntax Summaries"),
XS0038("It is a static error if any required attribute is not provided.\r\n" + "See: Syntax Summaries"),
XS0039("It is a static error if the port specified on the p:serialization is not the name of an output port on the pipeline in which it appears or if more than one p:serialization element is applied to the same port.\r\n"
+ "See: p:serialization"),
XS0040("It is a static error to specify any value other than true.\r\n" + "See: Parameter Inputs"),
XS0041("It is a static error to specify both binding and element on the same p:namespaces element.\r\n"
+ "See: Namespaces on variables, options, and parameters"),
XS0042("It is a static error to attempt to provide a binding for an input port on the declaration of an atomic step.\r\n"
+ "See: Document Inputs"),
XS0043("It is a static error if any attribute value does not satisfy the type required for that attribute.\r\n"
+ "See: Syntax Summaries"),
XS0044("It is a static error if any element in the XProc namespace or any step has element children other than those specified for it by this specification.\r\n"
+ "See: Syntax Summaries"),
XS0045("It is a static error if any string that must be interpreted as a QName uses a prefix for which there is not a namespace binding.\r\n"
+ "See: Syntax Summaries"),
XS0048("It is a static error to use a declared step as a compound step.\r\n" + "See: Extension Steps"),
XS0050("It is a static error if a pipeline attempts to import two (or more) libraries with URIs that identify steps associated with a particular version of XProc.\r\n"
+ "See: p:import"),
XS0051("It is a static error if the except-prefixes attribute on p:namespaces does not contain a list of tokens or if any of those tokens is not a prefix bound to a namespace in the in-scope namespaces of the p:namespaces element.\r\n"
+ "See: Namespaces on variables, options, and parameters"),
XS0052("It is a static error if the URI of a p:import cannot be retrieved or if, once retrieved, it does not point to a p:library, p:declare-step, or p:pipeline.\r\n"
+ "See: p:import"),
XS0053("It is a static error to import a single pipeline if that pipeline does not have a type.\r\n"
+ "See: p:import"),
XS0054("It is a static error to import more than one pipeline with the same type (either directly or within a library).\r\n"
+ "See: p:import"),
XS0055("It is a static error if a primary parameter input port has no binding and the pipeline that contains the step has no primary parameter input port.\r\n"
+ "See: Parameter Inputs"),
XS0057("It is a static error if a namespace prefix is used within the exclude-inline-prefixes attribute and there is no namespace binding in scope for that prefix.\r\n"
+ "See: p:inline"),
XS0058("It is a static error if the value #default is used within the exclude-inline-prefixes attribute and there is no default namespace in scope.\r\n"
+ "See: p:inline");
String explanation;
XPROC_ERRORS(String explanation) {
this.explanation = explanation;
}
}
/**
* Explains the error
*
* @param errorQName
* @return
*/
public static String translate(QName errorQName) {
String code = errorQName.toString().substring(4);
if (EnumUtils.isValidEnum(XPROC_ERRORS.class, code))
return XPROC_ERRORS.valueOf(code).explanation;
return "no explanation found";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy