On 04/09/07, Florent Georges <[EMAIL PROTECTED]> wrote:
> sebb wrote:
>
>  Hi
>
> > The expression is entered by the user, which is why it is
> > a pain to use the work-round.
>
>  Ok, I misunderstood you.  In this case, you should ask the user,
> besides the XPath expression, to bound namespace prefixes he/she used
> within this expression.
>
>  You should never rely on prefixes outside the context of prefix
> binding.  XPath is very convenient and powerful, but relies on the
> hosting language for some stuff, as the namespace bindings.  Within
> XSLT or any other XML hosting language, it is very intuitive; within a
> GUI it has to be more explicitely thought about.
>
>  For instance, with the following document:
>
> > >    <pr:elem1 xmlns:pr="uri 1">
> > >      <pr:elem2 xmlns:pr="uri 2"/>
> > >    </pr:elem1>
>
> the user could say (plain emails are not the easiest way to draw GUI's
> windows, but you should see the overall principle):
>
>    bindings:
>      u1=uri 1
>      u2=uri 2
>
>    expression:
>      /u1:elem1/u2:elem2
>
> to get the deepest element.

OK, I now understand that XPath requires that the namespace must be
(unambiguously) pre-defined; this is not possible when the namespace
is declared on a child element.

>  See the following page to find a way to set on the Java object
> standing for the XPath expression the bindings that the user set on the
> GUI:
>
> http://xml.apache.org/xalan-j/xpath_apis.html#namespacecontext

I've had a look at that, but it is a bad example: it is actually not
necessary to do any binding in that case. This can be seen by using
the ApplyXPathDOM or ApplyXPath command-line tests - they work fine.

Presumably this is because the namespaces are declared at the top
level, allowing xalan to use the declarations for the whole document.

Also, there has to be a nicer way to declare namespaces - the example
suggests that it is necessary to create ones own (hard-coded) classes.
Surely there is a utility class to do this?

>  Regards,
>
> --drkm
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>      
> ______________________________________________________________________________
> Stockage illimité de vos mails avec Yahoo! Mail. Changez aujourd'hui de mail !
>
>

Reply via email to