XMLDocument

class XMLDocument : XMLNode
  • Initializes a new XMLDocument using the contents of an existing FCPXML file.

    Throws

    An error object that, on return, identifies any parsing errors and warnings or connection problems.

    Declaration

    Swift

    public convenience init(contentsOfFCPXML URL: Foundation.URL) throws

    Parameters

    URL

    The URL to the FCPXML file.

  • Initializes a new XMLDocument as FCPXML.

    Declaration

    Swift

    public convenience init(resources: [XMLElement], events: [XMLElement], fcpxmlVersion: String)

    Parameters

    resources

    Resources an array of XMLElement objects

    events

    Events as an array of XMLElement objects

    fcpxmlVersion

    The FCPXML version of the document to use.

  • The FCPXML document as a properly formatted string.

    Declaration

    Swift

    public var fcpxmlString: String { get }
  • The fcpxml element at the root of the XMLDocument

    Declaration

    Swift

    public var fcpxmlElement: XMLElement? { get }
  • The resource element child of the fcpxml element.

    Declaration

    Swift

    public var fcpxResourceElement: XMLElement? { get }
  • An array of all resources in the FCPXML document.

    Declaration

    Swift

    public var fcpxResources: [XMLElement] { get }
  • The library XMLElement in the FCPXML document.

    Declaration

    Swift

    public var fcpxLibraryElement: XMLElement? { get }
  • An array of all event elements in the FCPXML document.

    Declaration

    Swift

    public var fcpxEvents: [XMLElement] { get }
  • An array of format resources in the FCPXML document.

    Declaration

    Swift

    public var fcpxFormatResources: [XMLElement] { get }
  • An array of asset resources in the FCPXML document.

    Declaration

    Swift

    public var fcpxAssetResources: [XMLElement] { get }
  • An array of multicam resources in the FCPXML document.

    Declaration

    Swift

    public var fcpxMulticamResources: [XMLElement] { get }
  • An array of compound clip resources in the FCPXML document.

    Declaration

    Swift

    public var fcpxCompoundResources: [XMLElement] { get }
  • An array of effect resources in the FCPXML document.

    Declaration

    Swift

    public var fcpxEffectResources: [XMLElement] { get }
  • An array of all projects in all events in the FCPXML document.

    Declaration

    Swift

    public var fcpxAllProjects: [XMLElement] { get }
  • An array of all clips in all events in the FCPXML document.

    Declaration

    Swift

    public var fcpxAllClips: [XMLElement] { get }
  • The version of FCPXML used in this document.

    Declaration

    Swift

    public var fcpxmlVersion: String? { get set }
  • The names of all events as a String array.

    Declaration

    Swift

    public var fcpxEventNames: [String] { get }
  • All items from all events as a XMLElement array.

    Declaration

    Swift

    public var fcpxAllEventItems: [XMLElement] { get }
  • The names of all items from all events as a XMLElement array.

    Declaration

    Swift

    public var fcpxAllEventItemNames: [String] { get }
  • The names of all projects from all events as a XMLElement array.

    Declaration

    Swift

    public var fcpxAllProjectNames: [String] { get }
  • Returns an array of all roles used in the FCPXML document.

    This function parses the entire XML document whenever called. Avoid calling it repeatedly and store the value separately instead.

    Declaration

    Swift

    public func fcpxAllRoles() -> [String]

    Return Value

    An array of String values.

  • Returns the highest resource ID number used in the FCPXML document.

    This function parses the entire XML document whenever called. Avoid calling it repeatedly and store the value separately instead.

    Declaration

    Swift

    public func fcpxLastResourceID() -> Int

    Return Value

    An integer value.

  • Returns the highest text style ID number used in the FCPXML document.

    This function parses the entire XML document whenever called. Avoid calling it repeatedly and store the value separately instead.

    Declaration

    Swift

    public func fcpxLastTextStyleID() -> Int

    Return Value

    An integer value.

  • Returns the resource that matches the given ID string.

    Declaration

    Swift

    public func resource(matchingID ID: String) -> XMLElement?

    Parameters

    matchingID

    The resource ID as a string in the form of r1

    Return Value

    The matching resource NSXMLElement

  • Returns asset resources that match the given URL.

    Declaration

    Swift

    public func assetResources(matchingURL url: URL, usingFilenameOnly: Bool, omittingExtension: Bool, caseSensitive: Bool) -> [XMLElement]

    Parameters

    matchingURL

    The URL to match with.

    usingFilenameOnly

    True if matching with just the filename, false if matching with the entire URL path.

    omittingExtension

    True if matching without the extension in the filename, false if matching with the entire filename.

    caseSensitive

    True if the search should be case sensitive, false if it should not.

    Return Value

    An array of XMLElement objects that are matching asset resources.

  • Adds a resource XMLElement to the FCPXML document.

    Declaration

    Swift

    public func add(resourceElement: XMLElement)

    Parameters

    resourceElement

    The XMLElement of the resource to be added.

  • Adds an array of resource XMLElements to the FCPXML document.

    Declaration

    Swift

    public func add(resourceElements: [XMLElement])

    Parameters

    resourceElements

    An array of resource XMLElement objects.

  • Removes the resource at the specified index.

    Important

    This method will remove all associated clips from all events in the FCPXML document. However, it will not remove synchronized clips, compound clips and multicams that contain the resource.

    Declaration

    Swift

    public func remove(resourceAtIndex index: Int)

    Parameters

    index

    The index of the resource within the resources element.

  • Removes all resources from the FCPXML document.

    Declaration

    Swift

    public func removeAllResources()
  • Adds an event to the library XMLElement of the FCPXML document.

    Declaration

    Swift

    public func add(event: XMLElement)

    Parameters

    event

    The XMLElement of the event to be added.

  • Adds an array of event XMLElements to the FCPXML document.

    Declaration

    Swift

    public func add(events: [XMLElement])

    Parameters

    events

    An array of event XMLElement objects.

  • Removes the event at the specified index.

    Declaration

    Swift

    public func remove(eventAtIndex index: Int)

    Parameters

    index

    The index of the event within the library element.

  • Removes all events from the library.

    Declaration

    Swift

    public func removeAllEvents()
  • Returns the version numbers of the DTD documents included in this framework bundle.

    Declaration

    Swift

    public func fcpxmlDTDVersions() -> [String]

    Return Value

    An array of String objects.

  • Converts a version string to an array of three Int values.

    Declaration

    Swift

    public func versionArrayFrom(version: String) -> [Int]

    Parameters

    version

    The version string to convert. Can have major, minor, and patch values, each separated by a dot.

    Return Value

    An array of three Int values. If three values were not included in the string, the missing values will be 0.

  • Verifies that this document’s FCPXML version number is at minimum the specified version.

    Declaration

    Swift

    public func versionIs(atMinimum minimum: String) -> Bool

    Parameters

    minimum

    A String of the minimum version. E.g. 1.7.1

    Return Value

    True if the document is at least the specified minimum version number.

  • Validates the XMLDocument against the DTD of the latest FCPXML version included in this framework. The XMLDocument is valid if no error is thrown.

    Throws

    An error describing the reason for the XML being invalid or another error, such as not being able to read or set the associated DTD file.

    Declaration

    Swift

    public func validateFCPXMLAgainstLatestVersion() throws
  • Validates the XMLDocument against the DTD of the FCPXML version specified. The version number must match a DTD resource included in the bundle. The XMLDocument is valid if no error is thrown.

    Throws

    An error describing the reason for the XML being invalid or another error, such as not being able to read or set the associated DTD file.

    Declaration

    Swift

    public func validateFCPXMLAgainst(version: String) throws

    Parameters

    version

    A String of the version number.

  • Parses the resource IDs, text style IDs, and roles, refreshing the fcpxLastResourceID, fcpxLastTextStyleID, and fcpxRoles properties. Call this method when initially loading an FCPXML document and when the IDs or roles change.

    Declaration

    Swift

    public func parseFCPXML()