Testing if an attribute is present

Subject: Testing if an attribute is present
From: Aidan Killian <aidan@xxxxxxxx>
Date: Mon, 27 Oct 1997 16:27:32 -0800
Hi,

	I am trying to test if an attribute is present in an element
(I do not care if it is expicitly specified or defaulted).

	Here is the situation: an element (cd) can have 3 attributes:
"day", "month" & "year". The first (day) is optional, the others are 
required.

	I want to output: YYYY-MM-DD or YYYY-MM if 'day' is absent.

	I get the following error whenever 'day' is absent (no matter what I
put in the 'if' statement):

jade:metafilter.dsl:79:2:E: 1st argument for primitive "literal" of
wrong type: "#f" not a string

	If I leave out the logic I get a different (understandable)
error.

Thanks,
	Aidan Killian

(B.T.W. I am working on getting DSSSL training)

;;;;;;;;;;;;;;;;;
;; output date ;;
;;;;;;;;;;;;;;;;;
(define (output-date)
	;;(if (equal? #t #f) (attribute-string "day" (current-node))
	(string-append
		(attribute-string "year" (current-node))
		"-"
		(attribute-string "month" (current-node))
		(if (attribute-string "day") ;; if "day" is present
			(string-append
				"-"
				(attribute-string "day" (current-node)))
			"")))



(element CD (make element gi: "CREATEDDATE" (make sequence
	(literal (output-date))
	(empty-sosofo))))		;; supress proper content

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


Current Thread