• Home
  • About Jon Dowdle
  • Lifestream
  • Code from TDD Demystified through Kat...
    Passing

    A big thanks to everyone that came out for today's CFMeetup. The code is located here and the presentation is located here. While practicing for this presentation, I noticed [...]

    Read more
KEEP IN TOUCH

Transforming Coldfusion code with XSLT

May16
2009
Written by Jon Dowdle

Note: For those looking for something useful, you won't find it in this post.

For a little Saturday fun, I set out to transform Coldfusion code using XSLT. It didn't take long before I ran into some issues.

The first problem I ran into was that most Coldfusion code doesn't have a root element (not to mention it isn't well formed XML in any sense).  You might be thinking "Well CFCs have a root node" and you'd be right. So I tried to transform a really simple CFC and I was somewhat successful.

The only caveat is that the use of a few almost all tags won't work. For example, <cfreturn foo /> isn't proper XML and Saxon complains. So at this point, this is pretty much a worthless exercise (see note above). Either way I ended up with something that did work (in the functional sense, not the useful sense). See the code below if you're interested in what the XSLT looks like.

XSLT Coldfusion

Very Simple CFC

Transformed Output

Posted in Code - Tagged coldfusion, xslt
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail
« My New Job at Interfolio Inc.
» Bundle of Coldfusion Feeds

4 Comments

  1. Russ's Gravatar Russ
    May 16, 2009 at 5:48 pm | Permalink

    Yeah I have no idea what you would want to do this for. Ideas?

    • Jon Dowdle's Gravatar Jon Dowdle
      May 17, 2009 at 7:40 am | Permalink

      I’ve been working with XSLT for the last week so this crazy idea popped into my head. The closest thing to a real-world application that this could be used in would be generating documentation. Fortunately there are much easier ways of doing this (cfcdoc).

  2. Ben Nadel's Gravatar Ben Nadel
    May 18, 2009 at 8:28 am | Permalink

    @Jon,

    I’ve often thought about playing around with this. I never had a real intent, but I thought it would be fun as I love XML. That’s an interesting problem about the parsing. I guess you’d have to make your own custom parser that would be more tag based than pure XML based.

  3. Jon Dowdle's Gravatar Jon Dowdle
    May 18, 2009 at 9:27 am | Permalink

    @Ben,

    It was a pretty interesting exercise.

    One could pre-process the CF and make it easier to parse. The simplest way would be to use a few simple regex’s on the input but I feel it would miss many cases. On the more complex side you could write a whole grammar and compile the CF to XML using lex/yacc. (note: I’m not sure if there is an easier way to do this, it is just what we used in school 3 years ago)

Recent Posts

  • Code from TDD Demystified through Katas
  • Awesome Web Development Links Found This Week
  • Taggable Demo Video (now with more code)
  • Taggable Demo Video
  • New jQuery Plugin: Taggable

Categories

  • Code
    • MySQL
    • Programming
    • Web Design
  • coldfusion
  • Life
    • Events
  • Reviews
  • Uncategorized
  • Work

Tags

adobe barcamp barcamporlando coldfusion ComplexByteArrayException concat conferences decorator design pattern Events firebug Form fowa html IE ignite infection control iterator javascript job jQuery movies MySql orlando Photos pirate booty pirates plugins poll project python railo software development sql stackoverflow stax.net style taggable tags talk like a pirate tips & tricks tools twitter washington dc Web Design

RSS Syndication

  • All posts
  • All comments

EvoLve theme by Theme4Press  •  Powered by WordPress jDowdle.com