292 |
if (newChild.getNodeType() == ELEMENT_NODE |
if (newChild.getNodeType() == ELEMENT_NODE |
293 |
&& getDocumentElement() != null) |
&& getDocumentElement() != null) |
294 |
{ |
{ |
295 |
throw new DomEx (DomEx.HIERARCHY_REQUEST_ERR, |
throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR, |
296 |
"document element already present: " + |
"document element already present: " + |
297 |
getDocumentElement(), newChild, 0); |
getDocumentElement(), newChild, 0); |
298 |
} |
} |
299 |
if (newChild.getNodeType() == DOCUMENT_TYPE_NODE |
if (newChild.getNodeType() == DOCUMENT_TYPE_NODE |
300 |
&& getDoctype() != null) |
&& getDoctype() != null) |
301 |
{ |
{ |
302 |
throw new DomEx (DomEx.HIERARCHY_REQUEST_ERR, |
throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR, |
303 |
"document type already present: " + |
"document type already present: " + |
304 |
getDoctype(), newChild, 0); |
getDoctype(), newChild, 0); |
305 |
} |
} |
306 |
} |
} |
307 |
|
|
376 |
{ |
{ |
377 |
if (name == null) |
if (name == null) |
378 |
{ |
{ |
379 |
throw new DomEx (DomEx.NAMESPACE_ERR, name, null, 0); |
throw new DomDOMException(DOMException.NAMESPACE_ERR, name, null, 0); |
380 |
} |
} |
381 |
int len = name.length(); |
int len = name.length(); |
382 |
if (len == 0) |
if (len == 0) |
383 |
{ |
{ |
384 |
throw new DomEx (DomEx.NAMESPACE_ERR, name, null, 0); |
throw new DomDOMException(DOMException.NAMESPACE_ERR, name, null, 0); |
385 |
} |
} |
386 |
|
|
387 |
// dog: rewritten to use the rules for XML 1.0 and 1.1 |
// dog: rewritten to use the rules for XML 1.0 and 1.1 |
407 |
(c < 0xfdf0 || c > 0xfffd) && |
(c < 0xfdf0 || c > 0xfffd) && |
408 |
(c < 0x10000 || c > 0xeffff)) |
(c < 0x10000 || c > 0xeffff)) |
409 |
{ |
{ |
410 |
throw new DomEx(DomEx.INVALID_CHARACTER_ERR, name, null, c); |
throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR, |
411 |
|
name, null, c); |
412 |
} |
} |
413 |
} |
} |
414 |
else |
else |
426 |
(c >= 0x20dd && c <= 0x20e0)) |
(c >= 0x20dd && c <= 0x20e0)) |
427 |
{ |
{ |
428 |
// Compatibility area and Unicode 2.0 exclusions |
// Compatibility area and Unicode 2.0 exclusions |
429 |
throw new DomEx(DomEx.INVALID_CHARACTER_ERR, name, null, c); |
throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR, |
430 |
|
name, null, c); |
431 |
} |
} |
432 |
break; |
break; |
433 |
default: |
default: |
434 |
if (c != ':' && c != '_' && (c < 0x02bb || c > 0x02c1) && |
if (c != ':' && c != '_' && (c < 0x02bb || c > 0x02c1) && |
435 |
c != 0x0559 && c != 0x06e5 && c != 0x06e6) |
c != 0x0559 && c != 0x06e5 && c != 0x06e6) |
436 |
{ |
{ |
437 |
throw new DomEx(DomEx.INVALID_CHARACTER_ERR, name, null, c); |
throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR, |
438 |
|
name, null, c); |
439 |
} |
} |
440 |
} |
} |
441 |
} |
} |
467 |
(c < 0x0300 || c > 0x036f) && |
(c < 0x0300 || c > 0x036f) && |
468 |
(c < 0x203f || c > 0x2040)) |
(c < 0x203f || c > 0x2040)) |
469 |
{ |
{ |
470 |
throw new DomEx(DomEx.INVALID_CHARACTER_ERR, name, null, c); |
throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR, name, |
471 |
|
null, c); |
472 |
} |
} |
473 |
} |
} |
474 |
else |
else |
491 |
(c >= 0x20dd && c <= 0x20e0)) |
(c >= 0x20dd && c <= 0x20e0)) |
492 |
{ |
{ |
493 |
// Compatibility area and Unicode 2.0 exclusions |
// Compatibility area and Unicode 2.0 exclusions |
494 |
throw new DomEx(DomEx.INVALID_CHARACTER_ERR, name, null, c); |
throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR, |
495 |
|
name, null, c); |
496 |
} |
} |
497 |
break; |
break; |
498 |
default: |
default: |
500 |
c != 0x0387 && (c < 0x02bb || c > 0x02c1) && |
c != 0x0387 && (c < 0x02bb || c > 0x02c1) && |
501 |
c != 0x0559 && c != 0x06e5 && c != 0x06e6 && c != 0x00b7) |
c != 0x0559 && c != 0x06e5 && c != 0x06e6 && c != 0x00b7) |
502 |
{ |
{ |
503 |
throw new DomEx(DomEx.INVALID_CHARACTER_ERR, name, null, c); |
throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR, |
504 |
|
name, null, c); |
505 |
} |
} |
506 |
} |
} |
507 |
} |
} |
523 |
if (index == 0 || index == (len - 1) || |
if (index == 0 || index == (len - 1) || |
524 |
name.lastIndexOf(':') != index) |
name.lastIndexOf(':') != index) |
525 |
{ |
{ |
526 |
throw new DomEx(DomEx.NAMESPACE_ERR, name, null, 0); |
throw new DomDOMException(DOMException.NAMESPACE_ERR, |
527 |
|
name, null, 0); |
528 |
} |
} |
529 |
} |
} |
530 |
} |
} |
559 |
continue; |
continue; |
560 |
} |
} |
561 |
} |
} |
562 |
throw new DomEx(DomEx.INVALID_CHARACTER_ERR, |
throw new DomDOMException(DOMException.INVALID_CHARACTER_ERR, |
563 |
new String(buf, off, len), null, c); |
new String(buf, off, len), null, c); |
564 |
} |
} |
565 |
} |
} |
566 |
|
|
609 |
if (namespaceURI != null |
if (namespaceURI != null |
610 |
&& !XMLConstants.XML_NS_URI.equals(namespaceURI)) |
&& !XMLConstants.XML_NS_URI.equals(namespaceURI)) |
611 |
{ |
{ |
612 |
throw new DomEx(DomEx.NAMESPACE_ERR, |
throw new DomDOMException(DOMException.NAMESPACE_ERR, |
613 |
"xml namespace is always " + |
"xml namespace is always " + |
614 |
XMLConstants.XML_NS_URI, this, 0); |
XMLConstants.XML_NS_URI, this, 0); |
615 |
} |
} |
616 |
namespaceURI = XMLConstants.XML_NS_URI; |
namespaceURI = XMLConstants.XML_NS_URI; |
617 |
} |
} |
618 |
else if (XMLConstants.XMLNS_ATTRIBUTE.equals(name) || |
else if (XMLConstants.XMLNS_ATTRIBUTE.equals(name) || |
619 |
name.startsWith("xmlns:")) |
name.startsWith("xmlns:")) |
620 |
{ |
{ |
621 |
throw new DomEx(DomEx.NAMESPACE_ERR, |
throw new DomDOMException(DOMException.NAMESPACE_ERR, |
622 |
"xmlns is reserved", this, 0); |
"xmlns is reserved", this, 0); |
623 |
} |
} |
624 |
else if (namespaceURI == null && name.indexOf(':') != -1) |
else if (namespaceURI == null && name.indexOf(':') != -1) |
625 |
{ |
{ |
626 |
throw new DomEx(DomEx.NAMESPACE_ERR, |
throw new DomDOMException(DOMException.NAMESPACE_ERR, |
627 |
"prefixed name '" + name + "' needs a URI", this, 0); |
"prefixed name '" + name + |
628 |
|
"' needs a URI", this, 0); |
629 |
} |
} |
630 |
|
|
631 |
Element element = new DomElement(this, namespaceURI, name); |
Element element = new DomElement(this, namespaceURI, name); |
668 |
*/ |
*/ |
669 |
public DocumentFragment createDocumentFragment() |
public DocumentFragment createDocumentFragment() |
670 |
{ |
{ |
671 |
return new DomFragment(this); |
return new DomDocumentFragment(this); |
672 |
} |
} |
673 |
|
|
674 |
/** |
/** |
719 |
{ |
{ |
720 |
checkChar(value, "1.1".equals(version)); |
checkChar(value, "1.1".equals(version)); |
721 |
} |
} |
722 |
return new DomCDATA(this, value); |
return new DomCDATASection(this, value); |
723 |
} |
} |
724 |
|
|
725 |
/** |
/** |
731 |
{ |
{ |
732 |
checkChar(buf, off, len, "1.1".equals(version)); |
checkChar(buf, off, len, "1.1".equals(version)); |
733 |
} |
} |
734 |
return new DomCDATA(this, buf, off, len); |
return new DomCDATASection(this, buf, off, len); |
735 |
} |
} |
736 |
|
|
737 |
/** |
/** |
747 |
checkName(target, xml11); |
checkName(target, xml11); |
748 |
if ("xml".equalsIgnoreCase(target)) |
if ("xml".equalsIgnoreCase(target)) |
749 |
{ |
{ |
750 |
throw new DomEx(DomEx.SYNTAX_ERR, |
throw new DomDOMException(DOMException.SYNTAX_ERR, |
751 |
"illegal PI target name", this, 0); |
"illegal PI target name", |
752 |
|
this, 0); |
753 |
} |
} |
754 |
checkChar(data, xml11); |
checkChar(data, xml11); |
755 |
} |
} |
756 |
return new DomPI(this, target, data); |
return new DomProcessingInstruction(this, target, data); |
757 |
} |
} |
758 |
|
|
759 |
/** |
/** |
805 |
} |
} |
806 |
else if (!XMLConstants.XML_NS_URI.equals(namespaceURI)) |
else if (!XMLConstants.XML_NS_URI.equals(namespaceURI)) |
807 |
{ |
{ |
808 |
throw new DomEx(DomEx.NAMESPACE_ERR, |
throw new DomDOMException(DOMException.NAMESPACE_ERR, |
809 |
"xml namespace is always " + |
"xml namespace is always " + |
810 |
XMLConstants.XML_NS_URI, this, 0); |
XMLConstants.XML_NS_URI, |
811 |
|
this, 0); |
812 |
} |
} |
813 |
} |
} |
814 |
else if (XMLConstants.XMLNS_ATTRIBUTE.equals(name) || |
else if (XMLConstants.XMLNS_ATTRIBUTE.equals(name) || |
820 |
} |
} |
821 |
else if (!XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) |
else if (!XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) |
822 |
{ |
{ |
823 |
throw new DomEx(DomEx.NAMESPACE_ERR, |
throw new DomDOMException(DOMException.NAMESPACE_ERR, |
824 |
"xmlns namespace must be " + |
"xmlns namespace must be " + |
825 |
XMLConstants.XMLNS_ATTRIBUTE_NS_URI, this, 0); |
XMLConstants.XMLNS_ATTRIBUTE_NS_URI, |
826 |
|
this, 0); |
827 |
} |
} |
828 |
} |
} |
829 |
else if (namespaceURI == null && name.indexOf(':') != -1) |
else if (namespaceURI == null && name.indexOf(':') != -1) |
830 |
{ |
{ |
831 |
throw new DomEx(DomEx.NAMESPACE_ERR, |
throw new DomDOMException(DOMException.NAMESPACE_ERR, |
832 |
"prefixed name needs a URI: " + name, this, 0); |
"prefixed name needs a URI: " + name, this, 0); |
833 |
} |
} |
834 |
return new DomAttr(this, namespaceURI, name); |
return new DomAttr(this, namespaceURI, name); |
924 |
dst = createEntityReference(src.getNodeName()); |
dst = createEntityReference(src.getNodeName()); |
925 |
break; |
break; |
926 |
case DOCUMENT_FRAGMENT_NODE: |
case DOCUMENT_FRAGMENT_NODE: |
927 |
dst = new DomFragment(this); |
dst = new DomDocumentFragment(this); |
928 |
if (deep) |
if (deep) |
929 |
{ |
{ |
930 |
for (Node ctx = src.getFirstChild(); ctx != null; |
for (Node ctx = src.getFirstChild(); ctx != null; |
999 |
// FALLTHROUGH |
// FALLTHROUGH |
1000 |
// can't import unrecognized or nonstandard nodes |
// can't import unrecognized or nonstandard nodes |
1001 |
default: |
default: |
1002 |
throw new DomEx(DomEx.NOT_SUPPORTED_ERR, null, src, 0); |
throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR, null, src, 0); |
1003 |
} |
} |
1004 |
|
|
1005 |
// FIXME cleanup a bit -- for deep copies, copy those |
// FIXME cleanup a bit -- for deep copies, copy those |
1094 |
} |
} |
1095 |
else |
else |
1096 |
{ |
{ |
1097 |
throw new DomEx(DomEx.NOT_SUPPORTED_ERR); |
throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR); |
1098 |
} |
} |
1099 |
} |
} |
1100 |
|
|
1160 |
{ |
{ |
1161 |
case DOCUMENT_NODE: |
case DOCUMENT_NODE: |
1162 |
case DOCUMENT_TYPE_NODE: |
case DOCUMENT_TYPE_NODE: |
1163 |
throw new DomEx(DomEx.NOT_SUPPORTED_ERR); |
throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR); |
1164 |
case ENTITY_NODE: |
case ENTITY_NODE: |
1165 |
case NOTATION_NODE: |
case NOTATION_NODE: |
1166 |
throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR); |
throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); |
1167 |
} |
} |
1168 |
if (source instanceof DomNode) |
if (source instanceof DomNode) |
1169 |
{ |
{ |
1295 |
DomNsNode src = (DomNsNode) n; |
DomNsNode src = (DomNsNode) n; |
1296 |
if (src == null) |
if (src == null) |
1297 |
{ |
{ |
1298 |
throw new DomEx(DomEx.NOT_FOUND_ERR); |
throw new DomDOMException(DOMException.NOT_FOUND_ERR); |
1299 |
} |
} |
1300 |
if (src.owner != this) |
if (src.owner != this) |
1301 |
{ |
{ |
1302 |
throw new DomEx(DomEx.WRONG_DOCUMENT_ERR, null, src, 0); |
throw new DomDOMException(DOMException.WRONG_DOCUMENT_ERR, |
1303 |
|
null, src, 0); |
1304 |
} |
} |
1305 |
boolean xml11 = "1.1".equals(version); |
boolean xml11 = "1.1".equals(version); |
1306 |
checkName(qualifiedName, xml11); |
checkName(qualifiedName, xml11); |
1317 |
if (XMLConstants.XML_NS_PREFIX.equals(prefix) && |
if (XMLConstants.XML_NS_PREFIX.equals(prefix) && |
1318 |
!XMLConstants.XML_NS_URI.equals(namespaceURI)) |
!XMLConstants.XML_NS_URI.equals(namespaceURI)) |
1319 |
{ |
{ |
1320 |
throw new DomEx(DomEx.NAMESPACE_ERR, |
throw new DomDOMException(DOMException.NAMESPACE_ERR, |
1321 |
"xml namespace must be " + |
"xml namespace must be " + |
1322 |
XMLConstants.XML_NS_URI, src, 0); |
XMLConstants.XML_NS_URI, src, 0); |
1323 |
} |
} |
1326 |
XMLConstants.XMLNS_ATTRIBUTE.equals(qualifiedName)) && |
XMLConstants.XMLNS_ATTRIBUTE.equals(qualifiedName)) && |
1327 |
!XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) |
!XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) |
1328 |
{ |
{ |
1329 |
throw new DomEx(DomEx.NAMESPACE_ERR, |
throw new DomDOMException(DOMException.NAMESPACE_ERR, |
1330 |
"xmlns namespace must be " + |
"xmlns namespace must be " + |
1331 |
XMLConstants.XMLNS_ATTRIBUTE_NS_URI, src, 0); |
XMLConstants.XMLNS_ATTRIBUTE_NS_URI, src, 0); |
1332 |
} |
} |
1333 |
if (XMLConstants.XML_NS_URI.equals(namespaceURI) && |
if (XMLConstants.XML_NS_URI.equals(namespaceURI) && |
1334 |
!XMLConstants.XML_NS_PREFIX.equals(prefix)) |
!XMLConstants.XML_NS_PREFIX.equals(prefix)) |
1335 |
{ |
{ |
1336 |
throw new DomEx(DomEx.NAMESPACE_ERR, |
throw new DomDOMException(DOMException.NAMESPACE_ERR, |
1337 |
"xml namespace must be " + |
"xml namespace must be " + |
1338 |
XMLConstants.XML_NS_URI, src, 0); |
XMLConstants.XML_NS_URI, src, 0); |
1339 |
} |
} |
1342 |
!(XMLConstants.XMLNS_ATTRIBUTE.equals(prefix) || |
!(XMLConstants.XMLNS_ATTRIBUTE.equals(prefix) || |
1343 |
XMLConstants.XMLNS_ATTRIBUTE.equals(qualifiedName))) |
XMLConstants.XMLNS_ATTRIBUTE.equals(qualifiedName))) |
1344 |
{ |
{ |
1345 |
throw new DomEx(DomEx.NAMESPACE_ERR, |
throw new DomDOMException(DOMException.NAMESPACE_ERR, |
1346 |
"xmlns namespace must be " + |
"xmlns namespace must be " + |
1347 |
XMLConstants.XMLNS_ATTRIBUTE_NS_URI, src, 0); |
XMLConstants.XMLNS_ATTRIBUTE_NS_URI, src, 0); |
1348 |
} |
} |
1355 |
// DOMElementNameChanged or DOMAttributeNameChanged |
// DOMElementNameChanged or DOMAttributeNameChanged |
1356 |
return src; |
return src; |
1357 |
} |
} |
1358 |
throw new DomEx(DomEx.NOT_SUPPORTED_ERR, null, n, 0); |
throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR, null, n, 0); |
1359 |
} |
} |
1360 |
|
|
1361 |
// -- XPathEvaluator -- |
// -- XPathEvaluator -- |