xsl-list
[Top] [All Lists]

[xsl] HTML/XHTML/HTML5 Serialization Options

2015-04-10 16:08:23
This may be a Saxon-specific question, but I'll start here as there may be
a general answer.

I am generating HTML, either as XHTML or HTML or HTML5 and I'm running
into issues with the handling of empty elements (meaning elements that
were or can be tagged as self-closed elements, e.g., <br>).

Doing a quick test with Saxon 9.6 and XSLT 2, given this input:

<p>A br element: before<br/>after</p>


And serializing it using method "html" the result is the expected:

<p>A br element: before<br>after
      </p>


But for XHTML it's:

<p>A br element: before
         <br></br>after
      </p>


What I would like to is a self-closed BR element: <br/>.

Looking at the Saxon documentation I didn't see any Saxon-specific
serialization parameters that would control this behavior.

I realize I could implement my own serializer but I'm not keen to go to
that length if at all possible.

Is there a general solution that allows me to have XHTML or HTML5 output
with self-closing elements?

This comes up for me in several contexts:

- Generating XHTML as required for EPUB2 and Kindle documents
- Generating HTML as required for Web sites
- Generating HTML5 as required for EPUB3 and for use in HTML5-based Web
sites

I suspect that the real problem is generating XHTML when I should be
generating HTML. I need to explore that more, but I wanted to understand
my readily-available serialization options first.

Thanks,

Eliot

—————
Eliot Kimber, Owner
Contrext, LLC
http://contrext.com

--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>