On 3/15/07 12:12 PM, "Jason Pamental" <[EMAIL PROTECTED]> wrote in
whole or in part:

> Hi all-
> 
> I'm trying to work through an XML/XSLT solution for creating dynamic
> navigation, in this case in a store. I have the Witango bits worked
> out to create the XML, and am trying to use XSLT (actually more
> specifically the @XSLT tag) to transform that XML into a UL with the
> formatting necessary to work with the menu system I have. My problem
> is mixing in the HTML with the XML attributes I need to construct the
> links. Any tips would be GREATLY appreciated!
> 
> Jason
> 
> Here's the XML:
> <?xml version="1.0" encoding="utf-8" ?>
> <nav>
> 
>    <home catUid="0" name="Store Main Page">
>      <page catUid="9" lo="1" name="Hats"/>
>      <page catUid="1" lo="2" name="Men's Shirts"/>
>      <page catUid="2" lo="3" name="Pet Gear"/>
>      <page catUid="8" lo="4" name="Outerwear">
>        <page catUid="11" lo="1" name="Womens Outerwear"/>
>      </page>
>      <page catUid="10" lo="5" name="Bags &amp; Luggage"/>
>    </home>
> 
> </nav>
> 
> and here's the XSLT:
> 
> <?xml version="1.0" encoding="utf-8" ?>
> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
> Transform">
> <xsl:output method="html" />
> <xsl:strip-space elements="*" />
> 
> <xsl:template match="/">
> <div class="imrcmain0 imgl" style="width:140px;z-index:
> 999999;position:relative;"><div class="imcm imde" id="imouter0"><ul
> id="imenus0">
>     <xsl:apply-templates />
> </ul><div class="imclear">&#160;</div></div></div>
> </xsl:template>
> 
> <xsl:template match="page">
>     <xsl:if test="count(child::*) > 0"><li class="dvm" style="width:
> 100%;"><a href="/store/?c="><span class="imea imeam"><span></span></
> span><xsl:value-of select="@name" /></a>
>       <div class='imsc'><div class='imsubc' style='width:
> 154px;top:-28px;left:135px;'><ul>
>         <xsl:apply-templates /></ul></div></div></li>
>     </xsl:if>
>     <xsl:if test="count(child::*) = 0">
>      <xsl:if test="count(parent::*) = 1"><li class='dvm' style='width:
> 100%;'><a href="/store/?c="><span class="imea imeam"><span></span></
> span><xsl:value-of select="@name" /></a>
>         <xsl:apply-templates /></li>
>      </xsl:if>
>      <xsl:if test="count(parent::*) > 1"><li><a href="/store/?
> c="><span class="imea imeam"><span></span></span><xsl:value-of
> select="@name" /></a>
>         <xsl:apply-templates /></li>
>      </xsl:if>
>     </xsl:if>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> What I'm trying to do is create the links with the element attribute
> 'catUid' evaluated within the 'href' - so instead of '<a href="/
> store/?c=">' I'd have <a href="/store/?c=9"> where the 9 is derived
> from this: <xsl:value-of select="@catUid" />. I've tried putting it
> inside the link like so: <a href="/store/?c=<xsl:value-of
> select="@catUid" />"> but that blows up. I've also tried wrapping
> either side of the portions of the link in CDATA tags but that didn't
> seem to help either. Can anyone give me some pointers here?
> 
> Thanks a bunch,
> 
> Jason
> 
> (feel free to tell me that I'm nuts to do this - I haven't figured
> out a way to handle the recursion in Witango directly, but I also
> want to learn about XSLT and be able to apply it in a wider range of
> solutions)


1) You need to use what is called "attribute value templates" (AVT)
<http://www.w3.org/TR/xslt#attribute-value-templates>.

This basically "processes" the value and inserts it directly.

<a href="/store/[EMAIL PROTECTED]">...</a>

2) An alternative is to concatenate the value and apply the attribute to the
HTML tag:

<a>
    <xsl:attribute name="href"><xsl:value-of
select="concat('/store/?c=,@catUid}')" /></xsl:attribute>

...
</a>

3) And if you really are having problems, set the value to a variable and
use in the AVT:

<xsl:variable name="c"><xsl:value-of select="@catUid" /></xsl:variable>
<a href="/store/?c={$c}">...</a>

Sometimes it depends upon how complex the attribute is.

-- 
Beverly Voth               Tier3 Data & Web Services Group, LLC
606-864-0041               http://www.tier3web.com/xml.htm

                Certified FileMaker 7 Developer
                     Web Design & Hosting
  Coldfusion, Witango, PHP, MS SQL, MySQL, FMP, XML/XSLT, CSS
Over 12 years experience integrating databases and the internet!

________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

Reply via email to