So if product.xml was loading up as
product.xml?productID=Product1
how can
I only show Product1 data?
I tried to get the value of productID
from the URL but this does not work..
<xsl:param name="productID" />
<xsl:value-of select="$productIDParam"/>
Is what I am trying to do even
possible by just using XML and XSLT?
Before initiating the transformation you need to obtain the value of the "productId" query variable and then pass this value as the value of a global-level, external parameter.
Different XSLT processors have different API for achieving this. For example the .NET XslCompiledTransform processor achieves this using instance(s) of the XsltArgumentList class passed as arguments of its Transform() method.
Here is a complete code example:
using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
public class Sample {
public static void Main() {
// Create the XslCompiledTransform and load the style sheet.
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load("discount.xsl");
// Create the XsltArgumentList.
XsltArgumentList argList = new XsltArgumentList();
// Calculate the discount date.
DateTime orderDate = new DateTime(2004, 01, 15);
DateTime discountDate = orderDate.AddDays(20);
argList.AddParam("discount", "", discountDate.ToString());
// Create an XmlWriter to write the output.
XmlWriter writer = XmlWriter.Create("orderOut.xml");
// Transform the file.
xslt.Transform(new XPathDocument("order.xml"), argList, writer);
writer.Close();
}
}
Therefore, you need to read the documentation of your XSLT processor for a description how to pass external parameters to the transformation.