I had the pleasure today to speak at the CFUN-03 conference about XML, XPath, and XSLT. The conference had a nice turnout and my presentation room was packed full of CFUNers eager to learn “What’s New for XML in CFMX” with a number of good questions.
You can download the examples and slides here.
This is the original presentation I wrote for AN-CFUG and has a different title and template than you saw at CFUN. Other than that, it’s the exact same presentation, and I only changed the title to match Kevin Schmidt’s title. Kevin was originally scheduled to give this presentation but was unable to travel due to a last minute emergency.
A couple of questions came up that I’d like to review here as well.
Does XML replace WDDX?
No, XML does not replace WDDX. WDDX is a great technology that’s been around for many years. It introduced many CF developers to XML before they could effectively use it given the toolset available at the time–even non-CF tools. WDDX provides the simplest mechanism to convert any complex data to an XML string and later desterilize it back to a variable. What’s more, WDDX actually does work across languages–as compared to SOAP which hasn’t even come close to fulfilling the cross-platform compatibility that’s been promised for the last few years.
XML, even with the new tags in CFMX, always requires a lot more work than WDDX. With XML you’re going to have some DOM style access, an XPath search, or possibly a translation, which can take a few minutes or hours to program. With WDDX, you always need just one line of code–<CFWDDX>. In other languages like JavaScript and Visual Basic, WDDX is just as simple to use via an object call.
The disadvantage of WDDX is its inflexibility. To use WDDX you must use the specific WDDX grammar. That is what provides the perfect cross-language support, but it also limits its use in outside programs and has kept WDDX as a primarily ColdFusion technology.
XML has the advantage of being totally flexible–you can use any grammar you want or that is dictated to you. The downside is you have to write your program to understand that grammar or write a translation for it.
Both technologies have their place, and I still use both XML and WDDX in my applications.
How do I create elements in XSLT?
During the presentation I showed an example which had specific syntax for creating attributes in the target document during a transformation, such as the following.
If we have an <xsl:attribute> tag to create attributes, how do we create elements?
The issue is that elements are simply created by nature of the XSLT transformation. You embed elements anywhere inside your XSLT match block and those elements are created in the target document. We don’t need special syntax for creating elements.
One might think that you can simply embed an XSLT tag inside the target document tag as is commonly done in ColdFusion. For example, the following is a perfectly valid CFML statement.
In this code we are embedding a <cfoutput> tag directly inside an <a> tag. You can’t do this in XSLT because at all times the XSLT file must be a valid XML document. This embedding is illegal in XML. Instead we use the <xsl:attribute> tag to create attributes on the enclosing tag.
There is also an <xsl:element> tag which is primarily used for creating dynamic elements–target documents with variable element names.
hey, nice site, perhaps youd like to check out mine: Mobic
hey, nice site, perhaps youd like to check out mine: ambien
Hi Guys
Thanks for taking the time posting. MSN have finally launch blogs, what was with the delay?
Domestic Call Center
Cya
Bruce
Pingback: online poker
Hi,
Interesting blog!
I thought I wanted to contribute with a cool site: http://poker365.info – it has got pokernews from all the big sites, and no ads!
Enjoy