Putting Domino's XML to use

No developer in their right mind can deny XML its future. XML is already all over the place. Wherever it isn't already it, more than likely, soon will be. This has been the case for quite some time now. However it has taken me until now to start looking at it in depth. I am more convinced now than ever of its importance. Hopefully you soon will be too. This is the first of what I hope to be a collection of articles on using XML with Domino that will no doubt expand in the future.

Domino started to adopt XML when release 5.0.2 introduced the "?ReadViewEntries" URL command. Since this feature was introduced I have never really understood its significance in relationship to Domino. After all, the only place I could see it was actually being used was in the R5 View Applet.

Before we start looking at what we can do with the command, let's look at what the above feature does. Consider this view:


Despite the fact that I called the view "xml", it is nothing more than an ordinary view and has no special formatting whatsoever. However here is a screen shot of Internet Explorer displaying results of a ReadViewEntries call to the view using this URL:



This is all very well, but what can we do with the above XML that is going to be useful to us, as developers? To a certain extent there is not much we can do. The problem is that to convert this into meaningful HTML we need to edit the source to include the line which tells the browser how to format the XML. Obviously we can't do this. The rest of this article is devoted solely to demonstrating how we can convert this data and to serve as an introduction to XSL.

Applying a little style:

The first thing I did was to save the source XML code returned from the above view to an .xml file on my hard drive. This meant that I could edit the file and add the following line to the top of it:

<?xml-stylesheet type="text/xsl" href="transform.xsl"?>

The browser now knows that the XML should be rendered according to the rules defined by the specified XSL file.

You might well be thinking that the title of this article is now a little misleading. Sorry, maybe it is. In practice you can't save the source and edit the file. Stick with me though as what I'm demonstrating is extremely useful and future articles will start to build on this technique to the point where it really is putting the XML to good use.

Let's now look at the XSL file and see what it is that formats the XML. In this particular instance I chose to design the XSL such that the resulting HTML will resemble the layout of CodeStore's "All View". Here is the code:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<title>An XML Example</title>
<h3>All recent articles from CodeStore.</h3>
<xsl:apply-templates select="viewentries" />

<!-- Top level template -->
<xsl:template match="viewentries">

<!-- Loop through each document (viewentry) and apply create the rows for each one-->
<xsl:for-each select="viewentry">
<td colspan="2">
<xsl:attribute name="href">
http://www.codestore.net/A55692/store.nsf/all/<xsl:value-of select="@unid"/>?OpenDocument
<xsl:value-of select="entrydata[@name='Title']"/></a>
<tr><td style="padding: 0px 5px 10px 10px;">
<xsl:value-of select="entrydata[@name='Abstract']" />...
<td valign="top"><b>
<xsl:value-of select="entrydata[@name='Area']"/>
</b><br />
{<xsl:value-of select="entrydata[@name='Published']"></xsl:value-of>}

Don't worry if the above is all Double-Dutch. Notice however that the format should be familiar due to the fact that XSL is derived from SGML in the same way HTML and XML are. Also, trust me that XSL really isn't that complicated. Explaining it in detail is well beyond the scope of this article and there are plenty of resource out there so I won't bother explaining it now. If you go through the above example line-by-line it should become obvious what it going on. Basically the "template" matches patterns within the data and reformats it. The format from the ReadViewEntries command is useful in that it always follows the pattern of /viewentries/viewentry/entrydata.

If you are using a browser that supports XML then you can take a look at the XML file that I saved and edited and see for yourself what effect the above XSL has on it. If you can't do that then here is what it should look like:


Obviously, the line that I added to the .xml file can't be added to the source generated by the ReadViewEntries command. To this end it is not possible to reproduce the above effect in practice. However what I hope to have introduced to you is the basis of the principles involved in XML processing. Future articles shall take this method further and show how we can actually use the technique in our applications. The key being that we can use JScript and the MSXML parser to parse the XML without the need to include the XSL refernce directly.

More resources:


