Text replacement - "<syntaxhighlight lang="xquery">" to "<pre lang='xquery'>"
{| width='100%'
|-valign="top"| width='120' | '''SignaturesSignature'''|{{Func|<pre>fetch:binary|( $uri href as xs:string|) as xs:base64Binary}}<br/pre>|-valign="top"
| '''Summary'''
|Fetches the resource referred to by the given URI {{Code|href}} string 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' | '''SignaturesSignature'''|{{Func|fetch:text|$uri as xs:string|xs:string}}<br/pre>{{Func|fetch:text|( $uri href 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|? := false()) as xs:string}}<br/pre>|-valign="top"
| '''Summary'''
|Fetches the resource referred to by the given {{Code|$urihref}} string 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> (�).
|-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' | '''SignaturesSignature'''|{{Func|fetch:doc|$uri as xs:string|document-node()}}<br/pre>{{Func|fetch:doc|( $uri href as xs:string, $options as map(*)?| := map { }) as document-node()}}</pre>|-valign="top"
| '''Summary'''
|Fetches the resource referred to by the given {{Code|$urihref}} string 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:* It is ''non-deterministicnondeterministic'', i.e., a new document node will be created by each call of this function.
* 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'''
|
* Retrieve an XML representation of the English Wikipedia main HTML page with whitespace stripped:
|-valign="top"| width='120' | '''SignaturesSignature'''|{{Func|fetch:binary-doc|$input as xs:anyAtomicType|document-node()}}<br/pre>{{Func|fetch:binary-doc|( $data input as xs:anyAtomicType, $options as map(*)?| := map { }) as document-node()}}</pre>|-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'''
|
* Retrieves file input as binary data and parses it as XML:
<syntaxhighlight pre lang="'xquery"'>
fetch:binary-doc(file:read-binary('doc.xml'))
</syntaxhighlightpre>
* Encodes a string as CP1252 and parses it as XML. The input and the string {{Code|touché}} will be correctly decoded because of the XML declaration:
* Encodes a string as UTF-16 and parses it as XML. The document will be correctly decoded, as the first bytes of the data indicate that the input must be UTF-16: