home contribute faq download

FunctX XQuery Functions

functx:scheme-from-uri

Returns the scheme from a URI

Google
Webxqueryfunctions.com

Description

The functx:scheme-from-uri function returns the scheme part of a URI, for example http or ftp, which appears before the colon. If there is no scheme (because it is a relative URI), a zero-length string is returned.

Arguments and Return Type

NameTypeDescription
$uri xs:string? the URI
return value xs:string

XQuery Function Declaration

See XSLT definition.
declare namespace functx = "http://www.functx.com";
declare function functx:scheme-from-uri
  ( $uri as xs:string? )  as xs:string? {

   substring-before($uri,':')
 } ;

Examples

XQuery ExampleResults
functx:scheme-from-uri(
   'http://www.datypic.com')
http
functx:scheme-from-uri(
   'ftp://ftp.datypic.com')
ftp
functx:scheme-from-uri('ftp.datypic.com')
zero-length string
functx:scheme-from-uri('www.datypic.com')
zero-length string
functx:scheme-from-uri('prod.html')
zero-length string

See Also

functx:is-absolute-uriWhether a URI is absolute
functx:fragment-from-uriReturns the fragment from a URI

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Datypic XQuery Services

Recommended Reading:

XQuery