XSLT Ugliness

Ovid on 2005-09-01T00:06:03

Here's the template I came up with to translate the first character of a string to upper case and subsequent underscores to spaces:

  
    
    
            
    
  

Yuck. Can't even get it Unicode aware (this is processed both client and server side).


XSLT fall out of my head..

Adrian on 2005-09-01T15:48:01

A couple of years back I went through a moderate amount of pain to get XSLT into my head. I wasn't an uber-guru but I could get stuff done without just randomly thrashing about.

Since then I've not had to do any XML that XML::Simple couldn't handle.

A week or so ago I needed to munge some OPML in a way that suited itself to an XSLT solution. Wrote failing test then switched to my code window to discover that.... XSLT had completely fallen out of my head. Seriously. I had to go dig out my Peacock O'Reilly before I could even vaguely remember the syntax.

I'm used to forgetting stuff. I've not had to write any serious C in about a decade - but I can still sit down and read the stuff, and go make minor tweaks if I need to.

XSLT seems to just have completely left my mind. Not a clue. Very weird.

It's possible but even uglier...

Mr. Muskrat on 2005-09-02T21:06:44

You can translate Unicode characters but it's going to be very ugly. You simply put the appropriate Unicode characters into the tranlation string. This will require massive amounts of your time to track down all of the necessary Unicode characters in upper and lower case. Not exactly something I'd want to do.

Extension Functions

ziggy on 2005-09-04T02:28:06

How are you invoking your stylesheet? Is it being run from a Perl script (via XML::LibXSLT)? Can you expose a Perl function as an extension function into the stylesheet and just punt the capitalization to something a little more amenable to solving the problem?

Re:Extension Functions

Ovid on 2005-09-04T04:11:57

I would like to do that but I've set it up to have the browser to handle the XSLT and falling back to server side processing if the browser cannot process XSLT. If I keep running to stuff like this, perhaps I'll rethink it.

Re:

Aristotle on 2005-10-15T16:12:11

The devious hack to leave this on the server would be to use XPath’s document() function to call back to the server. Stick the string in a query paramater and…