本文整理匯總了Java中org.w3c.dom.DOMException.WRONG_DOCUMENT_ERR屬性的典型用法代碼示例。如果您正苦於以下問題:Java DOMException.WRONG_DOCUMENT_ERR屬性的具體用法?Java DOMException.WRONG_DOCUMENT_ERR怎麽用?Java DOMException.WRONG_DOCUMENT_ERR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.w3c.dom.DOMException
的用法示例。
在下文中一共展示了DOMException.WRONG_DOCUMENT_ERR屬性的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkNode
/**
* Check that the node is either <code>null</code> or an
* <code>IIOMetadataNode</code>.
*/
private void checkNode(Node node) throws DOMException {
if (node == null) {
return;
}
if (!(node instanceof IIOMetadataNode)) {
throw new IIODOMException(DOMException.WRONG_DOCUMENT_ERR,
"Node not an IIOMetadataNode!");
}
}
示例2: selectNodeContents
public void selectNodeContents(Node refNode)
throws RangeException
{
if (fDocument.errorChecking) {
if( fDetach) {
throw new DOMException(
DOMException.INVALID_STATE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null));
}
if ( !isLegalContainer(refNode)) {
throw new RangeExceptionImpl(
RangeException.INVALID_NODE_TYPE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_NODE_TYPE_ERR", null));
}
if ( fDocument != refNode.getOwnerDocument() && fDocument != refNode) {
throw new DOMException(
DOMException.WRONG_DOCUMENT_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null));
}
}
fStartContainer = refNode;
fEndContainer = refNode;
Node first = refNode.getFirstChild();
fStartOffset = 0;
if (first == null) {
fEndOffset = 0;
} else {
int i = 0;
for (Node n = first; n!=null; n = n.getNextSibling()) {
i++;
}
fEndOffset = i;
}
}
示例3: setEndAfter
public void setEndAfter(Node refNode)
throws RangeException
{
if (fDocument.errorChecking) {
if( fDetach) {
throw new DOMException(
DOMException.INVALID_STATE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null));
}
if ( !hasLegalRootContainer(refNode) ||
!isLegalContainedNode(refNode)) {
throw new RangeExceptionImpl(
RangeException.INVALID_NODE_TYPE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_NODE_TYPE_ERR", null));
}
if ( fDocument != refNode.getOwnerDocument() && fDocument != refNode) {
throw new DOMException(
DOMException.WRONG_DOCUMENT_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null));
}
}
fEndContainer = refNode.getParentNode();
int i = 0;
for (Node n = refNode; n!=null; n = n.getPreviousSibling()) {
i++;
}
fEndOffset = i;
// If one boundary-point of a Range is set to have a root container
// other
// than the current one for the Range, the Range should be collapsed to
// the new position.
// The start position of a Range should never be after the end position.
if (getCommonAncestorContainer() == null
|| (fStartContainer == fEndContainer && fEndOffset < fStartOffset)) {
collapse(false);
}
}
示例4: setEnd
public void setEnd(Node refNode, int offset)
throws RangeException, DOMException
{
if (fDocument.errorChecking) {
if (fDetach) {
throw new DOMException(
DOMException.INVALID_STATE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null));
}
if ( !isLegalContainer(refNode)) {
throw new RangeExceptionImpl(
RangeException.INVALID_NODE_TYPE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_NODE_TYPE_ERR", null));
}
if ( fDocument != refNode.getOwnerDocument() && fDocument != refNode) {
throw new DOMException(
DOMException.WRONG_DOCUMENT_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null));
}
}
checkIndex(refNode, offset);
fEndContainer = refNode;
fEndOffset = offset;
// If one boundary-point of a Range is set to have a root container
// other
// than the current one for the Range, the Range should be collapsed to
// the new position.
// The start position of a Range should never be after the end position.
if (getCommonAncestorContainer() == null
|| (fStartContainer == fEndContainer && fEndOffset < fStartOffset)) {
collapse(false);
}
}
示例5: setStart
public void setStart(Node refNode, int offset)
throws RangeException, DOMException
{
if (fDocument.errorChecking) {
if ( fDetach) {
throw new DOMException(
DOMException.INVALID_STATE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null));
}
if ( !isLegalContainer(refNode)) {
throw new RangeExceptionImpl(
RangeException.INVALID_NODE_TYPE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_NODE_TYPE_ERR", null));
}
if ( fDocument != refNode.getOwnerDocument() && fDocument != refNode) {
throw new DOMException(
DOMException.WRONG_DOCUMENT_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null));
}
}
checkIndex(refNode, offset);
fStartContainer = refNode;
fStartOffset = offset;
// If one boundary-point of a Range is set to have a root container
// other
// than the current one for the Range, the Range should be collapsed to
// the new position.
// The start position of a Range should never be after the end position.
if (getCommonAncestorContainer() == null
|| (fStartContainer == fEndContainer && fEndOffset < fStartOffset)) {
collapse(true);
}
}
示例6: setStartAfter
public void setStartAfter(Node refNode)
throws RangeException
{
if (fDocument.errorChecking) {
if (fDetach) {
throw new DOMException(
DOMException.INVALID_STATE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null));
}
if ( !hasLegalRootContainer(refNode) ||
!isLegalContainedNode(refNode)) {
throw new RangeExceptionImpl(
RangeException.INVALID_NODE_TYPE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_NODE_TYPE_ERR", null));
}
if ( fDocument != refNode.getOwnerDocument() && fDocument != refNode) {
throw new DOMException(
DOMException.WRONG_DOCUMENT_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null));
}
}
fStartContainer = refNode.getParentNode();
int i = 0;
for (Node n = refNode; n!=null; n = n.getPreviousSibling()) {
i++;
}
fStartOffset = i;
// If one boundary-point of a Range is set to have a root container
// other
// than the current one for the Range, the Range should be collapsed to
// the new position.
// The start position of a Range should never be after the end position.
if (getCommonAncestorContainer() == null
|| (fStartContainer == fEndContainer && fEndOffset < fStartOffset)) {
collapse(true);
}
}
示例7: selectNode
public void selectNode(Node refNode)
throws RangeException
{
if (fDocument.errorChecking) {
if (fDetach) {
throw new DOMException(
DOMException.INVALID_STATE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null));
}
if ( !isLegalContainer( refNode.getParentNode() ) ||
!isLegalContainedNode( refNode ) ) {
throw new RangeExceptionImpl(
RangeException.INVALID_NODE_TYPE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_NODE_TYPE_ERR", null));
}
if ( fDocument != refNode.getOwnerDocument() && fDocument != refNode) {
throw new DOMException(
DOMException.WRONG_DOCUMENT_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null));
}
}
Node parent = refNode.getParentNode();
if (parent != null ) // REVIST: what to do if it IS null?
{
fStartContainer = parent;
fEndContainer = parent;
int i = 0;
for (Node n = refNode; n!=null; n = n.getPreviousSibling()) {
i++;
}
fStartOffset = i-1;
fEndOffset = fStartOffset+1;
}
}
示例8: checkNode
/**
* Check that the node is either {@code null} or an
* {@code IIOMetadataNode}.
*
* @throws DOMException if {@code node} is not {@code null} and not an
* instance of {@code IIOMetadataNode}
*/
private void checkNode(Node node) throws DOMException {
if (node == null) {
return;
}
if (!(node instanceof IIOMetadataNode)) {
throw new IIODOMException(DOMException.WRONG_DOCUMENT_ERR,
"Node not an IIOMetadataNode!");
}
}
示例9: CoreDocumentImpl
/** For DOM2 support. */
public CoreDocumentImpl(DocumentType doctype, boolean grammarAccess) {
this(grammarAccess);
if (doctype != null) {
DocumentTypeImpl doctypeImpl;
try {
doctypeImpl = (DocumentTypeImpl) doctype;
} catch (ClassCastException e) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
}
doctypeImpl.ownerDocument = this;
appendChild(doctype);
}
}
示例10: createDocument
/**
* Introduced in DOM Level 2. <p>
*
* Creates an XML Document object of the specified type with its document
* element.
*
* @param namespaceURI The namespace URI of the document
* element to create, or null.
* @param qualifiedName The qualified name of the document
* element to create.
* @param doctype The type of document to be created or null.<p>
*
* When doctype is not null, its
* Node.ownerDocument attribute is set to
* the document being created.
* @return Document A new Document object.
* @throws DOMException WRONG_DOCUMENT_ERR: Raised if doctype has
* already been used with a different document.
* @since WD-DOM-Level-2-19990923
*/
public Document createDocument(String namespaceURI,
String qualifiedName,
DocumentType doctype)
throws DOMException
{
if(namespaceURI == null && qualifiedName == null && doctype == null){
//if namespaceURI, qualifiedName and doctype are null, returned document is empty with
//no document element
return new DocumentImpl();
}
else if (doctype != null && doctype.getOwnerDocument() != null) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
}
DocumentImpl doc = new DocumentImpl(doctype);
Element e = doc.createElementNS( namespaceURI, qualifiedName);
doc.appendChild(e);
return doc;
}
示例11: createDocument
/**
* Introduced in DOM Level 2. <p>
*
* Creates an XML Document object of the specified type with its document
* element.
*
* @param namespaceURI The namespace URI of the document
* element to create, or null.
* @param qualifiedName The qualified name of the document
* element to create.
* @param doctype The type of document to be created or null.<p>
*
* When doctype is not null, its
* Node.ownerDocument attribute is set to
* the document being created.
* @return Document A new Document object.
* @throws DOMException WRONG_DOCUMENT_ERR: Raised if doctype has
* already been used with a different document.
* @since WD-DOM-Level-2-19990923
*/
public Document createDocument(String namespaceURI,
String qualifiedName,
DocumentType doctype)
throws DOMException
{
if (doctype != null && doctype.getOwnerDocument() != null) {
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR,
DOMMessageFormatter.formatMessage(
DOMMessageFormatter.XML_DOMAIN,
"WRONG_DOCUMENT_ERR", null));
}
DocumentImpl doc = new PSVIDocumentImpl(doctype);
Element e = doc.createElementNS( namespaceURI, qualifiedName);
doc.appendChild(e);
return doc;
}
示例12: createDocument
/**
* Introduced in DOM Level 2. <p>
*
* Creates an XML Document object of the specified type with its document
* element.
*
* @param namespaceURI The namespace URI of the document
* element to create, or null.
* @param qualifiedName The qualified name of the document
* element to create.
* @param doctype The type of document to be created or null.<p>
*
* When doctype is not null, its
* Node.ownerDocument attribute is set to
* the document being created.
* @return Document A new Document object.
* @throws DOMException WRONG_DOCUMENT_ERR: Raised if doctype has
* already been used with a different document.
* @since WD-DOM-Level-2-19990923
*/
public Document createDocument(
String namespaceURI,
String qualifiedName,
DocumentType doctype)
throws DOMException {
if (doctype != null && doctype.getOwnerDocument() != null) {
String msg =
DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
"WRONG_DOCUMENT_ERR",
null);
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
}
CoreDocumentImpl doc = new CoreDocumentImpl(doctype);
Element e = doc.createElementNS(namespaceURI, qualifiedName);
doc.appendChild(e);
return doc;
}
示例13: saveXML
/**
* DOM Level 3 WD - Experimental.
* Save the document or the given node and all its descendants to a string
* (i.e. serialize the document or node).
* <br>The parameters used in the <code>LSSerializer</code> interface are
* assumed to have their default values when invoking this method.
* <br> The result of a call to this method is the same the result of a
* call to <code>LSSerializer.writeToString</code> with the document as
* the node to write.
* @param node Specifies what to serialize, if this parameter is
* <code>null</code> the whole document is serialized, if it's
* non-null the given node is serialized.
* @return The serialized document or <code>null</code> in case an error
* occurred.
* @exception DOMException
* WRONG_DOCUMENT_ERR: Raised if the node passed in as the node
* parameter is from an other document.
*/
public String saveXML(Node node)
throws DOMException {
if ( errorChecking && node != null &&
this != node.getOwnerDocument() ) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
}
DOMImplementationLS domImplLS = (DOMImplementationLS)DOMImplementationImpl.getDOMImplementation();
LSSerializer xmlWriter = domImplLS.createLSSerializer();
if (node == null) {
node = this;
}
return xmlWriter.writeToString(node);
}