cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <joerg.heini...@gmx.de>
Subject Re: whitespaces using xsl:copy-of
Date Sat, 31 May 2003 19:36:47 GMT
Hello Stefan,

it's not possible by using <xsl:copy-of/>, but by using the identity 
transformation. Replace your <xsl:copy-of select="tagA"/> with 
<xsl:apply-templates select="tagA" mode="copy"/> and add the following 
template to your stylesheet:

<xsl:template match="node()" mode="copy">
   <xsl:copy>
     <xsl:copy-of select="@*"/>
     <xsl:apply-templates select="*|text()[normalize-space()]" mode="copy"/>
   </xsl:copy>
</xsl:template>

In this identity transformation only elements and text nodes containing 
non-whitespace characters are copied to the output.

Regards,

Joerg

Stefan Pietschmann wrote:
> hi guys,
>  
> at the moment I'm writing a Transformer for Cocoon 2.0.4 and my problem 
> is as follows:
>  
> There are certain tags not touched by the xslt a step earlier in the 
> pipeline and I want to read them out. let's say the structure is:
>  
> <tagA>
>     <sub/>
> </tagA>
>  
> Now I simply use xsl:copy-of in my XSLT to copy tagA over in the output, 
> so I am able to read it out in the following Transformer step.
> There I can search for tagA and make it a Node variable. I want to check 
> whether the first childnode of it is called "sub" or "seb".
> When I just output all the childnodes of tagA with their names 
> (getNodeName()) I get
> child1: "#text:     "
> child2: "sub: ...."
> child3: "#text:    "
>  
> well, it seems obvious that there are whitespaces before and after the 
> sub tag, which occur when using copy-of with an indented (a.k.a 
> pretty-printed) document.
>  If i change the original to be like <tagA><sub/></tagA> sub is the

> first and only childnode, otherwise not.
>  
> Now the question: Can I somehow get rid of whitespaces between tags when 
> copying tagA over to the output in my xslt?
>  
> Thanx for your help and I hope you got what i meant :P
>  
> Stefan Pietschmann

-- 

System Development
VIRBUS AG
Fon  +49(0)341-979-7419
Fax  +49(0)341-979-7409
joerg.heinicke@virbus.de
www.virbus.de


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


Mime
View raw message