Hi Flibbles,

Indeed, without a way to switch between namespaces, we're left with the
name() or local-name()-based expressions that can quickly become
ridiculous. Nonetheless, handling namespaces would be a very useful
feature, not only to ease the expression of paths, but also to handle the
cases where different schemas are used within the same document.

The most reasonable way to deal with this is probably the approach taken by
XSLT. It would involve that your now called $xpath features a default
namespace attribute, plus that it accepts a set of user-defined aliases,
like this:

<ul>
  <$xpath xmlns:ns1="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"
          xmlns:ns2="urn:schemas-microsoft-com:officedata"
          xmlns:ns3="http://ns.editeur.org/onix/3.0/reference";
          xmlns:ns4="http://www.w3.org/1999/xhtml";
          xmlns=ns3
          for-each="/OnixMessage/Product/*/Text/ns4:p/text()"
          variable="foo">
  <li><<foo>></li>
</$xpath>
</ul>

This would retrieve the text content of any XHTML paragraph appearing in
Text elements inside an ONIX document.

Note that ideally it should also be nestable so that the default namespace
can be changed temporarily to one of the namespaces defined in an outer
$xpath.

Cheers,
Xavier.

Le sam. 2 mai 2020 à 01:43, Flibbles <[email protected]> a
écrit :

> I'm trying to add namespace support now, and I have a question for you,
> Xavier, since you seem to have more experience with them.
>
> Are they actually this awful?
>
> Named namespaces aren't too bad. Just tie the prefix to the url, (like nm
> to http://namespace.com) and you can
> /nm:call/nm:elements/nm:all/nm:the/nm:way/nm:down.
>
> But if you use default namespaces, the standard XPath practice is to /
> [local-name()='make']/[local-name()='your']/[local-name()='paths']/
> [local-name()='like']/[local-name()='this'].
>
> Is this for real? Is it really that bad? It looks like the best
> alternative I can do is make it so any undeclared prefix can act as the
> default namespace, but I get the sense that's not an expected practice.
>
> -Flibbles
>
> --
> You received this message because you are subscribed to the Google Groups
> "TiddlyWiki" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/tiddlywiki/41ba7ea9-0477-4409-86fe-35f7b2167a6b%40googlegroups.com
> <https://groups.google.com/d/msgid/tiddlywiki/41ba7ea9-0477-4409-86fe-35f7b2167a6b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/CADeSwYNzGbfxovYEKai_xEx8ZsgfuohEZ4fHQ0hUe80NVjFrTw%40mail.gmail.com.

Reply via email to