<RefEntry id="parse-starttag-pi">
<!-- This file is generated automatically from the DSSSL source. -->
<!-- Do not edit this file! -->
<?html-filename parse-starttag-pi.html>

<RefMeta>
  <RefEntryTitle>parse-starttag-pi</RefEntryTitle>
  <RefMiscInfo Role="file">dblib.dsl</RefMiscInfo>
</RefMeta>

<RefNameDiv>
  <RefName>parse-starttag-pi</RefName>
  <RefPurpose>Parses a structured PI and returns a list of values</RefPurpose>
</RefNameDiv>

<RefSynopsisDiv><Title>Synopsis</Title>
<Synopsis>
(parse-starttag-pi pi)
</Synopsis>
</RefSynopsisDiv>

<RefSect1><Title>Description</Title>

<para>
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:
</para>
<para>
&#60;?pitarget name1="value1" name2=<literal>value2</literal> name3="value <literal>3</literal>">
</para>
<para>
This function parses a PI with this form and returns a list. The
list contains the pitarget and each of the name/value pairs:
</para>
<para>
("pitarget" "name1" "value1" "name2" "value2" "name3" "value <literal>3</literal>")</para>


</RefSect1>

<RefSect1><Title>Author</Title>

<para>
Norman Walsh, &lt;ndw@nwalsh.com&gt;
</para>
</RefSect1>
<RefSect1><Title>Source Code</Title>

<ProgramListing>
(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)))))))))
</ProgramListing>
</RefSect1>

</RefEntry>
