Forum Moderators: open
<query name="OrderSum" rowElementName="OrderTotal">
<sql>
<![CDATA[
select ordertotal from orders where ordernumber = @ordernum
]]>
</sql>
<queryparam paramname="@ordernum" paramtype="runtime"
requestparamname="ordernumber" defvalue="0" sqlDataType="int"
validationpattern="^\d{1,9}$" />
</query>
and here is the template where I am trying to insert it.
<xsl:template match="/">
<html>
<head>
<title>
<xsl:value-of
select="aspdnsf:AppConfig('StoreName')"
disable-output-escaping="yes" />
- DISTRIBUTOR NOTIFICATION ORDER NUMBER
<xsl:value-of select="$ordernumber" />
</title>
</head>
<body>[snip]
<td valign="top" align="left">test</td>
[/snip]</body>
</html>
</xsl:template>
I need to insert what my query returns where test is. I really have no idea how to do that. I have little to none experience in xml and just have been thrown into this by my employer. Thanks in advance,
[snip/]
[edited by: httpwebwitch at 11:45 pm (utc) on July 19, 2009]
[edit reason] removed specifics and code dump [/edit]
2) pass it into your XSL template as a parameter (read more about that, here [ca3.php.net])
3) use that parameter within your XSLT just as though it was a variable, like this:
<xsl:value-of select='$myparametername'/>
If so, the only documentation you'll have is the XML template you've got that was left behind w/ the existing store. Do you see any other places where a <query> is defined, and the results are inserted into HTML?
For instance, skim through the XML looking at all places where the word "OrderSum" appears. Maybe the back-end is reading the XML, performing DB transactions, then rewriting the XML with data injected into it.
Since it's ASP.NET, it's possible you're dealing with a compiled DLL, not the raw source code. Do you have the entire .NET Solution available (a *.sln file), and/or all the little *.cs files that make up the project? (please say yes)! In Visual Studio, I'd start with a File-In-Files search for "XML" or "XSLT" or "transform" or "param" and see what turns up in the source code. Then you can put it in "debug mode", add breakpoints, and step through the methods a line at a time and watch what happens as the XML is parsed and turned into an email message.
I've used C# (ASP.NET) on quite a few projects, but it is not my primary language. If this turns out to be an ASP.NET problem, we may need to rope in some help from people in the ASP.NET forum.
<query name="OrderItems" rowElementName="lineitem">
<sql>
<![CDATA[
select od.*
From dbo.Orders_ShoppingCart od with (NOLOCK)
where od.ordernumber = @ordernum and od.DistributorID = @distributorid
]]>
</sql>
<queryparam paramname="@ordernum" paramtype="runtime"
requestparamname="ordernumber" defvalue="0" sqlDataType="int"
validationpattern="^\d{1,9}$" />
<queryparam paramname="@distributorid" paramtype="runtime"
requestparamname="DistributorID" defvalue="0" sqlDataType="int"
validationpattern="^\d{1,9}$" />
</query>
Here is where I believe that query populates the xml because that is where I added test and it appears where it should in the email.
<table border="1" width="75%" cellspacing="0"
cellpadding="4">
<tr>
<td valign="top" align="left" width="60%">
<b>Item</b>
</td>
<td valign="top" align="left">
<b>Mfg Part #</b>
</td>
<td valign="top" align="center">
<b>Qty</b>
</td>
</tr>
<!-- ITEM_START -->
<xsl:apply-templates
select="/root/OrderItems/lineitem" />
<!-- ITEM_END -->
<tr>
<td></td>
<td valign="top" align="left">Total Order</td>
<td valign="top" align="left">test</td>
</tr>
</table>
I notice the root/OrderItems/lineitem. Does that have anything to do with it? It was my assumption that xml files had to have a layout already defined and then they could populate that. I can't seem to find this layout anywhere though? I really don't know enough to make too many assumptions though :). Thanks for all of your help.