As XslTransform is now obsolete, I now use XslCompiledTransform to transform my XML and XSLT documents. When transforming I want an XmlDocument returned so that I can further manipulate the output, to achieve this I use XMLWriter but for some unknown and baffling reason XMLWriter does not respect the ouput method of the XSL document and will ALWAYS give you XML and by XML I mean closing self closing tags etc. which is no good when you’re outputting HTML with textarea, link and script elements. I hate to do it but the only way to be confident of correct output was to parse the output string and replace these elements using a beefy regular expression. Does anyone else know how to force XHTML or even HTML output when using XMLWriter and XslCompiledTransform. I’ve given up looking.
Category Archives: xslt
Step away from the code
Since coming back to Karova, I’ve been doing ALOT more management of projects than I did before. Usually what happens is I get the projects once they’ve been spec’d (and prototype’d if appropriate) and then I manage the completion of the project from dev->staging->live and then pass it back to billing.
We always have a good number of projects on the go and my stack is always packed full of project details. The problem I’m having though is being able to step away from the code. I love coding and I know of no other feeling (achievable in an office environment) better than being in the "zone". With so many projects on-going it’s imperative that I delegate rather than try and get stuck in too much even if I know I am most familiar with a piece of software or technology.
It’s a great opportunity for me to step back from code and focus more on managaing and looking at things from a technologist point of view rather than a coder. Under that role I have already been able to play with Linq, ASP.NET 3.5 and SubSonic. Has anybody been in the same situation and have some advice?. For now I just know I need to stay disciplined and step away from the urge to start ‘xslt’ing and coding my ass off.
Extend your browser – ITWales
Last year I gave a presentation to the ITWales group on Content Syndication. I have been bullied into giving another presentation next Tuesday. I have entitled it “Extending your browser”. Directly from the flyer –
Firefox and the Gecko family of browsers are not simply web browsers, they can be extended to provide custom functionality, and used as platforms for building standalone applications. During the presentation I will discuss the anatomy of the Gecko engine and the Firefox browser, extensions and how to create an extension for the Firefox 2.0 browser using Aggreg8 (http://aggreg8.mozdev.org ) as an example.
Philip is a 2003 Software Engineering graduate of Dublin City University. He has been working at Karova Ltd for two years, on ecommerce and custom web applications, and now holds the position of Senior Developer. Outside the office, he hacks on Firefox extensions and small Python or Perl based open source projects. He loves C#, XSLT, Python, MySQL, WxPython, SVG, XUL, Gecko, Javascript, RSS, CSS, his Labrador puppy, Ubuntu and Mono.
You can also download a PDF version of the flyer. I’m even half way through writing the presentation so this weekend will be a busy one. Once I’m done, I’ll upload the PDFs of the presentation.
C# XML encoding woes
I have a simple XML document fragment with a euro symbol in it:
[code lang=”xml”]
Lorem ipsˆum dolor sit amet,
[/code]
which I want to load into an XML document.
[code lang=”cpp”]
System.Xml.XmlDocument doc=new System.Xml.XmlDocument();
doc.LoadXml(xml);
[/code]
I then output the XML of that doc to see that all is well – alas it is not, It has decided to re-enocde my beautiful numeric entities.
[code lang=”xml”]
Lorem ips€um dolor sit amet,
[/code]
I cannot find a way around this. It still works well, but god damnit . I want my bloody entity references back you bastards. Can anyone please help me. I have tried XMLTextReader and XML streams and all sorts of other google groups induced madness.
Update:
I managed to figure out a way to re-encode the data after it has been loaded into xml (after it has been xslt transformed or just as a string)-
[code lang=”cpp”]
System.Xml.XmlDocument docOut=new System.Xml.XmlDocument();
docOut.LoadXml(xml);
string text = docOut.OuterXml.ToString();
System.Text.StringBuilder sb = new System.Text.StringBuilder(text.Length);
foreach (char c in text)
{
if (c > 0x0080)
{
sb.Append(“&#”);
sb.Append((int)c);
sb.Append(‘;’);
}
else
{
sb.Append(c);
}
}
Log.logError(” sb.ToString(); = “+sb.ToString()+”\n”);
System.IO.StreamWriter sw = System.IO.File.CreateText(outXMLFile);
sw.Write(sb.ToString());
sw.Flush();
sw.Close();
//docOut.Save(outXMLFile);
[/code]
I’m not too sure but there might be a way to override the OuterXML property of the XMLDocument class. I hope so. For now it works and I am chuffed -now to get back to what weekends are really for, laundry and cleaning drinking 🙂
Half Viking Gallery Goes Live
It’s been a while on the back burner but this weekend I went hell for leather and managed to get the necessary coding done to get Halfviking.com live.
I manage all my photos 6000+ photos in Photoshop Elements and I am very happy with how it copes but it’s web gallery export sucks ass.
What I found was that PSE stores it’s data in an Access database. I wrote (using parts and few sub routines form album2gallery) a perl script to extract the data in the DB and write it to XML.
I then wrote a wad of python to parse the XML and create a static version of the gallery you now see. Using the Python Imaging Library I also managed to resize all the images to thumbnails and larger versions. All my photos are up now…. I have nothing to hide 🙂 .
There is still a couple of hitches (some duplicate albums [now fixed :)] and it’s not browser tested and I want to add some funky javascript) but I couldn’t be arsed waiting any longer… enjoy (or not)