-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.txt
148 lines (109 loc) · 4.44 KB
/
api.txt
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
SXML API reference
(parse-xml port)
Reads from port and parses the XML.
Returns an SXML tree.
(display-xml sxml output-port)
Convert SXML into XML and write out to output-port.
(tag? tag)
Checks if tag is a valid SXML tag.
Returns the boolean for if it is or not.
(append-list l)
Appends the lists in the list l.
This is useful for when you want to put multiple children
into a node other than at the end.
(get-children tag)
Returns the list of children of a tag.
(get-tag-name tag)
Returns the name of a tag.
(get-attr tag name)
Returns the value of the attribute named name from an
SXML tag tag if it exists. It is false otherwise.
(set-attr tag name val)
Returns a copy of tag with the attribute named name
set to value val. It is inserted if it is not present.
(del-attr tag name)
Returns a copy of tag without the attribute named name.
(select-tags sxml equals)
Returns a list of sxml nodes from sxml 1 level deep for which
equals returns true.
(select-tags-rec sxml equals)
Returns a list of sxml nodes from sxml of arbitrary depth for which
equals returns true.
(get-text tag)
Returns all of the text from text nodes that are children of the given tag.
(get-text-rec tag)
Returns all of the text from all of the text nodes within the given tag.
(connect-tag head body)
Makes a tag from the tag name and attributes of the tag head,
but the children body.
(make-match-always)
Makes a matcher that always matches. (Like ".*")
(make-match-exact-path path)
Makes a matcher that only matches an exact path. (No wildcards)
(make-match-path path)
Makes a matcher that matches a regular-expression-like language.
This is the recommended matcher.
* matches 0 or more tag names and ? matches 1 tag name.
Example: (* "table" * "th")
(make-comparison comparators)
Make a comparison function that tries comparing 2 arguments
by each element of the comparators list in order with the
first element being the most significant.
(make-comparison-int comparators)
Make a comparison function that tries comparing 2 arguments
by each element of the comparators list in order with the
first element being the most significant.
The comparison functions should be negative for less,
0 for equal, and positive for greater instead of
simply true for less or false otherwise.
(equals-tag-name name)
Returns a function that takes a tag and checks if it has
the same name as the given name.
(value-of-text tag)
Returns the text of a tag.
Equivalent to get-text-rec.
(make-value-of-attr attr)
Makes a function that will take a tag
and return the value of the specified attribute
or else an empty string.
(make-value-of-select equals value-of)
Selects tags according to equals 1 level deep, applies value-of to them,
and then concatenates the resulting strings.
(make-value-of-select-rec equals value-of)
Selects tags according to equals arbitrarily deep, applies value-of to them,
and then concatenates the resulting strings.
(make-value-of-first value-of)
Makes a function that attempts to take the value-of each element of a list.
It returns the first value for which it succeeds or false if it fails.
(make-comparison-string-int value-of)
Makes a function that takes the value-of and then does a string
comparsion on the result. The result of the comparison is returned
as -1, 0, or 1 for <,=,>.
(make-comparison-number-int value-of)
Makes a function that takes the value-of and then does a numerical
comparsion on the result by converting the strings into numbers.
The result of the comparison is returned as -1, 0, or 1 for <,=,>.
(just-children branch tagname)
Returns the children of the children of branch whose name is tagname.
(just-text branch tagname)
Returns the text of the children of branch whose name is tagname.
(group-by x value-of)
Groups x into lists of equal value-of values.
(apply-templates root templates param)
Apply templates to sxml tree from root passing param
as the parameter to those templates.
This is intended to be the function to start applying a template originally.
templates = list of (matcher . function)
(apply-templates-list root sxml templates param)
Apply templates to a list of tags.
(apply-templates-children root sxml templates param)
Apply templates to the children of a tag.
This is intended to continue applying a template to a subtree.
(trim str)
Change leading and trailing whitespace into a single space.
(trim-all sxml)
Trim an entire sxml tree.
(valid-attr attr)
Checks if the attributes of a tag are valid.
(valid-tag tag)
Checks if a tag is valid, including its children.