Monday, 4 October 2010

XQJ: binding document or sequence in pipeline

Bad thing from Cocoon / SAX pipeline point of view.
I found no way to bind SAX events effectively. Two options are available:

  • SAXSource - you must buffer events and then send them out on parse() method on XMLReader.
  • Provide StAX stream.

Both require buffering of SAX events, which can be a trouble in case of large XMLs. It kills all the elegancy and small memory foot-print.

An alternative would be to use StAX pipelines, which makes XSLT for example less effective.

I hope I mess something in docs, but...


So I must abandon the idea of using XQJ with C3 and Sedna for a moment, additional reasons: Sedna doesn't support latest XQuery things XQJ is good for and available XQJ implementation has closed source.
I switch back to default Sedna API.

TinyOS smells even better than I suspected : TUnit

#define assertEquals(msg, expected, actual)\
  if ((expected) != (actual)) {\
    assertEqualsFailed(msg, ((uint32_t) expected), ((uint32_t) actual), unique(UQ_ASSERTION));\
  } else {\
    assertSuccess();\
  }


So this is some holiday!
expected and actual are evaluated twice!
If you put this macro inside some if-else without nesting in {} you will get very funny things!


Why not:

#define assertEquals(msg, expected, actual) ({\
uint32_t e = expected;\
uint32_t a = actual;\
  if (a != e) {\
    assertEqualsFailed(msg, e, a, unique(UQ_ASSERTION));\
  } else {\
    assertSuccess();\
  }\
})


Why?!

How to fix it? - use Contiki.

Thursday, 23 September 2010

Good and pitty things about Sedna 3.3

Charles Foster implemented and XQJ API for Sedna - http://www.cfoster.net/sedna/xqj/
I made initial Cocoon3 components wrapping it, perfomance to be analyzed.
XQuery external variables can be used easily and loaded from streams/URLs.

And it would be natural to use XQuery update with external variable, ala:
declare variable $x external;
for $a in $x/a
return

    if( ... )
    then(
        insert
             ...
        into collection('aaa')/a[ id = $a/id ]
    )
    else (
        replace  ...

    )
It promises clear perfomance gains - parsed once in Sedna, no Java parsing-serialization.

And here comes pitty thing Sedna 3.3 doesn't supported "nested updates" - update can be only one and at the top of query. Ofcourse you can do some tricks still, but pitty.

Sedna team promises to implement XQuery update facility, but no timeline.

Anyway, I do not think this small thing will switch me to another XML DB :)

Thursday, 9 September 2010

Found smaller bug in NesC

Funny, suppose we have:

typedef struct 
{
    int a;
}strukt;


interface I
{
    command strukt func();
}

then
    call I.func().a 
doesn't work, it try to call "I.func().a", but
    (call I.func()).a 
helps :)

This call is strange indeed, main thing it is absolutely unneeded.

Common answer is - do not use TinyOS, it is too much a set of degree and diploma works, too less usable.

Tuesday, 27 July 2010

Thursday, 10 June 2010

Cocoon XML Pipelines

I was asked for an introductory description of pipelines and found nothing better than this old Cocoon intro.
Do you know some good one?

Main thing I want to highlight - pipelines are completely different paradigm to work with XML, although it has all the same parts - SAX, XSLT.

Actually you can look at W3C XProc - this has much more features, but I know no good implementation.

Cocoon is really good and comfortable - good Spring usage, everything is automated with Maven, very easy to make extensions using existing components. And Cocoon does everything I need.