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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass parameter to XML page

Status
Not open for further replies.

NTSGuru

Programmer
Jul 25, 2000
52
0
0
I have an XML page, and an XSL page... I would like to reference the XML page from an HTML page, and using that link, pass a parameter to the XML page that will allow me to filter what the XML page shows. Here's what I have as my XSL (my XML page is well-formed):

<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl=&quot; xmlns=&quot; result-ns=&quot;&quot;>
<xsl:template match=&quot;/&quot;>
<HTML>
<BODY>
<TABLE BORDER=&quot;2&quot;>
<TR><TD>Name</TD><TD>Gender</TD></TR>
<xsl:for-each select=&quot;NTS/person&quot;>
<TR>
<TD><xsl:value-of select=&quot;FirstName&quot;/>
<xsl:value-of select=&quot;LastName&quot;/></TD>
<TD><xsl:value-of select=&quot;Gender&quot;/></TD>
</TR>
</xsl:for-each>
</TABLE>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>


I know how to use the <xsl:if match=&quot;.[Gender='Male']&quot;> clause, but I would like to be able to have a Dynamic match possibility by referencing it this way from HTML:

<A HREF=&quot;mypage.xml?Gender=Male&quot;>Male</A>



Is this possible, or is there an easier way to do this?

TIA
Fred
 
You can use the <xsl:param> element just below the <xsl:stylesheet> element. This will take the variable that is provided in the URL.

So <xsl:param name=&quot;gender&quot;/> should accept your parameter.
NB the name &quot;gender&quot; should be replaced by whatever parameter you've passed it (e.g. Gender, sex-type etc).

You can then use this as a variable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top