NSXMLDTD Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/Foundation.framework |
| Availability | Available in OS X v10.4 and later. |
| Companion guide | |
| Declared in | NSXMLDTD.h |
Overview
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.
Tasks
Initializing an NSXMLDTD Object
Managing DTD Identifiers
Manipulating Child Nodes
-
– addChild: -
– insertChild:atIndex: -
– insertChildren:atIndex: -
– removeChildAtIndex: -
– replaceChildAtIndex:withNode: -
– setChildren:
Getting DTD Nodes by Name
Class Methods
predefinedEntityDeclarationForName:
Returns a DTD node representing the predefined entity declaration with the specified name.
Parameters
- name
A string identifying a predefined entity declaration.
Return Value
An autoreleased NSXMLDTDNode object, or nil if there is no match for name.
Discussion
The five predefined entity references (or character references) are “<” (less-than sign), “>” (greater-than sign), “&” (ampersand), “"” (quotation mark), and “'” (apostrophe).
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSXMLDTD.hInstance Methods
addChild:
Adds a child node to the end of the list of existing children.
Parameters
- child
The node object to add to the existing children.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSXMLDTD.hattributeDeclarationForName:elementName:
Returns the DTD node representing an attribute-list declaration for a given attribute and its element.
Parameters
- attrName
A string object identifying the name of an attribute.
- elementName
A string object identifying the name of an element.
Return Value
An autoreleased NSXMLDTDNode object, or nil if there is no matching attribute-list declaration.
Discussion
For example, in the attribute-list declaration:
<!ATTLIST person idnum CDATA "0000"> |
“idnum” would correspond to attrName and “person” would correspond to elementName.
Availability
- Available in OS X v10.4 and later.
Declared In
NSXMLDTD.helementDeclarationForName:
Returns the DTD node representing an element declaration for a specified element.
Parameters
- elementName
A string that is the name of an element.
Return Value
An autoreleased NSXMLDTDNode object, or nil if there is no match.
Availability
- Available in OS X v10.4 and later.
Declared In
NSXMLDTD.hentityDeclarationForName:
Returns the DTD node representing the entity declaration for a specified entity.
Parameters
- entityName
A string that is the name of an entity.
Return Value
An autoreleased NSXMLDTDNode object, or nil if there is no match.
Availability
- Available in OS X v10.4 and later.
Declared In
NSXMLDTD.hinitWithContentsOfURL:options:error:
Initializes and returns an NSXMLDTD object created from the DTD declarations in a URL-referenced source.
Parameters
- url
An
NSURLobject identifying a URL source.- mask
A bit mask specifying input options; bit-OR multiple options. The current valid options are
NSXMLNodePreserveWhitespaceandNSXMLNodePreserveEntities; these constants are described in the "Constants" section of theNSXMLNodereference.- error
On return, this parameter holds an
NSErrorobject describing any errors and warnings related to parsing and remote connection.
Return Value
An initialized NSXMLDTD object or nil if initialization fails because of parsing errors or other reasons.
Discussion
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.
Availability
- Available in OS X v10.4 and later.
See Also
-
– initWithData:options:error: -
– validateAndReturnError:(NSXMLDocument)
Declared In
NSXMLDTD.hinitWithData:options:error:
Initializes and returns an NSXMLDTD object created from the DTD declarations encapsulated in an NSData object
Parameters
- data
A data object containing DTD declarations.
- mask
A bit mask specifying input options; bit-OR multiple options. The current valid options are
NSXMLNodePreserveWhitespaceandNSXMLNodePreserveEntities; these constants are described in the "Constants" section of theNSXMLNodereference.- error
On return, this parameter holds an
NSErrorobject describing any errors and warnings related to parsing and remote connection.
Return Value
An initialized NSXMLDTD object or nil if initialization fails because of parsing errors or other reasons.
Discussion
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.
Availability
- Available in OS X v10.4 and later.
See Also
-
– initWithContentsOfURL:options:error: -
– validateAndReturnError:(NSXMLDocument)
Declared In
NSXMLDTD.hinsertChild:atIndex:
Inserts a child node in the receiver’s list of children at a specific location in the list.
Parameters
- child
An XML-node object that represents the child to insert.
- index
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.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSXMLDTD.hinsertChildren:atIndex:
Inserts an array of child nodes at a specified location in the receiver’s list of children.
Parameters
- children
An array of
NSXMLNodeobjects to insert as children of the receiver.- index
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.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSXMLDTD.hnotationDeclarationForName:
Returns the DTD node representing the notation declaration identified by the specified notation name.
Parameters
- notationName
A string that is the name of a notation.
Return Value
An autoreleased NSXMLDTDNode object, or nil if there is no match.
Availability
- Available in OS X v10.4 and later.
Declared In
NSXMLDTD.hpublicID
Returns the receiver’s public identifier.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSXMLDTD.hremoveChildAtIndex:
Removes the child node at a particular location in the receiver’s list of children.
Parameters
- index
An integer identifying the child node to remove. The indices of subsequent children in the list are decremented by one.
Discussion
The removed child node is released.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSXMLDTD.hreplaceChildAtIndex:withNode:
Replaces a child at a particular index with another child.
Parameters
- index
An integer identifying the position of a node in the receiver's list of child nodes.
- node
An
NSXMLNodeobject to replace the object at index.
Discussion
The replaced child node is released.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSXMLDTD.hsetChildren:
Removes all existing children of the receiver and replaces them with an array of new child nodes.
Parameters
- children
An array of
NSXMLNodeobjects. To remove all existing children, pass innil.
Discussion
Replaced or removed child nodes are released.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSXMLDTD.hsetPublicID:
Sets the public identifier of the receiver.
Parameters
- publicID
A string object specifying a public identifier.
Discussion
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.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSXMLDTD.hsetSystemID:
Sets the system identifier of the receiver.
Parameters
- systemID
A string object that encapsulates a URL locating a valid DTD.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSXMLDTD.hsystemID
Returns the receiver’s system identifier.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSXMLDTD.h© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-02-27)