cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Otmar Vobejda <>
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 

        <article id="123">DVD Philips</article>
        <article id="456">TV Panasonic</article>

            <name>Czech Rep.</name>

Appropriate XSLT:

<xsl:template match="data">
    <html><body><xsl:apply-templates select="goods"/></body></html>

<xsl:template match="goods">
    <xsl:apply-templates select="article"/>

<xsl:template match="article">
    <xsl:value-of select="."/> : <xsl:apply-templates 
select="/data/origin-country-enumeration"/> <br/>

<xsl:template match="/data/origin-country-enumeration">
    <select name="country_for_article_id_{/data/goods/article/@id}">
        <xsl:apply-templates select="item"/>

<xsl:template match="item">
    <option value="{id}"><xsl:value-of select="name"/></option>

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 
('/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:
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/>

Thanx a lot for your help!

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message