So, you want to display search results on your website?Here we provide a stylesheet (XSL file) that will convert OpenSearch Response feeds into HTML. You can use it on your website, or anywhere else, for free, as we’re licensing it under a Creative Commons license. It’s a good idea to use this stylesheet on your own OpenSearch feeds, so that users can see actual search results instead of raw XML. See also other OpenSearch Readers. On this Page:The FilesHere are the three files used: the stylesheet, and two associated files.
How to Use the Stylesheet
FeaturesWarning: jargon alert. The stylesheet will transform any OpenSearch feed into HTML. Assuming that the feed contains valid XHTML (or no HTML at all), the transformation should be valid XHTML 1.0. Please note that potentially malicious code (such as Javascript) is not dealt with. It is capable of transforming both OpenSearch RSS 1.0 and OpenSearch 1.1 Response feeds, in any of the following syndication formats: RSS 0.9, 0.91, 0.92, 0.93, 1.0, and 2.0, and Atom 1.0. It does not yet make use of suggested searches using OpenSearch Query. It is liberal, which means that it will try to make errors invisible to the user (it should ‘just work’), even if there are problems with the OpenSearch elements, or even if there is no feed at all. The stylesheet makes use of a variety of information, including supporting a number of RSS/Atom elements and popular extensions, such as author and category information. This, along with all text on the page, is configurable; see advanced usage. Advanced UsageTranslations and Text ChangesIt is actually quite simple to change any of the text used for the search results. Note, the language of the actual OpenSearch feed is not affected by any of this; just the text that the stylesheet adds on top of that. There is a section at the top of the os.xsl file where all the bits of text used are stored, along with descriptions of what each is used for. You can edit the os.xsl file in any text editor.
The section to edit should be easy to find; it is near the top, just below the If you translate the stylesheet into another language, we’d love to hear about it: please let us know. SettingsThe text used for translations is also used for settings, such as whether or not to display author information if it is available. The options are described in the source code, so see the above section for details. Customize AnythingAny of the files can be customized all you want. Go crazy! Within another Page
The stylesheet is currently designed to create a whole web page. If you
want to display an OpenSearch™ feed within another page, you will have
to use the XSLT on your web server, and modify it to remove some of the
HTML (e.g. the Technical Details: XSLTThe stylesheet is an XSLT. Modern web browsers such as Firefox, Internet Explorer, Safari (1.3 and up), and Opera have XSLT parsers built-in. If you would prefer to do the transformation on your web server (rather than client-side), you’ll need to make use of one of the publicly available XSLT parsers. The XSLT parser used by the Mozilla browser (and
derivatives, such as Firefox) does not support a certain XSLT command
that is required for the stylesheet to work properly. The Javascript
file (os.js) available here corrects for that problem. If you know you
won’t need to deal with that parser, then you do not need the
Javascript file, and you should modify the LicenseAll three files listed above are licensed under the Creative Commons Attribution-ShareAlike 2.5 License. |