I solved the problem. The problem was that I forgot to
>-----Original Message-----
>Ok guys, I could bang my head on the laptop, cause I dont
>get this to work. The scanrio: I am tryting to pass an
>parameter with the help of XslTransform to the xsl file.
>But whenever I run the code, I got the error:
>
>System.Xml.XPath.XPathException: Expression must evaluate
>to a node-set.
>
>Maybe somebody can help me out here:
>
>my xml file:
>
><?xml version="1.0" encoding="utf-8"?>
><CategoryList>
> <Category>
> <MainCategory>1</MainCategory>
> <Description>This is a list my XML
>articles.</Description>
> <Active>true</Active>
> </Category>
> <Category>
> <MainCategory>2</MainCategory>
> <Description>This is a list my XML
>articles.</Description>
> <Active>true</Active>
> </Category>
> <Category>
> <MainCategory>3</MainCategory>
> <Description>This is a list my XML
>articles.</Description>
> <Active>true</Active>
> </Category>
></CategoryList>
>
>my xsl file:
>
><?xml version="1.0"?>
><xsl:stylesheet version="1.0"
>xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"> ><xsl:param name="strXPath" />
>
><xsl:template match="/">
> <xsl:apply-templates select="$strXPath" />
></xsl:template>
>
><xsl:template match="Category">
> <xsl:copy-of select="." />
></xsl:template>
></xsl:stylesheet>
>
>my code:
>
>XmlDocument xmlDoc= new XmlDocument();
>xmlDoc.Load(Server.MapPath("categories.xml"));
>
>XslTransform xslt = new XslTransform();
>xslt.Load(Server.MapPath("categories.xslt"));
>
>XPathNavigator nav = xmlDoc.CreateNavigator();
>
>XsltArgumentList arguments = new XsltArgumentList();
>arguments.AddParam("strXPath", "", nav.Select
>("//Category/MainCategory"));
>
>MemoryStream ms = new MemoryStream();
>xslt.Transform( nav, null, ms, null);
>ms.Seek( 0, SeekOrigin.Begin );
>
>StreamReader sr = new StreamReader(ms);
>
>//Print out the result
>Response.Write(sr.ReadToEnd());
>
>Thanks, Sonu
>.