[TFUI] XML -> XSLT -> XHTML Nirvana
"Phlip" <[email protected]>
| Newsgroups | gmane.comp.programming.test-first-user-interfaces |
|---|---|
| Message-ID | <007001c5213d$71299780$0102a8c0@DF619121> |
TFUI:
Since reading /XP for Web Projects/, I took on an in-house web site project.
Some of it was already written, so I was not able to apply WebXP's Prime
Directive everywhere.
WebXP's Prime Directive is that all HTML in your browser must come from
XSLT, supplying markup, and XML, supplying data. The book makes a powerful
case for using that transformation as the nucleus of a build system, as an
automated site map, and as one helluva big validation test. At all times, a
web site should present no broken links or related cruft.
To follow that directive, you always push your data into a data
representation, store this in XML, and transform it with XSLT to generate
the output HTML. WebXP implies ones entire browser experience must come
through this pipeline.
I take the PD one step further, and always generate XHTML, using this
mysterious concoction in the XLST:
<xsl:output method="xml" media-type="text/html" standalone="no"
omit-xml-declaration="yes" encoding="UTF-8" />
That permits XPath in the tests to query out and verify details of the
intermediate XHTML.
However, when aiming for the goal "only XSLT supplies markup", I cheat.
Faced with a short schedule and long feature list, and face with the absurd
complexities required to code a lowly 'if' statement inside XSLT, I move the
'if' statement up into the project that generates the XML.
So, if I want a field to optionally appear hotpink, the generating program
calls something like this (in fictitious Perl):
set($myNode, 'my_data_name', '<span style="background-color:hotpink">my
data value</span>');
The intermediate XML attribute contains that snip of XHTML, escaped properly
to nest inside XML.
Then, the XSLT turns the escapes back into HTML, using something like
<xsl:value-of disable-output-escaping="yes" select="@my_data_name"/>.
This post is either a question or a manifesto, depending on if anyone has
read and/or followed the book more strictly than I and can raise any
objections!
--
Phlip
http://industrialxp.org/community/bin/view/Main/TestFirstUserInterfaces
To unsubscribe, email:
TestFirstUserInterfaces-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/TestFirstUserInterfaces/
<*> To unsubscribe from this group, send an email to:
TestFirstUserInterfaces-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/