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

Re: Generate N elements and attribute values

Subject: Re: Generate N elements and attribute values
From: "Kenny Bogoe (BogoeMD)" <kenny@xxxxxxxxx>
Date: Mon, 19 Jul 2004 11:32:21 +0200
html td name
Hi Mukul,
No, it is not for HTML. Actually I going to generate Adobe InCopy files with
tables on the fly. The Adobe InCopy file format is xml and can be imported
into Adobe InDesign to get rich graphic layout.

Regards,
Kenny





> Hi Kenny,
>   By adding more parameters to xsl:call-template, it
> should be possible to generate additional attributes
> for td. For content, I think some other technique
> would be required(I cannot guess just now).
> 
> But I am curious, for what purpose are you thinking to
> use the generated HTML. <td name="1" a="10" b="10">
> does not look like a standard HTML syntax.
> 
> Regards,
> Mukul
> 
> --- "Kenny Bogoe (BogoeMD)" <kenny@xxxxxxxxx> wrote:
>> Mukul, it looks great. I guess it is possible to
>> include one or more td
>> attributes based on variables if I follow your
>> example ? And content as well
>> ?
>> 
>> Result:
>> 
>> <tr no="1">
>> <td name="1" a="10" b="10">AAA</td>
>> <td name="1" a="15" b="20">BBB</td>
>> </tr>
>> <tr no="2">
>> <td name="2" a="25" b="10">CCC</td>
>> <td name="2" a="15" b="15">DDD</td>
>> </tr>
>> 
>> Thanks a lot for your help.
>> Kenny  
>> 
>> 
>> 
>>> Hi Kenny,
>>>  This is a slightly modified version of your
>>> stylesheet. 
>>> 
>>> <?xml version="1.0"?>
>>> <xsl:stylesheet
>>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>> version="1.0">
>>>  
>>> <xsl:output method="xml" indent="yes"/>
>>> 
>>> <xsl:template match="/root">
>>>    <xsl:call-template name="tr">
>>>      <xsl:with-param name="x" select="rows" />
>>>      <xsl:with-param name="y" select="cols" />
>>>    </xsl:call-template>
>>> </xsl:template>
>>>  
>>> <xsl:template name="tr">
>>>     <xsl:param name="x"/>
>>>     <xsl:param name="y"/>
>>>     
>>>     <xsl:variable name="temp" select="/root/rows"
>> />
>>>     
>>>     <tr no="{$temp - $x}">
>>>      <xsl:call-template name="td">
>>>        <xsl:with-param name="x" select="$y"/>
>>>        <xsl:with-param name="y" select="$temp -
>> $x"/>
>>>      
>>>      </xsl:call-template>
>>>     </tr>
>>>    
>>>     <xsl:if test="$x > 1">
>>>      <xsl:call-template name="tr">
>>>       <xsl:with-param name="x" select="$x - 1"/>
>>>       <xsl:with-param name="y" select="$y"/>
>>>      </xsl:call-template>
>>>     </xsl:if>
>>> </xsl:template>
>>>  
>>> <xsl:template name="td">
>>>     <xsl:param name="x"/>
>>>     <xsl:param name="y"/>
>>>   
>>>     <td name="{$y}" />
>>>     
>>>     <xsl:if test="$x > 1">
>>>      <xsl:call-template name="td">
>>>       <xsl:with-param name="x" select="$x - 1"/>
>>>       <xsl:with-param name="y" select="$y"/>
>>>      </xsl:call-template>
>>>     </xsl:if>
>>>  </xsl:template>
>>>   
>>> </xsl:stylesheet>
>>> 
>>> for e.g. when it is applied to XML -
>>> <?xml version="1.0"?>
>>> <root>
>>>   <rows>4</rows>
>>>   <cols>3</cols>
>>> </root>
>>> 
>>> it produces output-
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <tr no="0">
>>>   <td name="0"/>
>>>   <td name="0"/>
>>>   <td name="0"/>
>>> </tr>
>>> <tr no="1">
>>>   <td name="1"/>
>>>   <td name="1"/>
>>>   <td name="1"/>
>>> </tr>
>>> <tr no="2">
>>>   <td name="2"/>
>>>   <td name="2"/>
>>>   <td name="2"/>
>>> </tr>
>>> <tr no="3">
>>>   <td name="3"/>
>>>   <td name="3"/>
>>>   <td name="3"/>
>>> </tr>
>>> 
>>> Regards,
>>> Mukul
>>> 
>>>>>> This is the result tree I need:
>>>>>> 
>>>>>> <tr no="0">
>>>>>>     <td name="0"/>
>>>>>>     <td name="0"/>
>>>>>>     <td name="0"/>
>>>>>> </tr>
>>>>>> <tr no="1">
>>>>>>     <td name="1"/>
>>>>>>     <td name="1"/>
>>>>>>     <td name="1"/>
>>>>>> </tr>
>>>>>> <tr no="2">
>>>>>>     <td name="2"/>
>>>>>>     <td name="2"/>
>>>>>>     <td name="2"/>
>>>>>> </tr>
>>>>>> <tr no="3">
>>>>>>     <td name="3"/>
>>>>>>     <td name="3"/>
>>>>>>     <td name="3"/>
>>>>>> </tr>
>>>>>> 
>>>>>> 
>>>>>> Thanks,
>>>>>> Kenny Bogoe
> 
> 
> 
> 
> __________________________________
> Do you Yahoo!?
> Vote for the stars of Yahoo!'s next ad campaign!
> http://advision.webevents.yahoo.com/yahoo/votelifeengine/

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.