Thread: xsl question
View Single Post
  #1 (permalink)  
Old September 13th, 2005, 06:58 PM
bluisana bluisana is offline
Registered User
Join Date: Sep 2005
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default xsl question

I am having a problem making an xslt template to pase a small xml file I have.

I am passing the xslt file one parameter. I want to use this parameter to match a node that has the parameter in it then loop through its children.

the xml file looks like this.

    <LINK name="Education">
    <LINK name="Home"></LINK>
    <LINK name="Interests"></LINK>
    <LINK name="Contact"></LINK>
    <LINK name="Project"></LINK>
    <LINK name="Work"></LINK>
    <LINK name="About Site"></LINK>

I want to use my passed in parameter to match the name attribute of the link node and loop through the TITLE and URL elements within that node.

I was trying something like this without much luck.

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="" version="1.0">
<xsl:template match="/">

    <xsl:param name="LINK" select="Education"></xsl:param>
    <xsl:for-each select="//HEADER/LINK/@name">
        <xsl:if test="@name=$LINK">
        <xsl:for-each select="//HEADER/LINK/TITLE">
      <xsl:attribute name="HREF">test<xsl:value-of select="TITLE"/>test</xsl:attribute>
      <xsl:value-of select="@name" />




I know the loops above don't exactly make sense right now because I have been changing them so much but I can't get anything I try to work. I am setting the parameter "LINK" above to Education just for testing purposes.

Is there a better way to do this istead of using 2 loops?

Any help would be much apreciated.

Reply With Quote