If you are planning on getting serious with XML then I highly recommend you consider buying yourself a copy of XML Spy from Altova Software. A very powerful tool that should help you learning these new languages in more detail than I can ever explain.


Note: If you are using IE5 or IE5.5 you may well have been surprised to see that the XML linked to above didn't parse as you'd expect. This is due to the fact that these versions ship with version 2 of the MS XML Parser. This only includes support for a working-draft of the W3C's XSL Recomendation whereas the more up-to-date version 3 supports the final release.

If you aren't sure which version you are using then have a read of the answer to the first question in this FAQ. This should take you to this Version Sniffer. When there you need to check that version 3 is installed and that it is in Replace mode.

You can get version 3 of the MS XML Parser here....


  1. XML Views

    A nice article indeed. you can now have different styles of presentations(like in notes.net) with excerpts, by author, by date etc. Everything from one view. u need to chage the XSL stylesheet only. this is very useful when u have performance issues(like u cannot have more number of views, number of documents is more.. etc)

    u can combine some amount of javascript also and make it more dynamic.

    1. Re: XML Views

      xml is very usefull for web content but there are many other great uses for it.

      For example:

      Moving data from an Oracle database based system to domino. By using Java's Dom or Sax pakets you can then get data from the xml and save it to database fields.Both Dom and Sax are good although sax works best as it does not eat up so much memory.

      The only problem i have found is white space, everything needs to be trimmed.

      Rnext will pave the way for using Dom and Sax with lotus script, so you don't have to use Java in the future. And it must be much better than using microsoft.

      Unfortunately say some but not me xml is here to stay, so start learning it now!!

      kester simm

      Show the rest of this thread

    2. Re: XML Views

      I like the idea of reducing the number of views in a db. Using &RestrictToCategory has also been great for reducing the number of views in a db.

      I wish that &RestrictToCategory would allow you to use &Startkey as well. I have a "Go To" feature for web views that uses &Startkey to jump to a position in the view. However, it doesn't work with &Startkey.

      As for using XSLT with ?ReadViewEntries in Domino, I'm hooked! It used to be that when I needed to web-enable a "notes" app I had to make my own html views (the java applet for views is just too slow and the html generated by domino , even when you use css to help the formatting, isn't that great). HTML views is the way to go if you want nice clean and professional looking views.

      With XSLT, creating HTML views has become a snap. I have a working solution of using XSLT to transform "notes" views into html views. You can see it here:


      It is a client-side solution and requires IE 5+ and version 3 of the msxml parser. If you don't have version 3 of the msxml parser (or don't know) I provide a link to check your version and a link to automatically install version 3 of the msxml parser.

      I know that Jake doesn't like client-side solutions :) so I got some interest from some people on openNTF.org to come up with a server-side solution using my xsl stylesheets.


  2. XML Domino and other stuff....

    A very good article! DOmino provide us a simple way to get a view information and use differents ways to display data usin xsl. But I think that using xml to display domino views only could be similar to try to killl a fly using an Atomic Bomb ;-) Obviusly the most important part of it is the fact that you can integrate domino and other technologies (like sql server or another RDB) or application easily and without pain.

    Domino provides a good way to who data and if you include stuff like CSS, JS and others you can get awesome results (Jake's site is a very good example of it)

    So XML is the future, right here, right now, and we, Domino developers, must to take advantage of our dear Lotus Domino and learn the tricks to make it real.


    • avatar
    • Val
    • Tue 6 Nov 2001

    XML at the View conference

    Hi Jake,

    I am going to the View conference in Paris next week and I will be attending some of the XML seminars !

    I was wondering if you had any questions/queries that you wanted asked/answered in a hurry ?

    Let me know if you do and I will be glad to ask ?



  3. A leading question...

    This may be a leading question, but I'm going to post it just the same. First, a statement to provide some context: I have written a LotusScript-based XML tool that uses the MS XML Parser (in IE) to open a target XML document and march through the document based on a Parent Node that you can specify, i.e. start anywhere within the tree and look for all instances of that node and move inward. This is handled via a recursive function call. The result is one Notes document per parent node. The logic works great if I want to move from the specified parent node inward to create Notes Documents, but I have one instance [so far] where this is not the case. This is where I think (but don't know) where XSL may come to save the day. Ideally, the result needs to use one of the child nodes as the parent, but also keep the "named parent" data. Any ideas, am I wasting key strokes, or do you want to hear more?

    Thanks for any attention : ) Scott

  4. Using MSXML Parser securely

    I have been working with MSXML Parser in LotusScript agent for weeks now. Works great except with secure data. By that I mean that when the MSXML object requests a url from the domino server, it does not pass the userid/password and all I get back are documents that an Anonymous user would.

    Has anyone found this to be true?

    Would you mind posting and/or sending me the code you use for MSXML object related processing? Here is mine:

    Sub Initialize 'This agent uses the MS xml parser and the domino readviewentries url, styled by xsl, to create html on the server and send it to the browser ' setup error handling On Error Goto errorHandler Dim msxmlErrorNumber As Integer Dim msxmlErrorText As String ' setup variables Dim source As Variant Dim style As Variant Dim sourceURL As String Dim styleURL As String Dim result As String Dim s As New NotesSession Dim db As NotesDatabase Dim dbServerNotesName As NotesName Dim dbServerName As String Dim dbFilename As String Dim dbFilePath As String Dim dbFolderPath As String Dim dbFilePathURL As String Dim dbFolderPathURL As String Set db = s.CurrentDatabase Set dbServerNotesName = New NotesName(s.CurrentDatabase.Server) dbServerName = dbServerNotesName.Common dbFilename = s.CurrentDatabase.FileName dbFilePath = s.CurrentDatabase.FilePath dbFolderPath = Left$(dbFilePath , Len(dbFilePath) - Len(dbFileName) ) dbFilePathURL = replaceSubstring(dbFilePath, "\", "/") dbFolderPathURL = replaceSubstring(dbFolderPath, "\", "/") ' parameters ' these can be either files or urls, however relative URL's don't seem to work so use absolute URL's ' sourceURL="http://" & dbServerName & "/" & dbFilePathURL & "/ExampleViewForXMLCategorized?ReadViewEntries&ExpandView&Count=10000" ' styleURL = "http://" & dbServerName & "/" & dbFilePathURL & "/(XSL_View_Generic)?OpenPage" ' styleURL = "http://" & dbServerName & "/" & dbFilePathURL & "/(XSL_View_Specific)?OpenPage" sourceURL="http://localhost/zip/work/xmlenglish.nsf/(ViewForXML)?ReadViewEntries &ExpandView&Count=10000" styleURL = "http://localhost/zip/work/xmlenglish.nsf/(XSL_CategorizedView)?OpenPage" ' load the XML Set source = CreateObject("Microsoft.XMLDOM") source.async = False source.load(sourceURL) ' load the XSL Set style = CreateObject("Microsoft.XMLDOM") style.async = False style.load(styleURL) ' url is property of DOMDocument that shows last successfully loaded document ' Print "source = " & source.url & "<br />" ' debug ' Print "style = " & style.url & "<br />" ' debug ' minor error checking... If Not(source.parseError.errorCode = 0) Then msxmlErrorNumber = source.parseError.errorCode msxmlErrorText = source.parseError.reason Error msxmlErrorNumber , msxmlErrorText Else ' transform source result = source.transformNode(style) End If Stop ' output transformed result Print "content-type: text/html" Print result ' Print "end" ' debug Exit Sub errorHandler: ' no context doc, so just print to the screen/browser Print "Line# " & Erl() ", Error # " & Err() & ": """ & Error() & """" Exit Sub End Sub

    1. Re: Using MSXML Parser securely

      I would imagine this is due to the fact that you have not created a user context within the XMLDOM object. If you were doing this in jscript on a web page, the new object might inherit from the calling page (I'm guessing there, but think of it like opening another browser window).

      Because you're doing this in LS on the server, there is no connection between the effective Domino user and the XMLDOM object. Take a look at the XMLDOM documentation to see if there is some way of injecting the user/password into the object. You may have problems here with Domino's authentication method, as this relies on a cookie I beleive. also, sesion based authentication or not may make a difference.

      Show the rest of this thread

    2. Re: Using MSXML Parser securely

      I nearly gave up on server-side XSLT-transformation of ?ReadViewEntries..

      Thank you for posting this!

      I can't see if you got this to work with authentication..?

      What i changed is that i ran a login-url first.

      Dim loginURL As String loginURL = "http://domain.com/names.nsf?login&username=daffy&password=duck" ..

      Set source = CreateObject("Microsoft.XMLDOM") source.async = False 'get authenticated source.load( loginURL ) 'get the ?ReadViewEntries source.load( sourceURL )


      I use it on a SSL-secured server, which seems extremely hard to do with a java-agent.

      Again, thank you! :)

      Hide the rest of this thread

        • avatar
        • Andy Cunliffe
        • Mon 10 Nov 2008

        Re: Using MSXML Parser securely

        I realise it's been some time since this article was first posted but thought I'd share the method I've come up with for getting XML from the server when authentication is required without hard-coding a username and password and optionally transforming it server-side. I got some ideas from here, some from breakingpar.com but I found the key to the solution here: http://darkmag.net/darkBlog/files/DominoProxy.java - it can be done in Lotusscript too though.

        Basically, you can borrow the existing authentication cookie when sending your request server-side. If you call the agent in javascript there will automatically be a HTTP_Cookie field accessible on the document context, but you'll need this field to be present if you use this method as a WQO agent.

        Dim session As NotesSession

        Dim doc As NotesDocument

        Dim cookie As String

        Dim xhr As Variant

        Dim xmlurl As String

        Dim xslurl As String

        Dim xmldoc As Variant

        Dim xsldoc As Variant

        Dim html As String

        xmlurl = "http://server/db.nsf/view?readviewentries"

        xslurl = "http://server/db.nsf/notesview.xsl"

        Set session = New NotesSession

        Set doc = session.DocumentContext

        Set cookie = doc.GetItemValue("HTTP_Cookie")(0)

        Set xhr = CreateObject("Msxml2.XMLHTTP")

        Call xhr.open("GET", xmlurl, False)

        Call xhr.setRequestHeader("Cookie", cookie) ' after open method

        Call xhr.send()

        Set xmldoc = CreateObject("Msxml2.DOMDocument")

        Call xmldoc.loadXML(xhr.ResponseText)

        Call xhr.open("GET", xslurl, False) ' cookie doesn't need re-setting

        Call xhr.send()

        Set xsldoc = CreateObject("Msxml2.DOMDocument")

        Call xsldoc.loadXML(xhr.ResponseText)

        html = xmldoc.transformNode(xsldoc)

        Print "Content-Type: text/html"

        Print html

        Things are slightly different in Java but the principle is the same:

        import lotus.domino.*;

        import java.net.*;

        import com.lotus.xsl.*;

        import com.lotus.xml.xml4j2dom.*;

        import com.lotus.xsl.XSLTInputSource;

        import com.lotus.xsl.XSLTResultTarget;

        import java.io.*;


        NB: When performing multiple transformations the XSLTInputSource and the

        HttpURLConnection parameter must not have been used in a prior transformation.

        This may necessitate multiple connections to the same stylesheet.


        public class JavaAgent extends AgentBase {

        public void NotesMain() {

        try {

        PrintWriter pw = getAgentOutput();

        Session session = getSession();

        AgentContext agentContext = session.getAgentContext();

        Document doc = agentContext.getDocumentContext();

        URL xmlurl = new URL("http://server/db.nsf/view?readviewentries");

        HttpURLConnection xmlcon = (HttpURLConnection)xmlurl.openConnection();


        xmlcon.setRequestProperty("Cookie", doc.getItemValueString("HTTP_Cookie"));

        URL xslurl = new URL("http://server/db.nsf/notesview.xsl");

        HttpURLConnection xslcon = (HttpURLConnection)xslurl.openConnection();


        xslcon.setRequestProperty("Cookie", doc.getItemValueString("HTTP_Cookie"));

        StringWriter sw = new StringWriter();

        XSLProcessor xp = new XSLProcessor(new XML4JLiaison4dom());

        XSLTInputSource xml = new XSLTInputSource(xmlcon.getInputStream());

        XSLTInputSource xsl = new XSLTInputSource(xslcon.getInputStream());

        XSLTResultTarget output = new XSLTResultTarget(sw);

        xp.process(xml, xsl, output);

        pw.println("Content-Type: text/html")


        } catch(Exception e) {





        Hope someone finds this useful.

  5. Memory problems with XSLTranslate

    Just a little warning for those of you who are considering using the Java XSLTranslator.

    Following an article in Lotus Advisor, I've done some testing with translating Domino views to HTML using XSL Stylesheets combined with the "?ReadViewEntries" option.

    Everything works great, up to a point. The larger the views get, the slower the translation. Performance degration seems exponential, not linear.

    In R5, when the view has reached a certain size (about 7000 docs in my testing), certain "hickups" occur in the translator, resulting in erroneous HTML output.

    In the beta2 of Rnext, the XSLTranslator was improved, now problems didn't occur before my database contained 15000 docs. In beta3 of Rnext, the limit was even higher. I haven't tried tried the beta4 or the pre-release of r6 yet.

    So, if you are planning to use the XSLTranslator, do it on views that are small.

  6. Solution using Jake's example and Javascript

    Thanks Jake for a good article - I used it recently as a starting point when learning how to get Domino and XML to work together. I haven't gone too far but I thought I might add something to the main article.

    To get Jake's example working without any manual intervention:

    1. Create a HTML page (in Notepad or as a Domino page). 2. Create a named span on the page somewhere e.g. <SPAN id="XMLViewData"></SPAN>. 3. In the onLoad event run the following Javascript:

    var xmlDoc var xslDoc

    xmlDoc = new ActiveXObject('Microsoft.XMLDOM') xmlDoc.async = false;

    xslDoc = new ActiveXObject('Microsoft.XMLDOM') xslDoc.async = false;

    xmlDoc.load("http://www.codestore.org/A55692/store.nsf/xml?ReadViewEntries&Prefo rmat&Count=9999")


    XMLViewData.innerHTML = xmlDoc.documentElement.transformNode(xslDoc)


    Loading this page will load both the source Notes view (now a live representation) as well as the XSL Stylesheet and place it inside the SPAN.

    NOTE: The &Preformat extension to the ?ReadViewEntries seems to be very important - I couldn't get it to work without it.

    I'm still learning this stuff so hopefully I haven't misinformed anyone - apologies if any of this is wrong!

    Keep up the good work Jake!

    1. JS error - "Access is denied"

      Hmm. Spent some time trying to get your solution to work. One problem (I think) I found: there are a couple of double quotes in the script where I think there should be single quotes, e.g: "xslDoc.load("transform.xsl")" should be "xslDoc.load('transform.xsl')". Found a couple instances of that.

      But after making that substitution, it still doesn't work. In IE 5.5, I get this JS error page:

      Line: 11 Char: 0 Error: Access is denied Code: 0 URL: .../test.nsf/xml_test?OpenPage

      This is the source of the page:

      <html> <head> <title>XML test page</title> </head> <body onLoad="var xmlDoc var xslDoc xmlDoc = new ActiveXObject('Microsoft.XMLDOM') xmlDoc.async = false; xslDoc = new ActiveXObject('Microsoft.XMLDOM') xslDoc.async = false; xmlDoc.load('http://www.codestore.org/A55692/store.nsf/xml?ReadViewEntries&Prefo rmat&Count=9999') xslDoc.load('transform.xsl') XMLViewData.innerHTML = xmlDoc.documentElement.transformNode(xslDoc)"> <SPAN id="XMLViewData"></SPAN> </body> </html>

      I've always been mystified by the JS error line counting system - I can't even determine which line the error is in... do I start counting with zero or one? And do I start at "<html>" or the first actual line of JS code?

      Appreciate any feedback on this matter.


      Show the rest of this thread

  7. IBM Redbook on Domino XML

    There is a good 314 page book on [<i>How to use XML with Lotus Domino</i>] on the IBM Redbooks Site. Check it out at http://www.ibm.com/redbooks. If you want the exact URL, [<a href="http://publib-b.boulder.ibm.com/Redbooks.nsf/9445fa5b416f6e32852569ae006bb 65f/7fccf9355f830c15852569510043ef2a?OpenDocument" target="_blank">here it is</a>].

    • avatar
    • Marek
    • Tue 22 Oct 2002

    Netscape 7.0 does not apply xsl to xml doc

    I can see the xml doc with applied xsl in IE 6 but not in Netscape 7.0. There is no problem with this xml doc http://www.w3schools.com/xsl/cdcatalog_with_xsl.xml

    Anything special in must be in href?

      • avatar
      • Marek Nowicki
      • Wed 23 Oct 2002

      Re: Netscape 7.0 does not apply xsl to xml doc

      It looks like Netscape needs mime type for both source and stylesheet to be set to a XML mimetype (text/xml). In my application (which works on IE) I had <?xml-stylesheet type="text/xsl" href="Admin/xsls/Proposal2"?> (where Admin/xsls is a view and Proposal2 a key to retrieve the correct xsl). To satisfy Netscape I've created a simple agent called SetXMLMimeType which had: Print "Content-Type:text/xml; iso-8859-1" before printing xsl from the Proposal2 document - so my reference to the stylesheet is now: <?xml-stylesheet type="text/xml" href="SetXMLMimeType?OpenAgent&DocKey=Proposal2"?>. There was a small problem with '&' as my main stylesheet (Proposal2) had an xsl:include which had to be changed to: <xsl:include href="SetXMLMimeType?OpenAgent&amp;DocKey=Products2" /> . IE does not like type="text/xml" in '<?xml-stylesheet ...' so for now I will have 2 ways of assigning stylesheets (one for IE one for Netscape) - 'xsl:include' solution works for both browsers!

      Show the rest of this thread

    • avatar
    • chulluchor
    • Fri 25 Oct 2002

    Generic XSL to convert Views to HTML

    I wrote an XSL stylesheet which could convert any XML data from any ?ReadviewEntries command to convert the view to HTML , maintaining the same look and feel as an applet (twisties working fast etc) , with some simple customization of the view. But the problem I have is that I have to deal with views which have dynamic levels of hierarchy(my XSL already handles that). Also the number of documents in the view is extremely large (~10000). So my XSL takes painfully long time when the number of documents is > ~200 because it is recursive. I used a method to split the view using next and prev but that damages the hierarchical structure of the views.

    Can somebody help me on that?? I can provide more details if needed...

    Thanx Sonu

    1. Re: Generic XSL to convert Views to HTML


      Would you mind sharing your work. I have too worked on a generic XSL stylesheet that will convert any notes view into an html view. I have added the ability to pass different parameters to the xsl to control the look/functionality of the view. My work is posted at www.openNTF.org.

      Here is a link to the download:

      http://www.openntf.org/Projects/CodeBin/codebin.nsf/e4bf5e5e5c3f821e88256bda006d ac0c/3b006475e3b5bcde88256c4800728bca!OpenDocument

Your Comments


Navigate other articles in the category "XML"

« Previous Article Next Article »
None Found   Painting with SVG, a primer

About This Article

Author: Jake Howlett
Category: XML
Keywords: xml; xsl; tranform; readviewentries;


xmlview.xml (20 Kbytes)
transform.xsl (1 Kbytes)


Print Friendly

Let's Get Social

About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »