Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/Foundation.framework |
Availability | Available in Mac OS X v10.4 and later. |
Companion guide | |
Declared in | NSXMLDTD.h |
An instance of the NSXMLDTD
class represents a Document Type Definition. It is held as a property of an NSXMLDocument
instance, accessed through the NSXMLDocument
method DTD
(and set via setDTD:
).
In the data model, an NSXMLDTD
object is conceptually similar to namespace and attribute nodes: it is not considered to be a child of the NSXMLDocument
object although it is closely associated with it. It is at the “root” of a shallow tree consisting primarily of nodes representing DTD declarations. Acceptable child nodes are instances of the NSXMLDTDNode
class as well as NSXMLNode
objects representing comment nodes and processing-instruction nodes.
You create an NSXMLDTD
object in one of three ways:
By processing an XML document with its own internal (in-line) DTD
By process a standalone (external) DTD
Programmatically
Once an NSXMLDTD
instance is in place, you can add, remove, and change the NSXMLDTDNode
objects representing various DTD declarations. When you write the document out as XML, the new or modified internal DTD is included (assuming you set the DTD in the NSXMLDocument
instance). You may also programmatically create an external DTD and write that out to its own file.
– addChild:
– insertChild:atIndex:
– insertChildren:atIndex:
– removeChildAtIndex:
– replaceChildAtIndex:withNode:
– setChildren:
+ predefinedEntityDeclarationForName:
– elementDeclarationForName:
– attributeDeclarationForName:elementName:
– entityDeclarationForName:
– notationDeclarationForName:
Returns a DTD node representing the predefined entity declaration with the specified name.
+ (NSXMLDTDNode *)predefinedEntityDeclarationForName:(NSString *)name
A string identifying a predefined entity declaration.
An autoreleased NSXMLDTDNode
object, or nil
if there is no match for name.
The five predefined entity references (or character references) are “<” (less-than sign), “>” (greater-than sign), “&” (ampersand), “"” (quotation mark), and “'” (apostrophe).
NSXMLDTD.h
Adds a child node to the end of the list of existing children.
- (void)addChild:(NSXMLNode *)child
The node object to add to the existing children.
– insertChild:atIndex:
– insertChildren:atIndex:
– removeChildAtIndex:
– replaceChildAtIndex:withNode:
– setChildren:
NSXMLDTD.h
Returns the DTD node representing an attribute-list declaration for a given attribute and its element.
- (NSXMLDTDNode *)attributeDeclarationForName:(NSString *)attrName elementName:(NSString *)elementName
A string object identifying the name of an attribute.
A string object identifying the name of an element.
An autoreleased NSXMLDTDNode
object, or nil
if there is no matching attribute-list declaration.
For example, in the attribute-list declaration:
<!ATTLIST person idnum CDATA "0000"> |
“idnum” would correspond to attrName and “person” would correspond to elementName.
NSXMLDTD.h
Returns the DTD node representing an element declaration for a specified element.
- (NSXMLDTDNode *)elementDeclarationForName:(NSString *)elementName
A string that is the name of an element.
An autoreleased NSXMLDTDNode
object, or nil
if there is no match.
NSXMLDTD.h
Returns the DTD node representing the entity declaration for a specified entity.
- (NSXMLDTDNode *)entityDeclarationForName:(NSString *)entityName
A string that is the name of an entity.
An autoreleased NSXMLDTDNode
object, or nil
if there is no match.
NSXMLDTD.h
Initializes and returns an NSXMLDTD
object created from the DTD declarations in a URL-referenced source.
- (id)initWithContentsOfURL:(NSURL *)url options:(NSUInteger)mask error:(NSError **)error
An NSURL
object identifying a URL source.
A bit mask specifying input options; bit-OR multiple options. The current valid options are NSXMLNodePreserveWhitespace
and NSXMLNodePreserveEntities
; these constants are described in the "Constants" section of the NSXMLNode
reference.
On return, this parameter holds an NSError
object describing any errors and warnings related to parsing and remote connection.
An initialized NSXMLDTD
object or nil
if initialization fails because of parsing errors or other reasons.
You use this method to create a stand-alone DTD which you can thereafter query and use for validation. You can associate the DTD created through this message with a document by sending setDTD:
to an NSXMLDocument
object.
– initWithData:options:error:
– validateAndReturnError:
(NSXMLDocument)NSXMLDTD.h
Initializes and returns an NSXMLDTD
object created from the DTD declarations encapsulated in an NSData
object
- (id)initWithData:(NSData *)data options:(NSUInteger)mask error:(NSError **)error
A data object containing DTD declarations.
A bit mask specifying input options; bit-OR multiple options. The current valid options are NSXMLNodePreserveWhitespace
and NSXMLNodePreserveEntities
; these constants are described in the "Constants" section of the NSXMLNode
reference.
On return, this parameter holds an NSError
object describing any errors and warnings related to parsing and remote connection.
An initialized NSXMLDTD
object or nil
if initialization fails because of parsing errors or other reasons.
This method is the designated initializer for the NSXMLDTD
class. You use this method to create a stand-alone DTD which you can thereafter query and use for validation. You can associate the DTD created through this message with a document by sending setDTD:
to an NSXMLDocument
object.
– initWithContentsOfURL:options:error:
– validateAndReturnError:
(NSXMLDocument)NSXMLDTD.h
Inserts a child node in the receiver’s list of children at a specific location in the list.
- (void)insertChild:(NSXMLNode *)child atIndex:(NSUInteger)index
An XML-node object that represents the child to insert.
An integer identifying the location in the receiver's list of children to insert child. The indices of subsequent children in the list are incremented by one.
– addChild:
– insertChildren:atIndex:
– removeChildAtIndex:
– replaceChildAtIndex:withNode:
– setChildren:
NSXMLDTD.h
Inserts an array of child nodes at a specified location in the receiver’s list of children.
- (void)insertChildren:(NSArray *)children atIndex:(NSUInteger)index
An array of NSXMLNode
objects to insert as children of the receiver.
An integer identifying the location in the list of current children to make the insertion. The indices of subsequent children in the list are incremented by the number of inserted children.
– addChild:
– insertChild:atIndex:
– removeChildAtIndex:
– replaceChildAtIndex:withNode:
– setChildren:
NSXMLDTD.h
Returns the DTD node representing the notation declaration identified by the specified notation name.
- (NSXMLDTDNode *)notationDeclarationForName:(NSString *)notationName
A string that is the name of a notation.
An autoreleased NSXMLDTDNode
object, or nil
if there is no match.
NSXMLDTD.h
Returns the receiver’s public identifier.
- (NSString *)publicID
NSXMLDTD.h
Removes the child node at a particular location in the receiver’s list of children.
- (void)removeChildAtIndex:(NSUInteger)index
An integer identifying the child node to remove. The indices of subsequent children in the list are decremented by one.
The removed child node is released.
– addChild:
– insertChild:atIndex:
– insertChildren:atIndex:
– replaceChildAtIndex:withNode:
– setChildren:
NSXMLDTD.h
Replaces a child at a particular index with another child.
- (void)replaceChildAtIndex:(NSUInteger)index withNode:(NSXMLNode *)node
An integer identifying the position of a node in the receiver's list of child nodes.
An NSXMLNode
object to replace the object at index.
The replaced child node is released.
NSXMLDTD.h
Removes all existing children of the receiver and replaces them with an array of new child nodes.
- (void)setChildren:(NSArray *)children
An array of NSXMLNode
objects. To remove all existing children, pass in nil
.
Replaced or removed child nodes are released.
– addChild:
– insertChild:atIndex:
– insertChildren:atIndex:
– removeChildAtIndex:
– replaceChildAtIndex:withNode:
NSXMLDTD.h
Sets the public identifier of the receiver.
- (void)setPublicID:(NSString *)publicID
A string object specifying a public identifier.
This identifier should be in the default catalog in /etc/xml/catalog
or in a path specified by the environment variable XML_CATALOG_FILES
. When the public ID is set the system ID must also be set.
NSXMLDTD.h
Sets the system identifier of the receiver.
- (void)setSystemID:(NSString *)systemID
A string object that encapsulates a URL locating a valid DTD.
NSXMLDTD.h
Returns the receiver’s system identifier.
- (NSString *)systemID
NSXMLDTD.h
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-02-27)