{"id":19080421,"url":"https://github.com/seeminglyscience/newxmldocument","last_synced_at":"2025-04-30T06:10:26.547Z","repository":{"id":87373348,"uuid":"96840978","full_name":"SeeminglyScience/NewXmlDocument","owner":"SeeminglyScience","description":"Dynamic DSL for creating XML files","archived":false,"fork":false,"pushed_at":"2017-07-11T02:19:28.000Z","size":12,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-18T21:31:03.936Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","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/SeeminglyScience.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-07-11T02:19:07.000Z","updated_at":"2024-02-22T17:19:19.000Z","dependencies_parsed_at":"2023-03-27T13:05:07.752Z","dependency_job_id":null,"html_url":"https://github.com/SeeminglyScience/NewXmlDocument","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeeminglyScience%2FNewXmlDocument","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeeminglyScience%2FNewXmlDocument/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeeminglyScience%2FNewXmlDocument/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeeminglyScience%2FNewXmlDocument/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SeeminglyScience","download_url":"https://codeload.github.com/SeeminglyScience/NewXmlDocument/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251651231,"owners_count":21621716,"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","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":[],"created_at":"2024-11-09T02:23:33.562Z","updated_at":"2025-04-30T06:10:26.541Z","avatar_url":"https://github.com/SeeminglyScience.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NewXmlDocument\n\nNewXmlDocument is a PowerShell script that allows you to utilize a dynamic DSL (Domain Specific Language) to create new XML documents.\n\n## Features\n\n- Use hashtable syntax for defining attributes\n- Use command syntax for defining elements\n- Mix and match in the same ScriptBlock\n\n## Installation\n\n```powershell\nInstall-Script NewXmlDocument -Scope CurrentUser\n```\n\n## Motivation\n\nThis project was mainly created as a proof of concept for creating dynamic DSLs using the `CommandNotFoundAction` property of `$ExecutionContext.SessionState.InvokeCommand`. Outside of that it's pretty handy if you don't like working with XML.\n\n## Examples\n\n### Generic XML document\n\n```powershell\nNewXmlDocument.ps1 -FilePath '.\\Authors.xml' {\n    Authors {\n        Author {\n            Name = 'John'\n            Age = 30\n        }\n        Author {\n            Name = 'Tim'\n            Age = 10\n            'Writes about horror'\n        }\n    }\n}\n```\n\nProduces an XML file with the following content:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cAuthors\u003e\n  \u003cAuthor Name=\"John\" Age=\"30\" /\u003e\n  \u003cAuthor Name=\"Tim\" Age=\"10\"\u003eWrites about horror\u003c/Author\u003e\n\u003c/Authors\u003e\n```\n\n### Plaster Manifest\n\n```powershell\n$plaster = NewXmlDocument.ps1 -Namespace 'http://www.microsoft.com/schemas/PowerShell/Plaster/v1' {\n    plasterManifest {\n        schemaVersion = '1.0'\n        metadata {\n            name { 'TestManifest' }\n            id { (New-Guid).Guid }\n            version { '0.1.0' }\n            title { 'My Plaster Manifest' }\n            description { 'A plaster manifest created to test this function.' }\n        }\n        parameters {\n            parameter {\n                name = 'ModuleName'\n                type = 'Text'\n                prompt = 'Enter the name of the module'\n            }\n        }\n        content {\n            file {\n                source = '_module.psm1'\n                destination = '${PLASTER_PARAM_ModuleName}.psd1'\n            }\n            requireModule {\n                name = 'Pester'\n                minimumVersion = '3.4.0'\n                message = 'Without Pester, you will not be able to run tests!'\n            }\n        }\n    }\n}\n$plaster.Save('.\\plasterManifest.xml')\n```\n\nProduces an working plaster manifest XML document with the following content:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cplasterManifest schemaVersion=\"1.0\" xmlns=\"http://www.microsoft.com/schemas/PowerShell/Plaster/v1\"\u003e\n  \u003cmetadata\u003e\n    \u003cname\u003eTestManifest\u003c/name\u003e\n    \u003cid\u003e3598072f-578d-42f7-b576-101cadc5efce\u003c/id\u003e\n    \u003cversion\u003e0.1.0\u003c/version\u003e\n    \u003ctitle\u003eMy Plaster Manifest\u003c/title\u003e\n    \u003cdescription\u003eA plaster manifest created to test this function.\u003c/description\u003e\n  \u003c/metadata\u003e\n  \u003cparameters\u003e\n    \u003cparameter name=\"ModuleName\" type=\"Text\" prompt=\"Enter the name of the module\" /\u003e\n  \u003c/parameters\u003e\n  \u003ccontent\u003e\n    \u003cfile source=\"_module.psm1\" destination=\"${PLASTER_PARAM_ModuleName}.psd1\" /\u003e\n    \u003crequireModule name=\"Pester\" minimumVersion=\"3.4.0\" message=\"Without Pester, you will not be able to run tests!\" /\u003e\n  \u003c/content\u003e\n\u003c/plasterManifest\u003e\n```\n\n### Format Ps1Xml\n\n```powershell\nNewXmlDocument.ps1 -FilePath something.format.ps1xml {\n    # Piping 0 here is a bit of a hack to get around the Configuration keyword.\n    0 | Configuration {\n        ViewDefinitions {\n            View {\n                Name { 'System.RuntimeType' }\n                ViewSelectedBy {\n                    TypeName { 'System.RuntimeType' }\n                }\n                TableControl {\n                    TableHeaders {\n                        TableColumnHeader { Width { 10 }}\n                        TableColumnHeader { Label { 'Members' } }\n                    }\n                    TableRowEntries {\n                        TableRowEntry {\n                            TableColumnItems {\n                                TableColumnItem {\n                                    PropertyName { 'Name' }\n                                }\n                                TableColumnItem {\n                                    ScriptBlock { '$_.DeclaredMembers.Name -join \", \"' }\n                                }\n                            }\n                        }\n                    }\n                }\n            }\n        }\n    }\n}\n```\n\nCreates a working format.ps1xml file with the following contents:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cConfiguration\u003e\n  \u003cViewDefinitions\u003e\n    \u003cView\u003e\n      \u003cName\u003eSystem.RuntimeType\u003c/Name\u003e\n      \u003cViewSelectedBy\u003e\n        \u003cTypeName\u003eSystem.RuntimeType\u003c/TypeName\u003e\n      \u003c/ViewSelectedBy\u003e\n      \u003cTableControl\u003e\n        \u003cTableHeaders\u003e\n          \u003cTableColumnHeader\u003e\n            \u003cWidth\u003e10\u003c/Width\u003e\n          \u003c/TableColumnHeader\u003e\n          \u003cTableColumnHeader\u003e\n            \u003cLabel\u003eMembers\u003c/Label\u003e\n          \u003c/TableColumnHeader\u003e\n        \u003c/TableHeaders\u003e\n        \u003cTableRowEntries\u003e\n          \u003cTableRowEntry\u003e\n            \u003cTableColumnItems\u003e\n              \u003cTableColumnItem\u003e\n                \u003cPropertyName\u003eName\u003c/PropertyName\u003e\n              \u003c/TableColumnItem\u003e\n              \u003cTableColumnItem\u003e\n                \u003cScriptBlock\u003e$_.DeclaredMembers.Name -join \", \"\u003c/ScriptBlock\u003e\n              \u003c/TableColumnItem\u003e\n            \u003c/TableColumnItems\u003e\n          \u003c/TableRowEntry\u003e\n        \u003c/TableRowEntries\u003e\n      \u003c/TableControl\u003e\n    \u003c/View\u003e\n  \u003c/ViewDefinitions\u003e\n\u003c/Configuration\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseeminglyscience%2Fnewxmldocument","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseeminglyscience%2Fnewxmldocument","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseeminglyscience%2Fnewxmldocument/lists"}