public final class ProcessingInstruction extends TextNode
A processing instruction may contain characters and always has a target, which is treated as a pseudo-attribute (that is, it is not part of the textual content of the pseudo-instruction).
Node.PropertyIterator, Node.Type
ALL_PROPERTIES, EMPTY_LIST, FALSE, listenerData, next, NO_PROPERTY_ITERATOR, parent, previous, properties, readOnly, TRUE, UNSET
Constructor and Description |
---|
ProcessingInstruction(String target)
Constructs a empty processing instruction node.
|
ProcessingInstruction(String target,
char[] text,
int offset,
int length)
Constructs a processing instruction node containing specified
characters.
|
ProcessingInstruction(String target,
String text)
Constructs a processing instruction node containing specified
characters.
|
Modifier and Type | Method and Description |
---|---|
Node |
copy()
Returns a deep copy of this node.
|
static String |
formatPseudoAttributes(String[] nameValuePairs)
Formats specified pseudo-attribute name/value pairs.
|
String[] |
getPseudoAttributes()
Returns the textual content of this processing instruction parsed as
pseudo-attributes.
|
static String[] |
getRegisteredTargets()
Returns the (possibly empty) array of all registered PI targets.
|
String |
getTarget()
Returns the target of this processing instruction
|
Node.Type |
getType()
Returns the type of this node.
|
static boolean |
isRegisteredTarget(String target)
Tests whether specified target is a registered PI target.
|
Name |
name()
Returns the name of this element node, the name of this attribute node
or the target of this processing-instruction node.
|
static String[] |
parsePseudoAttributes(String text)
Parses specified text as if it was the XML representation of a list of
attributes.
|
static void |
registerTarget(String target)
Registers specified PI target.
|
void |
setPseudoAttributes(String[] nameValuePairs)
Changes the text contained in this processing instruction to specified
pseudo-attribute name/value pairs.
|
void |
setTarget(String target)
Changes the target of this processing instruction.
|
static void |
unregisterTarget(String target)
Unregisters specified PI target.
|
appendText, data, deleteText, getText, getTextChar, getTextChars, getTextLength, insertText, isXMLSpace, replaceText, setText
attributes, attributeValue, canInsertBefore, canReplace, compareTo, copyProperties, deepCopy, document, doGetBaseURL, equals, findCommonAncestor, firstChild, following, getBaseURL, getDocument, getDocumentListenerData, getFirstSibling, getInclusion, getLabel, getLastSibling, getNextElement, getNextSibling, getParent, getParentElement, getPosition, getPreviousElement, getPreviousSibling, getProperties, getProperty, getPropertyCount, getPropertyNames, getShortLabel, getSourceURL, getXPath, hasProperty, indexOfDocumentListenerData, isAncestorOf, isDescendantOf, isEditable, isReadOnly, isSiblingOf, lastChild, lookupInclusion, lookupInclusion, lookupProperty, namespacePrefixMap, parent, preceding, putProperty, removeProperties, removeProperty, sameInclusion, setDocumentListenerData, toString, type
public ProcessingInstruction(String target)
target
- the target of this processing instructionpublic ProcessingInstruction(String target, String text)
The target must be a NAME which does not begin with "xml". This is not checked by the constructors.
target
- the target of this processing instructiontext
- contains characters used to initialize this processing
instruction nodepublic ProcessingInstruction(String target, char[] text, int offset, int length)
target
- the target of this processing instructiontext
- contains characters used to initialize this processing
instruction nodeoffset
- index of first character within text used to
initialize this processing instruction nodelength
- number of characters in text used to initialize
this processing instruction nodepublic static void registerTarget(String target)
When a PI having a registered prefix is inserted (just inserted,
not deleted or replaced) in a Document
, a PITargetEvent
document event is sent to all DocumentListener
s.
The goal is to make it easy activating code in the application
handling the registered PI.
public static void unregisterTarget(String target)
public static String[] getRegisteredTargets()
public static boolean isRegisteredTarget(String target)
registerTarget(java.lang.String)
public Node copy()
Node
Note that node properties are automatically copied too.
See Node.copyProperties(com.xmlmind.xml.doc.Node)
.
public Node.Type getType()
Node
public String getTarget()
public void setTarget(String target)
target
- the new targetpublic String[] getPseudoAttributes()
parsePseudoAttributes(java.lang.String)
public static String[] parsePseudoAttributes(String text)
Example:
from="me" to='you'
is parsed as:
from me to you
Important: this method does not unescape
parsed pseudo-attribute values. It merely "unprotects"
(using a proprietary method) the apostrophe character
(U+0027
) in case formatPseudoAttributes(java.lang.String[])
"protected" this character.
text
- parsed textnull
if text has syntax
errors.XMLText.unescapeXML(java.lang.String)
public void setPseudoAttributes(String[] nameValuePairs)
public static String formatPseudoAttributes(String[] nameValuePairs)
parsePseudoAttributes(java.lang.String)
.
Example:
from me to you
is formatted as:
from="me" to="you"
Important: this method does not escape
passed pseudo-attribute values. It merely "protects"
(using a proprietary method) the apostrophe character
(U+0027
) to let parsePseudoAttributes(java.lang.String)
function in all cases.
nameValuePairs
- an array of String pairs: pseudo-attribute name
followed by pseudo-attribute value.
A null
value is equivalent to the empty string.
XMLText.escapeXML(java.lang.String)