[Oberon] XML Components

Yaroslav Romanchenko tobject at bk.ru
Sun Mar 14 13:42:12 MET 2010

Hi, Community!

I've made some XML components hierarchy.
E.g. there's component-container named DrakonDocument. It may has several instances of other child containers named DrakonSchema.
Every DrakonSchema container may has only elements (not containers) named DrakonElementHead, DrakonElementAction, ... and so on.
Then I've built at runtime simple document and stored it to XML successfully.
But when I try to deserialize XML back to component structure in memory it seems fails.
At first I've tried to make repository, load it and then load XML. Without success...
Actually, then I've tried experiment with standard repository too, but result is strange:
Repositories.Load Standard ~
Loading repository 'Standard' ... done.
TestComponents.Test Button ~
Component 'Button' not found

Is it bug???

Then I've rewrote code of WMComponents.Load such way to use own instance of ElementRegistry:
PROCEDURE RegisterAndLoad*(CONST filename: ARRAY OF CHAR; VAR document: DrakonComponents.DrakonDocument);
	content: XML.Content;
	registry: XML.ElementRegistry;
	name: Strings.String;

	(* Try to register elements' generators *)
	registry.RegisterElementByName("DrakonDocument", "DrakonComponents", "GenDrakonDocument");
	registry.RegisterElementByName("DrakonSchema", "DrakonComponents", "GenDrakonSchema");
	registry.RegisterElementByName("DrakonElementHead", "DrakonComponents", "GenDrakonElementHead");
	registry.RegisterElementByName("DrakonElementAction", "DrakonComponents", "GenDrakonElementAction");
	registry.RegisterElementByName("DrakonElementEnd", "DrakonComponents", "GenDrakonElementEnd");
	registry.RegisterElementByName("DrakonElementNode", "DrakonComponents", "GenDrakonElementNode");
	document := NIL;
	content := LoadWithRegistry(filename, registry);
	IF content # NIL THEN
		KernelLog.String("xml loaded!");
	IF content IS XML.Element THEN
		name := content(XML.Element).GetName();
	IF content IS DrakonComponents.DrakonDocument THEN
		KernelLog.String("content IS DrakonComponents.DrakonDocument");
		document := content(DrakonComponents.DrakonDocument)
END RegisterAndLoad;

It produces output:
xml loaded!

So, the root element of XML is XML.Element and element's name is correct, but element isn't of DrakonComponents.DrakonDocument type.

Modules attached below.
To create XML, execute: DrakonTest.TestCreate schema.XML ~
To load: DrakonTest.TestLoad schema.XML ~

Cheers, SAGE
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Drakon.zip
Type: application/zip
Size: 3812 bytes
Desc: not available
Url : https://lists.inf.ethz.ch/pipermail/oberon/attachments/20100314/5a5d0b8a/Drakon.zip

More information about the Oberon mailing list