{"id":15009286,"url":"https://github.com/gatkin/declxml","last_synced_at":"2025-09-11T01:07:37.694Z","repository":{"id":56221525,"uuid":"101486918","full_name":"gatkin/declxml","owner":"gatkin","description":"Declarative XML processing for Python","archived":false,"fork":false,"pushed_at":"2020-11-19T18:59:03.000Z","size":238,"stargazers_count":38,"open_issues_count":9,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-08-31T18:23:02.761Z","etag":null,"topics":["python","python27","python3","xml","xml-parser","xml-processing","xml-serializer"],"latest_commit_sha":null,"homepage":"https://declxml.readthedocs.io/en/latest/","language":"Python","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/gatkin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-26T13:18:42.000Z","updated_at":"2025-03-19T02:09:16.000Z","dependencies_parsed_at":"2022-08-15T15:00:27.876Z","dependency_job_id":null,"html_url":"https://github.com/gatkin/declxml","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/gatkin/declxml","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gatkin%2Fdeclxml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gatkin%2Fdeclxml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gatkin%2Fdeclxml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gatkin%2Fdeclxml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gatkin","download_url":"https://codeload.github.com/gatkin/declxml/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gatkin%2Fdeclxml/sbom","scorecard":{"id":419604,"data":{"date":"2025-08-11","repo":{"name":"github.com/gatkin/declxml","commit":"8cc2ff2fa813aa9d4c27d1964fe7d865029a1298"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/27 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 4 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T00:50:42.162Z","repository_id":56221525,"created_at":"2025-08-19T00:50:42.162Z","updated_at":"2025-08-19T00:50:42.162Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274557583,"owners_count":25307516,"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-09-10T02:00:12.551Z","response_time":83,"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":["python","python27","python3","xml","xml-parser","xml-processing","xml-serializer"],"created_at":"2024-09-24T19:24:16.954Z","updated_at":"2025-09-11T01:07:37.669Z","avatar_url":"https://github.com/gatkin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# declxml - Declarative XML Processing\n\n[![PyPI version](https://badge.fury.io/py/declxml.svg)](https://badge.fury.io/py/declxml)\n[![Python Versions](https://img.shields.io/pypi/pyversions/declxml.svg)](https://pypi.org/project/declxml/)\n[![Build Status](https://gregscottatkin.visualstudio.com/declxml/_apis/build/status/gatkin.declxml)](https://gregscottatkin.visualstudio.com/declxml/_build/latest?definitionId=1)\n[![codecov](https://codecov.io/gh/gatkin/declxml/branch/master/graph/badge.svg)](https://codecov.io/gh/gatkin/declxml)\n[![Documentation Status](https://readthedocs.org/projects/declxml/badge/?version=latest)](https://declxml.readthedocs.io/en/latest/?badge=latest)\n[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/gatkin/declxml/blob/master/LICENSE)\n\nXML processing made easy. No more writing and maintaining dozens or hundreds of lines of imperative serialization and parsing logic. With declxml, you declaratively define the structure of your XML document and let declxml handle the rest.\n\n## Installation\n\nInstall using either pip\n\n```bash\npip install declxml\n```\n\nor [Pipenv](https://docs.pipenv.org/)\n\n```bash\npipenv install declxml\n```\n\n## Documentation\n\nFor detailed documentation, see the project's [documentation page](http://declxml.readthedocs.io/).\n\n## Usage\n\nGiven some XML to process\n\n```xml\n\u003cauthor\u003e\n    \u003cname\u003eRobert A. Heinlein\u003c/name\u003e\n    \u003cbirth-year\u003e1907\u003c/birth-year\u003e\n    \u003cbook\u003e\n        \u003ctitle\u003eStarship Troopers\u003c/title\u003e\n        \u003cpublished\u003e1959\u003c/published\u003e\n    \u003c/book\u003e\n    \u003cbook\u003e\n        \u003ctitle\u003eStranger in a Strange Land\u003c/title\u003e\n        \u003cpublished\u003e1961\u003c/published\u003e\n    \u003c/book\u003e\n\u003c/author\u003e\n```\n\nCreate a declxml processor that defines the structure of the document\n\n```python\n\u003e\u003e\u003e import declxml as xml\n\n\u003e\u003e\u003e author_processor = xml.dictionary('author', [\n...     xml.string('name'),\n...     xml.integer('birth-year'),\n...     xml.array(xml.dictionary('book', [\n...         xml.string('title'),\n...         xml.integer('published')\n...     ]), alias='books')\n... ])\n\n```\n\nThen use that processor to parse the XML data\n\n```python\n\u003e\u003e\u003e from pprint import pprint\n\u003e\u003e\u003e author_xml = \"\"\"\n... \u003cauthor\u003e\n...     \u003cname\u003eRobert A. Heinlein\u003c/name\u003e\n...     \u003cbirth-year\u003e1907\u003c/birth-year\u003e\n...     \u003cbook\u003e\n...         \u003ctitle\u003eStarship Troopers\u003c/title\u003e\n...         \u003cpublished\u003e1959\u003c/published\u003e\n...     \u003c/book\u003e\n...     \u003cbook\u003e\n...         \u003ctitle\u003eStranger in a Strange Land\u003c/title\u003e\n...         \u003cpublished\u003e1961\u003c/published\u003e\n...     \u003c/book\u003e\n... \u003c/author\u003e\n... \"\"\"\n\u003e\u003e\u003e pprint(xml.parse_from_string(author_processor, author_xml))\n{'birth-year': 1907,\n     'books': [{'published': 1959, 'title': 'Starship Troopers'},\n               {'published': 1961, 'title': 'Stranger in a Strange Land'}],\n     'name': 'Robert A. Heinlein'}\n\n```\n\nThe same processor can also be used to serialize data to XML\n\n```python\n\u003e\u003e\u003e author = {\n...     'birth-year': 1920,\n...     'name': 'Issac Asimov',\n...     'books': [\n...         {\n...             'title': 'I, Robot',\n...             'published': 1950\n...         },\n...         {\n...             'title': 'Foundation',\n...             'published': 1951\n...         }\n...     ]\n...  }\n\n\n\u003e\u003e\u003e print(xml.serialize_to_string(author_processor, author, indent='    '))\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cauthor\u003e\n    \u003cname\u003eIssac Asimov\u003c/name\u003e\n    \u003cbirth-year\u003e1920\u003c/birth-year\u003e\n    \u003cbook\u003e\n        \u003ctitle\u003eI, Robot\u003c/title\u003e\n        \u003cpublished\u003e1950\u003c/published\u003e\n    \u003c/book\u003e\n    \u003cbook\u003e\n        \u003ctitle\u003eFoundation\u003c/title\u003e\n        \u003cpublished\u003e1951\u003c/published\u003e\n    \u003c/book\u003e\n\u003c/author\u003e\n\n```\n\nWant to work with objects instead of dictionaries? You can do that with declxml too\n\n```python\n\u003e\u003e\u003e class Author:\n...\n...     def __init__(self):\n...         self.name = None\n...         self.birth_year = None\n...         self.books = []\n...\n...     def __repr__(self):\n...         return 'Author(name=\\'{}\\', birth_year={}, books={})'.format(\n...             self.name, self.birth_year, self.books)\n\n\u003e\u003e\u003e class Book:\n...\n...     def __init__(self):\n...         self.title = None\n...         self.published = None\n...\n...     def __repr__(self):\n...         return 'Book(title=\\'{}\\', published={})'.format(self.title, self.published)\n...\n\n\u003e\u003e\u003e author_processor = xml.user_object('author', Author, [\n...     xml.string('name'),\n...     xml.integer('birth-year', alias='birth_year'),\n...     xml.array(xml.user_object('book', Book, [\n...         xml.string('title'),\n...         xml.integer('published')\n...     ]), alias='books')\n... ])\n\n\u003e\u003e\u003e xml.parse_from_string(author_processor, author_xml)\nAuthor(name='Robert A. Heinlein', birth_year=1907, books=[Book(title='Starship Troopers', published=1959), Book(title='Stranger in a Strange Land', published=1961)])\n\n```\n\nWhat about namedtuples, you say? Those are extremely useful, and declxml lets you work with them as well\n\n```python\n\u003e\u003e\u003e from collections import namedtuple\n\n\n\u003e\u003e\u003e Author = namedtuple('Author', ['name', 'birth_year', 'books'])\n\u003e\u003e\u003e Book = namedtuple('Book', ['title', 'published'])\n\n\n\u003e\u003e\u003e author_processor = xml.named_tuple('author', Author, [\n...     xml.string('name'),\n...     xml.integer('birth-year', alias='birth_year'),\n...     xml.array(xml.named_tuple('book', Book, [\n...         xml.string('title'),\n...         xml.integer('published')\n...     ]), alias='books')\n... ])\n\n\u003e\u003e\u003e xml.parse_from_string(author_processor, author_xml)\nAuthor(name='Robert A. Heinlein', birth_year=1907, books=[Book(title='Starship Troopers', published=1959), Book(title='Stranger in a Strange Land', published=1961)])\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgatkin%2Fdeclxml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgatkin%2Fdeclxml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgatkin%2Fdeclxml/lists"}