swirl
Guide to OmniMark 9   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
    Other Library Functions  
function  

uri.parse

 
 

Library: URI handling (OMURI)
Import: omuri.xmd
Return type: Switch

Returns: indication if the uri is valid


Declaration

export switch function
   parse      value      string uri
         into write-only string uri-components


Purpose

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:

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"
     again
would 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
 
 

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ LEGACY LIBRARIES ] [ ERRORS ]

OmniMark 9.1.0 Documentation Generated: September 2, 2010 at 1:38:10 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2010.