Subject: [xsl] lotus domino key problem From: Jon.Norman@xxxxxxxxx Date: Thu, 17 Oct 2002 10:36:56 +0100 |
In Lotus Domino any view can be expressed as XML using ?readviewentries. It creates one <viewentries> element which has multiple <viewentry> elements (one for each of the rows in the view), each <viewentry> element has multiple <entrydata> elements (one for each column in the view). Each <viewentry> element has a position attribute to show the position in the view. This position could be 1,2 etc to show that it occurs without being categorised or 1.1, 1.2 etc to show that it is the category that is in position 1 (or is a response to the document at position 1) or indeed at position 1.1.1, 1.1.2 etc to show that it is in the category or a response to the document at position 1.1 - don't worry an example follows!! I have an xsl style sheet which uses a recursive call to named templates so that i can enclose every viewentry that is a child to the current viewentry inside some html. - example at bottom. I would like to do this with a key to improve performance but don't know how to start. PLEASE HELP!! xml view example: <?xml version="1.0" ?> <viewentries toplevelentries="1"> <viewentry position="1" unid="D8444381CD533B9580256C47004FA4DD" noteid ="8FE" children="3" descendants="11" siblings="1"> <entrydata columnnumber="0" name="MenuTitle"> <text>Employee Benefits</text></entrydata> </viewentry> <viewentry position="1.1" unid="1F1DF73A20D57F4F80256C4B00432AE6" noteid ="902" children="2" descendants="3" siblings="3" response="true"> <entrydata columnnumber="0" name="MenuTitle"> <text>fisrt</text></entrydata> </viewentry> <viewentry position="1.1.1" unid="7C187CBBC25A573B80256C4C0032A062" noteid ="91A" children="1" descendants="1" siblings="2" response="true"> <entrydata columnnumber="0" name="MenuTitle"> <text>first1</text></entrydata> </viewentry> <viewentry position="1.1.1.1" unid="1B2C9B01078755BF80256C4C004950B3" noteid="926" siblings="1" response="true"> <entrydata columnnumber="0" name="MenuTitle"> <text>first1.1</text></entrydata> </viewentry> <viewentry position="1.1.2" unid="B575EE6C221CB7B080256C4C0032A669" noteid ="91E" siblings="2" response="true"> <entrydata columnnumber="0" name="MenuTitle"> <text>first2</text></entrydata> </viewentry> <viewentry position="1.2" unid="71ECED20A8F3609A80256C47004FB7FD" noteid ="90A" children="2" descendants="5" siblings="3" response="true"> <entrydata columnnumber="0" name="MenuTitle"> <text>Pension Scheme</text></entrydata> </viewentry> <viewentry position="1.2.1" unid="C4BFD2C499F348C880256C4B00432319" noteid ="912" children="2" descendants="3" siblings="2" response="true"> <entrydata columnnumber="0" name="MenuTitle"> <text>blah</text></entrydata> </viewentry> <viewentry position="1.2.1.1" unid="0425B542AC7801CE80256C4C004ABDFF" noteid="92A" children="1" descendants="1" siblings="2" response="true"> <entrydata columnnumber="0" name="MenuTitle"> <text>suz</text></entrydata> </viewentry> <viewentry position="1.2.1.1.1" unid="4666C67E3686155D80256C4C00513A9E" noteid="93A" siblings="1" response="true"> <entrydata columnnumber="0" name="MenuTitle"> <text>ajay</text></entrydata> </viewentry> <viewentry position="1.2.1.2" unid="D956D11FE84F517A80256C4C00513FC1" noteid="93E" siblings="2" response="true"> <entrydata columnnumber="0" name="MenuTitle"> <text>ajay2</text></entrydata> </viewentry> <viewentry position="1.2.2" unid="D20FA8EE27F9297680256C4800580DBB" noteid ="916" siblings="2" response="true"> <entrydata columnnumber="0" name="MenuTitle"> <text>sri</text></entrydata> </viewentry> <viewentry position="1.3" unid="6A8E4B55047B1EBB80256C520053703C" noteid ="94A" siblings="3" response="true"> <entrydata columnnumber="0" name="MenuTitle"> <text>blahblahblah</text></entrydata> </viewentry> </viewentries> xsl stylesheet example: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl=" http://www.w3.org/1999/XSL/Transform"> <xsl:output method = "html" encoding="Windows-1252" /> <xsl:template match="/"> <xsl:apply-templates select = "viewentries/viewentry" /> </xsl:template> <!--viewentry template --> <xsl:template match="viewentries/viewentry"> <xsl:if test="translate(@position,'.','')=@position"> <xsl:choose> <xsl:when test="@children"> <xsl:call-template name = "dowithchildren" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="child::entrydata"/><br/> </xsl:otherwise> </xsl:choose> </xsl:if> </xsl:template> <!--dowithchildren template --> <xsl:template name="dowithchildren"> <xsl:if test = "@children"> <xsl:value-of select="@position" /><haschildren><xsl:value-of select="child::entrydata"/><br/> <xsl:call-template name = "dochildren" /> <xsl:value-of select="@position" /></haschildren><br/> </xsl:if> </xsl:template> <!--dochildren template --> <xsl:template name="dochildren"> <xsl:param name="parentposition"><xsl:value-of select=" @position"/>.</xsl:param> <xsl:for-each select = "../viewentry"> <xsl:if test = "starts-with(@position,$parentposition)"> <! --it's a descendant --> <xsl:call-template name = "dotestchild" > <!--now test to see if directdescendant --> <xsl:with-param name="parentposition" select ="$parentposition"></xsl:with-param> </xsl:call-template> </xsl:if> </xsl:for-each> </xsl:template> <!--dotestchildtemplate --> <xsl:template name="dotestchild"> <xsl:param name="parentposition" /> <xsl:param name="descendantpos"> <xsl:value-of select="substring-after (@position,$parentposition)"/> </xsl:param> <xsl:param name="descendantposnodots"> <xsl:value-of select="translate($descendantpos,'.','')"/> </xsl:param> <xsl:if test="$descendantpos=$descendantposnodots"> <!--we now know this is a direct child --> <xsl:choose> <xsl:when test="@children"> <xsl:call-template name = "dowithchildren" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="child::entrydata"/><br/> </xsl:otherwise> </xsl:choose> </xsl:if> </xsl:template> </xsl:stylesheet> Privileged/Confidential information may be contained in this message. If you are not the addressee indicated in this message (or responsible for the delivery of the message to such person), you may not copy or deliver this message to anyone. In such case you should destroy the message, and notify us immediately. Opinions, conclusions and other information expressed in this message are not given or endorsed by my firm or employer unless otherwise indicated by an authorised representative independent of this message. This footnote also confirms that this email message and any attachments have been swept for the presence of computer viruses. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] xsl:number question, Ruediger Geys | Thread | [xsl] XML+XSL --> HTML, Satish, L. Gnanendra |
Fwd: Re: [xsl] Fwd: Built-in *@ vs., Janning Vygen | Date | Re: [xsl] How do I locate the paren, David Carlisle |
Month |