Subject: re: [xsl] newbie: problems computing output from variables From: Sam Griffiths <S.Griffiths@xxxxxxxxxx> Date: Wed, 7 Feb 2001 12:25:37 -0000 |
Hi - I hope you've got time to take a look at this one - it's got to the banging head against brick wall stage. I'm on the final leg of a FAQ 'site' implemented through xml/xsl. Things have started to get a bit tricky when I've tried to further compute data from an existing variable. The xsl I'm using is obviously wide of the mark - I've been messing around for too long without it working. I have been looking at Mike Kay's section on computational stylesheets and the answers lies therein I'm sure but I can't see it. (I'm coming at xsl/xml from a web design background which probably explains a lot!!) My XML is: *XML* <faqs> <lastid>2</lastid> <faq> <id>1</id> <edit_id>1</edit_id> [this question has not been edited or is re-archived] <question>this is a question</question> <answer>this is an answer</answer> </faq> <faq> <id>2</id> <edit_id>3</edit_id> [this question has been edited] <question>another question</question> <answer>another answer</answer> </faq> ... </faqs> *Note that where edit_id = id+1 the question has been edited. (Edited questions are formatted differently. Where a previously edited question has been archived, the edit_id is equalised with id). ----- I have been able to select edited instances of $question with: test="$id != $edit_id"> (so var edits = id != edit_id) ------- The problem is that I need to select the value of $question where: $edits[position() < 6]. Xerces tells me that it is unable to convert #BOOLEAN to a NodeList. The point of this is to display only the *x most recently edited questions* on the list and archive the older ones automatically - rather than using a separate 'archive' stylesheet (which relies on the administrator making a decision to prevent the list getting cluttered). My xsl (fumblings) are: <xsl:template match="/"> ... <xsl:variable name="edits" select="id != edit_id"/> <xsl:variable name="editvase" select="$edits[position() < 6]"/> <xsl:for-each select="/faqs/faq"> <xsl:choose> <xsl:when test="$edits"> <xsl:value-of select="$question"/><br/> <input name="edit_id" type="hidden" value="{id}"/> <!--</xsl:for-each>--> </xsl:when> </xsl:choose> </xsl:for-each> ... </xsl:template> Any help would be much appreciated - especially concerning the principle underlying my mistake - outputting boolean rather than nodesets... Thanks a lot Sam Interface Design Syzygy Ltd. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Multiply, Linda van den Brink | Thread | RE: [xsl] newbie: problems computin, Michael Kay |
RE: [xsl] Multiply, Ben Robb | Date | RE: [xsl] Multiply, Jo Kong HO |
Month |