Changes

Jump to navigation Jump to search
80 bytes removed ,  18:39, 1 December 2023
m
Text replacement - "syntaxhighlight" to "pre"
=Functions=
==html:parserdoc==
{| width='100%'
|-valign="top"| width='120' | '''SignaturesSignature'''|{{Code|'''<pre>html:parser'''doc() $href as xs:string?, $options as map(*)? := map { }}) as document-node()?<br /pre>|-valign="top"
| '''Summary'''
|Returns Fetches the name of HTML document referred to by the applied HTML parser (currently: given {{Code|$href}}, converts it to XML and returns a document node. The {{Code|TagSoup$options}})argument can be used to set [[Parsers#Options|TagSoup Options]]. If an |- valign="top"| ''empty string'Errors' is returned, TagSoup was not found in the classpath, and ''|{{Error|parse|#Errors}} the input will cannot be treated as well-formed converted to XML.<br />
|}
{| width='100%'
|-valign="top"| width='120' | '''SignaturesSignature'''|{{Func|html:parse|$input as xs:anyAtomicType|document-node()}}<br /pre>{{Func|html:parse|( $input value as xs:anyAtomicType, $options as map(*)?| := map { }) as document-node()}}<br /pre>|-valign="top"
| '''Summary'''
|Converts the HTML document specified by {{Code|$inputvalue}} to XML and returns a document node:<br/>* The input may either be a of type {{Code|xs:string or a binary item (}}, {{Code|xs:hexBinarybase64Binary}}, or {{Code|xs:base64Binary)hexBinary}}.* If the input is passed on in its binary representation, and if no encoding option is supplied, the HTML parser will try to automatically choose the correct encodingautomatically.
The {{Code|$options}} argument can be used to set [[Parsers#Options|TagSoup Options]].
|-valign="top"
| '''Errors'''
|{{Error|parse|#Errors}} the input cannot be converted to XML.
|}
==html:docparser== {{Mark|Introduced with BaseX 9.4:}}
{| width='100%'
|-valign="top"| width='120' | '''SignaturesSignature'''|{{FuncCode|'''html:doc|$uri as xs:string|document-nodeparser'''()}}<br />{{Func|html:doc|$uri as xs:string, $options as map(*)?|document-node()}}<br />|-valign="top"
| '''Summary'''
|Fetches Returns the name of the applied HTML document referred to by the given parser (currently: {{Code|$uriTagSoup}}, converts it to XML and returns a document node). The {{Code|$options}} argument can be used to set [[Parsers#Options|TagSoup Options]].|-| If an ''empty string'Errors'''|{{Error|parse|#Errors}} is returned, TagSoup was not found in the classpath, and the input cannot will be converted to treated as well-formed XML.<br/>
|}
;Query:
<syntaxhighlight pre lang="'xquery"'>
html:parse("<html>")
</syntaxhighlightpre>
;Result:
<syntaxhighlight pre lang="xml">
<html xmlns="http://www.w3.org/1999/xhtml"/>
</syntaxhighlightpre>
===Specifying Options===
;Query:
<syntaxhighlight pre lang="'xquery"'>
html:parse("<a href='ok.html'/>", map { 'nons': false() })
</syntaxhighlightpre>
;Result:
<syntaxhighlight pre lang="xml">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
</body>
</html>
</syntaxhighlightpre>
===Parsing Binary Input===
;Query:
<syntaxhighlight pre lang="'xquery"'>
html:parse(fetch:binary("https://en.wikipedia.org"))
</syntaxhighlightpre>
;Result:
<syntaxhighlight pre lang="xml">
<html xmlns="http://www.w3.org/1999/xhtml" class="client-nojs" dir="ltr" lang="en">
<head>
<meta charset="UTF-8"/>
...
</syntaxhighlightpre>
=Errors=
! width="110"|Code
|Description
|-valign="top"
|{{Code|parse}}
|The input cannot be converted to XML.
;Version 9.4
* Added: [[#html:doc{{Function||html:doc]]}}
;Version 9.0
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu