XSL overriding advice

4 views
Skip to first unread message

Jonathan Rochkind

unread,
Aug 20, 2012, 11:30:50 AM8/20/12
to xerxes-portal
So here where I am, we're evaluating other post-Metalib article search
options, and we have a prototype up.

I'd like to put a link on my Xerxes results screen (the one that
actually lists the hits) that says "Help us evaluate new search options"
or something, and when you click on it, sends you to my new tool, with
the existing Xerxes query in a url param.
http://something.org/somewhere?q=existing+xerxes_query

I'm looking through the XSL, but can't quite figure out if there's a way
for me to easily add this to my local Xerxes without overriding gigantic
swaths of Xerxes XSL (meaning I'd have a fixed copy locally and it would
need to be updated if Xerxes updated).

Which I guess I could do that, since this is just a temporary thing
anyway. But I'm not sure the best place to do that either.

Anyone more familiar with the XSL than me want to suggest an
intervention point, what Xerxes template I should over-ride to most
surgically be able to add this new line?

Jonathan Rochkind

unread,
Aug 20, 2012, 11:35:04 AM8/20/12
to xerxes...@googlegroups.com
Ah, I just discovered the XSL apply-imports function. If that really
works, maybe I can over-ride 'main' in metasearch_results, add my new
link at the top, but then call apply-imports to call the original one?

David, is there a way to over-ride main in a specific template like
metasearch_results.xsl now? I can't put it in my global includes.xsl
obviosuly, because it needs to just over-ride when metasearch_results is
in play -- I forget, there's some way to create a local override for a
specific template like metasearch_results in current xerxes, yeah?

It's been a while since I messed with this stuff.

Walker, David

unread,
Aug 20, 2012, 12:04:22 PM8/20/12
to xerxes...@googlegroups.com
If I were you, I might actually put it somewhere below the search box, rather than in the 'hits' section.

<xsl:template name="search_box">

That's a pretty small template, so you'd be overriding very little XSLT.

--Dave

-------------------------
David Walker
Interim Director, Systemwide Digital Library Services
California State University
562-355-4845
--
You received this message because you are subscribed to the Google Groups "xerxes-portal" group.
To post to this group, send email to xerxes...@googlegroups.com.
To unsubscribe from this group, send email to xerxes-porta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xerxes-portal?hl=en.

Jonathan Rochkind

unread,
Aug 20, 2012, 1:39:13 PM8/20/12
to xerxes...@googlegroups.com, Walker, David
Ah, that's a good idea, thanks.

(Re-remembered that apply-imports doesn't work for named templates).

And yes, you can over-ride a single xerxes xsl 'file', so for instance I
can over-ride the search_box template only on certain page(s).

Walker, David

unread,
Aug 20, 2012, 1:43:32 PM8/20/12
to Jonathan Rochkind, xerxes...@googlegroups.com
True. Although, it might be easier to only show this link on certain pages by defining that logic in your local version of the search_box template itself.

This, for example, would limit that test to the metasearch/results page.

<xsl:if test="//request/base = 'metasearch' and //request/action = 'results'">
... link here ...
</xsl:if>

That way you can just keep a local version of the ' search_box' template in your local includes.xsl -- no need to copy whole files.

Jonathan Rochkind

unread,
Aug 20, 2012, 1:53:43 PM8/20/12
to Walker, David, xerxes...@googlegroups.com
You don't need to copy a whole file, in fact. You can make a version of
a certain template file in your local xsl directory, and only include
templates in it that you want to override, you don't have to include
everything. Same as when you localize includes.xsl, you can localize any
other file that same way, only overriding templates or variables you
want to override.

In fact, you can override a template originally defined in global
includes.xsl in a local specific named xsl file -- and it'll only get
overridden for actions that load that named xsl file.

This is actually pretty easy if you really only want to override it on
one (or maybe two) files, easier I think than putting in choose/if
chains, and has the advantage of leaving it untouched with global source
used in all other actions. But there are times when the if/choose
approach would be better.

I've tried this, it seems to work. Great!
Reply all
Reply to author
Forward
0 new messages