Andrew Dunstan wrote:
>
>
> Hannu Krosing wrote:
>> Is it just that in you _can't_ use Xpath on fragments, and you _need_ to
>> pass full documents to Xpath ?
>> At least this is my reading of Xpath standard.
>>
>>
>
> I think that's possibly overstating it., unless I have missed
> something (W3 standards are sometimes not much more clear than the SQL
> standards ;-( )
>
> For instance, there's this, that implies at least that the tree might
> not be a document:
>
> A "/" at the beginning of a path expression is an abbreviation for
> the initial step fn:root(self::node()) treat as document-node()/
> (however, if the "/" is the entire path expression, the trailing "/"
> is omitted from the expansion.) The effect of this initial step is
> to begin the path at the root node of the tree that contains the
> context node. If the context item is not a node, a type error is
> raised [err:XPTY0020]. At evaluation time, if the root node above
> the context node is not a document node, a dynamic error is raised
> [err:XPDY0050].
>
> The problem is that we certainly do have to provide a context node
> (the standard is clear about that), and unless we want to convert a
> non-document to a node-set as James suggested and then apply the xpath
> expression to each node in the node-set, we have no way of sanely
> specifying the context node.
>
No-one has come up with an answer to this, so I propose to remove the
hackery. That leaves the question of what to do when the xml is not a
well formed document ... raise an error?
cheers
andrew