I have a dataset which is a simple dataset right now based on breakfast.
breakfast.xml
<?xml version="1.0" encoding="iso-8859-1"?><!-- Edited by XMLSpy® -->
<breakfast_menu>
<food>
<name>BelgianWaffles</name>
<price>$5.95</price>
description>two of our famous Belgian Waffles with plenty of real maple syrup</description>
<calories>650</calories>
</food>
<food>
<name>StrawberryBelgianWaffles</name>
<price>$7.95</price>
<description>light Belgian waffles covered with strawberries and whipped cream</description>
<calories>900</calories>
/food>
food>
name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price> <description>light Belgian waffles covered with an assortment of fresh berries and whipped cream</description> <calories>900</calories> </food> <food> <name>French Toast</name> <price>$4.50</price> <description>thick slices made from our homemade sourdough bread</description> <calories>600</calories>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>two eggs, bacon or sausage, toast, and our ever-popular hash browns</description> <calories>950</calories>
</food></breakfast_menu>
breakfast.xslt
<?xml version="1.0" encoding="ISO-8859-1"?><!-- Edited by XMLSpy® --><html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Xml;using System.Xml.Xsl;using System.Xml.XPath;
using System.Data;using System.Configuration;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls; public partial class Default2 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) {
XPathDocument myxmlDoc = new XPathDocument(Server.MapPath(".\\App_data\\breakfast.xml")); XslCompiledTransform myXSLTransform = new XslCompiledTransform(); myXSLTransform.Load(Server.MapPath(".\\App_data\\breakfast.xslt")); ; myXSLTransform.Transform(Server.MapPath(".\\App_data\\breakfast.xml"), null, Response.Output);
}
breakfastmy.xml
<?xml version= "1.0"?><?xml-stylesheet type="text/xsl" href="breakfastmy.xslt"?><breakfast_menu> <food> <name>BelgianWaffles</name> <price>$5.95</price> <description>two of our famous Belgian Waffles with plenty of real maple syrup</description> <calories>650</calories> </food> <food> <name>StrawberryBelgianWaffles</name> <price>$7.95</price> <description>light Belgian waffles covered with strawberries and whipped cream</description> <calories>900</calories> </food> <food> <name>Berry-Berry Belgian Waffles</name> <price>$8.95</price> <description>light Belgian waffles covered with an assortment of fresh berries and whipped cream</description> <calories>900</calories> </food> <food> <name>French Toast</name> <price>$4.50</price> <description>thick slices made from our homemade sourdough bread</description> <calories>600</calories> </food> <food> <name>Homestyle Breakfast</name> <price>$6.95</price> <description>two eggs, bacon or sausage, toast, and our ever-popular hash browns</description> <calories>950</calories> </food></breakfast_menu>
<body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE"> <table border="1"> <tr bgcolor="#9acd32"> <th>DESCRIPTION</th> <th>CALORIES</th> <th>PRICE</th> </tr> <xsl:for-each select="breakfast_menu/food"> <!--if i click on the first kind of breakfast which is belgianwaffles and write it here explicitly it shows the details for this kind of breakfatst but if pass it through xsl:param brkname it doesnt return anythng-->
Actullay my problem is that i m trying to pass value of breakfast name from default2.aspx page through querystring to default3.aspx page and from there i extract value of breakfast name through request.querystring which is stored in brkname variable.but my problem is that i have to pass this brkname to xslt page and filter the records and only show the details of the breakfast that have come in from querystring. While being specific brkname added in the parameter in xslt doesnt get the value .How can i do this ?Please provide help in this issue.
Umbraco QueryString
I want to take the all QueryString of the context in an xslt file .
Is something similar with :
or i have to build my own helper to get it.
Best regards , Vlad
I am not sure why you are trying to use some C# code in an XSLT file? I does not make sense I think? :)
Why don't you just use the built in XSLT extension to get the value from your Querystring?
You should be able to write something like this
Hope this is what you mean?
/Jan
Hi,
you can use the umbraco.library for that. That allready has a function: RequestQueryString(string key)
HTH,
PeterD
As Jan & PeterD have suggested this is the best way to do it - this has been documented in the WIKI
http://our.umbraco.org/wiki/reference/umbracolibrary/requestquerystring
Also Vlad you may find browsing through the WIKI useful, especially the umbraco.library section
http://our.umbraco.org/wiki/reference/umbracolibrary
<xsl:value-of select="umbraco.library:RequestQueryString('yourkey')"/>
it's the same with
I copy/paste from umbraco.dll .
I want to take the all Querystring , not just the value of a single key .
http://server/path/program?field1=value1&field2=value2&field3=value3...
i want to return from this url : field1=value1&field2=value2&field3=value3...
BR,
Vlad
You can create your own xslt extension with Request.QueryString.ToString()
Try this instead, it returns the complete querystring:
You can extend your xslt with your own C# methods - see this example:
http://www.simm.dk/umbraco-corner/articles/using-c-sharp-inside-your-xslt.aspx
I just created a wiki-page instead (same info, better overview):
http://our.umbraco.org/wiki/reference/xslt/extend-your-xslt-with-custom-functions
Thanks Simon for wiki article,
I know how to use c# in xslt, but trick with msxml:assembly is new for me :-)
Hi all, can you help me
I have a dataset which is a simple dataset right now based on breakfast.
breakfast.xml
<?xml version="1.0" encoding="iso-8859-1"?><!-- Edited by XMLSpy® -->
<breakfast_menu>
<food>
<name>BelgianWaffles</name>
<price>$5.95</price>
description>two of our famous Belgian Waffles with plenty of real maple syrup</description>
<calories>650</calories>
</food>
<food>
<name>StrawberryBelgianWaffles</name>
<price>$7.95</price>
<description>light Belgian waffles covered with strawberries and whipped cream</description>
<calories>900</calories>
/food>
food>
name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price> <description>light Belgian waffles covered with an assortment of fresh berries and whipped cream</description> <calories>900</calories> </food> <food> <name>French Toast</name> <price>$4.50</price> <description>thick slices made from our homemade sourdough bread</description> <calories>600</calories>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>two eggs, bacon or sausage, toast, and our ever-popular hash browns</description> <calories>950</calories>
</food></breakfast_menu>
breakfast.xslt
<?xml version="1.0" encoding="ISO-8859-1"?><!-- Edited by XMLSpy® --><html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE"> <xsl:for-each select="breakfast_menu/food"> <div style="background-color:teal;color:white;padding:4px"> <span style="font-weight:bold">
<a target="_blank">
<xsl:attribute name="href">Default3.aspx?Prac=<xsl:value-of select="name"/></xsl:attribute>
<xsl:value-of select="name"/></a>
</span>
</div>
</xsl:for-each>
</body></html>
Default2.aspx.cs
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Xml;using System.Xml.Xsl;using System.Xml.XPath;
using System.Data;using System.Configuration;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls; public partial class Default2 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) {
XPathDocument myxmlDoc = new XPathDocument(Server.MapPath(".\\App_data\\breakfast.xml")); XslCompiledTransform myXSLTransform = new XslCompiledTransform(); myXSLTransform.Load(Server.MapPath(".\\App_data\\breakfast.xslt")); ; myXSLTransform.Transform(Server.MapPath(".\\App_data\\breakfast.xml"), null, Response.Output);
}
breakfastmy.xml
<?xml version= "1.0"?><?xml-stylesheet type="text/xsl" href="breakfastmy.xslt"?><breakfast_menu> <food> <name>BelgianWaffles</name> <price>$5.95</price> <description>two of our famous Belgian Waffles with plenty of real maple syrup</description> <calories>650</calories> </food> <food> <name>StrawberryBelgianWaffles</name> <price>$7.95</price> <description>light Belgian waffles covered with strawberries and whipped cream</description> <calories>900</calories> </food> <food> <name>Berry-Berry Belgian Waffles</name> <price>$8.95</price> <description>light Belgian waffles covered with an assortment of fresh berries and whipped cream</description> <calories>900</calories> </food> <food> <name>French Toast</name> <price>$4.50</price> <description>thick slices made from our homemade sourdough bread</description> <calories>600</calories> </food> <food> <name>Homestyle Breakfast</name> <price>$6.95</price> <description>two eggs, bacon or sausage, toast, and our ever-popular hash browns</description> <calories>950</calories> </food></breakfast_menu>
breakfastmy.xslt
<?xml version="1.0" encoding="ISO-8859-1"?><!-- Edited by XMLSpy® --><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <xsl:param name="brkname" select="/in:inputs/in:param[@name='brkname]'"/> <!--<xsl:variable name="queryStringBase" select="'?qualification=', $qualification, '&studymode=', $studyMode,'&subject=', $subject, '&pagesize=', $pageSize)" /> <brkname> <xsl:value-of select="$brkname"/> </brkname>--> <html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE"> <table border="1"> <tr bgcolor="#9acd32"> <th>DESCRIPTION</th> <th>CALORIES</th> <th>PRICE</th> </tr> <xsl:for-each select="breakfast_menu/food"> <!--if i click on the first kind of breakfast which is belgianwaffles and write it here explicitly it shows the details for this kind of breakfatst but if pass it through xsl:param brkname it doesnt return anythng-->
<!--<xsl:if test="name= 'BelgianWaffles'">-->
<xsl:if test="name=$brkname">
<tr> <td><xsl:value-of select="description"/>
</td> <td>
<xsl:value-of select="calories"/>
</td>
<td> <xsl:value-of select="price"/> </td> </tr> </xsl:if> </xsl:for-each>
</table> </body> </html> </xsl:template></xsl:stylesheet>
Default3.aspx.cs
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Xml.Xsl;using System.IO;using System.Xml;using System.Xml.Xsl;using System.Xml.XPath;public partial class Default3 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { string brkname = Request.QueryString["prac"]; XsltArgumentList argList = new XsltArgumentList(); XPathDocument myxmlDoc2 = new XPathDocument(Server.MapPath(".\\App_data\\breakfastmy.xml")); XslCompiledTransform myXSLTransform2 = new XslCompiledTransform(); argList.AddParam("brkname", "", Request.QueryString["prac"]);
myXSLTransform2.Load(Server.MapPath(".\\App_data\\breakfastmy.xslt")); myXSLTransform2.Transform(Server.MapPath(".\\App_data\\breakfastmy.xml"), argList, Response.Output); }}
Actullay my problem is that i m trying to pass value of breakfast name from default2.aspx page through querystring to default3.aspx page and from there i extract value of breakfast name through request.querystring which is stored in brkname variable.but my problem is that i have to pass this brkname to xslt page and filter the records and only show the details of the breakfast that have come in from querystring. While being specific brkname added in the parameter in xslt doesnt get the value .How can i do this ?Please provide help in this issue.
I wil greatfull to you.
is working on a reply...