def validate(self): schemaData = decode_utf8(self.schemaView.toPlainText()) instanceData = decode_utf8(self.instanceEdit.toPlainText()) messageHandler = MessageHandler() schema = QtXmlPatterns.QXmlSchema() schema.setMessageHandler(messageHandler) schema.load(schemaData, QtCore.QUrl()) errorOccurred = False if not schema.isValid(): errorOccurred = True else: validator = QtXmlPatterns.QXmlSchemaValidator(schema) if not validator.validate(instanceData): errorOccurred = True if errorOccurred: self.validationStatus.setText(messageHandler.statusMessage()) self.moveCursor(messageHandler.line(), messageHandler.column()) background = QtCore.Qt.red else: self.validationStatus.setText("validation successful") background = QtCore.Qt.green styleSheet = 'QLabel {background: %s; padding: 3px}' % QtGui.QColor(background).lighter(160).name() self.validationStatus.setStyleSheet(styleSheet)
def __init__(self): super(MessageHandler, self).__init__() self.m_description = "" self.m_sourceLocation = QtXmlPatterns.QSourceLocation()