[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Questioning XSL

  • From: "Hunter, David" <dhunter@M...>
  • To: XML Developers' List <xml-dev@i...>
  • Date: Thu, 27 May 1999 12:05:57 -0400

pull xml into html
Apologies for coming in late to this thread, but I would like further
thoughts on a point of view which has been marginally mentioned, if at all,
which is the point that XSL can add a layer of abstraction to web
development that the DOM/CSS can't.

My point is, in the web development world, there are three kinds of people:
-people who write CONTENT
These people can use XML

-people who FORMAT web sites (designers)
These people can use XSL, to transform the XML into HTML/CSS

-people who write CODE
These people can use the DOM, with whatever programming languages they want,
to populate databases, or to pull information out of the databases and into
XML, or to calculate tax on the order our customer just entered, etc. etc.
etc.

I mean, think about the mess that was created when ASP first came on the
scene:  People took a technology with a lot of promise, but took it too far,
and ended up with ASP pages that had HTML mixed with scripting code mixed
with content, and ended up with an unmanageable mess of, well, TEXT.  Then
people got a bit wiser, and started creating server-side components, which
the ASP can call.  Now we've eliminated the code from the ASP page, except
the little bit that we need to call the components; we're just left with
just HTML and content.  This is more manageable.  (Apologies if I've just
mangled history, but it's what I've seen at a lot of my clients.)

Now, if we go to the paradigm I've mentioned above, we can have our content,
formatting, and code COMPLETELY separate from each other.  If our content
providers want to change their content, they can edit the XML files to their
hearts' content, without ever having to see code or caring about format.  If
our formatters decide they want to change the layout of the site, they can
edit the XSL stylesheets and CSS stylesheets to their hearts' content,
without ever seeing a line of code, or caring about content.  And the coders
simply have to pull in those XML files and XSL files, without caring what's
in them, and write the code to glue them together.  (Along with the tax
calculations, etc...  :-)

OTOH, if we take XSL out of the picture, then our formatters have no options
other than to
a)  change the layout of the XML documents, which will interfere with our
content providers
or
b)  use the DOM and write code to format the documents, which will interfere
with our coders.  (And make our formatters coders themselves.)

For example, suppose we have the following XML document:

<?xml version='1.0'?>
<Employee IncrediblyGoodLooking='true'>
	<Name>
		<FirstName>David</FirstName>
		<MiddleName>John Bartlett</MiddleName>
		<LastName>Hunter</LastName>
	</Name>
	<Occupation>Web Development Consultant/XML-Dev Newbie</Occupation>
	<Aside>Okay, he's good looking, but only in his own mind...</Aside>
	<id>123456</id>
</Employee>

And we want to format the document as in the simple attached HTML file.  As
you can see, the format of the HTML document is <em>completely
different</em> from the format in the XML document, even though all of the
information is there.  But our formatters don't have to write code to do it,
they can use XSL, and our content providers don't care, they can just use
the same XML DTD or Schema they've always been using.  The coders just have
to pull in the XML, pull in the XSL, and spit out the end result.  (I did it
in ASP, with Microsoft's IE5 XML parser.  It took ~7 lines of code in
VBScript.)

In case anyone is interested, the XSL I used to create the attached HTML
file is pasted below.  Apologies if it could have been done better, but this
is the first time I've used XSL.  (I'm using the XML parser that comes with
IE5.)

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
	<xsl:template match="/">

		<html>
		<head>
		<title>Employee <xsl:value-of select="Employee/id"/></title>
		<style>
		p
		{
		    MARGIN-LEFT: 2cm
		}
		h1
		{
		    FONT-FAMILY: Arial;
		    FONT-SIZE: 19pt
		}
		h6
		{
			FONT-FAMILY:  Arial;
		}
		body
		{
		    FONT-FAMILY: Arial Narrow
		}
		</style>
		</head>
		<body>

		<h1><xsl:value-of select="Employee/Occupation"/></h1>

		<p><b>Name</b>: <span><xsl:value-of
select="Employee/Name/FirstName"/> <xsl:value-of
select="Employee/Name/MiddleName"/> <xsl:value-of
select="Employee/Name/LastName"/></span></p>

		<p><b>Incredibly Good Looking</b>: <input title='Incredibly
Good Looking' type='checkbox'><xsl:if
test="Employee/@IncrediblyGoodLooking[.='true']"><xsl:attribute
name="CHECKED"/></xsl:if></input></p>
		
		<h6><xsl:value-of select="Employee/Aside"/></h6>

		</body>
		</html>
	</xsl:template>
</xsl:stylesheet>

Of course, the drawback to this is that if a page needs client-side script,
our formatters STILL have to mix code with display.

Thoughts?  Flames?

Employee 123456.htm


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.