Subject: RE: [xsl] Displaying Code Dependent on First Encounter of Specific Reference From: <Jarno.Elovirta@xxxxxxxxx> Date: Thu, 14 Oct 2004 09:21:03 +0300 |
Hi, > I'm developing a stylesheet that converts XML to html to > display research articles. The articles contains three > citation types, bibliographical, table call, and figure call. > Upon encountering a table call or figure call, I would like > to display the table or figure referred to immediately > following the paragraph that contains the call. I want the > table or figure to appear in the order they were referred to > in the paragraph and I want each table or figure to only > appear once in the outputted document. Tables and figures are > numbered in order of their reference, though at any point you > can refer to a table or figure that has been previously called. > > Citations look like this: > <xref ref-type="bibr" rid="B1">1</xref> > <xref ref-type="table" rid="T1">Table 1</xref> > <xref ref-type="fig" rid="F1">Figure 1</xref> > > Sample Input: > > [A paragraph that includes a citation for Table 1.] > [A paragraph that includes citations for Table 2, Table 1, > Figure 1, and Table 3.] > > Sample Output: > > [A paragraph that includes a citation for Table 1.] > > Table 1 > > [A paragraph that includes citations for Table 2, Table 1, > Figure 1, and Table 3.] > > Table 2 > Figure 1 > Table 3 > > My initial thought is to create a set of keys: > Key: Last Table Processed > Key: Last Figure Processed > Key: Last Table Encountered > Key: Last Figure Encountered How would you declare these, because keys cannot state anything about processing, they're just indices, really. > Since the tables and figures are numbered in order, a > comparison of the two keys should be in order. This > comparison should be made at the end of processing a > paragraph. However, I'm not quite sure how I'd make such a > comparison or even if I can use keys in that manner. I'm > thinking I might need to generate some sort of array to keep > track of the multiple citations encountered so that in the > sample provided the output is (Table 2, Figure 1, Table 3) > and not (Table 2, Table 3, Figure 1) or (Figure 1, Table 2, > Table 3). If I were to build an array, since at this point I > don't need to process <xref> citations of "bibr" type, those > should be ignored. Any suggestions would be greatly > appreciated. Thanks. I think you're overcomplicating things, and you're thinking in terms of procedural programming, not declarative. Just declare a key <xsl:key name="xref" match="xref" use="concat(@ref-type, ' ', @rid)"/> and then, when processing a paragraph <xsl:template match="para"> <p> <xsl:apply-templates/> </p> <xsl:for-each select="descendant::xref[generate-id() = generate-id(key('xref', concat(@ref-type, ' ', @rid)))]"> <xsl:apply-templates select="." mode="process-link"/> </xsl:for-each> </xsl:template> I.e. use Muenchian Grouping approach to check if the xref being processed is the first one in document order. Cheers, Jarno
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] FW: XSL calling Java prob, Ha Wai Hoe | Thread | [xsl] How to sort?, Mike G |
RE: [xsl] FW: XSL calling Java prob, Manpreet Singh | Date | [xsl] FW: XSL calling Java problem , Ha Wai Hoe |
Month |