XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] 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:
https://code.google.com/p/rundmc/source/browse/trunk/view/tag-library.xsl

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"
 xmlns:ml="http://developer.marklogic.com/site/internal"
 xmlns="http://www.w3.org/1999/xhtml">

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

 <ml:tabbed-features>
  <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>
  ...
 </div>

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

 <ml:article-abstract heading="Check this out."
                     href=""/learn/2009-07-search-api-walkthrough.xml"/>
</ml:page>


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. :-)

Evan





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


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS