[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Forbidden with several xsl:attribute from xsl:appl

Subject: RE: Forbidden with several xsl:attribute from xsl:apply-templates?
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Mon, 30 Jun 2003 18:48:36 +0100
cannot add attribute
I guess the problem is in the "..." that you haven't shown us. It is
probably writing elements or text nodes to the output. You can't write
an attribute after writing a text node or element child to the same
parent.

Michael Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Erik Beijnoff
> Sent: 30 June 2003 16:09
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Forbidden with several xsl:attribute from 
> xsl:apply-templates?
> 
> 
> I'm having a problem with two consecutive <xsl:apply-templates> that
> both should output <xsl:attribute>. I'm having a feeling that 
> I'm trying
> to do a forbidden thing, but I figured I'd turn to the list 
> to be sure.
> 
> Im running FOP togheter with Xalan to create PDF:s. So the 
> first step is
> the transformation of xml via xslt to xsl:fo then to pdf via FOP.
> However, problems occur.
> 
> The execution is as follows:
> 
> 1. A template gets called when an element with a "class" attribute is
> the active node.
> 2. The first apply-templates applies any template that is specific for
> elements with that name
> 3. The second apply-templates applies any template that is 
> specific for
> elements with that class name
> 
> In point three, the output "Cannot add attribute font-family 
> after child
> nodes or before an element is produced. Attribute will be 
> ignored." gets
> output at the command line.
> 
> I'm aware that all <xsl:attribute> must appear in template data before
> any child nodes, but I'd figured that since both 
> <apply-templates> only
> outputs <xsl:attribute>, it should work. Well, it seems like 
> it perhaps
> doesn't work that way after all.
> 
> 
> <!-- The template where the error occurs-->
> <xsl:template match="p">
>    <fo:block>
> 	<!-- First apply works -->
>      <xsl:apply-templates select="." mode="elementselection"/>
> 
>      <!-- Second gets it attribute output ignored -->
>      <xsl:apply-templates select="." mode="classselection"/>
> 
>      <xsl:apply-templates/>
>    </fo:block>
> </xsl:template>	
> 
> <!-- Attributes for a specific type of element is output -->
> <xsl:template match="h1" mode="elementselection">	
>    <xsl:attribute name="font-family">sans-serif</xsl:attribute>
>    <xsl:attribute name="font-size">20pt</xsl:attribute>
>    ...
> </xsl:template>
> 
> <!-- Attributes for an element with a specific class is output -->
> <xsl:template match="*[@class = 'leadtext']" mode="classselection">
>    <xsl:attribute 
> name="border-bottom-color">sans-serif</xsl:attribute>
> 
>    <xsl:attribute name="border-bottom-width">0.5pt</xsl:attribute>
>    ...
> </xsl:template>
> 
> Regards Erik Beijnoff
> erik@xxxxxxxxxxxx
> erik@xxxxxxxxxxxxxx
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.