{"id":15372072,"url":"https://github.com/xquery/mx","last_synced_at":"2025-04-15T14:06:33.704Z","repository":{"id":138760269,"uuid":"1846398","full_name":"xquery/mx","owner":"xquery","description":"MarkLogic XQuery Framework ","archived":false,"fork":false,"pushed_at":"2013-11-18T15:20:26.000Z","size":3759,"stargazers_count":8,"open_issues_count":4,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T14:06:18.461Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://github.com/xquery/mx","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xquery.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":"2011-06-04T10:36:06.000Z","updated_at":"2013-11-18T15:20:26.000Z","dependencies_parsed_at":"2023-03-11T17:06:25.794Z","dependency_job_id":null,"html_url":"https://github.com/xquery/mx","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/xquery%2Fmx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xquery%2Fmx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xquery%2Fmx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xquery%2Fmx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xquery","download_url":"https://codeload.github.com/xquery/mx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249085437,"owners_count":21210267,"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-10-01T13:49:32.171Z","updated_at":"2025-04-15T14:06:33.685Z","avatar_url":"https://github.com/xquery.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#IMPORTANT (mx is deprecated)\n\nGoto [RXQ - RESTXQ Annotations for building RESTful web applications](https://github.com/xquery/rxq)\n\n# MarkLogic XQuery framework (mx)\n\nMX is designed to provide a 'starting point' for developing MarkLogic XQuery web applications.\n\nIt is a 'work in progress' and a testbed for trying out things, so\nplease excuse the general unfinished state.\n\nThe principles of MX in a nutshell;\n\n* KISS ... keep concepts simple and to a minimum, preferably one if possible\n* everything has a URI\n* simplify MVC by allowing everything to be a Model \n* single import\n* TMTOWTDI e.g. dont constrain developer wherever possible \n\n\n## Website\n\n'sparse' documentation and source code can always be found from the MX github repo\n\nhttps://github.com/xquery/mx\n\n\n## Dependency\n\nMarkLogic server is required, please refer to MarkLogic excellent documentation for getting \nthe server installed and initializing a database and related HTTP application server.\n\nI have also bundled the excellent mustache.xq (Nuno Job / John\nSnelson) to show how to define templates using it.\n\nhttps://github.com/dscape/mustache.xq\n\n\n## Dist\n\nsrc/example-app - contains test application that uses mx.xqm\n\nsrc/xquery - contains mx.xqm library and mx-controller.xqy\n\ntests -  there are tests for mx but I have opted to not include them\nin the dist for the time being\n\n## Installation of example-app\n\nYou need to  ensure you have a MarkLogic database and application\nserver setup. \n\nOnce you have a working MarkLogic HTTP application server running then;\n\n    download mx (or get from git) distro\n\n    edit src/example-app/mx-controller.xqy and change $mx:app to reflect your path\n\n        declare variable $mx:app := mx:map( xdmp:document-get('/Users/jfuller/Source/Webcomposite/mx/src/example-app/app.xml'));\n\n    to\n\n        declare variable $mx:app := mx:map( xdmp:document-get('TO YOUR OWN PATH app.xml'));\n\nIn the ML application server set the following;\n\n    set root to where src/example-app is located in your environment\n\n    set url rewriter to /mx-controller.xqy?mode=rewrite\n\n    set error handler to /mx-controller.xqy?mode=error\n\n    you may have to set user with correct privileges depending on your\n    setup\n\nOnce you have done the above you should be able to access the example-app\n\n    ex. http://localhost:9000/mx?flush=true\n\n## Overview\n\nThe best way to learn what MX does and how to build applications with\nit is to review app.xml\n\n*src/example-app/app.xml* - defines all routing and how data and views come\ntogether. Note that this is loaded into an ML server field which is\nwhy you need to use the url param flush=1 to force reload (if you add\nnew changes or make a change to app.xml)\n\n*passthru* - will allow HTTP requests through\n\n```xml\n\u003cpath url=\"/resource/\" type=\"passthru\" description=\"\"/\u003e\n\u003cpath url=\"/robots.txt\" type=\"passthru\" description=\"\"/\u003e\n\u003cpath url=\"/static-test.html\" type=\"passthru\" description=\"\"/\u003e\n\u003cpath url=\"/app.xml\" type=\"passthru\" description=\"\"/\u003e\n```\n\n*http redirection* - will either forward or redirect HTTP request\n\n```xml\n\u003cpath url=\"/forward.test\" type=\"forward\" description=\"example of forwarding\"\u003e/static-test.html\u003c/path\u003e\n\u003cpath url=\"/redirect.test\" type=\"redirect\" description=\"example of\nredirecting,\nchanging the\nurl\"\u003e/static-test.html\u003c/path\u003e\n```\n\n*inline tests* - Shows how to generate static content\n\n```xml\n\u003cpath url=\"/inline.test\" method=\"GET\"\u003e\n\u003chtml\u003e\n\u003cbody\u003e\n\u003ch1\u003einline test\u003c/h1\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n\u003c/path\u003e\n```\n\n*data* - how to setup models  (but remember everything is a model)\n\n```xml\n\u003cpath url=\"/data.test\" method=\"GET\" description=\"inline test with no content type set, should fall back to using application/xml\"\u003e\n\u003cdata title=\"this is /data.test\"\u003e\n\u003ctest\u003e\n\u003ca\u003e{1 + 1}\u003c/a\u003e\n\u003c/test\u003e\n\u003c/data\u003e\n\u003c/path\u003e\n```\n\n*module* - how to invoke xquery modules\n\n```xml\n\u003cpath url=\"/xquery.test\" method=\"GET\" href=\"/modules/example.xqy\"/\u003e\n```\n\n\n*templates* - create templates which reuse data\n\n```xml\n\u003cpath url=\"/template1\" type=\"template\" method=\"GET\"\ncontent-type=\"text/html\" data=\"/data7.test\"\ndescription=\"create template with mustache\"\u003e\n\u003chtml\u003e\n\u003chead\u003e\n\u003c/head\u003e\n\u003cbody\u003e\nHello {{text}}!\n\u003c/body\u003e\n\u003c/html\u003e\n\u003c/path\u003e\n```\n\n*json* - there are some experiemental json stuff as well\n\n\n## Using in your own XQuery Applications\n\nAt a minimum you need 3 things;\n\n* mx.xqm - single module for mx\n* mx-controller.xqy - just edit path\n* app.xml - application specific\n\nI have tried not to make too much 'ceremony' e.g. its left to you how\nyou want to do things.\n\nObviously you will need to edit app.xml, but you are free to setup\nhowever way you want your modules, templates, etc.\n\n\n## URL Params\n\nappending the following url params to any url \n\n* debug=true   - will display underlying XML and HTTP Request\n  information\n\n```\nhttp://localhost:9000/inline.test?debug=true\n```\n\n* profile=true - will enable profiling information to be included in\n  debug \n\n```\nhttp://localhost:9000/inline.test?profile=true\u0026debug=true\n```\n\n* flush=true   - will force app.xml to reload into server field which\n  is required anytime you edit app.xml.\n\n```\nhttp://localhost:9000/inline.test?flush=true\n```\n\n* cache=true   - will enable inline function caching\n\n```\nhttp://localhost:9000/inline.test?cache=true\n```\n\n\n\n## Tests\n\nTests for mx are written in xproc contained under src/test/unit. To\nrun tests you must setup an XDBC application server in ML and set\nconfiguration within src/test/config.xml\n\n\u003cconfig\u003e\n\t\u003cconnection protocol=\"http\" host=\"localhost\" port=\"9002\" username=\"test\" password=\"test\"/\u003e\n\t\u003cconnection protocol=\"xdbc\" host=\"localhost\" port=\"9001\" username=\"test\" password=\"test\"/\u003e\n\u003c/config\u003e\n\nYou will also require installing Norman Walsh's implementation of\nXProc XMLCalabash.\n\nTo run tests review runner scripts under src/test/bin\n\n## Resources\n\nMX github: http://www.github.com/xquery/mx\n\nXSGI: previous experiment for use with eXist XML Database (http://code.google.com/p/xsgi/)\n\nMartin Fowler's Harvested Frameworks does a good job at capturing how MX was developed.\n\n\n## Acknowledgements\n\n\nMany of the principles embedded in MX were inspired by active/passive\nobservations and conversations with some of my MarkLogic colleagues;\n\nAlex Bleasdale, Micah Dubinko, Philip Fennel, Nuno Job, Justin Makeig,\nOlav Schrewing, Pete Aven, Norman Walsh\n\nThough of course, I take all the blame for anything incorrect, broken or plain stupid.\n\n\n## Contact\n\njim.fuller@webcomposite.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxquery%2Fmx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxquery%2Fmx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxquery%2Fmx/lists"}