Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLT xsl:param undefined

Status
Not open for further replies.

JoeMcGarvey

Programmer
Oct 31, 2002
47
US
Hi,
I have two xslt templates. The second template is called (xsl:call-template) by the first template. The second template can also be rendered separately from the first template, so it stands alone. The first templates XML contains a node that defines the "src" of an "img" tag that is in the second template.

I have an xsl:param "pageXML" that is set in the first template so the second called template knows which XML file to pull the "img src" value from.

FIRST TEMPLATE:
<xsl:param name=&quot;pagexml&quot;><xsl:value-of select=&quot;$xmlfile&quot;/></xsl:param>

<xsl:call-template name='pe_topnav'>
<xsl:with-param name='xmlfile'><xsl:value-of select='$global.path'/><xsl:value-of select='document($pagexml)//entity[@id=&quot;Navigation&quot;]/value'/></xsl:with-param>
</xsl:call-template>

SECOND TEMPLATE:
<img border=&quot;0&quot;>
<xsl:attribute name=&quot;src&quot;>
<xsl:apply-templates select=&quot;document($pagexml)//entity[@id='NavigationPhoto']/value&quot; mode=&quot;asset&quot;></xsl:apply-templates>
</xsl:attribute>
</img>

PROBLEM:
The above works when rendering the first template because the param is defined. It fails when rendering the second template alone because the xsl:param &quot;pagexml&quot; is &quot;undefined&quot;.

QUESTION:
How can I write an xsl:choose statement to say &quot;If xsl:param(&quot;pagexml&quot;) is undefined, set the &quot;src&quot; equal to &quot;anotherimage.gif&quot;?

Everytime I reference &quot;$pagexml&quot; in my if statement, I get the &quot;undefined&quot; error...

Thanks in advance!


Joe McGarvey - Web Application Developer
Paragraph, Inc. - Paragraph Publisher -
 
I think you mean something like:
Code:
<xsl:template name=&quot;pe_topnav&quot;>
  <xsl:param name=&quot;xmlfile&quot; select=&quot;'anotherimage.gif'&quot;/>
  <do_whatever/>
</xsl:template>

<xsl:template match=&quot;whatever&quot;>
  <xsl:call-template name=&quot;pe_topnav&quot;>
    <xsl:with-param name=&quot;xmlfile&quot;>
      <xsl:value-of select=&quot;$global.path&quot;/>
      <xsl:value-of select=&quot;document($pagexml)//entity[@id='Navigation']/value&quot;/>
    </xsl:with-param>
  </xsl:call-template>
</xsl:template>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top