My agentic slop goes here. Not intended for anyone else!
at main 12 kB view raw
1(** [Syndic.Rss1]: compliant with {{: http://web.resource.org/rss/1.0/spec} RSS 2 1.0}. *) 3 4module Error : module type of Syndic_error 5 6(** A descriptive title for the channel, image, item and textinput. See RSS 1.0 7 {{: http://web.resource.org/rss/1.0/spec#s5.3.1} § 5.3.1}, {{: 8 http://web.resource.org/rss/1.0/spec#s5.4.1} § 5.4.1}, {{: 9 http://web.resource.org/rss/1.0/spec#s5.5.1} § 5.5.1}, and {{: 10 http://web.resource.org/rss/1.0/spec#s5.6.1} § 5.6.1}. 11 12 {[ Syntax: <title>{title}</title> Requirement: Required for all Model: 13 (#PCDATA) (Suggested) Maximum Length: 40 (characters) for channel, image 14 and textinput (Suggested) Maximum Length: 100 for item ]} *) 15type title = string 16 17(** The text input field's (variable) name. {{: 18 http://web.resource.org/rss/1.0/spec#s5.6.3} See RSS 1.0 § 5.6.3}. 19 20 {[ Syntax: <name>{textinput_varname}</name> Requirement: Required if 21 textinput Model: (#PCDATA) (Suggested) Maximum Length: 500 ]} *) 22type name = string 23 24(** This can be - a brief description of the channel's content, function, 25 source, etc. {{: http://web.resource.org/rss/1.0/spec#s5.3.3} See RSS 1.0 26 § 5.3.3}; - or a brief description/abstract of the item. {{: 27 http://web.resource.org/rss/1.0/spec#s5.5.3} See RSS 1.0 § 5.5.3}; - or a 28 brief description of the textinput field's purpose. For example: "Subscribe 29 to our newsletter for..." or "Search our site's archive of..." {{: 30 http://web.resource.org/rss/1.0/spec#s5.6.2} See RSS 1.0 § 5.6.2}. 31 32 {[ Syntax: <description>{description}</description> Requirement: Required 33 only for channel and textinput Model: (#PCDATA) (Suggested) Maximum Length: 34 500 for channel and item (Suggested) Maximum Length: 100 for textinput ]} *) 35type description = string 36 37(** Establishes an RDF association between the optional image element [5.4] and 38 this particular RSS channel. The rdf:resource's {image_uri} must be the 39 same as the image element's rdf:about {image_uri}. {{: 40 http://web.resource.org/rss/1.0/spec#s5.3.4} See RSS 1.0 § 5.3.4} 41 42 {[ Syntax: <image rdf:resource="{image_uri}" /> Requirement: Required only 43 if image element present Model: Empty ]} *) 44type channel_image = Uri.t 45 46(** The URL of the image to used in the "src" attribute of the channel's image 47 tag when rendered as HTML. {{: http://web.resource.org/rss/1.0/spec#s5.4.2} 48 See RSS 1.0 § 5.4.2} 49 50 {[ Syntax: <url>{image_url}</url> Requirement: Required if the image 51 element is present Model: (#PCDATA) (Suggested) Maximum Length: 500 ]} *) 52type url = Uri.t 53 54(** This can be - The URL to which an HTML rendering of the channel title will 55 link, commonly the parent site's home or news page. {{: 56 http://web.resource.org/rss/1.0/spec#s5.3.2} See RSS 1.0 § 5.3.2} - Or the 57 URL to which an HTML rendering of the channel image will link. This, as 58 with the channel's title link, is commonly the parent site's home or news 59 page. {{: http://web.resource.org/rss/1.0/spec#s5.4.3} See RSS 1.0 § 60 5.4.3} - Or the item's URL. {{: 61 http://web.resource.org/rss/1.0/spec#s5.5.2} See RSS 1.0 § 5.5.2} - Or the 62 URL to which a textinput submission will be directed (using GET). {{: 63 http://web.resource.org/rss/1.0/spec#s5.6.4} See RSS 1.0 § 5.6.4} 64 65 {[ Syntax: <link>{link}</link> Requirement: Required for all Model: 66 (#PCDATA) (Suggested) Maximum Length: 500 ]} *) 67type link = Uri.t 68 69(** An RDF table of contents, associating the document's items [5.5] with this 70 particular RSS channel. Each item's rdf:resource {item_uri} must be the 71 same as the associated item element's rdf:about {item_uri}. 72 73 An RDF Seq (sequence) is used to contain all the items rather than an RDF 74 Bag to denote item order for rendering and reconstruction. 75 76 Note that items appearing in the document but not as members of the channel 77 level items sequence are likely to be discarded by RDF parsers. 78 79 {{: http://web.resource.org/rss/1.0/spec#s5.3.5} See RSS 1.0 § 5.3.5} 80 81 {[ Syntax: <items><rdf:Seq><rdf:li resource="{item_uri}" /> ... 82 </rdf:Seq></items> Requirement: Required ]} *) 83type items = Uri.t list 84 85(** Establishes an RDF association between the optional textinput element [5.6] 86 and this particular RSS channel. The {textinput_uri} rdf:resource must be 87 the same as the textinput element's rdf:about {textinput_uri}. 88 89 {{: http://web.resource.org/rss/1.0/spec#s5.3.6} See RSS 1.0 § 5.3.6} 90 91 {[ Syntax: <textinput rdf:resource="{textinput_uri}" /> Requirement: 92 Required only if texinput element present Model: Empty ]} *) 93type channel_textinput = Uri.t 94 95(** The channel element contains metadata describing the channel itself, 96 including a title, brief description, and URL link to the described 97 resource (the channel provider's home page, for instance). The \{resource\} 98 URL of the channel element's rdf:about attribute must be unique with 99 respect to any other rdf:about attributes in the RSS document and is a URI 100 which identifies the channel. Most commonly, this is either the URL of the 101 homepage being described or a URL where the RSS file can be found. 102 103 {{: http://web.resource.org/rss/1.0/spec#s5.3} See RSS 1.0 § 5.3} 104 105 {[ Syntax: <channel rdf:about="{resource}"> Requirement: Required Required 106 Attribute(s): rdf:about Model: (title, link, description, image?, items, 107 textinput?) ]} *) 108type channel = 109 { about: Uri.t (** must be unique *) 110 ; title: title 111 ; link: link 112 ; description: description 113 ; image: channel_image option 114 ; items: items 115 ; textinput: channel_textinput option } 116 117(** An image to be associated with an HTML rendering of the channel. This image 118 should be of a format supported by the majority of Web browsers. While the 119 later 0.91 specification allowed for a width of 1–144 and height of 120 1–400, convention (and the 0.9 specification) dictate 88×31. 121 122 {{: http://web.resource.org/rss/1.0/spec#s5.4} See RSS 1.0 § 5.4} 123 124 {[ Syntax: <image rdf:about="{image_uri}"> Requirement: Optional; if 125 present, must also be present in channel element [5.3.4] Required 126 Attribute(s): rdf:about Model: (title, url, link) ]} *) 127type image = {about: Uri.t; title: title; url: url; link: link} 128 129(** While commonly a news headline, with RSS 1.0's modular extensibility, this 130 can be just about anything: discussion posting, job listing, software patch 131 -- any object with a URI. There may be a minimum of one item per RSS 132 document. While RSS 1.0 does not enforce an upper limit, for backward 133 compatibility with RSS 0.9 and 0.91, a maximum of fifteen items is 134 recommended. 135 136 [about] must be unique with respect to any other rdf:about attributes in 137 the RSS document and is a URI which identifies the item. The value of 138 [about] should be identical to the value of the [link], if possible. 139 140 {{: http://web.resource.org/rss/1.0/spec#s5.5} See RSS 1.0 § 5.5} 141 142 {[ Syntax: <item rdf:about="{item_uri}"> Requirement: >= 1 Recommendation 143 (for backward compatibility with 0.9x): 1-15 Required Attribute(s): 144 rdf:about Model: (title, link, description?) ]} *) 145type item = 146 {about: Uri.t; title: title; link: link; description: description option} 147 148(** The textinput element affords a method for submitting form data to an 149 arbitrary URL — usually located at the parent website. The form processor 150 at the receiving end only is assumed to handle the HTTP GET method. 151 152 The field is typically used as a search box or subscription form — among 153 others. While this is of some use when RSS documents are rendered as 154 channels (see MNN) and accompanied by human readable title and description, 155 the ambiguity in automatic determination of meaning of this overloaded 156 element renders it otherwise not particularly useful. RSS 1.0 therefore 157 suggests either deprecation or augmentation with some form of resource 158 discovery of this element in future versions while maintaining it for 159 backward compatiblity with RSS 0.9. 160 161 [about] must be unique with respect to any other rdf:about attributes in 162 the RSS document and is a URI which identifies the textinput. [about] 163 should be identical to the value of the [link], if possible. 164 165 {{: http://web.resource.org/rss/1.0/spec#s5.6} See RSS 1.0 § 5.6 } 166 167 {[ Syntax: <textinput rdf:about="{textinput_uri}"> Requirement: Optional; 168 if present, must also be present in channel element [5.3.6] Required 169 Attribute(s): rdf:about Model: (title, description, name, link) ]} *) 170type textinput = 171 {about: Uri.t; title: title; description: description; name: name; link: link} 172 173(** The outermost level in every RSS 1.0 compliant document is the RDF element. 174 The opening RDF tag assocaties the rdf: namespace prefix with the RDF 175 syntax schema and establishes the RSS 1.0 schema as the default namespace 176 for the document. 177 178 While any valid namespace prefix may be used, document creators are advised 179 to consider "rdf:" normative. Those wishing to be strictly 180 backward-compatible with RSS 0.9 must use "rdf:". 181 182 {{: http://web.resource.org/rss/1.0/spec#s5.2} See RSS 1.0 § 5.2} 183 184 {[ Syntax: <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 185 xmlns="http://purl.org/rss/1.0/"> Requirement: Required exactly as shown, 186 aside from any additional namespace declarations Model: (channel, image?, 187 item+, textinput?) ]} *) 188type rdf = 189 { channel: channel 190 ; image: image option 191 ; item: item list 192 ; textinput: textinput option } 193 194val parse : ?xmlbase:Uri.t -> Xmlm.input -> rdf 195(** [parse xml] returns the RDF corresponding to [xml]. 196 197 @raise Error.raise_expectation if [xml] is not a valid RSS1 document. 198 199 @param xmlbase the base URI against which relative URIs in the XML RSS1 200 document are resolved. It is superseded by xml:base present in the document 201 (if any). *) 202 203val read : ?xmlbase:Uri.t -> string -> rdf 204(** [read fname] reads the file name [fname] and parses it. For the optional 205 parameters, see {!parse}. *) 206 207(**/**) 208 209(** An URI is given by (xmlbase, uri). The value of [xmlbase], if not [None], 210 gives the base URI against which [uri] must be resolved if it is relative. *) 211type uri = Uri.t option * string 212 213val unsafe : 214 ?xmlbase:Uri.t 215 -> Xmlm.input 216 -> [> `RDF of [> `Channel of [> `About of uri 217 | `Description of string list 218 | `Image of [> `URI of uri] list 219 | `Items of [> `Seq of [> `Li of [> `URI of uri] 220 list ] 221 list ] 222 list 223 | `Link of [> `URI of uri] list 224 | `TextInput of [> `URI of uri] list 225 | `Title of string list ] 226 list 227 | `Image of [> `About of uri 228 | `Link of [> `URI of uri] list 229 | `Title of string list 230 | `URL of [> `URI of uri] list ] 231 list 232 | `Item of [> `About of uri 233 | `Description of string list 234 | `Link of [> `URI of uri] list 235 | `Title of string list ] 236 list 237 | `TextInput of [> `About of uri 238 | `Description of string list 239 | `Link of [> `URI of uri] list 240 | `Name of string list 241 | `Title of string list ] 242 list ] 243 list ] 244(** Analysis without verification, enjoy ! *)