Δ All posts
Serving up SQL as XML to XSL document() via ASP
1 March 2007
Say that 10 times fast.
I am probably the last person on earth using ASP Classic to do XSL transforms (v 1.0). I find XSL's document() function handy to get live SQL data into the transform, and I prefer to use XSL rather than ASP to manipulate/navigate XML. This handy script accepts pseudo-SQL from XSL, builds a SQL query based on simple input, and serves up the result in XSL-edible XML.
A basic example:
xsl:variable name="pseudoSQL" select="'http://x.com/getXML.asp?fields=firstName&table=People&key=id&val=2'"
xsl:variable name="record" select="document($pseudoSQL)/Records/Record"
(Since formatting is kinda wide, future examples start after the domain. Also, you may have to replace '&' with & amp;)
How about all last names of people named 'Jon' or 'Joe'
getXML.asp?field=lastName&key=first&val=jon&val=joeHow about all last names of Jons with more than 8 fingers?
getXML.asp?field=lastName&key=first&val=jon&key=fingers&val=>8How about the top 5 people with 32 teeth, by last name?
getXML.asp?top=5&key=teeth&val=32&orderBy=lastShort of JOINs, I haven't found too much this script can't do. I've done complex grouping with counts, records between date ranges, complex date parts and CASTs, etc. Even when JOINs are neccessary, you can simply pass module=x and viola, it gives you the results of your pre-entered complex SQL (see script).
