Tag Archives: xslt

Search & Replace in XSLT 2

For a project at $WORK, we want to implement Solr’s spelling suggestions. When you ask solr to provide suggestions, it comes back with something like this (the original search was spinish englosh): <response> … <lst name="spellcheck"> <lst name="suggestions"> <lst name="spinish"> <int name="numFound">1</int> <int name="startOffset">19</int> <int name="endOffset">26</int> <arr name="suggestion"> <str>spanish</str> </arr> </lst> <lst name="englosh"> <int name="numFound">1</int> […]

Practical Fascism

On my recent project at work, I’ve instigated a number of features: An XSLT stylesheet that strips out all inline JavaScript and inline CSS before it ever hits the browser. Go-go Unobtrusive JavaScript! Lots of jUnit tests: Every piece of static HTML gets validated via RelaxNG (we had to use RelaxNG in order to allow […]

Client-Side XSLT

I’ve been playing with XSLT in the Browser. It appears simple enough: Just add an xml-stylesheet processing instruction to the top of your XML, pointing at your XSLT. <?xml-stylesheet href=”stylish.xsl” type=”text/xsl”?> But there’s one more condition that needs to be met: Inside the stylesheet itself, you have to say <xsl:output type=”html”/>. Not xml. Not leaving […]

XSLT Character Creation

I’ve just spent most of the afternoon on a character building exercise. I have some XML like this: <symbol unicode=”2103″/> And I need to turn that into the numeric character reference &#x2013;. It’s perfectly possible to do so with a bit of fudging around with <xsl:text disable-output-escaping=”yes”/>. But there’s a slight caveat: You’re not creating […]