Project

Profile

Help

Revision 43a8cfb1

Added by Michael Kay about 12 years ago

Fix bug 2898131 DOMSource only accepts Document and Element nodes

View differences:

latest9.1/bj/net/sf/saxon/dom/DOMSender.java
89 89
        receiver.setPipelineConfiguration(pipe);
90 90

  
91 91
        receiver.open();
92
        if (root.getNodeType() == Node.ELEMENT_NODE) {
93
            sendElement((Element)root);
94
        } else {
95
            // walk the root node
96
            receiver.startDocument(0);
97
            walkNode(root);
98
            receiver.endDocument();
92
        switch (root.getNodeType()) {
93
            case Node.DOCUMENT_NODE:
94
            case Node.DOCUMENT_FRAGMENT_NODE:
95
                receiver.startDocument(0);
96
                walkNode(root);
97
                receiver.endDocument();
98
                break;
99
            case Node.ELEMENT_NODE:
100
                sendElement((Element)root);
101
                break;
102
            case Node.TEXT_NODE:
103
            case Node.CDATA_SECTION_NODE:
104
                receiver.characters(((CharacterData)root).getData(), 0, 0);
105
                break;
106
            case Node.COMMENT_NODE:
107
                receiver.comment(((Comment)root).getData(), 0, 0);
108
                break;
109
            case Node.PROCESSING_INSTRUCTION_NODE:
110
                receiver.processingInstruction(
111
                        ((ProcessingInstruction)root).getTarget(),
112
                        ((ProcessingInstruction)root).getData(), 0, 0);
113
                break;
114
            default:
115
                throw new XPathException("DOMSender: unsupported kind of start node (" + root.getNodeType() + ")");
99 116
        }
100 117
        receiver.close();
101 118
    }
latest9.2/hej/net/sf/saxon/dom/DOMSender.java
89 89
        receiver.setPipelineConfiguration(pipe);
90 90

  
91 91
        receiver.open();
92
        if (root.getNodeType() == Node.ELEMENT_NODE) {
93
            sendElement((Element)root);
94
        } else {
95
            // walk the root node
96
            receiver.startDocument(0);
97
            walkNode(root);
98
            receiver.endDocument();
92
        switch (root.getNodeType()) {
93
            case Node.DOCUMENT_NODE:
94
            case Node.DOCUMENT_FRAGMENT_NODE:
95
                receiver.startDocument(0);
96
                walkNode(root);
97
                receiver.endDocument();
98
                break;
99
            case Node.ELEMENT_NODE:
100
                sendElement((Element)root);
101
                break;
102
            case Node.TEXT_NODE:
103
            case Node.CDATA_SECTION_NODE:
104
                receiver.characters(((CharacterData)root).getData(), 0, 0);
105
                break;
106
            case Node.COMMENT_NODE:
107
                receiver.comment(((Comment)root).getData(), 0, 0);
108
                break;
109
            case Node.PROCESSING_INSTRUCTION_NODE:
110
                receiver.processingInstruction(
111
                        ((ProcessingInstruction)root).getTarget(),
112
                        ((ProcessingInstruction)root).getData(), 0, 0);
113
                break;
114
            default:
115
                throw new XPathException("DOMSender: unsupported kind of start node (" + root.getNodeType() + ")");
99 116
        }
100 117
        receiver.close();
101 118
    }

Also available in: Unified diff