Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Variable/Dynamic test condition based on input parameters

From: "Alex" <hfamili@-----.--->
To: 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&#0;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>

&#160;<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.




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent