{"id":21429594,"url":"https://github.com/mayank-02/xmlalchemy","last_synced_at":"2025-09-08T19:33:35.040Z","repository":{"id":228951231,"uuid":"742166846","full_name":"mayank-02/xmlalchemy","owner":"mayank-02","description":"Command line tool to parse XML files and evaluate queries","archived":false,"fork":false,"pushed_at":"2024-06-16T17:55:37.000Z","size":1593,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-16T21:48:38.835Z","etag":null,"topics":["antlr4","join-optimizations","maven","parser","visitor","xml","xpath","xquery"],"latest_commit_sha":null,"homepage":"","language":"Java","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/mayank-02.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":"2024-01-11T22:24:50.000Z","updated_at":"2025-02-12T19:20:16.000Z","dependencies_parsed_at":"2024-03-21T10:17:30.687Z","dependency_job_id":"ac8d9ac6-f1d9-4f08-818a-8ad96b7b320d","html_url":"https://github.com/mayank-02/xmlalchemy","commit_stats":null,"previous_names":["mayank-02/xmlalchemy"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mayank-02/xmlalchemy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayank-02%2Fxmlalchemy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayank-02%2Fxmlalchemy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayank-02%2Fxmlalchemy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayank-02%2Fxmlalchemy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mayank-02","download_url":"https://codeload.github.com/mayank-02/xmlalchemy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayank-02%2Fxmlalchemy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274231437,"owners_count":25245585,"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-08T02:00:09.813Z","response_time":121,"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":["antlr4","join-optimizations","maven","parser","visitor","xml","xpath","xquery"],"created_at":"2024-11-22T22:18:24.249Z","updated_at":"2025-09-08T19:33:35.017Z","avatar_url":"https://github.com/mayank-02.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg width=12.5% src=\"./docs/logo.png\"\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003cimg width=25% src=\"./docs/logo-xmlalchemy.png\"\u003e\u003c/p\u003e\n\n\u003cp align=\"center\u003e\n\n![Coverage](https://img.shields.io/badge/coverage-100%25-darkgreen)\n![Contributions welcome](https://img.shields.io/badge/contributions-welcome-green.svg)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\n\u003c/p\u003e\n\nXMLAlchemy is a command line tool that can be used to parse XML files and evaluate queries. It supports the following operations:\n1. Evaluate XPath expressions.\n2. Evaluate XQuery expressions.\n3. Rewrite certain class of XQuery expressions and optimize its evaluation.\n\nXPath and XQuery references specifications can be found [here](./docs/xpath-and-xquery-semantics.pdf), where as join optimizations can be found [here](./docs/join-optimizations.pdf).\n\n## Setup\n\n1. `mvn clean install -U` to install the dependencies.\n2. `mvn test` to run the tests.\n3. `mvn clean package` to package the project and create the jar file.\n4. `java -jar target/xmlalchemy-1.0.0.jar --help` to run the program.\n\n## Authors\n\n1. [Mayank Jain](https://jainmayank.me)\n2. [Jonathan Woenardi](https://github.com/jonathanwoenardi)\n\n## Architecture\n\n### Directory Structure\n\n```plaintext\n├── main                                   # Main source code\n│   ├── antlr4                             # ANTLR4 grammar files\n│   │   └── edu/ucsd/xmlalchemy\n│   ├── java\n│   │   └── edu/ucsd/xmlalchemy            # Main package\n│   │                ├── xpath             # Classes for XPath expressions\n│   │                ├── xquery            # Classes for XQuery expressions\n│   │                ├── Expression.java   # Interface which all other expressions implement\n│   │                ├── Formatter.java    # Format XQuery expressions\n│   │                ├── Optimizer.java    # Rewrite and optimize XQuery expressions\n│   │                ├── Visitor.java      # Parses query and constructs IR/expressions\n│   │                ├── XPath.java        # XPath CLI\n│   │                └── XQuery.java       # XQuery CLI\n│   └── resources/style.xslt               # Style file for formatting XML output\n├── test                                   # Test source code\n│   ├── java\n│   │   └── edu/ucsd/xmlalchemy            # Main package\n│   └── resources\n│        └── milestone{1,2,3}              # Test cases for each milestone\n│           ├── document                   # XML files\n│           ├── input                      # Input queries\n│           └── output                     # Expected output and rewritten queries\n├── README.md                              # This file\n└── pom.xml                                # Maven configuration file\n```\n\n### Program Flow\n\n![Program Flow](./docs/program-flow.png)\n\n## Highlights\n\n1. Internal representation for all kinds of XQuery constructs which provides modularity, extensibility, and rewriting without string manipulation.\n2. Implement Wong-Youseffi algorithm for join order optimization.\n3. Optimize hash-based join by choosing the smaller table to build the hash table.\n4. Cache file reads for better performance.\n5. Implement custom serializer and formatter for XQuery queries.\n6. CLI for evaluating XPath and XQuery expressions with support for output and optimize flags.\n7. Maven project setup for dependency management and build automation.\n8. 100% test coverage powered by a comprehensive and fully-automated test suite with ~100 test cases testing evaluation, serialization and query rewriting.\n\n## References\n\n1. ANTLR tutorials and best practices:\n   * [ANTLR4](https://www.antlr.org/) and [ANTLR Lab](http://lab.antlr.org)\n   * [Best practices for ANTLR parsers](https://tomassetti.me/best-practices-for-antlr-parsers/)\n   * [Listeners and Visitors](https://tomassetti.me/listeners-and-visitors/)\n   * [ANTLR Mega Tutorial](https://tomassetti.me/antlr-mega-tutorial/#chapter47)\n2. [XPath and XQuery Semantics](./docs/xpath-and-xquery-semantics.pdf)\n3. [Join Optimizations](./docs/join-optimizations.pdf)\n4. W3C Document and Node API:\n   * [Node](https://docs.oracle.com/javase%2F7%2Fdocs%2Fapi%2F%2F/org/w3c/dom/Node.html)\n   * [Document](https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/Document.html)\n5. [BaseX](https://basex.org/) and [xpather.com](http://xpather.com/) for XPath and XQuery reference evaluation.\n6. [Debugger](https://code.visualstudio.com/docs/java/java-debugging#_debug-session-inputs) for Java in Visual Studio Code.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayank-02%2Fxmlalchemy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmayank-02%2Fxmlalchemy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayank-02%2Fxmlalchemy/lists"}