File: parse-starttag-pi.sgm

package info (click to toggle)
docbook-dsssl-doc 1.75-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 3,672 kB
  • ctags: 8
  • sloc: makefile: 37
file content (68 lines) | stat: -rw-r--r-- 1,846 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<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
resultis 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>