![]()  | 
 
  
  | 
||||
![]() ![]() ![]() ![]() ![]() ![]() ![]()  | 
    |||||
| 
 | 
||||||
| Other Library Functions | ||||||
| function | 
uri.extend | 
| 
Library: URI handling (OMURI)
 Import: omuri.xmd  | 
Return type: String Returns: the resolved relative-uri  | 
export string function
   extend      value string base-uri
          with value string relative-uri
  
Argument definitions
 The function uri.extend resolves relative URI references. If base-uri is an absolute URI and
        relative-uri is a relative one, the result will be an absolute URI reference. If they are both
        relative, the result of uri.extend will be a relative URI.
      
 There are two exceptional cases. If relative-uri is an absolute URI itself, uri.extend
        throws uri.already-absolute to indicate that. Alternatively, if relative-uri consists only of
        a URI fragment (e.g. "#section1"), uri.extend throws uri.current-document-reference.
        Neither exception has any parameters.
      
 In the following example, the function fetch-fresh-page uses uri.extend to resolve HTTP
        redirections and access the content of an HTML page even if it has been moved to a new location.
  import "omuri.xmd" prefixed by uri.
  import "omvfs.xmd" prefixed by vfs.
    
  define string source function
     fetch-fresh-page value string url
  as
     local vfs.file html-page initial { vfs.open-http url }
  
     do scan vfs.reader of html-page
     match ul '<html>' white-space*
              '<meta' white-space+ 'http-equiv="refresh"' white-space+
              'content="0; url=' any ** => new-url '"' white-space* '>'
        output fetch-fresh-page uri.extend url with new-url
  
      ; uri.current-document-reference cannot be handled here
      catch uri.already-absolute
        output fetch-fresh-page new-url
  
     else
        output #current-input
     done
    
Other Library Functions
  | 
Copyright © Stilo International plc, 1988-2010.