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