[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] What's wrong with namespaces? Some observations andsuggestions
- From: Michael Sokolov <sokolov@ifactory.com>
- To: Dimitre Novatchev <dnovatchev@gmail.com>
- Date: Sun, 05 Dec 2010 19:57:35 -0500
I would like the namespace-sensitivity of
select="table"
to be the same as the namespace-sensitivity of
select="./table"
but I think your proposal for the latter. Dimitre, would require that
the table children selected by the ./table expression have the same
namespace as the current node, whereas Michael's previous post, which
you seemed to be endorsing (?), would have the first expression above
select table children in any namespace.
I'm not sure which solution is best, but I do know I want consistency
-Mike
On 12/5/2010 7:55 PM, Dimitre Novatchev wrote:
> On Sun, Dec 5, 2010 at 3:41 PM, Michael Kay<mike@saxonica.com> wrote:
>>> An interesting question is how we would write compact XPath
>>> expressions for XML2:
>>>
>>> /*/head/body
>>>
>>> should select the :org.w3c.html.body element.
>>>
>>> Should we have to write:
>>>
>>> /*/head/body/:org.w3c.svg.svg
>>>
>>> or
>>>
>>> could it be:
>>>
>>> /*/head/body/:~svg.svg
>>>
>> My suggestion would be:
>>
>> select=":org.w3c.html.table"
>>
>> selects an element with this precise name
>>
>> select="table"
>>
>> selects a table element in any namespace - that is, an element that has
>> "table" as the final part of its name.
>>
>> Generally I think it's better if XPath is designed to over-retrieve rather
>> than under-retrieve - it's easier for the user to see what they did wrong if
>> they get too much data back than if they get nothing back.
> Yes, this principle is absolutely necessary for a single location step.
>
> When evaluating an expression containing more than one location step a
> useful convention can be used:
>
> ... /Name1/Name2
>
> Select all "Name2" elements that are children of "Name1" elements and
> are in the same namespace as their parents.
>
> That is, it is necessary to specify the full namespace or a part of
> it on a child element, only if the child element is not in the same
> namespace as the parent element.
>
> In this way,
>
> /*/head/body
>
> selects the
>
> org.w3c.html.body
>
> element. Here the top element, its child "head" and its child "body"
> all are in the "org.w3c.html" namespace.
>
> On the other side:
>
> /*/head/body/svg
>
> selects nothing, because the "svg" element isn't in the namespace
> ("org.w3c.html" ) of its parent.
>
> To select the "svg" element, either its full namespace or a part of
> the full namespace that is unique among all namespaces needs to be
> specified:
>
> /*/head/body/:org.w3c.svg.svg
>
> fully specified namespace,
>
> or:
>
> /*/head/body/:~svg.svg
>
> partially specified namespace.
>
> If we need to select all children of "Name1" regardless of their
> namespace, we have this natural notation:
>
> .../Name1/:*.Name2
>
> Using these rules results in a compact and convenient to use
> expression language while it still permits any more verbose form to be
> used.
>
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]