XLink Object Model 1.0.0

Delphi 3, 4, 5, 6, and Kylix Implementation

by Dieter Köhler


LICENSE

Copyright (c) 2002 by Dieter Köhler ("http://www.philo.de/xml/")

Definitions:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Package"), to deal in the Package without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Package, and to permit persons to whom the Package is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Package.

You may modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed a file, and provided that you do at least one of the following:

a) allow the Copyright Holder to include your modifications in the Standard Version of the Package.

b) use the modified Package only within your corporation or organization.

c) rename the Package not using the expression XDOM, rename any non standard executables, units, and classes so the names do not conflict with standard executables, units, and classes, and provide a separate manual page that clearly documents how it differs from the standard version.

d) make other distribution arrangements with the Copyright Holder.

The name of the Copyright Holder may not be used to endorse or promote products derived from this Package without specific prior written permission.

THE PACKAGE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE PACKAGE OR THE USE OR OTHER DEALINGS IN THE PACKAGE.


Introduction

The XLink Object Model package contains classes used to maintain collections of XLinks as specified in the W3C Proposed Recommendation "XML Linking Language (XLink) Version 1.0", ed. Steve DeRose, Eve Maler and David Orchard, available at "http://www.w3.org/TR/2000/PR-xlink-20001220/". Users not familiar with the "XML Linking Language (XLink) Version 1.0" recommendation are strongly encouraged to carefully study it first before they go on reading the present documentation and trying to understand the "XLink Object Model" package for Delphi.

XLinks are maintained by the classes of this package in form of a tree of XLink nodes. The root of such a tree is always a TXLinkCollection object.

XLink nodes are created and owned by other XLink nodes or a TXLinkCollection object. Therefore, the only objects an application creates by directly calling their create constructor are TXLinkCollection objects. All other tree objects are create by calling the respective factory methods of their parent objects. For example to create a new extended XLink node and add it to a TXLinkCollection object the AppendXLinkExtended() method of the TXLinkCollection object must be called.

For each type of child XLink nodes a parent XLink node has a special property object of type TXLinkList which holds an object list of the child XLink nodes. To free and delete an XLink node use the delete() method of the TXLinkList object. Note that TXLinkCollection itself is a descendant of TXLinkList and directly holds the TXLinkExtended it created.

The descriptions of the methods below omit explanations of parameters which correspond to XLink attributes as defined in the "XML Linking Language (XLink) Version 1.0" recommendation. Where names of those parameters get in conflict with predefined Delphi VCL keywords the prefix "XLink" was added to the names, for example the parameter for an XLink label attribute is called "XLinkLabel".


Exceptions


Defined Constants


Helper functions


TXLinkList = class

Used to maintaine lists of XLink nodes.

Public Methods

The methods listed below are equivalent to the respective methods of the Delphi VCL TObjectList class with the OwnsObjects property set to True.

constructor Create(const itemTypes: TXLinkTypes);
destructor Destroy; override;
procedure Clear; virtual;
procedure Delete(index: integer); virtual;
procedure Exchange(index1, index2: integer); virtual;
function First: TXLinkNode; virtual;
function IndexOf(item: TXLinkNode): integer; virtual;
function Last: TXLinkNode; virtual;
procedure Move(curIndex, newIndex: integer); virtual;
function Remove(item: TXLinkNode): integer; virtual;
Public Properties
property Items[index: integer]: TXLinkNode (readonly)

Use Items to access the XLink nodes in the list. Items is a zero-based array: The first object is indexed as 0, the second object is indexed as 1, and so forth. You can read or change the value at a specific index, or use Items with the Count property to iterate through the list. Reassigning an Items index frees the XLink node that previously occupied that position in the list.

property Length: integer (readonly)

The number of items in the list.


TXLinkNode = class

TXLinkNode is the base class for all other XLink node classes. Do not use this class in your applications directly.

Public Methods
constructor Create;
Public Properties
property AssociatedObject: TObject

