XSLT problem

XSLT problem

Post by Slavk » Sat, 05 Jul 2003 17:31:00



I have simple navigation system, that i'd like to improve, so selected item
would look diferent. I'll pass another parameter kategorijaID (over server
control), which I'd like to connect with different class name
(SelectedLink).

<xsl:output method="html" />
<xsl:param name="modulID"></xsl:param>
<xsl:template match="/">

 <xsl:for-each select="/Meni/Modul[$modulID]/Kategorija">
 <table class='TabelaRdeca' cellSpacing="0" cellPadding="2">
  <tr>
  <td>
  <a class='MeniLink'>
       <xsl:attribute name="href">

       </xsl:attribute>

</td></tr></table>
</xsl:for-each>
</xsl:template>

xml file:
<Meni>
     <Modul naslov="tema" modulID="3">
          <Kategorija kategorijaID="1" naslov="Aktualno" link="#" />
          <Kategorija kategorijaID="2" naslov="Ogledalo" link="#" />
          <Kategorija kategorijaID="3" naslov="Povezave" link="#" />
 </Modul>
</Meni>

I stuck. Any help welcome.
Slavko

 
 
 

XSLT problem

Post by Colin Mackenzi » Sat, 05 Jul 2003 17:44:58


not sure what you want exactly but

1/ in your for-each you are currently only matching Kategorija within Modul
which have CONTENT (i.e. text) equal to your modulID parameter.
Lookign at your XML where the modulID is NOT in the content but in a modulID
attrubute, you need


2/ to add processingbased on Kategorija
a) add  parameter for Kategorija
<xsl:param name="vKategorijaID>
b) check for that parameter (I am guessing waht you might want here
e.g.

$vKategorijaID]
would only process Kategorija which match the paremeter
or maybe you want


    <table class='TabelaRdeca' cellSpacing="0" cellPadding="2">
       <tr>
           <td>
               <a>
                    <xsl:attribute name="class">
                        <xsl:choose>

$vKategorijaID">SelectedLink<xsl:when>
                            <xsl:otherwise>MeniLink</xsl:otherwise>
                        </xsl:choose>
                    </xsl:attrribute>
                    <xsl:attribute name="href"><xsl:value-of


                </a>
            </td>
        </tr>
    </table>

Colin


> I have simple navigation system, that i'd like to improve, so selected
item
> would look diferent. I'll pass another parameter kategorijaID (over server
> control), which I'd like to connect with different class name
> (SelectedLink).

> <xsl:output method="html" />
> <xsl:param name="modulID"></xsl:param>
> <xsl:template match="/">

>  <xsl:for-each select="/Meni/Modul[$modulID]/Kategorija">
>  <table class='TabelaRdeca' cellSpacing="0" cellPadding="2">
>   <tr>
>   <td>
>   <a class='MeniLink'>
>        <xsl:attribute name="href">

>        </xsl:attribute>

> </td></tr></table>
> </xsl:for-each>
> </xsl:template>

> xml file:
> <Meni>
>      <Modul naslov="tema" modulID="3">
>           <Kategorija kategorijaID="1" naslov="Aktualno" link="#" />
>           <Kategorija kategorijaID="2" naslov="Ogledalo" link="#" />
>           <Kategorija kategorijaID="3" naslov="Povezave" link="#" />
>  </Modul>
> </Meni>

> I stuck. Any help welcome.
> Slavko


 
 
 

1. XSLT: Problem using variable in XPath statement

I'm having a problem using a variable in an XPath statement.  What I'm
trying to do is fairly simple, but damn it if I can get it to work
:-).

The essential details are as follows:

Named lists of books, and I can make a list out of other lists, as in
the GroupBookList definition

<BookInfo>

   <BookList>
      <Name>PhysicsBooks</Name>
      <Items>
         <Book>...</Book>
         <Book>...</Book>
          ...
      </Items>
   </BookList>

   <BookList>
      <Name>BiologyBooks</Name>
      <Items>
         <Book>...</Book>
         <Book>...</Book>
          ...
      </Items>
   </BookList>

   <GroupBookList>
      <Name>ScienceBooks</Name>
      <Items>
         <BookList>PhysicsBooks</BookList>
         <BookList>BiologyBooks</BookList>
      </Items>
   </GroupBookList>

</BookInfo>

I've got a template that can process a normal booklist of books to
generate some HTML.  For the GroupBookLists, for each reference to
normal booklist it contains, I want to apply that same template... so
for the science books group, it'd generate the HTML that concatenates
the HTML for the PhysicsBooks and BiologyBooks lists.  To implement
this, in the template matching on group booklists, I use a for-each to
iterate through Items/BookList, and within the for-each have the the
following statements:

   <xsl:variable name="bookListName">
      <xsl:value-of select="." />
   </xsl:variable>

   <xsl:apply-templates
       select="/BookInfo/BookList[Name = '$bookListName']" />

This doesn't work.  The bookListName variable has the correct value,
but for whatever reason it's not putting the correct value into the
XPath statement... (I know the XPath statement is correct because if I
put a literal value in there for the bookListname it works
correctly...)  I've also tried various variations on all this but I
can't get anything to work...

Any suggestions would be much appreciated.

2. A VENDRE pour Hobbyists

3. XSLT Problem

4. PIX rule-based syslog entries ?

5. XSLT: problem with transforming for a new namespace

6. Any comments on Psion 3a?

7. xslt: problem with the sum function

8. DESIGNER - Advice please from anyone using it

9. XSLT Problem

10. XSLT problem: entity references inside attribute values

11. XSLT problem

12. Complex xslt problem: adding hierarchies

13. XSLT problem can you help