see whatever…

jump to menu

August 19, 2007

Parsing XPath…

Filed under: Java,Python,XML — see @ 8:00 pm

… not using XPath on XML but actually parsing the XPath itself. I did a quick googling and about one of the few libs there seem to be is SAXPath which is part of Jaxen, the Java XPath lib also bundled with XOM. While I do like XOM and try to use it whenever I need to use XML and Java I was actually looking for an XPath parser for Python. Of course I could use SAXPath with Jython, but I could not find a XPath parser for pure (C)Python.

A basic splitter simply splitting an Xpath in its steps would be sufficient for the beginning so I thought so write my own. This basic functionality should not be too hard but in the end not too useful either… A complete XPath parser would probably be very hard to do, even XPath 1.0 is not the easiest, XPath 2.0 support would even be better.

So I am still wondering though if there is a library (or a part of a library like 4Suite, libxml (or better lxml) which does not seem to do this on first sight…) which does  XPath anyway and would emit the actual parsing of the XPath itself?

August 12, 2007

cssutils ongoings

Filed under: CSS,cssutils — see @ 4:08 pm

Walter Dörwald is currently helping a lot in improving cssutils. So it makes a lot of sense using the Google Codes SVN. Documentation is building up a bit, currently I am writing it in reStructuredText, I do not know yet how (and if) it will find its way in the GCs wiki.

Implementation of CSSValue and subclasses has begun. It will probable take quite a while for a next release (some weeks I guess) which will probably be a new 0.9.3 alpha release. 0.9.2 in in beta 3 now which is probably the last 0.9.2 release.

I always tried to avoided implementing CSSValue etc as it is quite a big area which takes a long time to implement and is somehow not easy to understand (at least for me ;) ). How the different interfaces should play together seems not very clear.

One specific point is why CSSStyleDeclaration.getPropertyCSSValue() for shorthand values should return “None” (null). It seems to make sense to simply return a CSSValueList. Maybe I do not understand this interface right, but it does seem overkill just to use it for values like “border-width: 1px 2px 3px 4px” which I guess it solely should be used for regarding the spec.

Also: If “border-width: 1px 2px” ist set which sets all 4 borders, should the CSSValueList have 2 or 4 values? I still have to decide on this.

Anyway, for now e.g. “background: #fff url(x.gif)” returns a CSSValueList with 2 items of CSSPrimitiveValue in it.

The whole thing gets a bit more complicated as I try to implement or at least “know” newer specs like CSS3 color (e.g. rgba() or hsl()) as well and maybe even include these even as they are not final yet.

I guess browser support for CSS took so long (and is still buggy or unreliable across different vendors and of course not nearly complete) as the specs are not the easiest. cssutils is a library to use stylesheets only, it does not even attempt to render them. Currently there is not even a way to say “I give you an element and you tell me its properties”… Hopefully this will come through time…

Anyway, great to have help and also actual use cases for the lib.

Powered by WordPress