The Object associated with this XLink node.

property Owner: TXLinkList (readonly)

The TXLinkList object that owns this XLink node, if any.

property XLinkType: TXLinkType (readonly)

Used by descendant XLink node classes to indicate the type of the XLink node.

property TypeAsWideString: wideString (readonly)

The XLinkType as a wideString according to the following table:

Class XLinkType TypeAsWideString
TXLinkNode ltNone 'none'
TXLinkExtended ltExtended 'extended'
TXLinkLocator ltLocator 'locator'
TXLinkArc ltArc 'arc'
TXLinkResource ltResource 'resource'
TXLinkTitle ltTitle 'title'

TXLinkExtended = class (TXLinkNode)

Used to represent an extended XLink.

Public Methods
constructor Create;
destructor Destroy; override;
procedure AppendContentOf(source: TXLinkExtended; copyObjInf: boolean); virtual;

Used to assign the content of another extended XLink node specified in the 'source' parameter to this extended XLink node. If 'copyObjInf' parameter is set to 'true' the associated Objects of the source node are copied, too.

function AppendXLinkArc(arcrole, title: wideString; show: TXLinkShow; actuate: TXLinkActuate; XLinkFrom, XLinkTo: wideString; associatedObject: TObject): TXLinkArc;

Creates and appends a new arc XLink node to this extended XLink node.

function AppendXLinkLocator(href, role, title, XLinklabel: wideString; associatedObject: TObject): TXLinkLocator; virtual;

Creates and appends a new locator XLink node to this extended XLink node.

function AppendXLinkResource(role, title, XLinkLabel: wideString; associatedObject: TObject): TXLinkResource; virtual;

Creates and appends a new resource XLink node to this extended XLink node.

function AppendXLinkTitle(associatedObject: TObject): TXLinkTitle; virtual;

Creates and appends a new title XLink node to this extended XLink node.

function InsertXLinkArc(index: integer; arcrole, title: wideString; show: TXLinkShow; actuate: TXLinkActuate; XLinkFrom, XLinkTo: wideString; associatedObject: TObject): TXLinkArc; virtual;

Creates and inserts a new arc XLink node into this extended XLink node.

function InsertXLinkLocator(index: integer; href, role, title, XLinklabel: wideString; associatedObject: TObject): TXLinkLocator; virtual;

Creates and inserts a new locator XLink node into this extended XLink node.

function InsertXLinkResource(index: integer; role, title, XLinkLabel: wideString; associatedObject: TObject): TXLinkResource; virtual;

Creates and inserts a new resource XLink node into this extended XLink node.

function InsertXLinkTitle(index: integer; associatedObject: TObject): TXLinkTitle; virtual;

Creates and inserts a new title XLink node into this extended XLink node.

Public Properties
property Locators: TXLinkList (readonly)

The list of created, owned and associated locator type XLink nodes.

property Resources: TXLinkList (readonly)

The list of created, owned and associated resource type XLink nodes.

property Role: wideString

The role attribute of this extended XLink node.

property Title: wideString

The title attribute of this extended XLink node.

property Titles: TXLinkList (readonly)

The list of created, owned and associated title type XLink nodes.


TXLinkLocator = class (TXLinkNode)

Used to represent a locator XLink.

Public Methods
constructor Create;
destructor Destroy; override;
procedure AppendContentOf(source: TXLinkLocator; copyObjInf: boolean); virtual;

Used to assign the content of another locator XLink node specified in the 'source' parameter to this locator XLink node. If 'copyObjInf' parameter is set to 'true' the associated Objects of the source node are copied, too.

function AppendXLinkTitle(associatedObject: TObject): TXLinkTitle; virtual;

Creates and appends a new title XLink node to this locator XLink node.

function InsertXLinkTitle(index: integer; associatedObject: TObject): TXLinkTitle; virtual;

Creates and inserts a new title XLink node into this locator XLink node.

