Module Interface XML:Basic:Element

SUMMARY: MODULE | CLASS | TYPE | PROC | VAR | CONST | DETAIL: TYPE | PROC | VAR | CONST

# XML:Basic:Element

### Import List

        XML:DTD
        XML:Locator
        XML:Writer

Class List
Element |
ElementFactory |
List |
PCData |
RootFactory |
StringBuffer |

Class Summary: Element [Detail]
      +--XML:Basic:Element.Element
Field Summary
next-: Element
Constructor Summary
InitElement(Element)
Method Summary
AddAttribute(String, AttValue): BOOLEAN Adds the attribute localName to the element elem.
AddCharacters(VAR StringVar, CharPos, CharPos) Adds character data to the content of element elem.
AddChild(Element) Adds the parsed child element child to elem.
CheckElement(): String Called at the very end of an XML element (after Element.MissingChild) to perform consistency checks on the whole element.
HasMixedContent(): BOOLEAN Returns TRUE, if element elem containes mixed content.
IsAttributeName(String): BOOLEAN Determines if localName is a valid name for an attribute of elem.
IsChildName(String): BOOLEAN Determines if localName is a valid name for a child element of elem.
MissingAttribute(): String Called at the end of the attribute list of a start tag to determine if any required attributes are missing.
MissingChild(): String Called at the end of an XML element to determine if any required child elements are missing.
NewChild(String): Element Creates a new instance of the child element if the child can appear at the current place in the element.
SetLocator(Locator) Using the locator l, the context of the element and its attributes can be determined.
Write(Writer) Serializes the object elem into an XML element.

Class Summary: ElementFactory [Detail]
      +--XML:Basic:Element.ElementFactory

Class Summary: List [Detail]
      +--XML:Basic:Element.List
Field Summary
head-: Element
tail-: Element
Constructor Summary
NewList(): List
Method Summary
Append(Element)
IsEmpty(): BOOLEAN
Write(Writer)

Class Summary: PCData [Detail]
      +---XML:Basic:Element.Element
           |
           +--XML:Basic:Element.PCData
Field Summary
chars-: StringBuffer
Inherited Fields
From XML:Basic:Element.Element: next
Constructor Summary
InitPCData(PCData)
NewPCData(): PCData
Method Summary
AddCharacters(VAR StringVar, CharPos, CharPos) Adds character data to the content of element pcdata.
Normalize(BOOLEAN, BOOLEAN)
Write(Writer) Serializes the object pcdata into an XML element.
Inherited Methods
From XML:Basic:Element.Element: AddAttribute, AddCharacters, AddChild, CheckElement, HasMixedContent, IsAttributeName, IsChildName, MissingAttribute, MissingChild, NewChild, SetLocator, Write

Class Summary: RootFactory [Detail]
      +--XML:Basic:Element.RootFactory
Constructor Summary
NewRootFactory(): RootFactory
Method Summary
AddFactory(StringVar, FactoryFunction)
NewElement(String): Element Called with the name of the root element of an XML document.

Class Summary: StringBuffer [Detail]
      +--XML:Basic:Element.StringBuffer
Field Summary
array-: String
length-: LONGINT
Constructor Summary
NewStringBuffer(StringVar): StringBuffer
Method Summary
AddCharacters(VAR StringVar, CharPos, CharPos)

Type Summary
AttValue = AttValue
CharPos = CharPos
FactoryFunction = (): Element
String = String
StringVar = StringVar

Procedure Summary
NewString(StringVar): String

Class Detail: Element

Field Detail

### next

    FIELD next-: Element

Constructor Detail

### InitElement

    PROCEDURE InitElement(elem: Element)

Method Detail

### AddAttribute

    PROCEDURE (elem: Element) AddAttribute(localName: String;
                           value: AttValue): BOOLEAN

> Adds the attribute localName to the element elem. If the attribute value value is valid, result is TRUE. Otherwise, this functions returns FALSE and the parser will generate an appropriate error message. The default implementation always returns FALSE.

### AddCharacters

    PROCEDURE (elem: Element) AddCharacters(VAR chars: StringVar;
                            charsStart: CharPos;
                            charsEnd: CharPos)

> Adds character data to the content of element elem. The new characters are in the character interval ``chars[charsStart..charsEnd-1]`'.

### AddChild

    PROCEDURE (elem: Element) AddChild(child: Element)

> Adds the parsed child element child to elem. The object child was previously created with Element.NewChild.

### CheckElement

    PROCEDURE (elem: Element) CheckElement(): String

> Called at the very end of an XML element (after Element.MissingChild) to perform consistency checks on the whole element. For example, this method makes sure that the combination of attributes and content does not violate any rules of the application.

> Result is an error message if some part of the element is invalid, and NIL on success. By default, NIL is returned.

> Any code that should be evaluted if an element is completed, should be placed in this method.

### HasMixedContent

    PROCEDURE (elem: Element) HasMixedContent(): BOOLEAN

> Returns TRUE, if element elem containes mixed content. In this case, the element may contain character data other than whitespace. For element that has only element content, Element.AddCharacters is not called, and an error is signalled if the element content includes non-whitespace characters. By default, element-only content is assumed.

### IsAttributeName

    PROCEDURE (elem: Element) IsAttributeName(localName: String): BOOLEAN

> Determines if localName is a valid name for an attribute of elem. If result is FALSE, the parser will generate an appropriate error message. By default, all attribute names are rejected.

### IsChildName

    PROCEDURE (elem: Element) IsChildName(localName: String): BOOLEAN

> Determines if localName is a valid name for a child element of elem. If result is FALSE, the parser will generate an appropriate error message. By default, all child names are rejected.

### MissingAttribute

    PROCEDURE (elem: Element) MissingAttribute(): String

> Called at the end of the attribute list of a start tag to determine if any required attributes are missing. Result is the name of one of the missing attributes, or NIL if all required attributes are present. The default behavious is to return NIL.

### MissingChild

    PROCEDURE (elem: Element) MissingChild(): String

> Called at the end of an XML element to determine if any required child elements are missing. Result is the name of one of the missing childs, or NIL if all required child elements are present. By default, NIL is returned.

### NewChild

    PROCEDURE (elem: Element) NewChild(localName: String): Element

> Creates a new instance of the child element if the child can appear at the current place in the element. Otherwise, it returns NIL. The default implementation always returns NIL.

### SetLocator

    PROCEDURE (elem: Element) SetLocator(l: Locator)

> Using the locator l, the context of the element and its attributes can be determined. This can be used to get the base URI relative to which an URI attribute value should be expanded. This method is called after an element has been created, and before any attribute or content data is passed on to it.

### Write

    PROCEDURE (elem: Element) Write(writer: Writer)

> Serializes the object elem into an XML element. The data is generated with the writer writer.

Class Detail: ElementFactory

Class Detail: List

Field Detail

### head

    FIELD head-: Element

### tail

    FIELD tail-: Element

Constructor Detail

### NewList

    PROCEDURE NewList(): List

Method Detail

### Append

    PROCEDURE (list: List) Append(elem: Element)

### IsEmpty

    PROCEDURE (list: List) IsEmpty(): BOOLEAN

### Write

    PROCEDURE (list: List) Write(w: Writer)

Class Detail: PCData

Field Detail

### chars

    FIELD chars-: StringBuffer

Constructor Detail

### InitPCData

    PROCEDURE InitPCData(pcdata: PCData)

### NewPCData

    PROCEDURE NewPCData(): PCData

Method Detail

### AddCharacters

    PROCEDURE (pcdata: PCData) AddCharacters(VAR chars: StringVar;
                            charsStart: CharPos;
                            charsEnd: CharPos)

> Adds character data to the content of element pcdata. The new characters are in the character interval ``chars[charsStart..charsEnd-1]`'.

> [Description inherited from AddCharacters]

> Redefines: AddCharacters

### Normalize

    PROCEDURE (pcdata: PCData) Normalize(stripLeadingWS: BOOLEAN;
                        stripTrailingWS: BOOLEAN)

### Write

    PROCEDURE (pcdata: PCData) Write(writer: Writer)

> Serializes the object pcdata into an XML element. The data is generated with the writer writer.

> [Description inherited from Write]

> Redefines: Write

Class Detail: RootFactory

Constructor Detail

### NewRootFactory

    PROCEDURE NewRootFactory(): RootFactory

Method Detail

### AddFactory

    PROCEDURE (rf: RootFactory) AddFactory(name: StringVar;
                         gen: FactoryFunction)

### NewElement

    PROCEDURE (rf: RootFactory) NewElement(name: String): Element

> Called with the name of the root element of an XML document. Result is a new instance of the element if the name is valid, or NIL otherwise.

Class Detail: StringBuffer

Field Detail

### array

    FIELD array-: String

### length

    FIELD length-: LONGINT

Constructor Detail

### NewStringBuffer

    PROCEDURE NewStringBuffer(value: StringVar): StringBuffer

Method Detail

### AddCharacters

    PROCEDURE (sb: StringBuffer) AddCharacters(VAR chars: StringVar;
                            charsStart: CharPos;
                            charsEnd: CharPos)

Type Detail

### AttValue

    TYPE AttValue = AttValue

### CharPos

    TYPE CharPos = CharPos

### FactoryFunction

    TYPE FactoryFunction = (): Element

### String

    TYPE String = String

### StringVar

    TYPE StringVar = StringVar

Procedure Detail

### NewString

    PROCEDURE NewString(value: StringVar): String