It has become common practice to give PIs structured values. The result is a PI that looks a lot like a start tag with attributes:
<?pitarget name1="value1" name2=value2 name3="value 3">
This function parses a PI with this form and returns a list. The list contains the pitarget and each of the name/value pairs:
("pitarget" "name1" "value1" "name2" "value2" "name3" "value 3")
(define (parse-starttag-pi pi) ;; Parses a structured PI and returns a list of values (let* ((strippi (strip pi)) (spacepos (string-index strippi " "))) (if (< spacepos 0) (list strippi) (let* ((pitarget (substring strippi 0 spacepos)) (pivalues (strip (substring strippi (+ spacepos 1) (string-length strippi))))) (let loop ((values pivalues) (result (list pitarget))) (if (string=? values "") result (loop (parse-skip-pi-attribute values) (append result (parse-pi-attribute values)))))))))