Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Variable/Dynamic test condition based on input parameters Variable/Dynamic test condition based on input parametersTo: NULL Date: 3/9/2007 5:23:00 AM This will sound very much like a VS2005 feature and it is somewhat that way except I am having to use .net framework 1.1. Having said that here is what I am trying to do: Use an XML file (and associated XSLT) to generate the menu for a page - similar to VS2005 site map feature. Here is the XML: <?xml version="1.0" encoding="utf-8" ?> <tossmenu> <menu title="Human Resources" modules="1,2,6" url="#"> <menu title="Holiday Schedule" modules="6" url="holidayschedule.aspx"></menu> <menu title="Employee Handbook" modules="6" url="emphandbook.aspx"></menu> <menu title="Safety Program" modules="6" url="safetyhandb�ok.aspx"></menu> <menu title="Admin" modules="1,2" url="#"> <menu title="New Employee" modules="1,2" url="emp_new.aspx"></menu> <menu title="Employee List" modules="1,2" url="adm_emp_view.aspx"></menu> </menu> </menu> </tossmenu> And here is the XSLT: <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" method="html"/> <xsl:template match="/tossmenu"> <DIV id="menu"> <UL> <LI> <UL> <xsl:apply-templates select="menu"/> </UL> </LI> </UL> </DIV> </xsl:template> <xsl:template match="menu"> <LI> <A><xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute> <xsl:if test="child::node()"> <IMG src="images/popup.gif" border="0"/> </xsl:if>  <xsl:value-of select="@title"/></A> <xsl:if test="child::node()"> <UL> <xsl:apply-templates select="menu"/> </UL> </xsl:if> </LI> </xsl:template> </xsl:stylesheet> This works, but now I need to do some filtering. The issue is that I need to dynamically output menu nodes depending on which modules they belong to - again very similar to the roles attribute in the .net 2.0 site map feature. My .net code loads the XML and XSLT objects and performs the transform. Before doing the transform I would like to pass the set of authorized module numbers to the XSLT transformer (perhaps as xsltargs) and then the XSLT simply outputs only those nodes that have the module numbers listed in their modules attribute (as a comma separated list of numbers). Here is the .net code: Dim oDoc As XmlDocument = New XmlDocument oDoc.Load(context.Server.MapPath("includes/menu.xml")) ' Load the XSLT transformer and inject modules Dim oXSLTransform As XslTransform = New XslTransform oXSLTransform.Load(Server.MapPath("includes/menu.xslt")) Dim xsltOut As System.IO.TextWriter xsltOut = New System.IO.StringWriter Dim writer As XmlTextWriter = New XmlTextWriter(xsltOut) writer.Formatting = Formatting.Indented writer.Indentation = 4 Dim resolver As New XmlUrlResolver oXSLTransform.Transform(oDoc, Nothing, writer, resolver) dim outputStr as string = xsltOut.toString() Thanks. Alex. | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
