Project

Profile

Help

Revision 61821eee

Added by Michael Kay about 1 year ago

Fix bug #4841 - HTML5 serialization

View differences:

latest10/hej/net/sf/saxon/serialize/HTMLEmitter.java
249 249
        uri = elemName.getURI();
250 250
        super.startElement(elemName, type, attributes, namespaces, location, properties);
251 251
        parentElement = elementStack.peek();
252
        if (elemName.hasURI("") &&
252
        if (isHTMLElement(elemName) &&
253 253
                (parentElement.equalsIgnoreCase("script") ||
254 254
                        parentElement.equalsIgnoreCase("style"))) {
255 255
            inScript = 0;
......
271 271
    @Override
272 272
    protected void writeAttribute(NodeName elCode, String attname, CharSequence value, int properties) throws XPathException {
273 273
        try {
274
            if (uri.isEmpty()) {
274
            if (isHTMLElement(elCode)) {
275 275
                if (isBooleanAttribute(elCode.getLocalPart(), attname, value.toString())) {
276 276
                    writer.write(attname);
277 277
                    return;
278 278
                }
279 279
            }
280
            if (inScript > 0) {
281
                properties |= ReceiverOption.DISABLE_ESCAPING;
282
            }
280 283
            super.writeAttribute(elCode, attname, value, properties);
281 284
        } catch (java.io.IOException err) {
282 285
            throw new XPathException(err);
......
433 436

  
434 437
    @Override
435 438
    protected String emptyElementTagCloser(String displayName, NodeName nameCode) {
436
        return "></" + displayName + ">";
439
        if (isHTMLElement(nameCode)) {
440
            return "></" + displayName + ">";
441
        } else {
442
            return "/>";
443
        }
437 444
    }
438 445

  
439 446
    /**
latest10/hej/net/sf/saxon/serialize/XMLEmitter.java
583 583
            } else {
584 584
                writer.write("=");
585 585
                writer.write(delimiter);
586
                writeEscape(value, true);
586
                if (ReceiverOption.contains(properties, ReceiverOption.DISABLE_ESCAPING)) {
587
                    writer.write(value.toString());
588
                } else {
589
                    writeEscape(value, true);
590
                }
587 591
                writer.write(delimiter);
588 592
            }
589 593
        } catch (java.io.IOException err) {

Also available in: Unified diff