Properly Utilize XSLT Parameters with ColdFusion

ColdFusion 19 December 2008 | 3 Comments

Often a CMS will store its content in a database as structured XML. The easiest way to display this data is often through a short XSLT, which ColdFusion can render a transform using the XmlTransform() function, introduced to ColdFusion in ColdFusion MX.

XSLT Parameter Usage

ColdFusion MX 7 introduced the ability to include parameters to the transform. Parameters allow you to pass in values to be rendered by the XSLT that are not included in the original XML. Following is an example of how an external parameter might be used with the following XML and XSLT:

XML:
  1. <Content>
  2.    <Title>My Title</Title>
  3.    <Hyperlink>/articles/my-article-name/</Hyperlink>
  4. </Content>

XML:
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3. <xsl :o utput method="xml" />
  4.  
  5. <xsl:template match="//Content">
  6. <xsl:param name="baseWebUrl" />
  7.    <a>
  8.       <xsl:attribute name="href">
  9.          <xsl:value-of select="$baseWebUrl" /><xsl:value-of select="Hyperlink" />
  10.       </xsl:attribute>
  11.    <xsl:value-of select="Title" />
  12.    </a>
  13. </xsl:template>
  14. </xsl:stylesheet>

Injecting a Parameter

According to the documentation at the Adobe Knowledge Base, parameters are "a structure containing XSL template parameter name-value pairs to use in transforming the document. The XSL transform defined in the xslString parameter uses these parameter values in processing the XML."

Usually when I create structures in ColdFusion, I use the familiar dot shorthand notation:

CODE:
  1. <cfset parameters = StructNew()>
  2. <cfset parameters.favoriteKitten = url.kitten />
  3. <cfset parameters.numberOfKittens = numKittens />
  4. <cfset parameters.baseWebUrl = application.webBase />
  5. <cfset MyXmlContent = XmlTransform(MyXmlDocument,MyXsltDocument,parameters)>

Using this method, my code would consistently fail to pass in any of the parameters. Careful reading of the ColdFusion 7 comments for the XmlTransform function reveals to us that we must use associative array notation for parameters to work properly. It's as easy as switching the assignation of keys in the structure from dot notation above, to the associative array notation below:

CODE:
  1. <cfset parameters = StructNew()>
  2. <cfset parameters["favoriteKitten"] = url.kitten />
  3. <cfset parameters["numberOfKittens"] = numKittens />
  4. <cfset parameters["baseWebUrl"] = application.webBase />
  5. <cfset MyXmlContent = XmlTransform(MyXmlDocument,MyXsltDocument,parameters)>

Structure Notation Reasoning

Why is this the case? Why should it make a difference? Quite likely, as the commentor noted in the documentation, it is due to the syntax of ColdFusion. XML and XSLT allows for the "-" character to be included in variable names. Instead of baseWebUrl, I could have named the parameter base-web-url. Using ColdFusion and dot object notation would have resulted in <cfset parameters.base-web-url = application.webBase />, which obviously would result in an attempted mathematically equation and a ColdFusion error.

So, just remember, don't use dot notation! Use associative array notation, or if you wish, the StructInsert() function to add your structure keys.

I hope this saves you at least half of the hair-tearing-out that I endured.

New MacBook Pros

Apple 12 December 2008 | 0 Comments

MacBook Pro Unboxing

MacBook Pro Unboxing
Originally uploaded by neatlysliced.

Lincoln got a new MacBook Pro and let me tell you, I am drooling in envy. That machine is so slick and streamlined. I almost regret repairing my own MacBook Pro rather than replacing it after my prior water fiasco (regarding which I am, at this very moment, on the phone with AppleCare regarding random power fluctuations).

The glossy screen is a lot nicer than I imagined. Due to the brilliant architecture, it seems a lot thinner, as the edges bevel from closer to the center. The older MacBooks were far more squared off.

The magnetic closing mechanism is much nicer than the button on the old MacBook Pro. It feels more secure, and is resistant to damage. My button has marking damage from where my nail has worn away the finish.

The speaker quality seems much nicer than my MacBook Pro. The entire case feels more solid, due to the new design - all cut from one piece of aluminum!

Apple even moves forward with a green screen - LED backlighting to cut down on energy draining. Expected battery life? Five hours. Highly recommended.

A Panel Apart

CSS 7 December 2008 | 0 Comments

An Event Apart 2008, Day 2, 5:00pm - 6:00pm

