Hi Holger, jholg@gmx.de, 17.12.2009 01:03:
Finally got around working on this, just checked in for review:
Committed revision 70160.
URL: http://codespeak.net/svn/lxml/branch/iso-schematron
This comes complete with doc updates, unittests and whatnot.
Cool, thanks!
* implemented as package lxml.schematron to cleanly bundle all the xsl/rng resources
That's ok. I was about to propose calling it "lxml.isoschematron" when I noticed that that was what you meant anway. :)
* the API allows for handing stylesheet parameters to the separate schematron-to-xsl compilation steps. Currently, these must be provided with stylesheet parameter properties in mind, i.e. text parameters must be given like {'phase': "'mandatory'"}. As all the stylesheet parameters seem to be text parameters, maybe we could make this a little more convenient and auto-strparam() everything in the arg dicts. But I think it's not really worth the effort and better to stick to normal stylesheet parameter handling
I prefer simplifying the interface here and make them all string parameters. I just skimmed through your code, it looks like you want users to pass dicts instead of regular keyword arguments. Why is that?
* I had to modify xmlerror.pxi to stay as close to the original validators' workings as possible:
$ svn diff --old=http://codespeak.net/svn/lxml/trunk/src/lxml/xmlerror.pxi@HEAD --new=src/lxml/xmlerror.pxi Index: src/lxml/xmlerror.pxi =================================================================== --- src/lxml/xmlerror.pxi (.../http://codespeak.net/svn/lxml/trunk/src/lxml/xmlerror.pxi) (revision 70161) +++ src/lxml/xmlerror.pxi (.../src/lxml/xmlerror.pxi) (working copy) @@ -71,6 +71,8 @@ else: self.filename = _decodeFilename(error.file)
+ #FIXME: This seems not to have been used anywhere, so far. Is my addition + #FIXME: of _utf8()-ing message & filename correct? cdef _setGeneric(self, int domain, int type, int level, int line, message, filename): self.domain = domain @@ -78,8 +80,8 @@ self.level = level self.line = line self.column = 0 - self.message = message - self.filename = filename + self.message = _utf8(message) + self.filename = _utf8(filename)
That won't work. Neither the message nor the filename need to be compatible with the UTF-8 encoding.
def __repr__(self): return u"%s:%d:%d:%s:%s:%s: %s" % ( @@ -102,6 +104,12 @@ def __get__(self): return ErrorLevels._getName(self.level, u"unknown")
+#FIXME: Can _LogEntry be settable itself so we don't need this? +cdef class _SettableLogEntry(_LogEntry): + cpdef setGeneric(self, int domain, int type, int level, int line, + message, filename): + self._setGeneric(domain, type, level, line, message, filename) + cdef class _BaseErrorLog: cdef _LogEntry _first_error cdef readonly object last_error @@ -172,7 +180,7 @@ message = u"%s, line %d" % (message, line) return exctype(message, code, line, column)
- cdef _buildExceptionMessage(self, default_message): + cpdef _buildExceptionMessage(self, default_message): if self._first_error is None: return default_message if self._first_error.message is not None and self._first_error.message:
Also, I added a Validator class to isoschematron that mimics etree._Validator. This wouldn't be necessary if etree._Validator made _error_log accessible from python. Can we just do that?
I wonder why this is necessary anyway. Can't we just reuse the error log of the underlying XSLT object? I don't expect that we need to generate any log messages ourselves, do we? Stefan