cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Johnston <coc...@lojjic.net>
Subject Re: Warnings for XSLT
Date Mon, 29 May 2006 01:10:41 GMT
Kamal Bhatt wrote:
> 
> Apologies, I did not see that. Yes, you are right most of those * is not 
> meant to be there. It was rendering right when I pasted it in. I did not 
> realise that is what the browser does. Sorry people, please ignore the 
> unnecessary *. Someone at work worked out that you don't need the node() 
> and * would surfice and seems to fix the problem. I would like to know 
> why it is a problem though..

I'm not sure, but one possibility: node() matches not only elements but 
any node: attributes, text, comments... so your template would have 
ended up trying to call local-name() on nodes that don't have a local 
name.  That would explain why changing it to match only elements with * 
cleared up the problem.

Since this isn't a Cocoon-specific issue, an XSLT mailing list or forum 
may be a better bet for getting the answer.  Or perhaps one specific to 
the XSLT processor you're using (Xalan?), since it's likely different 
processors handle these edge cases differently.

> What I was trying to do is copy one element 
> into another element and remove unnecessary namespace declarations (as 
> this is meant to be published XML) whilst retaining a specific namespace 
> (the supplier namespace).

There is a page on the Cocoon wiki about stripping extra namespace 
declarations, as it is a common problem: 
http://wiki.apache.org/cocoon/RemoveNamespaces

> 
> <files>
>  <supplier ...>
>     ...
>  </supplier>
>  <customRows>
>    ...
>  </customRows>
> </files>
> 
> becomes:
> 
> <sup:supplier sup:xmlns="..." xmlns="..." ...>
>  ...
>  <sup:supplementary>
>    <sup:customRows>
>    ...
>    </sup:customRows>
>  </sup:supplementary>
> </sup:supplier>
> 
> Here is an unadulterated version of the XSLT
> 
> <xsl:stylesheet version="1.0"
>    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>    xmlns:sup="http://www.calypso.net.au/apps/supub/SupplierV1.0"
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>    xmlns="http://www.calypso.net.au/apps/supub/SupplierV1.0"
>    >
>  <xsl:template match="files">
>     <xsl:apply-templates select="sup:supplier"/>
>  </xsl:template>
>  <xsl:template match="sup:supplier">
>    <supplier xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>      <xsl:apply-templates select="@*|node()"/>
>      <supplementary>
>    <xsl:apply-templates select="../customRows"/>
>      </supplementary>
>    </supplier>
>  </xsl:template>
> 
>  <xsl:template match="node()>
>    <xsl:element name="{local-name()}">
>      <xsl:apply-templates select="@*"/>
>      <xsl:if test="count(*) = 0">
>        <xsl:value-of select="."/>
>      </xsl:if>          <xsl:apply-templates select="child::*"/>
>    </xsl:element>
>  </xsl:template>
> 
>  <xsl:template match="@*">
>    <xsl:attribute name="{name()}">
>      <xsl:value-of select="."/>
>    </xsl:attribute>   </xsl:template>
> </xsl:stylesheet>
> 
> 

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


Mime
View raw message