Using jsoup as an alternative to the TagSoup
Hi team,
TagSoup is an old library that doesn't support the modern HTML5 features. It would be good to configure which library BaseX should be used to parse and serialize HTML.
What do you think?
Best regards, Oleksandr.
Hi Oleksandr,
starting with BaseX 12, validator.nu is available. Maybe Tagsoup will be preferred though if both are on the classpath. You can request explicitly that validator.nu’s parser be used like so:
html:parse('<html/>', {'method':'nu'}) → <html xmlns="http://www.w3.org/1999/xhtml"><head/><body/></html>Without setting the method to 'nu', the output is <html/>, the same as with {'method':'tagsoup'}.
According to [1], for fn:parse-html() validator.nu will be used by default:
parse-html('<html/>') → <html xmlns="http://www.w3.org/1999/xhtml"><head/><body/></html>
Gerrit
[1] https://docs.basex.org/main/Standard_Functions#fn:parse-html
Quoted text · Oleksandr Shpak · 9 lines
On 05.09.2026 10:26, Oleksandr Shpak via BaseX-Talk wrote: > Hi team, > > TagSoup is an old library that doesn't support the modern HTML5 features. It would be good to configure which library BaseX should be used to parse and serialize HTML. > > What do you think? > > Best regards, > Oleksandr.
Wow, I've missed it. Perfect news, thanks!
Quoted text · le-tex · 37 lines
On Sat, Sep 5, 2026 at 12:04 PM Imsieke, Gerrit, le-tex via BaseX-Talk < basex-talk at mailman.uni-konstanz.de> wrote: > Hi Oleksandr, > > starting with BaseX 12, validator.nu is available. Maybe Tagsoup will be > preferred though if both are on the classpath. You can request explicitly > that validator.nu’s parser be used like so: > > html:parse('<html/>', {'method':'nu'}) → <html xmlns=" > http://www.w3.org/1999/xhtml"><head/><body/></html> > > Without setting the method to 'nu', the output is <html/>, the same as > with {'method':'tagsoup'}. > > According to [1], for fn:parse-html() validator.nu will be used by > default: > > parse-html('<html/>') → <html xmlns="http://www.w3.org/1999/xhtml > "><head/><body/></html> > > Gerrit > > [1] https://docs.basex.org/main/Standard_Functions#fn:parse-html > > On 05.09.2026 10:26, Oleksandr Shpak via BaseX-Talk wrote: > > Hi team, > > > > TagSoup is an old library that doesn't support the modern HTML5 > features. It would be good to configure which library BaseX should be used > to parse and serialize HTML. > > > > What do you think? > > > > Best regards, > > Oleksandr. > >
For anyone like me who is easily confused, when it ships with BaseX 12 "validator.nu" is called "htmlparser-*.*.*.jar".
So in BaseX 12.4 it's htmlparser-1.4.16.jar if you're checking the contents of lib/ to reassure yourself it's really in there.
-- Graydon
Quoted text · Oleksandr Shpak · 33 lines
On Sun, Sep 6, 2026, at 17:24, Oleksandr Shpak via BaseX-Talk wrote: > Wow, I've missed it. Perfect news, thanks! > > On Sat, Sep 5, 2026 at 12:04 PM Imsieke, Gerrit, le-tex via BaseX-Talk <basex-talk at mailman.uni-konstanz.de> wrote: >> Hi Oleksandr, >> >> starting with BaseX 12, validator.nu is available. Maybe Tagsoup will be preferred though if both are on the classpath. You can request explicitly that validator.nu’s parser be used like so: >> >> html:parse('<html/>', {'method':'nu'}) → <html xmlns="http://www.w3.org/1999/xhtml"><head/><body/></html> >> >> Without setting the method to 'nu', the output is <html/>, the same as with {'method':'tagsoup'}. >> >> According to [1], for fn:parse-html() validator.nu will be used by default: >> >> parse-html('<html/>') → <html xmlns="http://www.w3.org/1999/xhtml"><head/><body/></html> >> >> Gerrit >> >> [1] https://docs.basex.org/main/Standard_Functions#fn:parse-html >> >> On 05.09.2026 10:26, Oleksandr Shpak via BaseX-Talk wrote: >> > Hi team, >> > >> > TagSoup is an old library that doesn't support the modern HTML5 features. It would be good to configure which library BaseX should be used to parse and serialize HTML. >> > >> > What do you think? >> > >> > Best regards, >> > Oleksandr. > > > -- > s0rr0w
Written for BaseX 12.4. BaseX may have changed since: please check the current documentation.