Public Properties
property Href: wideString

The href attribute of this locator XLink node.

property Role: wideString

The role attribute of this locator XLink node.

property Title: wideString

The title attribute of this locator XLink node.

property Titles: TXLinkList (readonly)

The list of created, owned and associated title type XLink nodes.

property XLinkLabel: wideString

The label attribute of this locator XLink node.


TXLinkArc = class (TXLinkNode)

Used to represent an arc XLink.

Public Methods
constructor Create;
destructor Destroy; override;
procedure AppendContentOf(source: TXLinkArc; copyObjInf: boolean); virtual;

Used to assign the content of another arc XLink node specified in the 'source' parameter to this arc XLink node. If 'copyObjInf' parameter is set to 'true' the associated Objects of the source node are copied, too.

function AppendXLinkTitle(associatedObject: TObject): TXLinkTitle; virtual;

Creates and appends a new title XLink node to this arc XLink node.

function InsertXLinkTitle(index: integer; associatedObject: TObject): TXLinkTitle; virtual;

Creates and inserts a new title XLink node into this arc XLink node.

Public Properties
property Actuate: TXLinkActuate

The actuate attribute of this arc XLink node.

property Arcrole: wideString

The arcrole attribute of this arc XLink node.

property Show: TXLinkShow

The show attribute of this arc XLink node.

property ShowAsWideString: wideString (readonly)

The show attribute of this arc XLink node as a wideString.

property Title: wideString

The title attribute of this arc XLink node.

property Titles: TXLinkList (readonly)

The list of created, owned and associated title type XLink nodes.

property XLinkFrom: wideString

The from attribute of this arc XLink node.

property XLinkTo: wideString

The to attribute of this arc XLink node.


TXLinkResource = class (TXLinkNode)

Used to represent a resource XLink.

Public Methods
constructor Create;
Public Properties
property Role: wideString

The role attribute of this resource XLink node.

property Title: wideString

The title attribute of this resource XLink node.

property XLinkLabel: wideString

The label attribute of this resource XLink node.


TXLinkTitle = class (TXLinkNode)

Used to represent a title XLink.

Public Methods
constructor Create;

TXLinkCollection = class(TXLinkList)

TXLinkCollection is the main class to access and maintaine XLink nodes.

Public Methods
constructor Create;
procedure AppendContentOf(source: TXLinkCollection; copyObjInf: boolean); virtual;

Used to assign the content of another XLink collection specified in the 'source' parameter to this TXLinkCollection object. If 'copyObjInf' parameter is set to 'true' the associated Objects of the source collection are copied, too.

function AppendXLinkExtended(role, title: wideString; associatedObject: TObject): TXLinkExtended; virtual;

Creates and appends a new extended XLink node to this TXLinkCollection object.

function AppendXLinkSimple(href, role, arcrole, title: wideString; show: TXLinkShow; actuate: TXLinkActuate; associatedObject: TObject): TXLinkExtended; virtual;

Simulates an append operation of a simple XLink. In fact it creates and appends a new extended XLink node to this TXLinkCollection object. Attached to the new extended XLink node is a newly created resource XLink node, a newly created arc XLink node and, unless the 'href' parameter is an empty wideString, a newly created locator XLink node.

function InsertXLinkExtended(index: integer; role, title: wideString; associatedObject: TObject): TXLinkExtended; virtual;

Creates and inserts a new extended XLink node into this TXLinkCollection object.

function InsertXLinkSimple(index: integer; href, role, arcrole, title: wideString; show: TXLinkShow; actuate: TXLinkActuate; associatedObject: TObject): TXLinkExtended; virtual;

Simulates an insert operation of a simple XLink. In fact it creates and inserts a new extended XLink node to this TXLinkCollection object. Attached to the new extended XLink node is a newly created resource XLink node, a newly created arc XLink node and, unless the 'href' parameter is an empty wideString, a newly created locator XLink node.