You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Joerg Heinicke <jo...@gmx.de> on 2004/01/09 01:55:49 UTC

XPath problem with default namespace (was: content aggregation + links to used files)

On 08.01.2004 09:09, Nele Vogel wrote:

> Joerg,
> 
> it works! :-))) I removed the default namespace from cincludeFiles.xsl as
> you suggested and changed the match statements in news.xsl. Further I
> removed the default namespace from my XML data. The elements <news> and
> <file> are now matched and properly displayed.

...

> I understand, that working without namespaces is not a good idea, *but for
> now* it enables me to continue my work.

Nice to hear. I played around with your stylesheets and the namespaced 
and prefixed version. First I can confirm the non-working. Second I 
found the reason for it. IMO it's a but in Xalan. If I change the 
select="./@path" to select="./@s:path" it works (with prefix 's' bound 
to you namespace uri). But AFAIK while elements should be in default 
namespace, attributes should not.

(CCing J.Pietschmann as I know he knows a bit about XSLT and XPath too. 
But I don't know if he reads more than encoding and FOP related 
questions. Also CCing xalan-dev as they might be interested or can tell 
me I'm wrong.)

To summarize it shortly:
An element is created using following template

   <xsl:template match="dir:file">
     <xsl:element name="file">
       <xsl:attribute name="path">
         <xsl:value-of select="concat($path,./@name)"/>
       </xsl:attribute>
     </xsl:element>
   </xsl:template>

and default namespace is declared: xmlns="http://www.sevencs.com".

In another stylesheet same default namespace is declared and 
additionally this namespace uri is bound to prefix s.

Following template matches, but the value-of does not work:

   <xsl:template match="s:file">
     <xsl:text>following file was added:</xsl:text>
     <xsl:value-of select="./@path"/>
   </xsl:template>

Only if I change it to @s:path it works. Is this correct??? And what's 
the appropriate part in the spec - always when I search for a specific 
answer I don't find it.

Joerg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: XPath problem with default namespace

Posted by Joerg Heinicke <jo...@gmx.de>.
On 12.01.2004 20:19, J.Pietschmann wrote:

> Joerg Heinicke wrote:
> 
>> To summarize it shortly:
>> An element is created using following template
>>
>>   <xsl:template match="dir:file">
>>     <xsl:element name="file">
>>       <xsl:attribute name="path">
>>         <xsl:value-of select="concat($path,./@name)"/>
>>       </xsl:attribute>
>>     </xsl:element>
>>   </xsl:template>
>>
>> and default namespace is declared: xmlns="http://www.sevencs.com".
> 
> 
> If the attribute is put into the default (prefixless) namespace in
> scope, it's definitely a bug. The XSLT spec states:
>  If the namespace attribute is not present, then the QName is
>  expanded into an expanded-name using the namespace declarations
>  in effect for the xsl:attribute element, *not* including any
>  default namespace declaration.
> while for elements the default namespace is taken into account.
> 
> Will you rise a bug for the XSLT processor (Xalan, I supppose)?

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26075

Joerg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: XPath problem with default namespace

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Joerg Heinicke wrote:
> To summarize it shortly:
> An element is created using following template
> 
>   <xsl:template match="dir:file">
>     <xsl:element name="file">
>       <xsl:attribute name="path">
>         <xsl:value-of select="concat($path,./@name)"/>
>       </xsl:attribute>
>     </xsl:element>
>   </xsl:template>
> 
> and default namespace is declared: xmlns="http://www.sevencs.com".

If the attribute is put into the default (prefixless) namespace in
scope, it's definitely a bug. The XSLT spec states:
  If the namespace attribute is not present, then the QName is
  expanded into an expanded-name using the namespace declarations
  in effect for the xsl:attribute element, *not* including any
  default namespace declaration.
while for elements the default namespace is taken into account.

Will you rise a bug for the XSLT processor (Xalan, I supppose)?

J.Pietschmann

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org