Am Mittwoch, 4. April 2007 15:20 schrieb Nikolay Samokhvalov: > > To determine if an XML datum is a document, call xml_is_document(). The > > implementation of that function is probably not the best possible one, > > but what the xpath() code does it totally wrong nevertheless. > > You are proposing 2-3 (depends on the case) parsing times for the one XML > value instead of current 1-2
I know it's bad, and something like adding a bit (byte) to mark this in the value would be good, but that doesn't change the fact that (xmlStrncmp((xmlChar *) VARDATA(data), (xmlChar *) "<?xml", 5) == 0) is not a valid method to tell apart a document from a fragment. Proof: pei=# select xml '<?xml version="1.0"?><foo>bar</foo>' IS DOCUMENT; ?column? ---------- t (1 row) pei=# select xml '<?xml version="1.0"?><foo>bar</foo><foo>bar</foo>' IS DOCUMENT; ?column? ---------- f (1 row) pei=# select xml '<foo>bar</foo>' IS DOCUMENT; ?column? ---------- t (1 row) pei=# select xml '<foo>bar</foo><foo>bar</foo>' IS DOCUMENT; ?column? ---------- f (1 row) -- Peter Eisentraut http://developer.postgresql.org/~petere/ ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster