cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Otmar Vobejda <ot...@hcwerk.cz>
Subject XSLT - how to refer to attribute in "calling" element
Date Wed, 12 Nov 2003 02:39:50 GMT
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


Mime
View raw message