[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: HTML/XHTML/HTML5 Serialization Options

Subject: Re: HTML/XHTML/HTML5 Serialization Options
From: "Eliot Kimber ekimber@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 27 Apr 2015 21:20:27 -0000
Re:  HTML/XHTML/HTML5 Serialization Options
I did a little more testing and here's what I found for the input "<br/>"
using Saxon 9.6, just to confirm Mike's assertion about what Saxon does
(and should be expected to do based on the spec):

Input doc: HTML tags with no namespace:

format="html": <br>
format="xhtml": <br></br>

Input doc: HTML tags in XHTML namespace:

format="html": <br></br>
format="xhtml": <br />

Since I want "<br />" in the result clearly I need to have my input HTML
in the XHTML namespace and a format value of "xhtml".

Cheers,


E.

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




On 4/10/15, 4:23 PM, "Michael Kay mike@xxxxxxxxxxxx"
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

>As it happens I've been working on this the last couple of days: I found
>that there were no tests in the W3C QT3 test suite for XHTML
>serialization, and I committed about 50 this morning.
>
>In XSLT 2.0, the XHTML serialization method treats elements like <br/>
>specially only if they are in the XHTML namespace.
>
>In 3.0, it depends on whether the property html-version="5" is set. If
>not, it behaves as before: only elements in the XHTML namespace are
>recognized. But with html-version="5", elements in no namespace are also
>recognized.
>
>Inevitably, given the shortage of test material, I found that Saxon 9.6
>doesn't get all the details right, but on this particular point, I think
>it's largely conformant.
>
>Michael Kay
>Saxonica
>mike@xxxxxxxxxxxx
>+44 (0) 118 946 5893
>
>
>
>
>On 10 Apr 2015, at 22:08, Eliot Kimber ekimber@xxxxxxxxxxxx
><xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
>> 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
>>
>> bbbbb
>> Eliot Kimber, Owner
>> Contrext, LLC
>> http://contrext.com

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.