logo

Δ 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=joe
How about all last names of Jons with more than 8 fingers?
getXML.asp?field=lastName&key=first&val=jon&key=fingers&val=>8
How about the top 5 people with 32 teeth, by last name?
getXML.asp?top=5&key=teeth&val=32&orderBy=last
Short 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).

just realized how annoying linking twitter to facebook would make him on facebook. UNDO.

...twittered about 4 days ago

Projects