RE: RE : [xsl] Setting attributes of FO element

Subject: RE: RE : [xsl] Setting attributes of FO element
From: "Michael Earls" <michael@xxxxxxxxxx>
Date: Wed, 17 Apr 2002 10:42:24 -0400
<xsl:if/> evaluates an expression

<xsl:if test='@colspan'/> is an accurate test to see if a colspan
attribute exists.  No problem there.

>From a technical perspective, it seems the answer was revealed earlier
by stating that you must use the xsl namespace for attribute and
value-of elements (since they are not members of the "fo" namespace).

However, to address your deeper design issue, I have had similar
templates that used some dynamic value to determine the colspan.

If you are creating rows below this row (I'm assuming that this is for a
header column of sorts), consider using count(some_element) where
some_element is the element that you use to render the columns in the
proceeding rows.

Here is an example:
(I have replaced the xsl:element tags with HTML tags to make this easier
to read)

...some HTML...

<tr>
	<!-- I don't use for-each in my production template, I use a
template, but this should suffice for demonstration purposes -->
	<xsl:for-each select="group">
		<td>
			<xsl:value-of select="group/@name"/>
		</td>
	<xsl:for-each>
</tr>
<tr>
	<td>
		<xsl:attribute name="colspan"><xsl:value-of
select="count(group)"/></xsl:attribute>

		This is a cell that takes up all the space
	</td>
</tr>

... Some more HTML ...

Here is a representation (best viewed with fixed-width font like Courier
New):

-------------------
|  A  |  B  |  C  |
-------------------
|                 |
| This is a cell  |
| that takes up   |
| all the space   |
-------------------

While this does not illustrate the concept within your "fo" domain, it
should illustrate my point.  If not, let me know and I'll try to clarify
(I don't know much about XSL/FO).

Michael Earls 

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Nicolas
Mazziotta
Sent: Wednesday, April 17, 2002 10:10 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE : [xsl] Setting attributes of FO element


Attention:
<fo:attribute> and <fo:value-of> do not exist.
<xsl:if> must test a value.
What do you want to do? Could you be clearer (more concrete)?

> -----Message d'origine-----
> De : owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl- 
> list@xxxxxxxxxxxxxxxxxxxxxx] De la part de Emma Larsson Envoyé : 
> mercredi 17 avril 2002 15:47 À : xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Objet : [xsl] Setting attributes of FO element
> 
> Hi all..
> 
> How do I set the attribute to a FO element after the element has been 
> declared?
> 
> I want to do something like this:
> 
> <fo:table-cell>
>     <xsl:if test='@colspan'>
>         <fo:attribute name="number-columns-spanned">
>               <fo:value-of select="@colspan" />
>        </fo:attribute>
>     </xsl:if>
> </fo:table-cell>
> 
> That is, I want to set the attribute number-columns-spanned for the 
> element table-cell. But the attribute is not always set in the XML 
> file, so I can't count
on
> the value being
> set..
> 
> The 'solution' above is not supported, at least not as far as I can
see.
> Is there any other
> way to solve the problem? Any help is appreciated...
> 
> /Emma
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 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