Beispiel #1
0
# stdlib
from xml.FtCore import get_translator
from xml.xpath import CompiletimeException
from xml.xpath import RuntimeException

_ = get_translator("xpath")

COMPILETIME = {
    CompiletimeException.INTERNAL:
    _("There is an internal bug in 4XPath.  Please report this error code to [email protected]: %s"
      ),
    CompiletimeException.SYNTAX:
    _("Parse error at line %d, column %d: %s"),
    CompiletimeException.PROCESSING:
    _("Error evaluating expression."),
    # CompiletimeException.: _(''),
}

RUNTIME = {
    RuntimeException.INTERNAL:
    _("There is an internal bug in 4XPath.  Please report this error code to [email protected]: %s"
      ),
    RuntimeException.NO_CONTEXT:
    _("An XPath Context object is required in order to evaluate an expression."
      ),
    RuntimeException.UNDEFINED_VARIABLE:
    _('Variable undefined: ("%s", "%s").'),
    RuntimeException.UNDEFINED_PREFIX:
    _('Undefined namespace prefix: "%s".'),
    RuntimeException.WRONG_ARGUMENTS:
    _("Error in arguments to %s: %s"),
Beispiel #2
0
from xml.dom import INVALID_MODIFICATION_ERR, NAMESPACE_ERR, INVALID_ACCESS_ERR
from xml.dom import VALIDATION_ERR

# EventException
from xml.dom import UNSPECIFIED_EVENT_TYPE_ERR

#Range Exceptions
from xml.dom import BAD_BOUNDARYPOINTS_ERR
from xml.dom import INVALID_NODE_TYPE_ERR

# Fourthought Exceptions
from xml.dom import XML_PARSE_ERR

from xml.FtCore import get_translator

_ = get_translator("dom")


DOMExceptionStrings = {
    INDEX_SIZE_ERR: _("Index error accessing NodeList or NamedNodeMap"),
    DOMSTRING_SIZE_ERR: _("DOMString exceeds maximum size"),
    HIERARCHY_REQUEST_ERR: _("Node manipulation results in invalid parent/child relationship."),
    WRONG_DOCUMENT_ERR: _("Node is from a different document"),
    INVALID_CHARACTER_ERR: _("Invalid or illegal character"),
    NO_DATA_ALLOWED_ERR: _("Node does not support data"),
    NO_MODIFICATION_ALLOWED_ERR: _("Attempt to modify a read-only object"),
    NOT_FOUND_ERR: _("Node does not exist in this context"),
    NOT_SUPPORTED_ERR: _("Object or operation not supported"),
    INUSE_ATTRIBUTE_ERR: _("Attribute already in use by an element"),
    INVALID_STATE_ERR: _("Object is not, or is no longer, usable"),
    SYNTAX_ERR: _("Specified string is invalid or illegal"),
from xml.xslt import Error
from xml.FtCore import get_translator

_ = get_translator("xslt")


g_errorMessages = {
    Error.INTERNAL_ERROR: _('There is an internal bug in 4XSLT.  Please report this error code to [email protected]: %s'),
    Error.PATTERN_SYNTAX: _('Syntax error in pattern at location %s (XPattern production number: %d).'),
    Error.PATTERN_SEMANTIC: _('Parse tree error in pattern at location %s (XPattern production number: %d, error type: %s, error value: %s, traceback:\n%s'),

    Error.APPLYIMPORTS_WITH_NULL_CURR_TPL: _('apply-imports used where there is no current template.  (see XSLT Spec)'),
    Error.ILLEGAL_IMPORT: _('import is not allowed here.  '),
    Error.STYLESHEET_PARSE_ERROR: _('Stylesheet (%s): XML parse error at line %d, column %d: %s'),
    Error.CIRCULAR_VAR: _('Circular variable reference error (see XSLT Spec: 11.4) for variable or parameter: (%s, %s)'),
    Error.SOURCE_PARSE_ERROR: _('Source document (%s): %s'),
#    Error.STYLESHEET_PARSE_ERROR: _('Stylesheet(XML) parse exception at line %d, column %d: %s'),
#    Error.SOURCE_PARSE_ERROR: _('Source document XML parse exception at line %d, column %d: %s'),
    Error.ILLEGAL_CALLTEMPLATE_CHILD: _('call-templates child must be with-param., (see XSLT Spec: 6)'),
    Error.ILLEGAL_APPLYTEMPLATE_CHILD: _('apply-templates child must be with-param or sort., (see XSLT Spec: 5.4)'),
    Error.WHEN_AFTER_OTHERWISE: _('when cannot succeed otherwise.'),
    Error.MULTIPLE_OTHERWISE: _('there cannot be more than one otherwise within a choose.'),
    Error.ILLEGAL_CHOOSE_CHILD: _('choose child must be "when" or "otherwise"., (see XSLT Spec: 9.2)'),
    Error.CHOOSE_WHEN_AFTER_OTHERWISE: _('choose cannot have "when" child after "otherwise" child., (see XSLT Spec: 9.2)'),
    Error.CHOOSE_MULTIPLE_OTHERWISE: _('choose only allowed one "otherwise" child., (see XSLT Spec: 9.2)'),
    Error.CHOOSE_REQUIRES_WHEN_CHILD: _('choose must have atleast one "when" child., (see XSLT Spec: 9.2)'),
    Error.ILLEGAL_TEXT_CHILD: _('xsl:text cannot have any child elements"., (see XSLT Spec: 7.2)'),
    Error.ILLEGAL_ATTRIBUTESET_CHILD: _('attribute-set child must be "attribute"., (see XSLT Spec: 7.1.4)'),
    Error.ATTRIBUTESET_REQUIRES_NAME: _('missing attribute-set required attribute name., (see XSLT Spec: 7.1.4)'),
    Error.INVALID_FOREACH_SELECT: _('for-each select attribute must evaluate to a node set (see XSLT Spec: 8)'),
from xml.xpath import RuntimeException, CompiletimeException

from xml.FtCore import get_translator

_ = get_translator("xpath")

COMPILETIME = {
    CompiletimeException.INTERNAL: _('There is an internal bug in 4XPath.  Please report this error code to [email protected]: %s'),
    CompiletimeException.SYNTAX: _('Parse error at line %d, column %d: %s'),
    CompiletimeException.PROCESSING: _('Error evaluating expression.'),
    #CompiletimeException.: _(''),
    }

RUNTIME = {
    RuntimeException.INTERNAL: _('There is an internal bug in 4XPath.  Please report this error code to [email protected]: %s'),

    RuntimeException.NO_CONTEXT: _('An XPath Context object is required in order to evaluate an expression.'),
    RuntimeException.UNDEFINED_VARIABLE: _('Variable undefined: ("%s", "%s").'),
    RuntimeException.UNDEFINED_PREFIX: _('Undefined namespace prefix: "%s".'),
    RuntimeException.WRONG_ARGUMENTS: _('Error in arguments to %s: %s'),
    #RuntimeException.: _(''),
    }

Beispiel #5
0
import XPattern

from xml.FtCore import get_translator

_ = get_translator("xslt")


SYNTAX_ERR_MSG = _("Error parsing pattern:\n'%s'\nSyntax error at or near '%s' Line: %d, Production Number: %s")
INTERNAL_ERR_MSG = _("Error parsing pattern:\n'%s'\nInternal error in processing at or near '%s', Line: %d, Production Number: %s, Exception: %s")

class SyntaxException(Exception):
    def __init__(self, source, lineNum, location, prodNum):
        Exception.__init__(self, SYNTAX_ERR_MSG%(source, location, lineNum, prodNum))
        self.source = source
        self.lineNum = lineNum
        self.loc = location
        self.prodNum = prodNum

class InternalException(Exception):
    def __init__(self, source, lineNum, location, prodNum, exc, val, tb):
        Exception.__init__(self, INTERNAL_ERR_MSG%(source, location, lineNum, prodNum, exc))
        self.source = source
        self.lineNum = lineNum
        self.loc = location
        self.prodNum = prodNum
        self.errorType = exc
        self.errorValue = val
        self.errorTraceback = tb

import threading
g_parseLock = threading.RLock()