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.

Inheritance


Conforms To


Import Statement


Swift

import Foundation

Objective-C

@import Foundation;

Availability


Available in OS X v10.4 and later.
  • 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, error error: NSErrorPointer)

    Objective-C

    - (instancetype)initWithContentsOfURL:(NSURL *)url options:(NSUInteger)mask error:(NSError **)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.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    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, error error: NSErrorPointer)

    Objective-C

    - (instancetype)initWithData:(NSData *)data options:(NSUInteger)mask error:(NSError **)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.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    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.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    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

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    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.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    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

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns a DTD node representing the predefined entity declaration with the specified name.

    Declaration

    Swift

    class func predefinedEntityDeclarationForName(_ name: String) -> NSXMLDTDNode?

    Objective-C

    + (NSXMLDTDNode *)predefinedEntityDeclarationForName:(NSString *)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).

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the DTD node representing an element declaration for a specified element.

    Declaration

    Swift

    func elementDeclarationForName(_ elementName: String) -> NSXMLDTDNode?

    Objective-C

    - (NSXMLDTDNode *)elementDeclarationForName:(NSString *)elementName

    Parameters

    elementName

    A string that is the name of an element.

    Return Value

    An autoreleased NSXMLDTDNode object, or nil if there is no match.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the DTD node representing an attribute-list declaration for a given attribute and its element.

    Declaration

    Swift

    func attributeDeclarationForName(_ attrName: String, elementName elementName: String) -> NSXMLDTDNode?

    Objective-C

    - (NSXMLDTDNode *)attributeDeclarationForName:(NSString *)attrName elementName:(NSString *)elementName

    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.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the DTD node representing the entity declaration for a specified entity.

    Declaration

    Swift

    func entityDeclarationForName(_ entityName: String) -> NSXMLDTDNode?

    Objective-C

    - (NSXMLDTDNode *)entityDeclarationForName:(NSString *)entityName

    Parameters

    entityName

    A string that is the name of an entity.

    Return Value

    An autoreleased NSXMLDTDNode object, or nil if there is no match.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.

  • Returns the DTD node representing the notation declaration identified by the specified notation name.

    Declaration

    Swift

    func notationDeclarationForName(_ notationName: String) -> NSXMLDTDNode?

    Objective-C

    - (NSXMLDTDNode *)notationDeclarationForName:(NSString *)notationName

    Parameters

    notationName

    A string that is the name of a notation.

    Return Value

    An autoreleased NSXMLDTDNode object, or nil if there is no match.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.4 and later.