{"id":20633176,"url":"https://github.com/publica-re/react-xml-transformer","last_synced_at":"2026-04-17T23:31:29.689Z","repository":{"id":57138409,"uuid":"282292750","full_name":"publica-re/react-xml-transformer","owner":"publica-re","description":"A XSLT-inspired XML transformer for React","archived":false,"fork":false,"pushed_at":"2020-07-30T15:01:03.000Z","size":2283,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-18T01:05:21.777Z","etag":null,"topics":["react","xml-transformer","xslt"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/publica-re.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}},"created_at":"2020-07-24T18:43:22.000Z","updated_at":"2024-05-31T11:40:33.000Z","dependencies_parsed_at":"2022-09-02T19:22:33.401Z","dependency_job_id":null,"html_url":"https://github.com/publica-re/react-xml-transformer","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/publica-re%2Freact-xml-transformer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/publica-re%2Freact-xml-transformer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/publica-re%2Freact-xml-transformer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/publica-re%2Freact-xml-transformer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/publica-re","download_url":"https://codeload.github.com/publica-re/react-xml-transformer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242633882,"owners_count":20161234,"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":["react","xml-transformer","xslt"],"created_at":"2024-11-16T14:19:05.358Z","updated_at":"2026-04-17T23:31:24.669Z","avatar_url":"https://github.com/publica-re.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-xml-transformer ⚙\n\n\u003e A XSLT-inspired XML transformer for React\n\n[![NPM](https://img.shields.io/npm/v/react-xml-transformer.svg)](https://www.npmjs.com/package/react-xml-transformer) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n## Note\n\nThis is currently a proof of concept. I do not recommend using it in a production build.\n\nContributions are still welcome to ship it into the wild ! 🚀\n\n## Demonstration\n\nYou can find a demo [here](https://react-xml-transformer.publica.re/demo/) and the source code on [GitHub](https://github.com/publica-re/react-xml-transformer/blob/master/example/) !\n\n## Install\n\n```bash\nyarn add react-xml-transformer\n```\n\n## Usage\n\n### Basic usage\n\nFirst, you have to note that we rely on a global context to which the templates are registered, which allows us to use concurrent template systems in the same project.\n\nWe thus recommend to create a file `context.ts` with the following code:\n\n```ts\nimport Transformer from \"react-xml-transformer\";\nconst ctx = new Transformer.Context();\nexport default ctx;\n```\n\nWhen that's done, you can create your main component that imports your context. That's a good place to load the XML file you want to render too, but you can also do as I did, that is to pass the document to your `App`.\n\n```ts\nimport React from \"react\";\nimport Transformer from \"react-xml-transformer\";\nimport ctx from \"./context\";\n\nexport default class App extends React.Component\u003c{ document: XMLDocument }\u003e {\n  render() {\n    if (this.state.document !== undefined)\n      return (\n        \u003cTransformer.Stylesheet\n          contextData={ctx}\n          contextDocument={this.state.document}\n        /\u003e\n      );\n    return null;\n  }\n}\n```\n\nYou're now ready to implement your first template ! In order to do that, just inherit `Transformer.Template` and you can get rocking !\n\n```ts\nimport * as React from \"react\";\nimport Transformer from \"react-xml-transformer\";\nimport ctx from \"./context\";\n\nexport default class Para extends Transformer.Template {\n  render() {\n    return (\n      \u003cp\u003e\n        \u003cTransformer.ApplyTemplates {...this.ctx} /\u003e\n      \u003c/p\u003e\n    );\n  }\n}\n\nctx.register(Para, { path: \"para\" });\n```\n\nNotice two things: 1. we imported our `context` 2. we used it to register our `template`. The `path` is just the XPath that has to match your node !\n\nIt now only remains to import our newly defined template in our `App`, and we're done !\n\n```ts\n...\nimport Transformer from \"react-xml-transformer\";\nimport ctx from \"./context\";\nimport \"./Para\";\n\nexport default class App extends React.Component\u003c{ document: XMLDocument }\u003e {\n...\n```\n\n### Go futher\n\nYou can take a look at [GitHub](https://github.com/publica-re/react-xml-transformer/blob/master/example/) for an example or the [documentation](https://react-xml-transformer.publica.re) !\n\n## License\n\nCopyright 2020, [David Baumgartner](https://github.com/dvbmgr).\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see \u003chttps://www.gnu.org/licenses/\u003e.\n\n## Contributing\n\nI welcome happily contributions to pull request through [GitHub](https://github.com/publica-re/react-xml-transformer).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpublica-re%2Freact-xml-transformer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpublica-re%2Freact-xml-transformer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpublica-re%2Freact-xml-transformer/lists"}