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

Re: Application Design

  • From: James Strachan <james_strachan@y...>
  • To: Al Snell <alaric@a...>, Mike.Champion@S...
  • Date: Mon, 13 Aug 2001 13:35:00 +0100

xtags parse reader
I think XSLT is suprisingly complex for non-lisp programmers to pick up and
really understand. I agree with many posters on the list that XSLT is often
used for too much and a programming language should often be used instead.

Its easy for people to forget that most of the power and expressiveness of
XSLT comes from using XPath as an expression language. XPath is fairly easy
to pick up and use in conventional programming languages too.

e.g. here's some Java code using dom4j which uses XPath to process all
hypertext links...

// parse a document
SAXReader reader = new SAXReader();
Document doc = reader.read( "foo.xml" );

// process each hyper text link...
List links = doc.selectNodes( "//a[@href]" );
for (Iterator iter = links.iterator(); iter.hasNext(); ) {
    Element a = (Element) iter.next();
    String text = a.getText();
    String uri = a.attributeValue( "href" );
    ...
}

Most developers can deal with collections, objects, procedural code and
whatnot quite easily - so I prefer the general approach of using XPath with
a real programming language. Its easier for developers to pick up,
understand and maintain.



> On Sat, 11 Aug 2001 Mike.Champion@S... wrote:
>
> > Thanks for such a thorough response.  I think I need to learn more
> > about PHP; my response took a more generic "procedural vs. declarative"
> > spin.  It sounds like PHP (like XSLT) has a bit of both characteristics.
>
> It's almost identical to ASP in many ways. It's different from JSP in that
> JSP has the "custom tags" feature which is nice, but is harder to install
> (classpaths get me every time with Java :-)

I agree custom tags are pretty cool.

There's a JSP custom tag library called XTags which allows people to do
XPath expressions from inside JSP.

http://jakarta.apache.org/taglibs/doc/xtags-doc/intro.html

This allows XPath to be used to process XML (in a similar way to XSLT) while
still being inside a traditional scripting language, JSP, so you can still
use all your existing scripts, code, custom tags and java expressions while
still benefitting from the power and expressiveness of XPath.

For example, here's a piece of JSP for styling the current XML news
headlines from an RSS feed:-

<html>
<%@ taglib uri="http://jakarta.apache.org/taglibs/xtags-1.0" prefix="xtags"
%>
<head>
<title>XML news</title>
</head>

<body>
<h1>XML news at <%= new Date() %></h1>
<ul>
<xtags:parse
url="http://www.moreover.com/cgi-local/page?o=rss&c=XML%20and%20metadata%20n
ews"/>
<xtags:forEach select="//item">
  <li>
  <a href="<xtags:valueOf select="link"/>">
    <xtags:valueOf select="title"/>
  </a>
  : <xtags:valueOf select="description"/>
  </li>
</xtags:forEach>
</ul>
</body>
</html>


James



_________________________________________________________

Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com




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.