Okay. I think I found the proper solution. I have examples and short 
documentation here <https://flibbles.github.io/tw5-xml/>. Basically, when 
elements have namespaces, whether explicit or default, the xpath wants a 
prefix to go with it. In your use-case, you'd do this:

<ul>
<$xpath xmlns:onix="http://ns.editeur.org/onix/3.0/reference";
        xmlns:ns4="http://www.w3.org/1999/xhtml";
        for-each="/onix:ONIXMessage/onix:Product/*/onix:Text/ns4:p/text()"
        variable="foo">
  <li><<foo>></li>
</$xpath>
</ul>


It's a little more verbose than what you were proposing, but the upside is 
that this will never suffer from ambiguous namespaces if multiple default 
namespaces are used within one document. Also, you don't have to add onix: 
prefixes throughout your own documents.

I do have one neat trick though. That xmlns:onix attribute will be 
available in all nested <$xpath> widgets. You could even define xmlns:onix 
using <$set> or <$vars>. Or you can globally define it with \define 
xmlns:onix() in a global macro tiddler. That should help trim down 
verbosity.

Unless you see a flaw with this, I *think* is is probably the way to go. 
Now that I better understand namespaces, being explicit with all namespaces 
in an XPath query actually makes sense to me. No ambiguity. Queries can 
traverse documents with a litany of changing namespace scopes.

-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/dd7264cc-7dd6-4a3f-8417-ef1367042404%40googlegroups.com.

Reply via email to