|
|||||
|
||||||
Other Library Functions |
function |
uri.parse |
Library: URI handling (OMURI)
Import: omuri.xmd |
Return type: Switch Returns: indication if the uri is valid |
export switch function parse value string uri into write-only string uri-components
Function uri.parse
parses the argument URI and stores its components into the uri-components
argument. uri-components is cleared first. It must be a variable-size shelf, or OmniMark will report a
program error otherwise.
If the uri argument is a well-formed URI, uri.parse
returns true
and fills the
uri-components shelf with its components. Each component is corresponding to the BNF productions
presented in RFC 2396, appendix A. The following keys can be returned:
scheme
absolute URI
relative URI
opaque part
absolute path
network path
registry name
query
user
host name
IPv4 address
IPv6 address
port
Hex-encoded characters in the parsed URI appear decoded in all uri-components shelf item values,
except in absolute URI
and relative URI
where they remain encoded. For
example, the output of the following program:
import "omuri.xmd" prefixed by uri. process local string components variable assert uri.parse "file://localhost/C:/My%%20Documents" into components repeat over components as c output key of c || ": %"" || c || "%"%n" againwould be
host name: "localhost" absolute path: "/C:/My Documents" network path: "//localhost/C:/My Documents" scheme: "file" absolute URI: "file://localhost/C:/My%20Documents"
If you only want to validate a URI string and don't need its parsed components, you can specify an anonymous
shelf literal as the uri-components argument:
output "Malformed URI: " || my-URI unless uri.parse my-URI into { }
Other Library Functions
|
Copyright © Stilo International plc, 1988-2010.