Project

Profile

Help

Revision 46b6fb2e

Added by Michael Kay almost 13 years ago

Fix bug 2461757 - DOM text nodes whose value is null

View differences:

latest9.1/bj/net/sf/saxon/dom/NodeWrapper.java
357 357
                return sb1;
358 358

  
359 359
            case Type.ATTRIBUTE:
360
                return ((Attr)node).getValue();
360
                return emptyIfNull(((Attr)node).getValue());
361 361

  
362 362
            case Type.TEXT:
363 363
                if (span == 1) {
364
                    return node.getNodeValue();
364
                    return emptyIfNull(node.getNodeValue());
365 365
                } else {
366 366
                    FastStringBuffer fsb = new FastStringBuffer(100);
367 367
                    Node textNode = node;
368 368
                    for (int i=0; i<span; i++) {
369
                        fsb.append(textNode.getNodeValue());
369
                        fsb.append(emptyIfNull(textNode.getNodeValue()));
370 370
                        textNode = textNode.getNextSibling();
371 371
                    }
372 372
                    return fsb.condense();
......
374 374

  
375 375
            case Type.COMMENT:
376 376
            case Type.PROCESSING_INSTRUCTION:
377
                return node.getNodeValue();
377
                return emptyIfNull(node.getNodeValue());
378 378

  
379 379
            default:
380 380
                return "";
381 381
        }
382 382
    }
383 383

  
384
    private static String emptyIfNull(String s) {
385
        return (s==null ? "" : s);
386
    }    
387

  
384 388
    private static void expandStringValue(NodeList list, StringBuffer sb) {
385 389
        final int len = list.getLength();
386 390
        for (int i = 0; i < len; i++) {
latest9.1/bj/net/sf/saxon/om/Navigator.java
584 584
                }
585 585
            case Type.TEXT:
586 586
                {
587
                    out.characters(node.getStringValueCS(), 0, 0);
587
                    CharSequence val = node.getStringValueCS();
588
                    if (val.length() != 0) {
589
                        out.characters(val, 0, 0);
590
                    }
588 591
                    return;
589 592
                }
590 593
            case Type.COMMENT:

Also available in: Unified diff