public class ProcessingInstruction extends Node
This class represents an XML processing instruction. Each processing instruction has two key properties:
?>
. The syntax of the data
depends completely on the processing instruction.
Other than forbidding ?>
, XML defines
no rules for processing instruction data.
Constructor and Description |
---|
ProcessingInstruction(ProcessingInstruction instruction)
Create a copy of a processing instruction.
|
ProcessingInstruction(String target,
String data)
Create a processing instruction with a certain target and data.
|
Modifier and Type | Method and Description |
---|---|
ProcessingInstruction | copy()
Returns a deep copy of this processing instruction with no
parent, that can be added to this document or a different
one.
|
Node | getChild(int position)
Throws
IndexOutOfBoundsException because
processing instructions do not have children. |
int | getChildCount()
Returns 0 because processing instructions do not have children.
|
String | getTarget()
Returns the processing instruction target.
|
String | getValue()
Returns the processing instruction data.
|
void | setTarget(String target)
Sets the target.
|
void | setValue(String data)
Sets the data.
|
String | toString()
Returns a
String representation
of this processing instruction suitable for
debugging and diagnosis. |
String | toXML()
Returns the actual XML form of this processing instruction,
such as might be copied and pasted from the original document.
|
detach, equals, getBaseURI, getDocument, getParent, hashCode, query, query
public ProcessingInstruction(String target, String data)
Create a processing instruction with a certain target and data.
target
- the target of the processing instructiondata
- the processing instruction dataIllegalTargetException
- if the target is not a
non-colonized name or is the string "xml" in any caseIllegalDataException
- if data contains "?>" or any
other illegal characterspublic ProcessingInstruction(ProcessingInstruction instruction)
Create a copy of a processing instruction.
instruction
- the processing instruction to copypublic final String getTarget()
Returns the processing instruction target.
public void setTarget(String target)
Sets the target.
target
- the new targetIllegalTargetException
- if the proposed target
is not an XML 1.0 non-colonized name or is the string
"xml" in any casepublic void setValue(String data)
Sets the data.
data
- the data to setIllegalDataException
- if data
is null
or otherwise not legal XML processing instruction datapublic final String getValue()
Returns the processing instruction data.
public final Node getChild(int position)
Throws IndexOutOfBoundsException
because
processing instructions do not have children.
public final int getChildCount()
Returns 0 because processing instructions do not have children.
getChildCount
in class Node
public final String toXML()
Returns the actual XML form of this processing instruction, such as might be copied and pasted from the original document.
public ProcessingInstruction copy()
Returns a deep copy of this processing instruction with no parent, that can be added to this document or a different one.
public final String toString()
Returns a String
representation
of this processing instruction suitable for
debugging and diagnosis. This is not
the XML representation of this processing instruction.
toString
in class Object
ProcessingInstruction
Copyright 2002-2023 Elliotte Rusty Harold
elharo@ibiblio.org