This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: can templates be nested?


dmitri kerievsky wrote:
>  question is how to transfer the mailto value:
> 
> <xsl:template match="catalog/artist/album/label/person">
>   <a href="{concat('mailto:', @email)}">
>     <xsl:value-of select="@name"/>
>   </a>
> </xsl:template>

When pasting code samples, please re-indent them to use a couple spaces, like
I did above, rather than using tabs. Your second line has 5 tabs(!) which on
many screens means 40 spaces!

The template above matches a 'person' element that has a 'label' parent,
'album' grandparent, and so on. It may not be necessary to specify anything
but 'person' in the match, unless there is a risk you would be processing
any 'person' elements that appear in different contexts.

> <track address="1 main street" telephone="(3333" email="e@opt.net" web=""
> group="yes">joe doe</track>

> the idea was to have the track name appear as hyperlink with
> mailto:e@opt.net. The top template works by itself, but how to
> include that function inside the track template?

Why would you want to invoke the template for 'person' elements? You didn't
quite explain what the correlation is between 'person' and 'track'. In fact, I
see no example of 'person' elements in your XML, so I can only assume that all
the info you need is in the 'track' element. Wouldn't this work (in your track 
template)?

<td align="right">
  <xsl:choose>
    <xsl:when test="contains(@email,'@')">
      <a href="mailto:{@email}";>
        <xsl:value-of select="."/>
      </a>
    </xsl:when>
    <xsl:otherwise>&#160;</xsl:otherwise>
  </xsl:choose>
</td>

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]