How to perform calculation?

Subject: How to perform calculation?
From: Philippe CASIDY <pcasidy@xxxxxxxxxxx>
Date: Tue, 16 May 2000 18:01:44 +0200 (CEST)
Hello!

I am wondering how I could do some calculations on values inside my
documents. I am using JADE and TeX backend.

For instance, I have the followind DTD and instance :

<!ENTITY % doctype "TEST"                >
<!ELEMENT %doctype;- - ( DETAILS )       >
<!ELEMENT DETAILS  - - (LINE+)           >
<!ELEMENT LINE     - - (DESC& QUANTITY ) >
<!ELEMENT DESC     - O (#PCDATA)         >
<!ELEMENT QUANTITY - O (#PCDATA)         >


<!DOCTYPE TEST SYSTEM "test.dtd">

<Test>
<DETAILS>
<LINE>
<DESC>Fisrt Value
<QUANTITY>15
</LINE>
<LINE>
<DESC>Second Value
<QUANTITY>1
</LINE>
</DETAILS>
</Test>

In my DSSSL, I would like to sum the values of QUANTITY and to have this
result inserted in the output.

For instance, here is a DSSSL:


(root (make simple-page-sequence ) )

(define %column1_width% 6cm)
(define %column2_width% 2cm)
(define %column3_width% 2.5cm)
(define %column4_width% 2.5cm)
(define %column5_width% 2cm)
(define %column6_width% 2cm)

(element TEST
  	(make simple-page-sequence
    		font-name:     "Helvetica"
    		left-margin:   2cm
    		right-margin:  2cm
    		top-margin:    2cm
		bottom-margin: 4cm
		left-footer:	(empty-sosofo)
		center-footer:	(empty-sosofo)
	)
)

(element DETAILS
	(make table
		table-border:		#t
		space-before:	6pt
		space-after:	6pt
		(make table-column				; DESC
			column-number:			1
			cell-before-column-margin:	6pt
			cell-after-column-margin:	6pt
			display-alignment:		'center
			width:				%column1_width%
		)
		(make table-column		; QUANTITY
			column-number:	2
			cell-after-column-margin:	6pt
			display-alignment:		'center
			width:				%column2_width%
		)
		(process-children)
		(make table-row
			(make table-cell
				(make paragraph
				quadding:	'center
					(literal "Total")
				)
			)
		
		(make table-cell
			(make paragraph
				quadding:	'start
					(literal "How to calculate the sum?")
			)
		)
		)
	)
)

(element LINE
	(make table-row
		(make table-cell
			(make paragraph
				quadding:	'center
				(process-node-list
					(select-elements
						(descendants (current-node))
						"DESC"
					)
				)
			)
		)
		(make table-cell
			(make paragraph
				quadding:	'center
				(process-node-list
					(select-elements
						(descendants (current-node))
						"QUANTITY"
					)
				)
			)
		)
	)
)


Thanks for your help!

Phil.




 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread