Libraries.Data.Formats.ExtensibleMarkupReader Documentation

The ExtensibleMarkupReader class reads in data files in what is known as the Extensible Markup Language (XML). This language is a standard format designed for processing a wide variety of types of data. There are different kinds of XML readers, predominately known as DOM (Document Object Model) and SAX (Simple API for XML). This library works like SAX, which means that users of this library must pass an object that will receive messages about the parse as it occurs.

Example Code

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

ExtensibleMarkupReader reader //first create the reader
File xml //then create a file
xml:SetPath("Data.xml") //set its path to a file we've created
reader:Read(xml) //read the xml 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)

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()

GetMarkupListener()

This action gets the markup listener used durring parsing.

Return

Libraries.Data.Formats.MarkupListener: The MarkupListener used durring parsing.

Example

use Libraries.Data.Formats.ExtensibleMarkup

class main
    action main
        ExtensibleMarkupReader reader
        MyMarkupListenerClass myListener
        reader:SetMarkupListener(myListener)
        MarkupListener listenter = reader:GetMarkupListener()
    end
end

class MyMarkupListenerClass is MarkupListener
    action StartElement(Element element)
    end

    action Value(text value)
    end

    action EndElement(Element element)
    end
end

Read(Libraries.System.File file)

This action gets the data from the given file and parses the it as an XML document.

Parameters

Example

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

ExtensibleMarkupReader reader 
//This file should be in the same folder as the executable for this script.
File xml 
xml:SetPath("Data.xml")
reader:Read(xml)

Read(text xml)

This action parses the given text as an XML document

Parameters

  • text xml: The text representing the XML to be parsed.

Example

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

DocumentTypeDefinition MyDocumentTypeDefinition
MyDocumentTypeDefinition:Read("<root></root>")

SetMarkupListener(Libraries.Data.Formats.MarkupListener listener)

This action sets the markup listener to be used durring parsing.

Parameters

Example

use Libraries.Data.Formats.ExtensibleMarkup

class main
    action main
        ExtensibleMarkupReader reader
        MyMarkupListenerClass myListener
        reader:SetMarkupListener(myListener)
    end
end

class MyMarkupListenerClass is MarkupListener
    action StartElement(Element element)
    end

    action Value(text value)
    end

    action EndElement(Element element)
    end
end