XML technologies / XML / XML in a Nutshell / DOM reference / Object reference / entity
(Excerpt from "XML in a Nutshell" by Elliotte Rusty Harold & W. Scott Means)
The Entity object represents a value replacing a particular general XML entity. Whether a user of DOM actually sees Entity objects depends on whether the implementation validates and whether entity references are replaced automatically.
Java example
// Finde die Deklaration des Entity mein_entity.
Entity ndEnt = (Entity)doc.getDoctype().getEntities( ).
getNamedItem("mein_entity");
Attributes
An Entity object has the following attributes, all of which are read-only:
inputEncoding: DOMString (3)
Returns the character encoding determined at parse time for an external parsed entity. For more information about character encodings, see Internationalization. For internal parsed entities or when the encoding is unknown, the attribute has the value null. Read-only.
Java binding
public String getInputEncoding( );
notationName: DOMString
If the entity is not replaced by the parser, this is its notation name. Otherwise, this attribute has the value null.
Java binding
public String getNotationName( );
Java example
// Ist dies ein vom Parser zu ersetzendes Entity?
boolean fParsedEnt = ndEnt.getNotationName( ) == null;
publicId: DOMString
The PUBLIC identifier (a URI) of the entity, or null, if none was specified.
Java binding
public String getPublicId( );
systemId: DOMString
The SYSTEM identifier (a URI) of the entity, or null, if none was specified.
Java binding
public String getSystemId( );
Java example
// Lies PUBLIC- oder SYSTEM-Identifier dieses Entitys.
Entity ndEnt = (Entity)doc.getDoctype().getEntities( ).getNamedItem("my_ entity");
String strURL = ndEnt.getPublicId( );
// Wenn es keinen PUBLIC-Identifier gibt, ...
if (strURL == null) {
// ... nehmen wir den SYSTEM-Identifier.
strURL = ndEnt.getSystemId( );
}
xmlEncoding: DOMString (3)
Returns the character encoding specified in the encoding pseudo-attribute of the text declaration for an external parsed entity. If there is no text declaration, the value is null. Read-only.
Java binding
public String getXmlEncoding( );
xmlVersion: DOMString (3)
Returns the value of the version pseudo-attribute of an external parsed entity’s text declaration. If there is no text declaration, the value is null. Read-only.
Java binding
public String getXmlVersion( );
Methods
The object Entity has no methods.
Copyright © 2005 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from the book "XML in a Nutshell" is subject to the same conditions as the printed edition: the work and all its parts are protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de