[Zope3-dev] Re: Better access to APIs in paths (was Re: needingviewsclues - template/title troubles)

Martijn Faassen faassen@vet.uu.nl
Thu, 27 Feb 2003 18:49:32 +0100


Shane Hathaway wrote:
> Jim Fulton wrote:
> >But nowhere in your xslt is the namespace prefix stuck inside,
> >much less the middle of, an attribute value.
> 
> http://www.aasted.org/xsl/content.php?ch=5
> 
> This tutorial shows how to use XML namespaces in XSLT.  With the prefix 
> "add" mapped to the namespace "http://www.phonedirectory.org/XML" using 
> an xmlns attribute, an XSLT template may contain this directive:
> 
> <xsl:template match="add:addresses">
> 
> So at least the syntax is familiar to users of XSLT.

Right, XPath picks up the XML namespaces from the XSLT's XML document context.
XPath expressions are stored in attributes.

So if you have an XPath expression like so:

html:head//dc:bar

'html' and 'dc' are looked up in a mapping defined by the XSLT context,
which might look like this:

<p xmlns:html="http://somethingorother.com" xmlns:dc="http://hey.com">
  <xsl:value-of select="html:head//dc:bar" />
</p>

Analogously it could make a lot of sense to just use the normal xmlns
mechanism and not define any separate mechanism for this new kind of
namespace namespaces. So:

<p xmlns:dc="http://hey.com">
  <span tal:replace="here/dc:title" /> 
</p>

The main concern with this is if I had to keep repeating this too often,
for instance if I fill in a slot and want to refer to namespaces defined
in the macro. XML's namespace mechanism has nothing that allows this,
though perhaps XML import or something allows this. Perhaps a kind of
hack that allows you to pass namespaces into context would be okay, though
(possibly turned on by default for ZPT):

<p tal:namespace_include="standard">
  <span tal:replace="here/dc:title" />
</p>

I don't know if any other XML systems have needed something like this
in the past. Perhaps something along these lines has been discussed for
XSLT?

Regards,

Martijn