Read the previous talk in this series, Designing the Next Generation of Web Apps by Jeff Veen, or view An Event Apart’s Table of Contents

A Panel Apart

Eric MeyerJeffrey Zeldman & Special Guests (Jeff Veen and Cameron Moll)

  • Take ownership of browser standards? Everyone is like, uh, what? 
  • W3C has nothing going on right now: Eric Meyer and Jeff Veen
  • Eric: JS is the only way that we're going to get advanced CSS3 standards
  • JZ: being a part of the w3c is kinda weird, because it's so time consuming, you would need a company to pay you to work at the w3c, but then you wouldn't be into design anymore because you've spent so much time with w3c. Then, you'll be discouraged because there is so much overhead involved in being a part of it, hatemail, mailing lists, it's like going to the DMV. (not verbatim, in my own words)
  • What defines an image from being content apart from presentation?
    • EM: if I would need alt text for it, then it's content, otherwise presentation because decorative. "If I need alt text so that Google can pick it up, then it needs to be content"
    • JZ: like Cameron Moll's site, the flourishes would be presentational content
  • Do you have any advice about designing for phones?
    • CM: Ask the boss about the need for this. What is the need? Don't go build some mobile web piece because it's the next big craze, but what will people need? People with blackberries aren't going to want to be browsing like an iphone user will. 
    • JZ: Does it need to be exactly the same as the site? Does it need to be like NYTimes design that makes it easy to browse and look at articles? Do you want it like Flickr where you just need to see recent activity, see a few basic things? Most the cool things with Flickr happen with Ajax that a real web browser is required, so you don't want the same behavior. Thus, there is a simpler UI. Let's make the phone have maybe a different experience, maybe there's a call to action on the phone, and take away the rest of the website. A call of action could be more important than making it look pretty on the phone.
    • JV: got off the blue line and couldn't remember how far the Sheraton, and they didn't even have the address on the home page. Silliness. This is a perfect time to make a phone version.
  • How do you deal with not having a copywriter?
    • JZ: Happy Cog does content development and IA at the same time, they sneak in copy, unless the client understands that on his own. Good writing makes good interface, they make it part of the IA so they can have clean, good, happy copy. Happy cogs :D
      • Know yourself, your strengths, who the users are, and what KIND of language/reading level/existence of humor/etc. Client may realize that THEY CAN'T write that and so they'll want a writer then. They put it IN their budget.
    • CM: He would just slip those things in wherever possible, and it usually went live that way. Now in house, they have an entire translation department.

This completes the An Event Apart 2008 notes series. View the Table of Contents to ensure you have completed your reading.

Cats Love Apple

Apple 6 December 2008 | 0 Comments

Cats Love Apple

Cats Love Apple
Originally uploaded by MorrowLess.

Awwwwwww this appeals to my inner mac-lover and my inner cat-lover.

CheckBoxList outputs a table by default

ASP.NET 4 December 2008 | 2 Comments

Building an ASP.NET site, I needed to use a server-side CheckBoxList control. Much to my irritation, the server control output each <input type="checkbox" /> in a tr of a table containing the entire list. I thought, how awful!

Fortunately, I found a way for the server control to quickly output each input in spans rather than table rows: CheckBoxListId.RepeatLayout = RepeatLayout.Flow

The default value is RepeatLayout.Table. Now my checkboxes are cooler.

Designing the Next Generation of Web Apps

Random 18 November 2008 | 0 Comments

An Event Apart 2008, Day 2, 3:45pm - 4:45pm

Read the previous talk in this series, The Arts & Crafts of Web Design - or What Would William Do? by Curt Cloninger, or view An Event Apart’s Table of Contents

Designing the Next Generation of Web Apps

