Mac Developer Library

Developer

Foundation Framework Reference NSXMLDTD Class Reference

Options
Deployment Target:

On This Page
Language:

NSXMLDTD

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.

  • Initializes and returns an NSXMLDTD object created from the DTD declarations in a URL-referenced source.

    Declaration

    Swift

    convenience init(contentsOfURL url: NSURL, options mask: Int) throws

    Objective-C

    - (instancetype)initWithContentsOfURL:(NSURL *)url options:(NSUInteger)mask error:(NSError * _Nullable *)error

    Parameters

    url

    An NSURL object identifying a URL source.

    mask

    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.

    error

    On return, this parameter holds an NSError object 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.

  • Initializes and returns an NSXMLDTD object created from the DTD declarations encapsulated in an NSData object

    Declaration

    Swift

    init(data data: NSData, options mask: Int) throws

    Objective-C

    - (instancetype)initWithData:(NSData *)data options:(NSUInteger)mask error:(NSError * _Nullable *)error

    Parameters

    data

    A data object containing DTD declarations.

    mask

    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.

    error

    On return, this parameter holds an NSError object 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.

  • Sets the public identifier of the receiver.

    Declaration

    Swift

    var publicID: String?

    Objective-C

    @property(copy) NSString *publicID

    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.

  • Returns the receiver’s public identifier.

    Declaration

    Swift

    var publicID: String?

    Objective-C

    @property(copy) NSString *publicID

    Availability

    Available in OS X v10.4 and later.

  • Sets the system identifier of the receiver.

    Declaration

    Swift

    var systemID: String?

    Objective-C

    @property(copy) NSString *systemID

    Parameters

    systemID

    A string object that encapsulates a URL locating a valid DTD.

    Availability

    Available in OS X v10.4 and later.

    See Also

    – systemID

  • Returns the receiver’s system identifier.

    Declaration

    Swift

    var systemID: String?

    Objective-C

    @property(copy) NSString *systemID

    Availability

    Available in OS X v10.4 and later.