cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conal Tuohy" <Conal.Tu...@vuw.ac.nz>
Subject RE: XSLT - how to refer to attribute in "calling" element
Date Wed, 12 Nov 2003 02:59:02 GMT
Hi Otmar

I'm not entirely sure of the format of the html form you want to produce, but I think the
issue is that you need to pass a parameter (the article id) to the template which builds the
list of countries for that article.

<xsl:apply-templates select="/data/origin-country-enumeration">
	<xsl:with-param name="article-id" select="@id"/>
</xsl:apply-templates>

See http://www.w3.org/TR/xslt#element-with-param

PS this kind of question is better asked on the MulberryTech XSLT list - you'll usually get
a quicker (and better) response there.

Regards

Con

> -----Original Message-----
> From: Otmar Vobejda [mailto:otmar@hcwerk.cz]
> Sent: Wednesday, 12 November 2003 3:40 p.m.
> To: users@cocoon.apache.org
> Subject: XSLT - how to refer to attribute in "calling" element
> 
> 
> Hi, I have a little problem and I don't know, how to make it. 
> I'll try 
> to show it on the small senseless example :)
> 
> This is source XML, that contains data about some pieces of goods and 
> enumeration of countries, we want to attach to the articles 
> in the HTML 
> form:
> 
> <data>       
>     <goods>
>         <article id="123">DVD Philips</article>
>         <article id="456">TV Panasonic</article>
>     </goods>   
> 
>     <origin-country-enumeration>
>         <item>
>             <id>1</id>
>             <name>Czech Rep.</name>
>         </item>
>         <item>
>             <id>2</id>
>             <name>USA</name>
>         </item>
>         <item>
>             <id>3</id>
>             <name>Japan</name>
>         </item>       
>     </origin-country-enumeration>
> </data>
> 
> Appropriate XSLT:
> 
> <xsl:template match="data">
>     <html><body><xsl:apply-templates select="goods"/></body></html>
> </xsl:template>
> 
> <xsl:template match="goods">
>     <xsl:apply-templates select="article"/>
> </xsl:template>
> 
> <xsl:template match="article">
>     <xsl:value-of select="."/> : <xsl:apply-templates 
> select="/data/origin-country-enumeration"/> <br/>
> </xsl:template>
> 
> <xsl:template match="/data/origin-country-enumeration">
>     <select name="country_for_article_id_{/data/goods/article/@id}">
>         <xsl:apply-templates select="item"/>
>     </select>
> </xsl:template>
> 
> <xsl:template match="item">
>     <option value="{id}"><xsl:value-of select="name"/></option>
> </xsl:template>
> 
> This template should to show name of article and selectbox with 
> countries of origin of article. Each selectbox should have in 
> name ID of 
> article to tell me (not to me exactly, but to the precessed 
> script :), 
> which country user selected to which article.
> 
> Problem is in the line <select 
> name="country_for_article_id_{/data/goods/article/@id}"> 
> ('/data/goods/article/@id' is not absolutly correct, because 
> it returns 
> twice value 123), where I want put IDs of accordant articles.
> 
> I'd like to get this code:
> <html><body>
> DVD Philips: <select name="country_of_article_id_123">
>     <option value="1">Czech Rep.</option>
>     <option value="2">USA</option>
>     <option value="3">Japan</option>
>     </select> <br/>
> TV Panasonic: <select name="country_of_article_id_456">
>     <option value="1">Czech Rep.</option>
>     <option value="2">USA</option>
>     <option value="3">Japan</option>
>     </select> <br/>
> </body></html>
> 
> Thanx a lot for your help!
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 

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


Mime
View raw message