{"id":15951742,"url":"https://github.com/peteruhnak/xml-magritte-generator","last_synced_at":"2025-10-21T17:59:36.050Z","repository":{"id":93122062,"uuid":"81719027","full_name":"peteruhnak/xml-magritte-generator","owner":"peteruhnak","description":"Library for generating class hierarchy with Magritte descriptions from XML","archived":false,"fork":false,"pushed_at":"2018-10-01T09:29:51.000Z","size":186,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T11:11:09.245Z","etag":null,"topics":["code-generator","magritte","pharo","xml"],"latest_commit_sha":null,"homepage":null,"language":"Smalltalk","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peteruhnak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-12T10:42:59.000Z","updated_at":"2023-03-10T18:37:56.000Z","dependencies_parsed_at":"2023-06-05T00:30:26.183Z","dependency_job_id":null,"html_url":"https://github.com/peteruhnak/xml-magritte-generator","commit_stats":{"total_commits":31,"total_committers":2,"mean_commits":15.5,"dds":"0.032258064516129004","last_synced_commit":"325465fead94c2a317914767a9b9b77aa4752608"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/peteruhnak/xml-magritte-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peteruhnak%2Fxml-magritte-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peteruhnak%2Fxml-magritte-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peteruhnak%2Fxml-magritte-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peteruhnak%2Fxml-magritte-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peteruhnak","download_url":"https://codeload.github.com/peteruhnak/xml-magritte-generator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peteruhnak%2Fxml-magritte-generator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280308521,"owners_count":26308494,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-generator","magritte","pharo","xml"],"created_at":"2024-10-07T13:03:57.083Z","updated_at":"2025-10-21T17:59:35.998Z","avatar_url":"https://github.com/peteruhnak.png","language":"Smalltalk","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DEPRECATED\n\nThis project is deprecated.\n\n# XML Magritte Generator\n[![Build Status](https://travis-ci.org/peteruhnak/xml-magritte-generator.svg?branch=master)](https://travis-ci.org/peteruhnak/xml-magritte-generator) [![Coverage Status](https://coveralls.io/repos/github/peteruhnak/xml-magritte-generator/badge.svg?branch=master)](https://coveralls.io/github/peteruhnak/xml-magritte-generator?branch=master)\n\nWith this library you can take a \"nice\" XML and generate Pharo class hierarchy with Magritte Descriptions for each variable.\nI use [Magritte XML Bindings](https://github.com/magritte-metamodel/XML-Bindings/), which gives the hierarchy free XML import/export.\n\nThe generator will try to guess basic types (Boolean, Integer, Float, String), and the relationship between the parent and child elements (attribute, collection (oneToMany), reference (oneToOne)).\n\nFor example if you feed it \"nice\" XMLs like this one\n\n```xml\n\u003cmachine id=\"12\"\u003e\n\t\u003cversion value=\"1.2.7\" /\u003e\n\t\u003canyOnline\u003efalse\u003c/anyOnline\u003e\n\t\u003cnodes\u003e\n\t\t\u003cnode id=\"node-1\"\u003e\n\t\t\t\u003cisOnline\u003efalse\u003c/isOnline\u003e\n\t\t\t\u003caddress\u003e\n\t\t\t\t\u003chost\u003e127.0.0.1\u003c/host\u003e\n\t\t\t\t\u003cport\u003e80\u003c/port\u003e\n\t\t\t\u003c/address\u003e\n\t\t\u003c/node\u003e\n\t\u003c/nodes\u003e\n\u003c/machine\u003e\n```\n\nit will exhaust class hierarchy and populate it with the content\n\n![machine.png](machine.png)\n\n## Unsupported\n\nSince it is mostly magic, it doesn't always work, for example in the scenarios below.\nNote that it may fail in a variety of unforeseen circumstances, so feel free to [open an issue](https://github.com/peteruhnak/xml-magritte-generator/issues).\n\n#### Namespaces / namespaced names:\n\nI didn't look much into how namespaces are actually propagated through the document; not just prefixing, but also NS inheriting. With consistent document the names can be easily mapped.\n\n```xml\n\u003cxmi:element /\u003e\n\u003celement xml:attr=\"value\" /\u003e\n```\n\n#### Elements with non-uniform repeating children:\n\nBecause I use the `container` element as variable name to hold `child` references.\n\nThis is ok:\n\n```xml\n\u003croot\u003e\n  \u003ccontainer\u003e\n    \u003cchild /\u003e\n    \u003cchild /\u003e\n  \u003c/container\u003e\n\u003c/root\u003e\n```\n\nThis is not ok:\n\n```xml\n\u003croot\u003e\n  \u003ccontainer\u003e\n    \u003cchild /\u003e\n    \u003cchild /\u003e\n    \u003cotherThing /\u003e\n  \u003c/container\u003e\n\u003c/root\u003e\n```\n\n#### Cross-tree references\n\nThis is much easier for XMI, but for generic XML there's a lot of ambiguity.\nMaybe a type override specifying that `source` and `target` are `#REF` ids to `/state-machien/states/state`.\n\n```xml\n\u003cstate-machine\u003e\n\t\u003cstates\u003e\n\t\t\u003cstate id=\"10\" /\u003e\n\t\t\u003cstate id=\"15\" /\u003e\n\t\u003c/states\u003e\n\t\u003ctransitions\u003e\n\t\t\u003ctransition source=\"10\" target=\"15\" /\u003e\n\t\u003c/transitions\u003e\n\u003cstate-machine\u003e\n```\n\n## Usage\n\nUse the generator along those lines:\n\n*`dom` is an instance of `XMLDocument`*\n\n### Generator\n\n```smalltalk\ngen := XOGStructureGenerator new.\n\"optional attributes, they have their default values\"\ngen packageName: 'MachineGenerated'.\ngen classPrefix: 'XXX'. \"to avoid name conflicts\"\ngen rootClassName: 'MXObject'. \"a class from which all the classes will inherit\"\n\n\"run the generator; this will NOT create the code yet\"\ngen processDocument: dom.\n\n\"retrieve CBChangesSet¹, so additional modifications can be performed\"\nchanges := gen changes.\n\n(CBChangesBrowser changes: changes refactoringChanges) open.\n```\n\n¹ Documentation on CBChangesSet is available in [Changes Builder project](https://github.com/peteruhnak/pharo-changes-builder)\n\n\n## Connecting with XML nodes\n\n**NOTE** that all the generated classes must contain this method:\n\n```\ndescriptionContainer\n\t\u003cmagritteContainer\u003e\n\t^ super descriptionContainer\n\t\txmlElementName: self class xmlElementName;\n\t\tyourself\n```\n\nyou can either:\n\n* use `'MXObject'` which implements it\n* add the method to your own root class\n* use `TMXDescription` trait\n* do whatever you want\n\n## Reading / Writing\n\n### XML → Object\n\n```smalltalk\nobj := XXXClassForRootElement new magritteDescription fromXmlNode: dom root.\n```\n\n### Object → XML\n\n```smalltalk\nobj magritteDescription toXmlDocument: obj.\n```\n\n### Inference\n\nThe inferencers guess the element/attribute value type (String, Boolean, ...) as well as their type that relates them to their attributes and children (list, complex, inlined, ...).\n\n```smalltalk\ntypes := XOGTypeClassification new classificationFor: dom.\nvalueTypes := XOGValueTypeInference new inferDocument: dom.\nclassification := XOGElementClassification new classifyTypes: types andValues: valueTypes.\n```\n\n## Installation\n\n```smalltalk\nMetacello new\n    baseline: #XMLMAGenerator;\n    repository: 'github://peteruhnak/xml-magritte-generator/repository';\n    load\n```\n\nDependencies:\n\n```smalltalk\nBaselineOfXMLMAGenerator project latestVersion projects asArray collect: #name. \"#('XMLParser' 'XPath' 'Magritte' 'MagritteXMLBindings' 'ChangesBuilder')\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeteruhnak%2Fxml-magritte-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeteruhnak%2Fxml-magritte-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeteruhnak%2Fxml-magritte-generator/lists"}