Thread: xsl question
View Single Post
  #2 (permalink)  
Old September 14th, 2005, 02:27 AM
joefawcett's Avatar
joefawcett joefawcett is offline
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Try to avoid using // in paths, it's an expensive process to select all nodes in the document when you know what level they are at anyway.
Your main problem is that your param defaults to Education, i.e. the XSLT tries to evaluate Education as a node test not a string, you need 'Education'. Your search logic can also be simplified, try this:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:param name="LINK" select="'Education'" />

  <xsl:template match="/">   
    <xsl:apply-templates select="HEADER/LINK[@name = $LINK]" />
  </xsl:template>

  <xsl:template match="LINK">
    <h3><xsl:value-of select="@name" /></h3>
    <xsl:apply-templates select="TITLE" />
  </xsl:template>

  <xsl:template match="TITLE">
    <a href="{following-sibling::URL[1]}"><xsl:value-of select="." /></a>  
  </xsl:template>
</xsl:stylesheet>
I think your XML would be easier to manage if you had thius sort of thing:
Code:
  <LINKS name="Education">
    <LINK><TITLE>HighSchool</TITLE>
      <URL>/Intrests.aspx</URL>
    </LINK>
    <LINK><TITLE>Bachelors</TITLE>
      <URL>/Projects.aspx</URL>
    </LINK>
    <LINK><TITLE>Masters</TITLE>
      <URL>/Projects.aspx</URL>
    </LINK>
    <LINK><TITLE>Certifications</TITLE>
      <URL>/Projects.aspx</URL>
    </LINK>
  </LINKS>

--

Joe (Microsoft MVP - XML)
Reply With Quote