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

Re: Tag libraries in XSLT / XQuery?

  • From: Erik Hennum <efhennum@gmail.com>
  • To: Evan Lenz <evan@evanlenz.net>
  • Date: Wed, 25 Aug 2010 20:11:57 -0700

Re:  Tag libraries in XSLT / XQuery?
Hi, Evan:

If I'm reading it correctly, that's a cool technique for selection and configuration of portal features when rendering different kinds of documents.  The practical value of the technique is clear (so thanks for mentioning it).

I think JSP tag libraries pose the question whether a better separation of concerns is possible if the page can pass sequences to tags and receive sequences from tags (in callbacks).

Maybe that's as far as discussion can take it without a reasonable concrete vehicle for inspection; thanks for kicking around the question in advance of that.

Erik Hennum

On Wed, Aug 25, 2010 at 5:05 PM, Evan Lenz <evan@evanlenz.net> wrote:
Hi Erik,

I think for most cases, basic XSLT processing, using a modified identity transform, should do the trick. Then, you simply define the tags in the tag library using normal XSLT template rules, as done here:

This is part of the code I wrote in a project to create a back-end framework for the MarkLogic Developer community.

Note that there are no pre-processors or other such acrobatics. Just a modified identity transform, with a (left-most-indented) template rule in the unnamed mode for each custom tag in the library.

For example, the source for the current home page's content (at http://developer.marklogic.com) looks like this:

<ml:page status="Published"

 <h1>Learn, share, discuss</h1>

  <ml:feature href=""/features/eclipse.xml"/>   <ml:feature href=""/features/office-toolkits.xml"/>   <ml:feature href=""/features/xqdebug.xml"/>  </ml:tabbed-features>

 <div class="announcement single">
  <p>Welcome to the MarkLogic Developer Community...</p>

 <ml:recent-news-and-events suppress-more-links="yes"/>

 <ml:article-abstract heading="Check this out."

As you can see, it's a mixture of regular XHTML and custom tags (in the "ml" namespace). Apply page.xsl to this and you get the final XHTML result in the browser.

To see the custom tag implementations, just look at tag-library.xsl, e.g., <xsl:template match="tabbed-features">.

So, in my opinion, XSLT is already an excellent implementation language for custom tag libraries. (And with products that let you mix-and-match XSLT and XQuery, you can get the best of both worlds.)

If you wanted to extend it to support general XPath expressions (without using a pre-processor) you could use an eval() function, but I generally don't find the need to do that. Custom libraries are called "custom" for a reason. :-)


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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.
First Name
Last Name
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.