cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Conny Krappatsch <co...@smb-tec.com>
Subject RE: XSLT and namespaces: two different planets
Date Fri, 25 Aug 2000 07:26:17 GMT
I would agree with Ed,

I'm missing a very important part in Stefano's stylesheet example: the
namespace(ns) declaration. The stylesheet should look like this:

<xsl:stylesheet ...
    xmlns:my="http://myhost.com/mystuff">

    ...
    <xsl:template match="my:page">
    </xsl:template>
    ....
</xsl:stylesheet>

'my:page' will be expanded using the ns declaration (see Ed's mail).
The prefix can be seen as a link between the elements and the ns
declaration. You can even have several elements (and attributes) with different
prefixes belonging to the same ns (if you set your ns declarations
right).

Conny

Ed Staub wrote:
> Stefano,
> 
> I don't understand...
> 
> clearly you didn't really move the page, just changed the namespace prefix
> in this context.
> 
> Is the issue that the prefix in the stylesheet has to change if a matching
> _source_ prefix changes?  I don't believe this is true; namespaces are
> matched on the URI, not the prefix.  I haven't checked this to be positive
> that it's implemented correctly in Xalan, but I bet it is.  The XPath spec
> is pretty clear; in section 2.3: "A node test that is a QName is true if and
> only if the type of the node (see [5 Data Model]) is the principal node type
> and has an expanded-name equal to the expanded-name specified by the QName."
> ("Expanded name" is local part + URI.
> 
> Is the issue that the prefix in the stylesheet has to change if a matching
> destination prefix changes?  This can be dodged with <xsl:namespace-alias>,
> assuming it works correctly.
> 
> Or, in door #3... did I miss your point entirely?
> 
> -Ed Staub
> 
> -----Original Message-----
> From: Stefano Mazzocchi [mailto:stefano@apache.org]
> Sent: Thursday, August 24, 2000 2:32 PM
> To: Cocoon; Scott Boag
> Subject: XSLT and namespaces: two different planets
> 
> 
> I got my hands dirty with SAX2 and, man, I love their namespace support,
> it's great, clean, perfect, just fits perfectly with what I need.
> 
> Then I look at XSLT and, hmmm, their level of namespace support isn't
> quite what I like... ok, let's make an example:
> 
>  <my:page xmlns:my="http://myhost.com/mystuff">
>    ...
>  </my:page>
> 
> How would a "normal" person access this in XSLT? simple
> 
>  <xsl:template match="my:page">
>  </xsl:template>
> 
> All right (I know you already smell the problem, but keep going) then I
> move my page to
> 
>  <my-stuff:page xmlns:my-stuff="http://myhost.com/mystuff">
>   ...
>  <my-stuff:page>
> 
> because I found that that the "my" prefix is used in another (and more
> famous) schema.
> 
> Great, while good behaving SAX2 applications don't give a damn since the
> "page" element is correctly interpreted (in memory) as
> 
>  http://myhost.com/mystuff^page
> 
> no matter what prefix is used (as the namespace spec rules), in XSLT...
> well, I honestly don't know.
> 
> Please help, the XPath spec is not very clear about this.
> 
> --
> Stefano Mazzocchi      One must still have chaos in oneself to be
>                           able to give birth to a dancing star.
> <stefano@apache.org>                             Friedrich Nietzsche
> --------------------------------------------------------------------
>  Missed us in Orlando? Make it up with ApacheCON Europe in London!
> ------------------------- http://ApacheCon.Com ---------------------
-- 
________________
Conny Krappatsch
SMB GmbH
mailto:conny@smb-tec.com
http://www.smb-tec.com


Mime
View raw message