示例#1
0
    def validate(self):
        schemaData = decode_utf8(self.schemaView.toPlainText())
        instanceData = decode_utf8(self.instanceEdit.toPlainText())

        messageHandler = MessageHandler()

        schema = QXmlSchema()
        schema.setMessageHandler(messageHandler)
        schema.load(schemaData)

        errorOccurred = False
        if not schema.isValid():
            errorOccurred = True
        else:
            validator = QXmlSchemaValidator(schema)
            if not validator.validate(instanceData):
                errorOccurred = True

        if errorOccurred:
            self.validationStatus.setText(messageHandler.statusMessage())
            self.moveCursor(messageHandler.line(), messageHandler.column())
            background = Qt.red
        else:
            self.validationStatus.setText("validation successful")
            background = Qt.green

        styleSheet = 'QLabel {background: %s; padding: 3px}' % QColor(background).lighter(160).name()
        self.validationStatus.setStyleSheet(styleSheet)
示例#2
0
    def validate(self):
        schemaData = decode_utf8(self.schemaView.toPlainText())
        instanceData = decode_utf8(self.instanceEdit.toPlainText())

        messageHandler = MessageHandler()

        schema = QXmlSchema()
        schema.setMessageHandler(messageHandler)
        schema.load(schemaData)

        errorOccurred = False
        if not schema.isValid():
            errorOccurred = True
        else:
            validator = QXmlSchemaValidator(schema)
            if not validator.validate(instanceData):
                errorOccurred = True

        if errorOccurred:
            self.validationStatus.setText(messageHandler.statusMessage())
            self.moveCursor(messageHandler.line(), messageHandler.column())
            background = Qt.red
        else:
            self.validationStatus.setText("validation successful")
            background = Qt.green

        styleSheet = 'QLabel {background: %s; padding: 3px}' % QColor(
            background).lighter(160).name()
        self.validationStatus.setStyleSheet(styleSheet)
示例#3
0
    def check_xml_validity(self, xml):
        message_handler = MessageHandler()

        LOGGER.debug("checking phrasebook xml against %s", STYLESHEET)
        f = QtCore.QFile(STYLESHEET)
        f.open(QtCore.QIODevice.ReadOnly)
        schema = QXmlSchema()
        schema.load(f)

        validator = QXmlSchemaValidator(schema)
        validator.setMessageHandler(message_handler)
        result = validator.validate(self.text.encode("utf8"))

        return result, message_handler
示例#4
0
    def check_validity(self, xml):
        '''
        check that the dom validates
        '''
        self.message_handler.reset()

        LOGGER.debug("checking phrasebook xml against %s", STYLESHEET)

        f = QtCore.QFile(STYLESHEET)
        f.open(QtCore.QIODevice.ReadOnly)
        schema = QXmlSchema()
        schema.load(f)

        validator = QXmlSchemaValidator(schema)
        validator.setMessageHandler(self.message_handler)
        result = validator.validate(xml.encode("utf8"))

        if result:
            LOGGER.debug("Feescale complies with stylesheet!")
        else:
            LOGGER.warning(
                "Feescale does not comply with stylesheet %s" % STYLESHEET)
        return (result, self.message_handler.last_error)
示例#5
0
    def check_validity(self, xml):
        '''
        check that the dom validates
        '''
        self.message_handler.reset()

        LOGGER.debug("checking phrasebook xml against %s", STYLESHEET)

        f = QtCore.QFile(STYLESHEET)
        f.open(QtCore.QIODevice.ReadOnly)
        schema = QXmlSchema()
        schema.load(f)

        validator = QXmlSchemaValidator(schema)
        validator.setMessageHandler(self.message_handler)
        result = validator.validate(xml.encode("utf8"))

        if result:
            LOGGER.debug("Feescale complies with stylesheet!")
        else:
            LOGGER.warning("Feescale does not comply with stylesheet %s" %
                           STYLESHEET)
        return (result, self.message_handler.last_error)