While Notes is not a relational database, you will commonly find a lot of lookups (using @dblookup, @getprofilefield, @getdocfield) when examining Notes and Domino forms. One common use is to retrieve the list of possible keywords from a configuration rather than hard coding them. Another use is to store status data (like priority) language neutral and use a lookup to internationalize the interface.
In XLST by default we usually apply ONE stylesheet to ONE XML document. However there is the very handy document() function that allows to "look" into another document. The document() function comes with it's own set of challenges you have to work around. In the example provided, I show how to use document() to transform a language neutral priority code into localized string.
First let us start with a sample document:
<?xml version="1.0" encoding="UTF-8"?>
<supportrequests>
<supportrequest>
<system type="server">tt34Xp</system>
<priority>01</priority>
<description>The harddisk runs out of space!</description>
</supportrequest>
</supportrequests>
I put in more that one request in the downloadable, so you have better results. Now I define an XML file with the localized Values for the priority:
<?xml version="1.0" encoding="UTF-8"?>
<priorities>
<priority-key>
<level>01</level>
<term language="English">High</term>
<term language="German">Hoch</term>
</priority-key>
<priority-key>
<level>02</level>
<term language="English">Normal</term>
<term language="German">Normal</term>
</priority-key>
<priority-key>
<level>03</level>
<term language="English">Low</term>
<term language="German">Niedrig</term>
</priority-key>
</priorities>
To be able to access this second document in XSLT, you need to use the document() function. There are two items to consider: we can't simply call from one document context (our support request) to another (our priorities document) and typing document() all the time becomes confusing. So in step one I define a global variable in my stylesheet, that allows me to reference directly to the priorities:
<xsl:variable name="param-top" select="document('Priorities.xml')/priorities"/>
To get the language sorted out, that should be used, I use a parameter, that is set to English as default:
<xsl:param name="sheetLanguage" select="'English'"/>
All XSLT transformers allow to supply parameters, so you can overwrite the language without touching the XLST file again. The style sheet is pretty normal until the line where we want to substitute the priority number with the priority name of our choice. Here we need to switch the context from the main document to the priority document. We can do that with the help of "apply-templates":
<!-- now retrieve the value by lookup in the external document -->
<xsl:apply-templates select="$param-top">
<xsl:with-param name="curParam" select="."/>
<xsl:with-param name="curLanguage" select="$sheetLanguage"/>
<xsl:with-param name="curPrio" select="priority"/>
</xsl:apply-templates>
Since $param-top points to the parameter document, the context is switched and the parameter document becomes active, so we can retrieve the desired name easily with a little xPath expression:
<xsl:template match="priorities">
<xsl:param name="curLanguage"/>
<xsl:param name="curPrio"/>
<xsl:value-of select="priority-key[level=$curPrio]/term[@language=$curLanguage]"/>
</xsl:template>
Since there are no more nested apply-template statements in the priorities template, execution returns back to the main document.
You can use this technique with all sort of lookup needs. A smart thing to do: specify the second document as an URL, so you can take advantage of an dynamic creation of the lookup document if needed.
You can find the 3 files in the downloads section.
1. Steven Jacobs07/20/2004 17:10:32
Nice article; however, I've been oing this since the later versions of R5 (as long as xml/xlst engine was on the server). It seems that most non-Domino developers are satisfied with the "food" they are fed and they forget what programming is all about...finding new ways to make/integrate technology (in so many words...). Also, this site seems to be a bash on Domino development (I know it is not; well, not completely; however, I have created extremely complicated, transactional, e-Commerce, RDMS, and complicated OLE apps using Notes. Notes is the only software out there that can handle so many different languages/products in its environment, while reducing the overhead of maintence.
The articles on this site mention products and phrases, that might be subject to copyright or trademarks. So we acknowledge, that the copyrights belong to the owner of the respective copyright or trademark.The links on this page are provided for convenience and are constitute no endorsement of the content of the target site.
So once your ready to discuss if and/or how to move away from Domino contact us.











