homepage Welcome to WebmasterWorld Guest from 54.237.54.83
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
Modfying existing xml with little experience
andrewsmd




msg:3954473
 4:31 pm on Jul 17, 2009 (gmt 0)

I have an xml file that I have posted the entire file at the end of this. Right here I will post the relevant code.
Here is a query

<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]

 

httpwebwitch




msg:3955669
 11:37 am on Jul 20, 2009 (gmt 0)

1) do the query, get the result. Turn it into an XML fragment.

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'/>

andrewsmd




msg:3955769
 2:03 pm on Jul 20, 2009 (gmt 0)

Thank you for your response. Is there anywhere I can read about just xml. This site isn't doe in php.

httpwebwitch




msg:3955966
 6:29 pm on Jul 20, 2009 (gmt 0)

Then what is it done in?
To do SQL queries, you must be building the site with a server-side scripting language, like PHP, C#.NET, ASP.NET, JSP, ColdFusion... ?

You can not interact with a database via client-side XML and XSLT alone.

andrewsmd




msg:3955969
 6:36 pm on Jul 20, 2009 (gmt 0)

It is an asp dot net storefront website that was custom built for us. We had a client call in and want the layout of this confirmation email sent changed. ASP is the server language used. This project is enormous and I was just thrown into it. I have managed to send the total order and test where they should be positioned. I just copied the syntax to create the query from another query already in the xml file. If I need to edit some asp page, then is there somewhere in the xml file that would point to that script so I would know which one to edit? I really have never worked with this at all and so it's rather daunting.

httpwebwitch




msg:3956048
 8:27 pm on Jul 20, 2009 (gmt 0)

Since it's custom-built, I'm guessing there is no documentation nor support, and the developer(s) who built it are long gone. Am I right.

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.

andrewsmd




msg:3956069
 8:47 pm on Jul 20, 2009 (gmt 0)

I have all of the cs code behinds. It is a web project, but if I have to edit the cs files, I can just re publish it. I copied that query syntax following another query on the same page. I know quite a bit about asp.net but I develop in VB. If I need help in the cs, I can get that somewhere else. Right now, I don't even really know what I am supposed to change to make the xml do what I want to. I'll post a couple pieces of the file to see if that helps you any. Here is a query that was already in the file

<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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved