GithubHelp home page GithubHelp logo

jquery.xmleditor's Introduction

jquery.xmleditor

A web browser based XML editor. It provides a general use graphical tool for creating new or modifying existing XML documents in your web browser. Information is extracted from an XML schema (XSD file) to provide the user with information about what elements, subelements and attributes are available at different points in the structure, and a GUI based means of adding or removing them from the document.

Additionally, this project includes a tool for generating JSON objects from XML schemas, which can either be directly used in browsers or precompiled (see xsd/xsd2json.js).

Try it out in our jquery.xmleditor demo page using the MODS 3.4 schema.

And here's a demo starting from an existing xml file

This project was developed as a part of the Carolina Digital Repository for use in our administrative tools, but is fully functional as a standalone client. This tool is intended to serve as a general schema driven XML editor that runs in web browsers, although some default behaviors are oriented towards it.
For our own usage, it retrieves and submits documents to a SWORD 2.0 enabled repository.

Features

  • Graphical editor mode for displaying and modifying XML elements
  • Text editor mode for directly modifying the underlying document (using the Cloud9 editor)
  • Contextual, schema driven menus for adding new elements, subelements and attributes in both the graphical and text editing modes
  • Fully javascript and CSS based, jquery widget
  • AJAX submission of document modifications
  • Export the document to a file in web browsers that support it
  • Keyboard shortcuts for navigation and other operations
  • Standalone tool for building JSON representations of XML schemas (see the xsd/ folder in this project)

How to use

Locating schema files

Due to restrictions most web browsers have on cross domain requests in javascript, all necessary XSD files must be located in the same domain as the page the editor is embedded in.
But rather than lugging the XSD files around everywhere, you can precompile a JSON representation of your schemas to include instead.
It'll also save your users some loading time.

Embedding the editor

<div id="xml_editor"><root></root></div>
<script>
  $(function() {
		$("#xml_editor").modsEditor({
                schemaObject: schemaObject
        });
  });
</script>

Generate and use the schema object at run time instead of precompiling

See the runtime schema generation demo

<script>
  $(function() {
        var extractor = new Xsd2Json("mods-3-4.xsd", {"schemaURI":"mods-3-4/", "rootElement": "mods"});

        $("#mods_editor").modsEditor({
                schemaObject: extractor.getSchema()
        });
  });
</script>

Startup options for jquery.xmleditor

  • schemaObject - Javascript object representing the structure defined in an XML schema. It should be generated by xsd2json. See the provided xsd2json examples. This object is required.
  • ajaxOptions - Used for communicating with a remote source for receiving and/or submitting documents. It is an object containing the following properties:
    • xmlUploadPath - URL to submit the XML document to
    • xmlRetrievalPath - URL to retrieve the starting XML document from
    • xmlRetrievalParams - Any additional parameters to submit in the retrieval request
  • documentTitle - Title for the document being edited, which is displayed at the top of the editor.
  • menuEntries - A list of additional entries to add to the top menu bar, such as adding new help entries.
  • confirmExitWhenUnsubmitted - Causes web browsers to prompt users if they try to navigate away from the editor while there are unsubmitted changes. Valid values: True or false.
  • undoHistorySize - The number of history states remembered by the undo/redo feature. Default is 20.
  • namespaces - Associative list containing any additional namespaces you wish to make active in the editor
  • targetNS - Namespace URI for the base document being edited. If not set, it is determined by the namespace of the root node from the provided schema.
  • targetPrefix - Suggested prefix for the target namespace. If not set, the prefix will be determined based on the prefix of the targetNS

Startup options for xsd2json

Building the plugin yourself

If we wish to build the combined jquery.xmleditor.js yourself, you can use the provided rake script. With rake installed, simple type "rake" in the root directory of this project.

License Information

Copyright 2013 The University of North Carolina at Chapel Hill

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Authors

Ben Pennell

Mike Daines

Attribution

Cloud9 IDE vkbeautify expanding.js jquery jquery.xmlns json2.js and cycle.js

jquery.xmleditor's People

Contributors

bbpennel avatar daines avatar aeschylus avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.