Libraries.Data.Formats.DocumentTypeDefinition Documentation

The DocumentTypeDefinition class reads document type definition declarations defined within an XML document.

Example Code

use Libraries.System.File
use Libraries.Data.Formats

DocumentTypeDefinition reader //first create the reader
File dtd //then create a file
dtd:SetPath("Data.dtd") //set its path to a file we've created
reader:Read(dtd) //read the dtd file

Inherits from: Libraries.Language.Object

Actions Documentation

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetEntityValue(text name)

This action gets the entity value for the entity name passed to it.

Parameters

  • text name

Return

text: The value of the entity.

Example

use Libraries.Data.Formats

DocumentTypeDefinition MyDocumentTypeDefinition
MyDocumentTypeDefinition:Read("<!DOCTYPE note [<!ENTITY language "Quorum">]>")
output MyDocumentTypeDefinition:GetEntityValue("language") // output will be Quorum

GetExternalFileName()

This action gets the external file for this document type definition.

Return

text: The name of the external file used durring parsing.

Example

use Libraries.System.File
use Libraries.Data.Formats

DocumentTypeDefinition MyDocumentTypeDefinition
File dtd 
dtd:SetPath("Data.dtd")
MyDocumentTypeDefinition:Read(dtd)

if MyDocumentTypeDefinition:HasExternalFile()
    output MyDocumentTypeDefinition:GetExternalFileName() // output will be "Data.dtd"
end

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetRootElement()

This action gets the name of the root element for this document type definition.

Return

text: The name of the root element.

Example

use Libraries.System.File
use Libraries.Data.Formats

DocumentTypeDefinition MyDocumentTypeDefinition
File dtd 
dtd:SetPath("Data.dtd")
MyDocumentTypeDefinition:Read(dtd)
text value = MyDocumentTypeDefinition:GetRootElement()

HasExternalFile()

This action checks to see if there is an external file for this document type definition.

Return

boolean: True if an external file was used when parsing the document type definition, false otherwise.

Example

use Libraries.System.File
use Libraries.Data.Formats

DocumentTypeDefinition MyDocumentTypeDefinition
File dtd 
dtd:SetPath("Data.dtd")
MyDocumentTypeDefinition:Read(dtd)
boolean value = MyDocumentTypeDefinition:HasExternalFile() // value will be true

Read(text dtd)

This action parses the given text as a document type definition

Parameters

  • text dtd: The text representing the document type dfinition to be parsed.

Example

use Libraries.System.File
use Libraries.Data.Formats

DocumentTypeDefinition MyDocumentTypeDefinition
MyDocumentTypeDefinition:Read("<!DOCTYPE note [<!ENTITY language "Quorum">]>")

Read(Libraries.System.File file)

This action gets the data from the given file and parses the document type definition in it.

Parameters

Example

use Libraries.System.File
use Libraries.Data.Formats

DocumentTypeDefinition MyDocumentTypeDefinition
File dtd 
dtd:SetPath("Data.dtd")
MyDocumentTypeDefinition:Read(dtd)

SetSourceDirectory(text directory)

This action sets the source directory for the document type definition. If the DTD uses external sources, they need to be in this directory.

Parameters

  • text directory: The directory of external sources.

Example

use Libraries.Data.Formats

DocumentTypeDefinition MyDocumentTypeDefinition
MyDocumentTypeDefinition:SetSourceDirectory("C:\")
MyDocumentTypeDefinition:Read("<!DOCTYPE note SYSTEM "note.dtd">")