[XML-DEV Mailing List Archive Home]
[Reply To This Message]
Re: Tag libraries in XSLT / XQuery?
- From: Erik Hennum <firstname.lastname@example.org>
- To: Evan Lenz <email@example.com>
- Date: Wed, 25 Aug 2010 20:11:57 -0700
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.
On Wed, Aug 25, 2010 at 5:05 PM, Evan Lenz <firstname.lastname@example.org>
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:
<h1>Learn, share, discuss</h1>
<div class="announcement single">
<p>Welcome to the MarkLogic Developer Community...</p>
<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. :-)
| [Thread Prev]
| [Thread Next]
| [Date Next]
| [Thread Index]
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
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