Changes

Jump to navigation Jump to search
286 bytes added ,  14:17, 20 July 2022
no edit summary
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|fetch:binary|$uri as xs:string|xs:base64Binary}}<br/>
|-valign="top"
| '''Summary'''
|Fetches the resource referred to by the given URI and returns it as [[Lazy Module|lazy]] {{Code|xs:base64Binary}} item.
|-valign="top"
| '''Errors'''
|{{Error|open|#Errors}} the URI could not be resolved, or the resource could not be retrieved.
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|fetch:text|$uri as xs:string|xs:string}}<br/>{{Func|fetch:text|$uri as xs:string, $encoding as xs:string|xs:string}}<br/>{{Func|fetch:text|$uri as xs:string, $encoding as xs:string, $fallback as xs:boolean|xs:string}}<br/>
|-valign="top"
| '''Summary'''
|Fetches the resource referred to by the given {{Code|$uri}} and returns it as [[Lazy Module|lazy]] {{Code|xs:string}} item:
* The UTF-8 default encoding can be overwritten with the optional {{Code|$encoding}} argument.
* By default, invalid characters will be rejected. If {{Code|$fallback}} is set to true, these characters will be replaced with the Unicode replacement character <code>FFFD</code> (&#xFFFD;).
|-valign="top"
| '''Errors'''
|{{Error|open|#Errors}} the URI could not be resolved, or the resource could not be retrieved.<br/>{{Error|encoding|#Errors}} the specified encoding is not supported, or unknown.
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|fetch:doc|$uri as xs:string|document-node()}}<br/>{{Func|fetch:doc|$uri as xs:string, $options as map(*)?|document-node()}}
|-valign="top"
| '''Summary'''
|Fetches the resource referred to by the given {{Code|$uri}} and returns it as a document node.<br/>The {{Code|$options}} argument can be used to change the parsing behavior. Allowed options are all [[Options#Parsing|parsing]] and [[Options#XML Parsing|XML parsing]] options in lower case.<br/>The function differs from {{Code|fn:doc}} in various aspects:
* A document created by this function will be garbage-collected as soon as it is not referenced anymore.
* URIs will not be resolved against existing databases. As a result, it will not trigger any locks (see [[Transaction Management#Limitations|limitations of database locking]] for more details).
|-valign="top"
| '''Errors'''
|{{Error|open|#Errors}} the URI could not be resolved, or the resource could not be retrieved.
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|fetch:binary-doc|$input as xs:anyAtomicType|document-node()}}<br/>{{Func|fetch:binary-doc|$data as xs:anyAtomicType, $options as map(*)?|document-node()}}
|-valign="top"
| '''Summary'''
|Converts the specified {{Code|$input}} ({{Code|xs:base64Binary}}, {{Code|xs:hexBinary}}) to XML and returns it as a document node.<br/>In contrast to {{Code|fn:parse-xml}}, which expects a string, the input can be arbitrarily encoded. The encoding will be derived from the XML declaration or (in case of UTF-16 or UTF-32) from the first bytes of the input.<br/>The {{Code|$options}} argument can be used to change the parsing behavior. Allowed options are all [[Options#Parsing|parsing]] and [[Options#XML Parsing|XML parsing]] options in lower case.
|-valign="top"
| '''Examples'''
|
fetch:binary-doc(convert:string-to-base64("<xml/>", "UTF16"))
</syntaxhighlight>
|-valign="top"
| '''Errors'''
|{{Error|open|#Errors}} the input could not be parsed.
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|fetch:content-type|$uri as xs:string|xs:string}}<br/>
|-valign="top"
| '''Summary'''
|Returns the content-type (also called mime-type) of the resource specified by {{Code|$uri}}:
* If a remote resource is addressed, the request header will be evaluated.
* If the addressed resource is locally stored, the content-type will be guessed based on the file extension.
|-valign="top"
| '''Errors'''
|{{Error|open|#Errors}} the URI could not be resolved, or the resource could not be retrieved.
|-valign="top"
| '''Examples'''
|
! width="110"|Code
|Description
|-valign="top"
|{{Code|encoding}}
|The specified encoding is not supported, or unknown.
|-valign="top"
|{{Code|open}}
|The URI could not be resolved, or the resource could not be retrieved.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu