Flexible queries in distributed structured and semistructured documents