|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: automatic generation of figure numbers
Hello,
Thank you for your mail. I think I need to clarify the "reference" part of my problem. Below is a sample of my XML code. I apologize for the clumsy formatting/indenting, basically when I pasted the code into the email editor, the indenting etc got disturbed. As you will see below, the <figure> element is interspersed with other elements. The <figure> element is used wherever I feel the need to insert an image/picture. I have attempted to highlight the places (in the code) where the <figure> element is being used so that it is easy for you to spot the element. I have used the following method to indicate the presence of the element: ****INSTANCE 1 <figure file="pic.gif">Figure</figure>***** As you can see, I have inserted *****INSTANCE 1 at the beginning (to indicate the number of ocurrence) and **** at the end of the element. **** INSTANCE 1 do not form part of the actual code. I just thought I should clarify that before I explain the code. <component type="DC CONTACTOR-41A296327AM" toc2="contactor"> <activity type="FUNCTIONAL DESCRIPTION" toc2="func_desc"> <text_description> <para> The Type 41A296327AM DC Contactor ****INSTANCE 1<figure file="one.gif">figure</figure>****** is a magnetically operated device used for opening and closing electrical power circuits. The contactor is equipped with one stationary and two movable main contacts. The movable contacts are mounted on an ar- mature which closes when the operating coil is energized. Removing power from the operating coil permits the spring-loaded armature to open and to break the electrical circuit made by the main contacts. The contactor can also actuate control circuits through auxiliary contacts, called interlocks *******INSTANCE 2<figure file="two.gif">Figure</figure>*********. These op-erate in conjunction with the armature of the contactor. An arc chute, mounted over the contacts, helps to extinguish the electrical arc generated when the contac-tor opens. </para> </text_description> <activity type="INSPECTION" toc2="inspect"> <warning> <para> WARNING: To prevent personal injury from elec-trical shock, turn off power before inspecting the contactor. </para> </warning> <text_description> <para> In general, the inspection schedule for the contactor should conform to the inspection schedule established for the vehicle but may be modified, as required, by actual operating experience. *****INSTANCE 3 <figure file="three.gif">Figure</figure>******* The following information is offered as a general inspection guide which calls attention to what should be inspected and what to look for when making the inspec-tion. If the inspection results call for corrective mainte-nance to be performed, the procedures for carrying out such maintenance are covered in the MAINTENANCE section of this publication. *******INSTANCE 4<figure file="one.gif">Figure</figure>***** Visually inspect contactor for dirt or contaminants. Clean contactor if necessary. Check for loose electrical connections and mounting hardware. Tighten all loose hardware. Check for worn connecting wires. If wires are worn, correct the cause of wear and replace wires. </para> </text_description> </activity> In the code, you will see that each <figure> has a required attribute called "file" which is used in the XSL code to point to the gif file that a particular <figure> element refers to, e.g. <figure file = one.gif>Figure</figure> means that this particular instance of the <figure> element points to the file "one.gif". Now, the way that XSL formats the <figure> element is as follows: XSL converts the text within <figure> to a hyperlink. In addition to that, it generates a number that it places alongside the text (concatenation)and it actually hyperlinks the contatenated piece, i.e. for the first instance of <figure>, it generates a number "1" and appends this to the text of <figure>. The text of <figure> is "Figure". So the final output is the hyperlink "Figure 1". This hyperlink points to the file specified by the attribute "file" e.g. if you click on the hyperlink "Figure 1" in the output, the file "one.gif" is opened. How do I generate the number "1"? Well I was using the following code in the XSL code (similar to what Sebastian suggested): <xsl:template match="figure">
<xsl:variable name="fig">
<xsl:number level="any"/>
</xsl:variable>
<a>
<xsl:attribute name="href">
<xsl:value-of select="@file"/>
</xsl:attribute>
<xsl:value-of select="."/><xsl:value-of select="$fig"/>
</a>
</xsl:template>Here the variable "fig" is used to generate the figure number. However if you see the XML code, there are 4 instances of the <figure> element as shown
one.gif INSTANCE 1
two.gif INSTANCE 2
three.gif INSTANCE 3
one.gif INSTANCE 4The first 3 instances have unique/different "file" values, which means that they point to different image files. However the 4th instance has the same value for the "file" attribute as the 1st instance. This measn that somewhere in the document I feel the need to refer to "Figure 1" again , i.e. I may have multiple occurences of "Figure 1" in the document. Now my XSL code generates a new integer for each occurence of <figure>. However the problem arises when I need "Figure 1" to occur again, i.e. basically I want the number "1" (or whatever the number might be) to occur again. The XSL code should somehow compare the "file" value of the current <figure> element with the "file" values of all the preceding <figure> elements and if it finds that there is a match (which it will if two <figure> elements point to the same file), it should assign the same number to the current <figure> element as it did to the earlier "matching" <figure> element. I hope I have the problem is clearer now. I would be very grateful if you could suggest a solution. Thank you very much for you help. Thanks, Regards, Dhruv From: "Cline, Ken" <kcline@xxxxxxxx> To: "'XSL-List@xxxxxxxxxxxxxxxx'" <XSL-List@xxxxxxxxxxxxxxxx> CC: "'dhruv_r@xxxxxxxxxxx'" <dhruv_r@xxxxxxxxxxx> Subject: RE: automatic generation of figure numbers Date: Wed, 4 Oct 2000 12:02:54 -0400
Share information about yourself, create your own public profile at http://profiles.msn.com. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