Jeff Veen

  • He's going through the history of computers, how he liked Pong when he was six, and how it progressed.
  • Jeff left Google about 5 months ago (today is October 14, 2008). 
  • "When I'm feeling dumb, it's usually not my fault. It's usually someone not communicating something, [etc.]"
  • Cholera - John Snow used design and the sanitation maps to show that a pump was causing the cholera, not the air. Took the map, drew all the deaths at each address, then used design by taking out everything that wasn't proving his point.
  • This is visual design oriented, not technical design. That's why my notes here are sparse.
  • Inspiration comes from all different places. If having difficulty, stop looking for a bit.
  • Use the visual to help make statistics more real - The MegaPenny Project. (screens)
  • Try to find the story in the data, and how to be a good data visualization designer?
    • assign different visual cues to each dimension of the data. Maybe black marks next to each address, bullet points like an Indiana Jones global flight, whathaveyou.
    • Remove everything that isn't telling the story. Journalists already follow this.
  • Learn to give up control, and that helps you on your way to be a good interactive designer. In can show up in any context, and that's ok.
    • CSS Zen Garden is a perfect example of giving up design.
    • Jeremy Keith makes it clear that you can choose your style. My content can show up anywhere.
    • An aggregator, so you don't see any of the design. Relinquish control. 
    • A braille browser. Letting go.
  • Tons of data visualization analysis and examples. No links given out. New York Times Casualties of War. I wish he gave out links.
  • Storytelling -> discovery. Allow them to discover their own stories.
  • A huge percentage of Google's audience was coming from outside the USA.
  • 1) Start with the user 2) Know yourself, then an option #3, Then understand the user
  • User research is important, but those two are so key. Put research into the context of what you know.
  • "Everything I've built has come from the frustration that it didn't yet exist." - Matt Mullenweg, founder of WordPress
  • Everywhere you look, inspiration can come from.... (he ends with screenshot of Pong from the beginning)

Skip to An Event Apart’s Table of Contents

The Arts & Crafts of Web Design – or What Would William Do?

Random 13 November 2008 | 0 Comments

An Event Apart 2008, Day 2, 3:45pm - 4:45pm

Read the previous talk in this series, The In-House Designer by Cameron Moll, or view An Event Apart’s Table of Contents

The Arts & Crafts of Web Design - or What Would William Do?

Curt Cloninger

  • It's all about being like this William Morris dude, his ethic.
  • Via Cameron Mollhttp://tinyurl.com/6x4lg
  • This William dude's thing was:
    1. Stay true to Nature and Materials
      • What are the material properties of a pixel?
      • We're dealing with light: light coming off of a screen.
      • Also dealing with code, but mainly, staying true to a pixel.
      • Need not simulate a physical material
      • Typography is our material: 
        • push css-typography (like coudal.com )
        • Coudal is using letter-spacing to change the kerning of these letters.
        • http://poccuo.com/ If you learn one thing from this: Georgia, 40px. That's all. Beautiful.
        • oversized text = easy to use (vimeo vs. youtube, roov, twitter, 37 signals)
        • Vimeo: It's like it says, our service will be easy to use, see how easy it is to read this text!
        • ROOV: Just use that space on the text, don't fill it with a bunch of stuff
        • 37Signals: "Work well". It shows it is easy to use, gives you that feeling, so warm and fuzzy.
      • Behaviour as material: It should look like it does what it does. When Ajax first came out, it was like "What! No. There needs to be a refresh." So there needs to be a transitional animation so that it looks like it's doing what it's doing. Even though you don't need to, just give the feeling, it's our material.
    2. Unite art (design) and hand craft
      • When is "genius design" more appropriate than "user-centered" design? When contemporary visual culture becomes corrupted. When forging a new medium. Read: iPod is genius design. 
    3. Unite the microcosmic and macrocosmic
      • He started to get really interested in typography
      • Started on the paper, the form of the type, etc, and went out wider until lastly, the printed matter on the page
      • Showing detail on buildings
      • If it doesn't need to be scalable, don't automate it, make each section slightly different.
    4. value utility. value beauty.
      • Beauty alone is a legitimate reason for something to exist.
      • Now that everyone can make a cookie-cutter site for free, beauty and customization is more important than ever.
      • This is not about taking over the page with ornamentation, but using it for flourish and make it beautiful. Great designers did these ornamental things for a long time, "until these Swiss designers came in and then everything went all" wonky. 
    5. Enjoy work.
      • Everyone is here because we enjoy what we're doing and it makes us excited.
      • So, ensure that what we're doing is something that is pleasing to us.
      • If you're not excited, get excited by delving deeper, or maybe go into something else.
      • Orchestrate things so that you do what you like (like what Cameron's talk was on).
    6. Redesign the whole world
      • "My hope is to get mumbo jumbo out of the world." - William Morris, on his deathbed. (As in, to eliminate it)
      • Designers make the world. Design the context around your design.

View the next talk in this series: Designing the Next Generation of Web Apps by Jeff Veen, or skip to An Event Apart’s Table of Contents