Project

Profile

Help

Revision cce9e8c8

Added by Michael Kay over 11 years ago

Fix bug 3065410 DOMResult: top level text nodes

View differences:

latest9.2/hej/net/sf/saxon/dom/DOMWriter.java
6 6
import net.sf.saxon.om.NamespaceConstant;
7 7
import net.sf.saxon.om.StandardNames;
8 8
import net.sf.saxon.trans.XPathException;
9
import net.sf.saxon.value.Whitespace;
9 10
import org.w3c.dom.*;
10 11

  
11 12

  
......
182 183
            if (nextSibling != null && level == 0) {
183 184
                currentNode.insertBefore(text, nextSibling);
184 185
            } else {
185
                currentNode.appendChild(text);
186
                if (currentNode.getNodeType() == Node.DOCUMENT_NODE) {
187
                    if (Whitespace.isWhite(chars)) {
188
                        // do nothing with top-level whitespace
189
                    } else {
190
                        throw new XPathException("The DOM model does not allow text as a direct child of a document node");
191
                    }
192
                } else {
193
                    currentNode.appendChild(text);
194
                }
186 195
            }
187 196
        } catch (DOMException err) {
188 197
            throw new XPathException(err);

Also available in: Unified diff