134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
-
-
+
+
|
(define (maybe-attr name attrs [missing ""])
(define result (assoc name attrs))
(cond
[(pair? result) (cadr result)]
[else missing]))
;; Returns a function will test if a txexpr's tag matches the given symbol.
(define (make-tag-predicate tagsym)
(lambda (tx) (and (txexpr? tx) (equal? tagsym (get-tag tx)))))
(define (make-tag-predicate . tagsyms)
(lambda (tx) (if (and (txexpr? tx) (member (get-tag tx) tagsyms)) #t #f)))
(define (tx-strs xpr)
(cond
[(txexpr? xpr) (apply string-append (map tx-strs (get-elements xpr)))]
[(string? xpr) xpr]
[else ""]))
|