From: Craig B. <cra...@ma...> - 2021-08-03 19:08:21
|
I had a similar problem. It boiled down to fn:serialize defaulting to XHTML output, where the self-closing tags are legal, but the browser was interpreting the content as HTML5 rather than XHTML. In HTML5 self-closing tags are illegal on non-void elements, and the browser handles the error by turning all following siblings into children, i.e., the self-closing tag is interpreted as an opening tag with an implicit closing tag at the end of the parent. Made quite a mess of my web page until I finally figured out what was happening. I solved the problem by forcing it to serialize as HTML5, adding something like the following as the options parameter to fn:serialize: <output:serialization-parameters xmlns:output="http://www.w3.org/2010/xslt-xquery-serialization"> <output:method>html</output:method> <output:version>5.0</output:version> </output:serialization-parameters> In your case you might be able to do the equivalent in the serialization option at the top of your script. You might also be able to convince the browser that what it's getting is XHTML. It would need to see a header something like this: Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 However, it seems that the media-type part of your serialization option should already be doing that, so I'm not sure why your browser isn't handling the XHTML. You could fire up the debugging tools in your browser and see what content type you're really getting in the page headers. I was not able to get the browser to recognize the XHTML content type in my case because it was a portion of the page getting rewritten via AJAX and the content type was application/json. Serializing to HTML5 before embedding the AJAX results in JSON solved the problem for me. > On Aug 3, 2021, at 12:24 PM, Christian Achter <chr...@ge...> wrote: > > Dear community, > > I have a problem with an XQuery script that calls an XSLT script to convert some XML from the eXist database to HTML. > > E.g. this XML > > <lb/> > > gets converted to this HTML > > <span class="br" data-lineNum="6"/> > > which is a self-closing <span /> tag. But <span> is not allowed to be a self-closing tag <span ... /> in HTML. Instead it should be <span ...></span> with no content, but the attributes as above. > > I tried several things. The XSLT is called from within an XQuery script, so I declared in this XQuery file: > > declare option exist:serialize "method=xhtml media-type=application/xhtml+html"; > > But still I get self-closing <span />-tags. > > How can I force the HTML part to be like this: > > <span class="br" data-lineNum="6"></span> > > ?? > > Thanks in advance and let me know if more information is needed. > > Kind regards > Christian > > > > > _______________________________________________ > Exist-open mailing list > Exi...@li... > https://lists.sourceforge.net/lists/listinfo/exist-open ________________________________________ Craig A. Berry "... getting out of a sonnet is much more difficult than getting in." Brad Leithauser |