public abstract class Markup extends Content
prefix:name
. If
present, the prefix is a short mnemonic referring to an XML namespace, and
denotes the XML namespace to which this Markup belongs. Markup interns
all three prefix, name and identifier symbols, since these may be used in
various forms of search, which are optimised for identity-comparison.
Markup is distinguished from other kinds of Content, in that Markup nodes
are identified by name, rather than by their content-type. It is possible
to search for Markup either by name, by the full identifier, or by
content-type. Markup offers the ability to search for the XML Namespace
defining the Markup. This triggers a search in the document either for
xmlns:abc
attributes matching the prefix abc
of this Markup, or for the default xmlns
attribute, if no
prefix is defined. If no given Namespace, or default Namespace is
defined, this Markup formally belongs to the empty Namespace.
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
identifier
The unique identifier of this Markup content.
|
private java.lang.String |
name
The short name of this Markup content.
|
private java.lang.String |
prefix
The namespace prefix of this Markup content.
|
Constructor and Description |
---|
Markup(java.lang.String identifier)
Creates a new Markup content with the given identifier or short name.
|
Markup(java.lang.String prefix,
java.lang.String name)
Creates a new Markup content with the given prefix and name.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getIdentifier()
Returns the identifier of this Markup content.
|
java.lang.String |
getName()
Returns the name of this Markup content.
|
Namespace |
getNamespace()
Returns the namespace associated with this Markup.
|
java.lang.String |
getPrefix()
Returns the prefix of this Markup content.
|
private void |
invalidID(java.lang.String message,
java.lang.String identifier)
Throws a SyntaxError reporting a malformed or illegal identifier.
|
private void |
setName(java.lang.String name)
Secret method to validate XML name identifiers.
|
private void |
setPrefix(java.lang.String prefix)
Secret method to validate XML prefix identifiers.
|
addAttribute, addContent, addContent, clone, descendants, descendants, detach, getAttributes, getComment, getContent, getContent, getContent, getContents, getContents, getDocument, getParent, getText, getType, hasContents, iterator, iterator, removeContent, removeContent, removeContents, setParent, toString
private java.lang.String identifier
private java.lang.String prefix
private java.lang.String name
public Markup(java.lang.String identifier) throws SyntaxError
:
', the part preceding the colon is treated as the
prefix, and the part following as the short name. The identifier may
not be null. If the identifier starts with a colon, the namespace is
anonymous (the empty string).identifier
- the full identifier, or short name.SyntaxError
- if the identifier is not a valid XML name token.public Markup(java.lang.String prefix, java.lang.String name) throws SyntaxError
prefix
+ ":
" + name
.
Neither the prefix nor the name may be null.prefix
- the prefix relating to a namespace.name
- the local name of this Markup content.SyntaxError
- if either the prefix or the name are not valid
XML name tokens.private void invalidID(java.lang.String message, java.lang.String identifier) throws SyntaxError
message
- the error message.identifier
- the identifier, or null if empty.SyntaxError
- deliberately.private void setName(java.lang.String name) throws SyntaxError
name
- the name.SyntaxError
- if the identifier is invalid.private void setPrefix(java.lang.String prefix) throws SyntaxError
prefix
- the prefix.SyntaxError
- if the prefix is invalid.public java.lang.String getIdentifier()
==
" for speed. If this Markup content has no prefix,
the identifier is equivalent to the name. Otherwise, it is the
concatenation of the symbols prefix
+ ":
" +
name
.getIdentifier
in class Content
public java.lang.String getPrefix()
==
"
for speed.public java.lang.String getName()
==
"
for speed. The name is the short name of the Markup content,
disregarding any prefix.public Namespace getNamespace()