Subject: AW: [xsl] tricky problem filtering input and counting output From: "Szabo, Patrick \(LNG-VIE\)" <patrick.szabo@xxxxxxxxxxxxx> Date: Tue, 22 Feb 2011 15:44:05 +0100 |
Hi, I hope I'm imagining this correctly. Couldn't you filter the input before you do the counting ?! You could dump the document and sections elements you don't need and count afterwards. regards . . . . . . . . . . . . . . . . . . . . . . . . . . Patrick Szabo XSLT-Entwickler LexisNexis Marxergasse 25, 1030 Wien mailto:patrick.szabo@xxxxxxxxxxxxx Tel.: +43 (1) 534 52 - 1573 Fax: +43 (1) 534 52 - 146 -----UrsprC<ngliche Nachricht----- Von: Trevor Nicholls [mailto:trevor@xxxxxxxxxxxxxxxxxx] Gesendet: Dienstag, 22. Februar 2011 15:38 An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Betreff: [xsl] tricky problem filtering input and counting output Hi My input XML is grouped into documents and sections which can be nested to arbitrary depth. I have a transform which processes the input into one or more output HTML documents, following the rule that any "document" element, or any "section" element with attribute "@break='Y'", should direct its output to a new file. Each output file contains navigation links to the previous and next files in the output. So far so good. The mechanism to achieve this is more or less as follows (leaving a lot to the imagination): <xsl:template match="document | section[@break='Y']"> <xsl:variable name="output"> <xsl:call-template name="subfile-name" /> </xsl:variable> <xsl:result-document href="{$output}.html"> <xsl:call-template name="html-file" /> </xsl:result-document> </xsl:template> <xsl:template name="subfile-name"> <xsl:number count="document | section[@break='Y']" level="any" /> </xsl:template> <xsl:variable name="subfile-cnt" select="count(//document) + count(//section[@break='Y'])" /> <xsl:template name="navigation"> <xsl:variable name="thisnum"> <xsl:number count="document | section[@break='Y']" level="any" /> </xsl:variable> <xsl:variable name="prevnum" select="($thisnum - 1)" /> <xsl:variable name="nextnum" select="($thisnum + 1)" /> <xsl:choose> <xsl:when test="$prevnum > 0"> <xsl:call-template name="buildlink"> <xsl:with-param name="href" select="{$prevnum}.html" /> <xsl:with-param name="content" select="'Previous'" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:text>Previous</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text> | </xsl:text> <xsl:choose> <xsl:when test="$subfile-cnt > $nextnum"> <xsl:call-template name="buildlink"> <xsl:with-param name="href" select="{$nextnum}.html" /> <xsl:with-param name="content" select="'Next'" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:text>Next</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> This works fine because the output documents form an unbroken sequence from 1 to N. Now I am required to filter the input on some condition which means certain output HTML pages are suppressed. I can do the filtering easily enough by modifying the first template in the foregoing <xsl:template match="document | section[@break='Y']"> <xsl:variable name="output"> <xsl:call-template name="subfile-name" /> </xsl:variable> <xsl:variable name="select"> <xsl:call-template name="filter-output" /> </xsl:variable> <xsl:if test="$select='Y'"> <xsl:result-document href="{$output}.html"> <xsl:call-template name="html-file" /> </xsl:result-document> </xsl:if> </xsl:template> again, leaving the content of the "filter-output" template to your imagination. I'm sure you know what's coming next; either the output file numbering needs to be fixed so the sequence is still continuous, or the navigation template needs a means of establishing what the next and previous unsuppressed file numbers actually are. I am finding either of these extraordinarily difficult. Can someone please help me see how to cut through the knot? Thanks for any assistance Cheers Trevor
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] tricky problem filtering inpu, Trevor Nicholls | Thread | Re: AW: [xsl] tricky problem filter, Wendell Piez |
Re: [xsl] Cheaper to prepend or app, Dimitre Novatchev | Date | re: [xsl] The set datatype implemen, Vladimir Nesterovsky |
Month |