A list with XML comments

29 03 2007

To take a short break from ASP.Net, I want to go thru and remind myself about a nice little technique I used to create a dynamic “list” type website, with XML comments. The XML comments are interesting because of 2 things, firstly if you force it into a

pre or textarea tag it’s very easy to keep whitespace. Secondly there aren’t any character limitations, so you can use something simple like MSAccess for your database, and then have unlimited comment fields.

I use the ID field from the Database to make each node unique. Then when I’m displaying the contents of a row, I also go and fetch the node with the same ID and stick a link to an XML and XSL file. Of course, this could be problematic with large lists, but if your to-do list is that big, you’ve probably got better things to do then f*cking around with a website.

Here’s the IE only JavaScript I’ve been using:

function applyXSLTWithParam(xmlFileName, xslFileName, paramName, paramValue)
{
var objXML;
var objXSLT;
var objxsltTemplate;
var objxsltProcessor;

try
{
objXML = new ActiveXObject("Microsoft.XMLDOM");
objXML.async = false;
objXML.validateOnParse = false;

objXSLT = new ActiveXObject("MSXML2.FreeThreadedDOMDocument.3.0");
objXSLT.async = false;
objXSLT.validateOnParse = false;

//Load XML and XSLT documents
objXML.load(xmlFileName);
objXSLT.load(xslFileName);

objxsltTemplate = new ActiveXObject("MSXML2.XSLTemplate.3.0");
objxsltTemplate.stylesheet = objXSLT;
objxsltProcessor = objxsltTemplate.createProcessor();
objxsltProcessor.input = objXML;
objxsltProcessor.addParameter(paramName, paramValue);

objxsltProcessor.transform();

return objxsltProcessor.output;
}
catch(e)
{
//error handling
}
}

function more(a,b)
{
backside.style.display ="block"
up.style.display ="block"
up.innerHTML= applyXSLTWithParam("xml/content.xml", "xml/detail.xsl", "proj", b)
}

function editmore(b)
{
backside.style.display ="block"
up.style.display ="block"
up.innerHTML= applyXSLTWithParam("xml/content.xml", "xml/editdetail.xsl", "proj", b)
}

function notepad(a,b)
{
backside.style.display ="block"
up.style.display ="block"
up.innerHTML= applyXSLTWithParam("xml/content.xml", "xml/notepad.xsl", "proj", "1")
}

function less()
{

backside.style.display ="none"
up.style.display ="none"
}

It’s actually quite a nice little scratchpad, where I can take notes while on conf calls or cut and paste whole emails in keeping most of the whitespace.


Actions

Information

Leave a comment