├── .gitignore ├── demo ├── examples │ ├── default_templates │ │ ├── image.xml │ │ ├── video.xml │ │ ├── mods.xml │ │ └── audio.xml │ ├── test │ │ ├── includer.xsd │ │ ├── no-target-ns.xsd │ │ └── dc.xsd │ ├── atom │ │ └── xml.xsd │ ├── dcterms │ │ ├── dcmitype.xsd │ │ ├── dc.xsd │ │ └── xml.xsd │ ├── eac-cpf │ │ ├── xlink.xsd │ │ └── xml.xsd │ ├── mods-3-4 │ │ └── xlink.xsd │ ├── marc_relators.json │ └── spoonful_of_mods.xml ├── no-target-ns.html ├── xsd2json_example2.html ├── xsd2json_example.html ├── include-test.html ├── mods.html ├── stylesheets │ ├── reset.css │ └── demo.css ├── relator.html ├── cpf.html ├── templates.html └── atom.html ├── tests ├── issue-068-1 │ ├── schema.xsd │ └── schema.json ├── issue-068-2 │ ├── schema.xsd │ └── schema.json ├── issue-071-1 │ ├── schema_bar.xsd │ ├── schema.xsd │ └── schema.json ├── issue-071-2 │ ├── schema_bar.xsd │ ├── schema.xsd │ └── schema.json ├── tests.css ├── issue-066-3 │ ├── schema.xsd │ └── schema.json ├── issue-080-1 │ ├── schema.xsd │ └── schema.json ├── issue-067-2 │ ├── schema_sub.xsd │ ├── schema.xsd │ └── schema.json ├── issue-080-4 │ ├── schema.xsd │ ├── include-no-ns.xsd │ └── schema.json ├── issue-066-1 │ ├── schema.xsd │ └── schema.json ├── issue-066-2 │ ├── schema.xsd │ └── schema.json ├── issue-067-1 │ ├── schema_sub.xsd │ ├── schema.xsd │ └── schema.json ├── issue-080-5 │ ├── schema.xsd │ └── schema.json ├── issue-067-3 │ ├── schema.xsd │ └── schema.json ├── update-tests ├── issue-080-2 │ ├── schema.xsd │ └── schema.json ├── issue-080-3 │ ├── schema.xsd │ └── schema.json ├── tests.json ├── issue-080-include-test │ ├── schema.xsd │ ├── no-target-ns.xsd │ └── dc.xsd ├── issue-084-2 │ ├── schema.xsd │ └── schema.json ├── issue-082-1 │ ├── schema.xsd │ └── schema.json ├── issue-084-1 │ ├── schema.xsd │ └── schema.json ├── index.html ├── issue-082-2 │ ├── schema.xsd │ └── schema.json ├── issue-080-no-target-ns │ ├── schema.xsd │ └── dc.xsd ├── issue-078-atom │ └── xml.xsd ├── issue-078-dcterms │ ├── dcmitype.xsd │ └── dc.xsd ├── tests.js ├── issue-084-cpf │ └── xlink.xsd └── issue-078-mods-3-4 │ └── xlink.xsd ├── xsd ├── build.html ├── README.md ├── build.js └── src │ └── xsd2json.js ├── Rakefile ├── src ├── namespace_list.js ├── xml_autocomplete.js ├── xml_cdata_node.js ├── xml_attribute_stub.js ├── xml_comment_node.js ├── format_xml.js ├── attribute_menu.js ├── add_node_menu.js ├── undo_history.js ├── xml_text_node.js ├── xml_attribute.js ├── xml_unspecified_element.js ├── schema_tree.js ├── xml_templates.js ├── abstract_xml_object.js ├── modify_element_menu.js └── xml_element_stub.js ├── bower.json ├── package.json ├── index.html └── lib ├── jquery.autosize-min.js ├── ace └── src-min │ ├── theme-textmate.js │ └── keybinding-emacs.js └── json2.js /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | .DS_Store 3 | .idea 4 | -------------------------------------------------------------------------------- /demo/examples/default_templates/image.xml: -------------------------------------------------------------------------------- 1 | 2 | image 3 | -------------------------------------------------------------------------------- /demo/examples/default_templates/video.xml: -------------------------------------------------------------------------------- 1 | 3 | video 4 | -------------------------------------------------------------------------------- /demo/examples/default_templates/mods.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/issue-068-1/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /tests/issue-068-2/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /tests/issue-071-1/schema_bar.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /tests/issue-071-2/schema_bar.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /demo/examples/default_templates/audio.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Audio 4 | -------------------------------------------------------------------------------- /tests/tests.css: -------------------------------------------------------------------------------- 1 | .ok { 2 | color: #0a0; 3 | } 4 | .failure { 5 | color: #e00; 6 | } 7 | a { 8 | color: inherit; 9 | text-decoration: inherit; 10 | } 11 | a:hover { 12 | color: #00a; 13 | } 14 | th { 15 | text-align: left; 16 | } 17 | -------------------------------------------------------------------------------- /tests/issue-066-3/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /tests/issue-071-1/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /tests/issue-080-1/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /tests/issue-067-2/schema_sub.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /tests/issue-071-2/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /tests/issue-080-4/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /tests/issue-066-1/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /tests/issue-066-2/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /tests/issue-067-1/schema_sub.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /tests/issue-080-5/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/issue-067-1/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /tests/issue-067-2/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /tests/issue-080-4/include-no-ns.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /tests/issue-067-3/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /xsd/build.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /tests/update-tests: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from json import dump 4 | from os import chdir 5 | from os import listdir 6 | from os.path import dirname 7 | from os.path import isdir 8 | 9 | chdir(dirname(__file__)) 10 | with open('tests.json', 'w') as f: 11 | dump(fp=f, indent=2, separators=(',', ': '), obj={ 12 | 'testcases': [ 13 | entry 14 | for entry in reversed(sorted(listdir('.'))) 15 | if isdir(entry) 16 | ], 17 | }) 18 | f.write('\n') 19 | -------------------------------------------------------------------------------- /tests/issue-080-2/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tests/issue-080-3/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tests/issue-068-2/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": true, 3 | "ns": 4, 4 | "namespaces": [ 5 | { 6 | "prefix": "xml", 7 | "uri": "http://www.w3.org/XML/1998/namespace" 8 | }, 9 | { 10 | "prefix": "xmlns", 11 | "uri": "http://www.w3.org/2000/xmlns/" 12 | }, 13 | { 14 | "prefix": "html", 15 | "uri": "http://www.w3.org/1999/xhtml/" 16 | }, 17 | { 18 | "prefix": "xs", 19 | "uri": "http://www.w3.org/2001/XMLSchema" 20 | }, 21 | { 22 | "prefix": "", 23 | "uri": "http://example.com/foo" 24 | } 25 | ], 26 | "elements": [] 27 | } 28 | -------------------------------------------------------------------------------- /demo/examples/test/includer.xsd: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /tests/tests.json: -------------------------------------------------------------------------------- 1 | { 2 | "testcases": [ 3 | "issue-084-cpf", 4 | "issue-084-2", 5 | "issue-084-1", 6 | "issue-082-2", 7 | "issue-082-1", 8 | "issue-080-no-target-ns", 9 | "issue-080-include-test", 10 | "issue-080-5", 11 | "issue-080-4", 12 | "issue-080-3", 13 | "issue-080-2", 14 | "issue-080-1", 15 | "issue-078-mods-3-4", 16 | "issue-078-dcterms", 17 | "issue-078-atom", 18 | "issue-071-2", 19 | "issue-071-1", 20 | "issue-068-2", 21 | "issue-068-1", 22 | "issue-067-3", 23 | "issue-067-2", 24 | "issue-067-1", 25 | "issue-066-3", 26 | "issue-066-2", 27 | "issue-066-1" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /tests/issue-080-include-test/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /tests/issue-068-1/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": true, 3 | "ns": 4, 4 | "namespaces": [ 5 | { 6 | "prefix": "xml", 7 | "uri": "http://www.w3.org/XML/1998/namespace" 8 | }, 9 | { 10 | "prefix": "xmlns", 11 | "uri": "http://www.w3.org/2000/xmlns/" 12 | }, 13 | { 14 | "prefix": "html", 15 | "uri": "http://www.w3.org/1999/xhtml/" 16 | }, 17 | { 18 | "prefix": "xs", 19 | "uri": "http://www.w3.org/2001/XMLSchema" 20 | }, 21 | { 22 | "prefix": "", 23 | "uri": "http://example.com/foo" 24 | } 25 | ], 26 | "elements": [ 27 | { 28 | "values": [], 29 | "type": "anyType", 30 | "ns": 4, 31 | "name": "Foo", 32 | "element": true, 33 | "attributes": [], 34 | "elements": [] 35 | } 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /tests/issue-080-1/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": true, 3 | "ns": 4, 4 | "namespaces": [ 5 | { 6 | "prefix": "xml", 7 | "uri": "http://www.w3.org/XML/1998/namespace" 8 | }, 9 | { 10 | "prefix": "xmlns", 11 | "uri": "http://www.w3.org/2000/xmlns/" 12 | }, 13 | { 14 | "prefix": "html", 15 | "uri": "http://www.w3.org/1999/xhtml/" 16 | }, 17 | { 18 | "prefix": "xs", 19 | "uri": "http://www.w3.org/2001/XMLSchema" 20 | }, 21 | { 22 | "prefix": "", 23 | "uri": "http://example.com/foo" 24 | } 25 | ], 26 | "elements": [ 27 | { 28 | "values": [], 29 | "type": "string", 30 | "ns": 4, 31 | "name": "Foo", 32 | "element": true, 33 | "attributes": [], 34 | "elements": [] 35 | } 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /tests/issue-066-1/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": true, 3 | "ns": 4, 4 | "namespaces": [ 5 | { 6 | "prefix": "xml", 7 | "uri": "http://www.w3.org/XML/1998/namespace" 8 | }, 9 | { 10 | "prefix": "xmlns", 11 | "uri": "http://www.w3.org/2000/xmlns/" 12 | }, 13 | { 14 | "prefix": "html", 15 | "uri": "http://www.w3.org/1999/xhtml/" 16 | }, 17 | { 18 | "prefix": "xs", 19 | "uri": "http://www.w3.org/2001/XMLSchema" 20 | }, 21 | { 22 | "prefix": "foo", 23 | "uri": "http://example.com/foo" 24 | } 25 | ], 26 | "elements": [ 27 | { 28 | "values": [], 29 | "type": "string", 30 | "ns": 4, 31 | "name": "Foo", 32 | "element": true, 33 | "attributes": [], 34 | "elements": [] 35 | } 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /tests/issue-066-2/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": true, 3 | "ns": 4, 4 | "namespaces": [ 5 | { 6 | "prefix": "xml", 7 | "uri": "http://www.w3.org/XML/1998/namespace" 8 | }, 9 | { 10 | "prefix": "xmlns", 11 | "uri": "http://www.w3.org/2000/xmlns/" 12 | }, 13 | { 14 | "prefix": "html", 15 | "uri": "http://www.w3.org/1999/xhtml/" 16 | }, 17 | { 18 | "prefix": "xs", 19 | "uri": "http://www.w3.org/2001/XMLSchema" 20 | }, 21 | { 22 | "prefix": "foo", 23 | "uri": "http://example.com/foo" 24 | } 25 | ], 26 | "elements": [ 27 | { 28 | "values": [], 29 | "type": "string", 30 | "ns": 4, 31 | "name": "Foo", 32 | "element": true, 33 | "attributes": [], 34 | "elements": [] 35 | } 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /tests/issue-066-3/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": true, 3 | "ns": 4, 4 | "namespaces": [ 5 | { 6 | "prefix": "xml", 7 | "uri": "http://www.w3.org/XML/1998/namespace" 8 | }, 9 | { 10 | "prefix": "xmlns", 11 | "uri": "http://www.w3.org/2000/xmlns/" 12 | }, 13 | { 14 | "prefix": "html", 15 | "uri": "http://www.w3.org/1999/xhtml/" 16 | }, 17 | { 18 | "prefix": "xs", 19 | "uri": "http://www.w3.org/2001/XMLSchema" 20 | }, 21 | { 22 | "prefix": "foo", 23 | "uri": "http://example.com/foo" 24 | } 25 | ], 26 | "elements": [ 27 | { 28 | "values": [], 29 | "type": "string", 30 | "ns": 4, 31 | "name": "Foo", 32 | "element": true, 33 | "attributes": [], 34 | "elements": [] 35 | } 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /tests/issue-067-1/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": true, 3 | "ns": 4, 4 | "namespaces": [ 5 | { 6 | "prefix": "xml", 7 | "uri": "http://www.w3.org/XML/1998/namespace" 8 | }, 9 | { 10 | "prefix": "xmlns", 11 | "uri": "http://www.w3.org/2000/xmlns/" 12 | }, 13 | { 14 | "prefix": "html", 15 | "uri": "http://www.w3.org/1999/xhtml/" 16 | }, 17 | { 18 | "prefix": "xs", 19 | "uri": "http://www.w3.org/2001/XMLSchema" 20 | }, 21 | { 22 | "prefix": "foo", 23 | "uri": "http://example.com/foo" 24 | } 25 | ], 26 | "elements": [ 27 | { 28 | "values": [], 29 | "type": "string", 30 | "ns": 4, 31 | "name": "Foo", 32 | "element": true, 33 | "attributes": [], 34 | "elements": [] 35 | } 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /tests/issue-067-2/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": true, 3 | "ns": 4, 4 | "namespaces": [ 5 | { 6 | "prefix": "xml", 7 | "uri": "http://www.w3.org/XML/1998/namespace" 8 | }, 9 | { 10 | "prefix": "xmlns", 11 | "uri": "http://www.w3.org/2000/xmlns/" 12 | }, 13 | { 14 | "prefix": "html", 15 | "uri": "http://www.w3.org/1999/xhtml/" 16 | }, 17 | { 18 | "prefix": "xs", 19 | "uri": "http://www.w3.org/2001/XMLSchema" 20 | }, 21 | { 22 | "prefix": "foo", 23 | "uri": "http://example.com/foo" 24 | } 25 | ], 26 | "elements": [ 27 | { 28 | "values": [], 29 | "type": "string", 30 | "ns": 4, 31 | "name": "Foo", 32 | "element": true, 33 | "attributes": [], 34 | "elements": [] 35 | } 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /tests/issue-067-3/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": true, 3 | "ns": 4, 4 | "namespaces": [ 5 | { 6 | "prefix": "xml", 7 | "uri": "http://www.w3.org/XML/1998/namespace" 8 | }, 9 | { 10 | "prefix": "xmlns", 11 | "uri": "http://www.w3.org/2000/xmlns/" 12 | }, 13 | { 14 | "prefix": "html", 15 | "uri": "http://www.w3.org/1999/xhtml/" 16 | }, 17 | { 18 | "prefix": "xs", 19 | "uri": "http://www.w3.org/2001/XMLSchema" 20 | }, 21 | { 22 | "prefix": "foo", 23 | "uri": "http://example.com/foo" 24 | } 25 | ], 26 | "elements": [ 27 | { 28 | "values": [], 29 | "type": "string", 30 | "ns": 4, 31 | "name": "Foo", 32 | "element": true, 33 | "attributes": [], 34 | "elements": [] 35 | } 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /tests/issue-071-1/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": true, 3 | "ns": 4, 4 | "namespaces": [ 5 | { 6 | "prefix": "xml", 7 | "uri": "http://www.w3.org/XML/1998/namespace" 8 | }, 9 | { 10 | "prefix": "xmlns", 11 | "uri": "http://www.w3.org/2000/xmlns/" 12 | }, 13 | { 14 | "prefix": "html", 15 | "uri": "http://www.w3.org/1999/xhtml/" 16 | }, 17 | { 18 | "prefix": "xs", 19 | "uri": "http://www.w3.org/2001/XMLSchema" 20 | }, 21 | { 22 | "prefix": "", 23 | "uri": "http://example.com/foo" 24 | }, 25 | { 26 | "prefix": "ns1", 27 | "uri": "http://example.com/bar" 28 | } 29 | ], 30 | "elements": [ 31 | { 32 | "values": [], 33 | "type": "string", 34 | "ns": 5, 35 | "name": "Bar", 36 | "element": true, 37 | "attributes": [], 38 | "elements": [] 39 | } 40 | ] 41 | } 42 | -------------------------------------------------------------------------------- /tests/issue-071-2/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": true, 3 | "ns": 5, 4 | "namespaces": [ 5 | { 6 | "prefix": "xml", 7 | "uri": "http://www.w3.org/XML/1998/namespace" 8 | }, 9 | { 10 | "prefix": "xmlns", 11 | "uri": "http://www.w3.org/2000/xmlns/" 12 | }, 13 | { 14 | "prefix": "html", 15 | "uri": "http://www.w3.org/1999/xhtml/" 16 | }, 17 | { 18 | "prefix": "xs", 19 | "uri": "http://www.w3.org/2001/XMLSchema" 20 | }, 21 | { 22 | "prefix": "bar", 23 | "uri": "http://example.com/bar" 24 | }, 25 | { 26 | "prefix": "", 27 | "uri": "http://example.com/foo" 28 | } 29 | ], 30 | "elements": [ 31 | { 32 | "values": [], 33 | "type": "string", 34 | "ns": 4, 35 | "name": "Bar", 36 | "element": true, 37 | "attributes": [], 38 | "elements": [] 39 | } 40 | ] 41 | } 42 | -------------------------------------------------------------------------------- /tests/issue-084-2/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /tests/issue-082-1/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "rubygems" 2 | require "sprockets" 3 | 4 | task :default => "jquery.xmleditor.js" 5 | 6 | task "jquery.xmleditor.js" => FileList.new("src/*") do 7 | environment = Sprockets::Environment.new 8 | environment.append_path "src" 9 | 10 | File.open("jquery.xmleditor.js", "w+") do |f| 11 | f << ";(function($){" + environment.find_asset("jquery.xmleditor.js").to_s + "})(jQuery);" 12 | end 13 | end 14 | 15 | task "xsd2json.js" => FileList.new("xsd/src/*") do 16 | environment = Sprockets::Environment.new 17 | environment.append_path "xsd/src" 18 | 19 | File.open("xsd/xsd2json.js", "w+") do |f| 20 | f << ";var Xsd2Json = function() {" + environment.find_asset("xsd2json.js").to_s + "; return Xsd2Json;}.call();" 21 | end 22 | end 23 | 24 | task "mods.js" do 25 | FileUtils.cd("xsd") 26 | system "phantomjs build.js ../mods.js" 27 | end 28 | 29 | task :clean do 30 | FileUtils.rm_f("jquery.xmleditor.js") 31 | end 32 | -------------------------------------------------------------------------------- /tests/issue-084-1/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/namespace_list.js: -------------------------------------------------------------------------------- 1 | function NamespaceList(namespaceList) { 2 | this.namespaceURIs = {}; 3 | this.namespaceToPrefix = {}; 4 | 5 | if (namespaceList) { 6 | $.extend({}, namespaceList); 7 | var self = this; 8 | $.each(this.namespaces, function() { 9 | self.namespaceToPrefix[value] = key; 10 | }); 11 | } 12 | } 13 | 14 | NamespaceList.prototype.addNamespace = function(nsURI, nsPrefix) { 15 | this.namespaceURIs[nsPrefix] = nsURI; 16 | this.namespaceToPrefix[nsURI] = nsPrefix; 17 | }; 18 | 19 | NamespaceList.prototype.containsURI = function(nsURI) { 20 | return nsURI in this.namespaceToPrefix; 21 | }; 22 | 23 | NamespaceList.prototype.containsPrefix = function(nsPrefix) { 24 | return nsPrefix in this.namespaceURIs; 25 | }; 26 | 27 | NamespaceList.prototype.getNamespacePrefix = function(nsURI) { 28 | if (!nsURI) { 29 | return ""; 30 | } 31 | 32 | var prefix = this.namespaceToPrefix[nsURI]; 33 | if (prefix) 34 | prefix += ":"; 35 | return prefix; 36 | }; -------------------------------------------------------------------------------- /tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | jQuery.xmleditor Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |

Summary

17 | 18 | 19 | 20 | 21 |
Total
OK
Fail
22 |

Tests

23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /tests/issue-082-2/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /tests/issue-080-no-target-ns/schema.xsd: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /demo/examples/test/no-target-ns.xsd: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.xmleditor", 3 | "main": "jquery.xmleditor.js", 4 | "version": "1.3.0", 5 | "homepage": "https://github.com/UNC-Libraries/jquery.xmleditor", 6 | "authors": [ 7 | "Ben Pennell (https://github.com/bbpennel)", 8 | "Mike Daines (https://github.com/mdaines)", 9 | "Dean Farrell ", 10 | "Volker Diels-Grabsch (https://github.com/m-click)" 11 | ], 12 | "description": "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.", 13 | "keywords": [ 14 | "xml", 15 | "editor", 16 | "mods", 17 | "mets" 18 | ], 19 | "license": "Apache 2.0", 20 | "ignore": [ 21 | "**/.*", 22 | "node_modules", 23 | "bower_components", 24 | "test", 25 | "tests" 26 | ] 27 | } -------------------------------------------------------------------------------- /tests/issue-080-include-test/no-target-ns.xsd: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery.xmleditor", 3 | "main": "jquery.xmleditor.js", 4 | "version": "1.3.0", 5 | "description": "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.", 6 | "keywords": [ 7 | "xml", 8 | "editor", 9 | "mods", 10 | "mets" 11 | ], 12 | "repository": { 13 | "url": "https://github.com/UNC-Libraries/jquery.xmleditor", 14 | "type": "git" 15 | }, 16 | "scripts": { 17 | "build-project": "rake" 18 | }, 19 | "author": "UNC Chapel Hill Libraries", 20 | "contributors": [ 21 | "Ben Pennell (https://github.com/bbpennel)", 22 | "Mike Daines (https://github.com/mdaines)", 23 | "Dean Farrell ", 24 | "Volker Diels-Grabsch (https://github.com/m-click)" 25 | ], 26 | "license": "Apache 2.0" 27 | } -------------------------------------------------------------------------------- /tests/issue-080-2/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": true, 3 | "ns": 4, 4 | "namespaces": [ 5 | { 6 | "prefix": "xml", 7 | "uri": "http://www.w3.org/XML/1998/namespace" 8 | }, 9 | { 10 | "prefix": "xmlns", 11 | "uri": "http://www.w3.org/2000/xmlns/" 12 | }, 13 | { 14 | "prefix": "html", 15 | "uri": "http://www.w3.org/1999/xhtml/" 16 | }, 17 | { 18 | "prefix": "xs", 19 | "uri": "http://www.w3.org/2001/XMLSchema" 20 | }, 21 | { 22 | "prefix": "foo", 23 | "uri": "http://example.com/foo" 24 | } 25 | ], 26 | "elements": [ 27 | { 28 | "values": [], 29 | "type": "string", 30 | "ns": 4, 31 | "name": "Foo1", 32 | "element": true, 33 | "attributes": [], 34 | "elements": [] 35 | }, 36 | { 37 | "values": [], 38 | "type": "string", 39 | "ns": 4, 40 | "name": "Foo2", 41 | "element": true, 42 | "attributes": [], 43 | "elements": [] 44 | }, 45 | { 46 | "values": [], 47 | "type": "string", 48 | "ns": 4, 49 | "name": "Foo3", 50 | "element": true, 51 | "attributes": [], 52 | "elements": [] 53 | } 54 | ] 55 | } 56 | -------------------------------------------------------------------------------- /tests/issue-080-3/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": true, 3 | "ns": 4, 4 | "namespaces": [ 5 | { 6 | "prefix": "xml", 7 | "uri": "http://www.w3.org/XML/1998/namespace" 8 | }, 9 | { 10 | "prefix": "xmlns", 11 | "uri": "http://www.w3.org/2000/xmlns/" 12 | }, 13 | { 14 | "prefix": "html", 15 | "uri": "http://www.w3.org/1999/xhtml/" 16 | }, 17 | { 18 | "prefix": "xs", 19 | "uri": "http://www.w3.org/2001/XMLSchema" 20 | }, 21 | { 22 | "prefix": "foo", 23 | "uri": "http://example.com/foo" 24 | } 25 | ], 26 | "elements": [ 27 | { 28 | "values": [], 29 | "type": "string", 30 | "ns": 4, 31 | "name": "Foo1", 32 | "element": true, 33 | "attributes": [], 34 | "elements": [] 35 | }, 36 | { 37 | "values": [], 38 | "type": "string", 39 | "ns": 4, 40 | "name": "Foo2", 41 | "element": true, 42 | "attributes": [], 43 | "elements": [] 44 | }, 45 | { 46 | "values": [], 47 | "type": "string", 48 | "ns": 4, 49 | "name": "Foo3", 50 | "element": true, 51 | "attributes": [], 52 | "elements": [] 53 | } 54 | ] 55 | } 56 | -------------------------------------------------------------------------------- /tests/issue-080-5/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": true, 3 | "ns": 4, 4 | "namespaces": [ 5 | { 6 | "prefix": "xml", 7 | "uri": "http://www.w3.org/XML/1998/namespace" 8 | }, 9 | { 10 | "prefix": "xmlns", 11 | "uri": "http://www.w3.org/2000/xmlns/" 12 | }, 13 | { 14 | "prefix": "html", 15 | "uri": "http://www.w3.org/1999/xhtml/" 16 | }, 17 | { 18 | "prefix": "xs", 19 | "uri": "http://www.w3.org/2001/XMLSchema" 20 | }, 21 | { 22 | "prefix": "", 23 | "uri": null 24 | } 25 | ], 26 | "elements": [ 27 | { 28 | "values": [], 29 | "type": null, 30 | "ns": 4, 31 | "name": "root", 32 | "element": true, 33 | "attributes": [], 34 | "elements": [ 35 | { 36 | "values": [], 37 | "type": "string", 38 | "ns": 4, 39 | "name": "name", 40 | "element": true, 41 | "attributes": [], 42 | "elements": [] 43 | } 44 | ], 45 | "choices": [ 46 | { 47 | "elements": [ 48 | "4:name" 49 | ], 50 | "minOccurs": null, 51 | "maxOccurs": 1 52 | } 53 | ] 54 | } 55 | ] 56 | } -------------------------------------------------------------------------------- /tests/issue-080-4/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": true, 3 | "ns": 4, 4 | "namespaces": [ 5 | { 6 | "prefix": "xml", 7 | "uri": "http://www.w3.org/XML/1998/namespace" 8 | }, 9 | { 10 | "prefix": "xmlns", 11 | "uri": "http://www.w3.org/2000/xmlns/" 12 | }, 13 | { 14 | "prefix": "html", 15 | "uri": "http://www.w3.org/1999/xhtml/" 16 | }, 17 | { 18 | "prefix": "xs", 19 | "uri": "http://www.w3.org/2001/XMLSchema" 20 | }, 21 | { 22 | "prefix": "", 23 | "uri": "http://example.com/foo" 24 | } 25 | ], 26 | "elements": [ 27 | { 28 | "values": [], 29 | "type": null, 30 | "ns": 4, 31 | "name": "root", 32 | "element": true, 33 | "attributes": [], 34 | "elements": [ 35 | { 36 | "values": [], 37 | "type": "string", 38 | "ns": 4, 39 | "name": "name", 40 | "element": true, 41 | "attributes": [], 42 | "elements": [] 43 | } 44 | ], 45 | "choices": [ 46 | { 47 | "elements": [ 48 | "4:name" 49 | ], 50 | "minOccurs": null, 51 | "maxOccurs": 1 52 | } 53 | ] 54 | } 55 | ] 56 | } -------------------------------------------------------------------------------- /xsd/README.md: -------------------------------------------------------------------------------- 1 | xsd2json 2 | ======== 3 | 4 | ## To build the JSON schema object 5 | 6 | This directory contains a script for PhantomJS, build.js, which can build the mods.js file at the root of the repository or as follows: 7 | 8 | $ phantomjs build.js ../mods.js 9 | $ phantomjs build.js ../demo/examples/mods.json ../demo/examples/mods-3-4/ mods-3-4.xsd 10 | $ phantomjs build.js dcterms.js ../demo/examples/dcterms/ ../demo/examples/dcterms.xsd dctermsSchema 11 | 12 | Usage: 13 | `build.js [ ]` 14 | - output filename - The name of the file to generate, containing the JSON object created from the given schemas. If set to "" then the results are output to console. 15 | - schema path - The file path to the location of the schemas to be used. If not set, then the current directory is used. 16 | - base schema filename - The filename of the first schema to begin processing, which will serve as the root of the generated object. *.xsd if not set. 17 | - JSON variable name - Name of the javascript variable assigned the JSON object result. "schema" if not set. 18 | 19 | 20 | ## To extract the schema object at run time 21 | `var extractor = new Xsd2Json("mods-3-4.xsd", {"schemaURI":"mods-3-4/"});` 22 | -------------------------------------------------------------------------------- /tests/issue-082-1/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": true, 3 | "ns": 3, 4 | "namespaces": [ 5 | { 6 | "prefix": "xml", 7 | "uri": "http://www.w3.org/XML/1998/namespace" 8 | }, 9 | { 10 | "prefix": "xmlns", 11 | "uri": "http://www.w3.org/2000/xmlns/" 12 | }, 13 | { 14 | "prefix": "html", 15 | "uri": "http://www.w3.org/1999/xhtml/" 16 | }, 17 | { 18 | "prefix": "foo", 19 | "uri": "http://example.com/foo" 20 | }, 21 | { 22 | "prefix": "xs", 23 | "uri": "http://www.w3.org/2001/XMLSchema" 24 | } 25 | ], 26 | "elements": [ 27 | { 28 | "values": [], 29 | "type": null, 30 | "ns": 3, 31 | "name": "Main", 32 | "element": true, 33 | "attributes": [], 34 | "elements": [ 35 | { 36 | "values": [], 37 | "type": "string", 38 | "ns": 3, 39 | "name": "Foo", 40 | "element": true, 41 | "attributes": [ 42 | { 43 | "values": [], 44 | "type": "string", 45 | "ns": 3, 46 | "name": "foo", 47 | "attribute": true 48 | } 49 | ], 50 | "elements": [] 51 | } 52 | ] 53 | } 54 | ] 55 | } 56 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | jQuery.xmleditor 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |
20 |

jQuery.xmleditor MODS Editing Demo

21 | View 22 | the Project on GitHub UNC-Libraries/jquery.xmleditor 23 | 24 |
25 |
26 |
27 | 28 |
29 | 36 |
37 |

38 | This project is maintained by UNC-Libraries 40 |

41 |
42 | 43 | -------------------------------------------------------------------------------- /tests/issue-084-1/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": true, 3 | "ns": 3, 4 | "namespaces": [ 5 | { 6 | "prefix": "xml", 7 | "uri": "http://www.w3.org/XML/1998/namespace" 8 | }, 9 | { 10 | "prefix": "xmlns", 11 | "uri": "http://www.w3.org/2000/xmlns/" 12 | }, 13 | { 14 | "prefix": "html", 15 | "uri": "http://www.w3.org/1999/xhtml/" 16 | }, 17 | { 18 | "prefix": "foo", 19 | "uri": "http://example.com/foo" 20 | }, 21 | { 22 | "prefix": "xs", 23 | "uri": "http://www.w3.org/2001/XMLSchema" 24 | } 25 | ], 26 | "elements": [ 27 | { 28 | "values": [], 29 | "type": null, 30 | "ns": 3, 31 | "name": "Base", 32 | "element": true, 33 | "attributes": [], 34 | "elements": [] 35 | }, 36 | { 37 | "values": [], 38 | "type": null, 39 | "ns": 3, 40 | "name": "Foo", 41 | "element": true, 42 | "attributes": [], 43 | "elements": [ 44 | { 45 | "values": [], 46 | "type": "string", 47 | "ns": 3, 48 | "name": "Bar", 49 | "element": true, 50 | "attributes": [ 51 | { 52 | "values": [], 53 | "type": "string", 54 | "ns": 3, 55 | "name": "bar", 56 | "attribute": true 57 | } 58 | ], 59 | "elements": [] 60 | } 61 | ] 62 | } 63 | ] 64 | } 65 | -------------------------------------------------------------------------------- /tests/issue-084-2/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": true, 3 | "ns": 3, 4 | "namespaces": [ 5 | { 6 | "prefix": "xml", 7 | "uri": "http://www.w3.org/XML/1998/namespace" 8 | }, 9 | { 10 | "prefix": "xmlns", 11 | "uri": "http://www.w3.org/2000/xmlns/" 12 | }, 13 | { 14 | "prefix": "html", 15 | "uri": "http://www.w3.org/1999/xhtml/" 16 | }, 17 | { 18 | "prefix": "foo", 19 | "uri": "http://example.com/foo" 20 | }, 21 | { 22 | "prefix": "xs", 23 | "uri": "http://www.w3.org/2001/XMLSchema" 24 | } 25 | ], 26 | "elements": [ 27 | { 28 | "values": [], 29 | "type": null, 30 | "ns": 3, 31 | "name": "Base", 32 | "element": true, 33 | "attributes": [], 34 | "elements": [] 35 | }, 36 | { 37 | "values": [], 38 | "type": null, 39 | "ns": 3, 40 | "name": "Foo", 41 | "element": true, 42 | "attributes": [], 43 | "elements": [ 44 | { 45 | "values": [], 46 | "type": "string", 47 | "ns": 3, 48 | "name": "Bar", 49 | "element": true, 50 | "attributes": [ 51 | { 52 | "values": [], 53 | "type": "string", 54 | "ns": 3, 55 | "name": "bar", 56 | "attribute": true 57 | } 58 | ], 59 | "elements": [] 60 | } 61 | ] 62 | } 63 | ] 64 | } 65 | -------------------------------------------------------------------------------- /tests/issue-082-2/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema": true, 3 | "ns": 3, 4 | "namespaces": [ 5 | { 6 | "prefix": "xml", 7 | "uri": "http://www.w3.org/XML/1998/namespace" 8 | }, 9 | { 10 | "prefix": "xmlns", 11 | "uri": "http://www.w3.org/2000/xmlns/" 12 | }, 13 | { 14 | "prefix": "html", 15 | "uri": "http://www.w3.org/1999/xhtml/" 16 | }, 17 | { 18 | "prefix": "foo", 19 | "uri": "http://example.com/foo" 20 | }, 21 | { 22 | "prefix": "xs", 23 | "uri": "http://www.w3.org/2001/XMLSchema" 24 | } 25 | ], 26 | "elements": [ 27 | { 28 | "values": [], 29 | "type": null, 30 | "ns": 3, 31 | "name": "Main", 32 | "element": true, 33 | "attributes": [], 34 | "elements": [ 35 | { 36 | "values": [], 37 | "type": "string", 38 | "ns": 3, 39 | "name": "Foo", 40 | "element": true, 41 | "attributes": [ 42 | { 43 | "values": [], 44 | "type": "string", 45 | "ns": 3, 46 | "name": "bar", 47 | "attribute": true 48 | }, 49 | { 50 | "values": [], 51 | "type": "string", 52 | "ns": 3, 53 | "name": "foo", 54 | "attribute": true 55 | } 56 | ], 57 | "elements": [] 58 | } 59 | ] 60 | } 61 | ] 62 | } 63 | -------------------------------------------------------------------------------- /demo/no-target-ns.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | jQuery.xmleditor 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |
20 |

jQuery.xmleditor no target namespace Demo

21 | View 22 | the Project on GitHub UNC-Libraries/jquery.xmleditor 23 | 24 |
25 |
26 |
27 | 28 |
29 | 38 |
39 |

40 | This project is maintained by UNC-Libraries 42 |

43 |
44 | 45 | 46 | -------------------------------------------------------------------------------- /demo/xsd2json_example2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | jQuery.xmleditor 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |
20 |

jQuery.xmleditor Embedded XSD Demo

21 | View 22 | the Project on GitHub UNC-Libraries/jquery.xmleditor 23 | 24 |
25 |
26 |
27 | 28 |
29 | 38 |
39 |

40 | This project is maintained by UNC-Libraries 42 |

43 |
44 | 45 | 46 | -------------------------------------------------------------------------------- /demo/examples/atom/xml.xsd: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | See http://www.w3.org/TR/xmlbase/ for 30 | information about this attribute. 31 | 32 | 33 | 34 | 35 | 36 | See http://www.w3.org/TR/xml-id/ for 37 | information about this attribute. 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /tests/issue-078-atom/xml.xsd: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | See http://www.w3.org/TR/xmlbase/ for 30 | information about this attribute. 31 | 32 | 33 | 34 | 35 | 36 | See http://www.w3.org/TR/xml-id/ for 37 | information about this attribute. 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /demo/xsd2json_example.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | jQuery.xmleditor 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |
20 |

jQuery.xmleditor Embedded XSD Demo

21 | View 22 | the Project on GitHub UNC-Libraries/jquery.xmleditor 23 | 24 |
25 |
26 |
27 | 28 |
29 | 38 |
39 |

40 | This project is maintained by UNC-Libraries 42 |

43 |
44 | 45 | 46 | -------------------------------------------------------------------------------- /demo/include-test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | jQuery.xmleditor 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |
20 |

jQuery.xmleditor no target namespace Demo

21 | View 22 | the Project on GitHub UNC-Libraries/jquery.xmleditor 23 | 24 |
25 |
26 |
27 | 28 |
29 | 38 |
39 |

40 | This project is maintained by UNC-Libraries 42 |

43 |
44 | 45 | 46 | -------------------------------------------------------------------------------- /src/xml_autocomplete.js: -------------------------------------------------------------------------------- 1 | $.widget( "custom.xml_autocomplete", $.ui.autocomplete, { 2 | messages: { 3 | noResults: '', 4 | results: function() {} 5 | }, 6 | 7 | _create: function() { 8 | this._super(); 9 | this.menu.element.addClass("xml_autocomplete"); 10 | }, 11 | 12 | _resizeMenu: function() { 13 | var matchWidth = this.options.matchSize.outerWidth(); 14 | this.menu.element.outerWidth(matchWidth); 15 | }, 16 | 17 | _renderMenu: function( ul, items ) { 18 | var self = this; 19 | var validItemFunction = this.options.validItemFunction; 20 | 21 | // Sort suggestions by proximity of search term to the beginning of the item 22 | var rankMap = []; 23 | $.each(items, function(index, item) { 24 | if (validItemFunction && validItemFunction(item.value)) 25 | return true; 26 | rankMap.push([item.value.toLowerCase().indexOf(self.term.toLowerCase()), item]); 27 | }); 28 | 29 | if (rankMap.length == 0) { 30 | this.close(); 31 | return; 32 | } 33 | 34 | rankMap.sort(function(a, b) { 35 | return a[0] - b[0]; 36 | }); 37 | 38 | $.each(rankMap, function(index, item) { 39 | self._renderItemData(ul, item[1]); 40 | }); 41 | }, 42 | 43 | _renderItem : function(ul, item) { 44 | var re = new RegExp("((" + this.term + ")+)"); 45 | var label = item.label.replace(re, "$1"); 46 | return $("
  • ") 47 | .data("item.autocomplete", item) 48 | .append("" + label + "") 49 | .appendTo(ul); 50 | }, 51 | 52 | _move: function( direction, event ) { 53 | this._super(direction, event); 54 | this._resizeMenu(); 55 | } 56 | }); -------------------------------------------------------------------------------- /demo/mods.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | jQuery.xmleditor MODS Document Editing Demo 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 |

    jQuery.xmleditor Spoonful of Math MODS Editing Demo

    21 | View 22 | the Project on GitHub UNC-Libraries/jquery.xmleditor 23 | 24 |
    25 |
    26 |
    27 |
    28 | 40 |
    41 |

    42 | This project is maintained by UNC-Libraries 44 |

    45 |
    46 | 47 | 48 | -------------------------------------------------------------------------------- /xsd/build.js: -------------------------------------------------------------------------------- 1 | var system = require("system"); 2 | var fs = require("fs"); 3 | var page = require("webpage").create(); 4 | 5 | if (system.args.length < 2) { 6 | console.log("Usage: build.js [ ]"); 7 | console.log("Example: phantomjs build.js ../demo/examples/mods.js ../demo/examples/mods-3-4/ mods-3-4.xsd modsSchema"); 8 | phantom.exit(1); 9 | } 10 | 11 | var output = system.args[1]; 12 | // This is the directory where all it will attempt to find all referenced schemas first before trying any URLs 13 | var schemaPath = null; 14 | if (system.args.length > 2) { 15 | schemaPath = system.args[2]; 16 | } else { 17 | schemaPath = "./"; 18 | } 19 | // The filename of the first schema to process 20 | var baseSchema; 21 | if (system.args.length > 3) { 22 | baseSchema = system.args[3]; 23 | } else { 24 | baseSchema = "*.xsd"; 25 | } 26 | // Name of the JSON variable constructed from this schema 27 | var variableName = null; 28 | if (system.args.length > 4) { 29 | variableName = system.args[4]; 30 | } 31 | 32 | page.open("./build.html", function() { 33 | var json = page.evaluate(function(schemaPath, baseSchema) { 34 | var options = { 35 | 'schemaURI': schemaPath 36 | } 37 | 38 | var extractor = new Xsd2Json(baseSchema, options); 39 | 40 | return extractor.stringify(); 41 | }, schemaPath, baseSchema); 42 | 43 | if (json) { 44 | if (variableName != null) 45 | json = "var " + variableName + " = " + json + ";"; 46 | if (output) 47 | fs.write(output, json, "w"); 48 | else 49 | console.log(json); 50 | } else 51 | console.error("null result from script evaluation"); 52 | 53 | phantom.exit(); 54 | 55 | }); 56 | -------------------------------------------------------------------------------- /demo/examples/dcterms/dcmitype.xsd: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | DCMI Type Vocabulary XML Schema 11 | XML Schema for http://purl.org/dc/dcmitype/ namespace 12 | 13 | Created 2008-02-11 14 | 15 | Created by 16 | 17 | Tim Cole (t-cole3@uiuc.edu) 18 | Tom Habing (thabing@uiuc.edu) 19 | Jane Hunter (jane@dstc.edu.au) 20 | Pete Johnston (p.johnston@ukoln.ac.uk), 21 | Carl Lagoze (lagoze@cs.cornell.edu) 22 | 23 | This schema defines a simpleType which enumerates 24 | the allowable values for the DCMI Type Vocabulary. 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /tests/issue-078-dcterms/dcmitype.xsd: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | DCMI Type Vocabulary XML Schema 11 | XML Schema for http://purl.org/dc/dcmitype/ namespace 12 | 13 | Created 2008-02-11 14 | 15 | Created by 16 | 17 | Tim Cole (t-cole3@uiuc.edu) 18 | Tom Habing (thabing@uiuc.edu) 19 | Jane Hunter (jane@dstc.edu.au) 20 | Pete Johnston (p.johnston@ukoln.ac.uk), 21 | Carl Lagoze (lagoze@cs.cornell.edu) 22 | 23 | This schema defines a simpleType which enumerates 24 | the allowable values for the DCMI Type Vocabulary. 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /demo/stylesheets/reset.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2008 The University of North Carolina at Chapel Hill 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /* Eric Meyer's Reset Reloaded 17 | Accessed 3/1/10 18 | http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/ 19 | */ 20 | 21 | html, body, div, span, applet, object, iframe, 22 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 23 | a, abbr, acronym, address, big, cite, code, 24 | del, dfn, em, font, img, ins, kbd, q, s, samp, 25 | small, strike, strong, sub, sup, tt, var, 26 | dl, dt, dd, ol, ul, li, 27 | fieldset, form, label, legend, 28 | table, caption, tbody, tfoot, thead, tr, th, td { 29 | margin: 0; 30 | padding: 0; 31 | border: 0; 32 | outline: 0; 33 | font-weight: inherit; 34 | font-style: inherit; 35 | font-size: 100%; 36 | font-family: inherit; 37 | vertical-align: baseline; 38 | } 39 | /* remember to define focus styles! */ 40 | :focus { 41 | outline: 0; 42 | } 43 | body { 44 | line-height: 1; 45 | color: black; 46 | background: white; 47 | } 48 | ol, ul { 49 | list-style: none; 50 | } 51 | /* tables still need 'cellspacing="0"' in the markup */ 52 | table { 53 | border-collapse: separate; 54 | border-spacing: 0; 55 | } 56 | caption, th, td { 57 | text-align: left; 58 | font-weight: normal; 59 | } 60 | blockquote:before, blockquote:after, 61 | q:before, q:after { 62 | content: ""; 63 | } 64 | blockquote, q { 65 | quotes: "" ""; 66 | } -------------------------------------------------------------------------------- /demo/relator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 22 | 23 | 24 | 25 |
    26 | <mods xmlns="http://www.loc.gov/mods/v3"> 27 | <name> 28 | <role> 29 | <roleTerm /> 30 | </role> 31 | </name> 32 | </mods> 33 |
    34 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /demo/stylesheets/demo.css: -------------------------------------------------------------------------------- 1 | header { 2 | margin-bottom: 15px; 3 | } 4 | 5 | header h1, header h2, header h3, header h4, header h5, header h6 { 6 | color:#222; 7 | margin:0 0 20px; 8 | } 9 | 10 | header p, header ul, header ol, header table, header pre, header dl { 11 | margin:0 0 20px; 12 | } 13 | 14 | header h1, header h2, header h3 { 15 | line-height:1.1; 16 | } 17 | 18 | header h1 { 19 | font-size:28px; 20 | } 21 | 22 | header h2 { 23 | color:#393939; 24 | } 25 | 26 | header h3, header h4, header h5, header h6 { 27 | color:#494949; 28 | } 29 | 30 | header ul li + li { 31 | width:88px; 32 | border-left:1px solid #fff; 33 | } 34 | 35 | header ul li + li + li { 36 | border-right:none; 37 | width:89px; 38 | } 39 | 40 | header ul a strong { 41 | font-size:14px; 42 | display:block; 43 | color:#222; 44 | } 45 | header ul { 46 | list-style:none; 47 | height:40px; 48 | 49 | padding:0; 50 | 51 | background: #eee; 52 | background: -moz-linear-gradient(top, #f8f8f8 0%, #dddddd 100%); 53 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd)); 54 | background: -webkit-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); 55 | background: -o-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); 56 | background: -ms-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); 57 | background: linear-gradient(top, #f8f8f8 0%,#dddddd 100%); 58 | 59 | border-radius:5px; 60 | border:1px solid #d2d2d2; 61 | box-shadow:inset #fff 0 1px 0, inset rgba(0,0,0,0.03) 0 -1px 0; 62 | width:270px; 63 | } 64 | 65 | header li { 66 | width:89px; 67 | float:left; 68 | border-right:1px solid #d2d2d2; 69 | height:40px; 70 | } 71 | 72 | header ul a { 73 | line-height:1; 74 | font-size:11px; 75 | color:#999; 76 | display:block; 77 | text-align:center; 78 | padding-top:6px; 79 | height:40px; 80 | text-decoration: none; 81 | } 82 | 83 | header .view a { 84 | color: #39C; 85 | text-decoration: none; 86 | font-weight: 400px; 87 | } 88 | 89 | body { 90 | padding: 20px; 91 | color: #777195; 92 | } 93 | 94 | #xml_editor { 95 | font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif; 96 | font-size: 14px; 97 | background-color: #fff; 98 | } -------------------------------------------------------------------------------- /tests/tests.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | var runTest = function(name) { 3 | var schema = new Xsd2Json('schema.xsd', {schemaURI: name + '/'}).getSchema()(); 4 | var rawExpectedSchema; 5 | $.ajax({ 6 | url: name + '/schema.json', 7 | async: false 8 | }).done(function(data) { 9 | rawExpectedSchema = data; 10 | }); 11 | var expectedSchema = JSON.retrocycle(rawExpectedSchema); 12 | if (!_.isEqual(schema, expectedSchema)) { 13 | console.log(name, 'result', schema, 'expected', expectedSchema); 14 | throw Error('Wrong result schema'); 15 | } 16 | }; 17 | var getTestcases = function() { 18 | var responseData; 19 | $.ajax({ 20 | url: 'tests.json', 21 | async: false 22 | }).done(function(data) { 23 | responseData = data; 24 | }); 25 | return responseData.testcases; 26 | }; 27 | var buildTestcasesTable = function(testcases) { 28 | testcases.forEach(function(name) { 29 | var tr = $(''); 30 | var a = tr.find('a'); 31 | a.text(name); 32 | var m = name.match(/^issue-([0-9]+)/); 33 | if (m !== null) { 34 | var issue = m[1]; 35 | a.attr('href', 'https://github.com/UNC-Libraries/jquery.xmleditor/issues/' + issue); 36 | } 37 | tr.appendTo($('.testcases')); 38 | }); 39 | }; 40 | var main = function() { 41 | var testcases = getTestcases(); 42 | var totalCount = testcases.length; 43 | var okCount = 0; 44 | $('.totalCount').text(totalCount); 45 | buildTestcasesTable(testcases); 46 | $('.testcases tr').each(function(i, tr) { 47 | var name = $(tr).find('a').text(); 48 | var ok = false; 49 | var errorMessage = ''; 50 | try { 51 | runTest(name); 52 | ok = true; 53 | } catch (e) { 54 | errorMessage = e.message; 55 | } 56 | $(tr).addClass(ok ? 'ok' : 'failure'); 57 | $(tr).find('td').text(ok ? 'OK' : errorMessage); 58 | if (ok) { 59 | okCount++; 60 | } 61 | }); 62 | var failCount = totalCount - okCount; 63 | $('.okCount').text(okCount); 64 | $('.failCount').text(failCount); 65 | $('.summary').addClass(failCount === 0 ? 'ok' : 'failure'); 66 | }; 67 | main(); 68 | }); 69 | -------------------------------------------------------------------------------- /demo/cpf.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 22 | 23 | 24 |

    EAC-CPF Example with Language Autocomplete

    25 |

    Language suggestions in: control > languageDeclaration > language


    26 |
    27 | <eac-cpf xmlns="urn:isbn:1-931666-33-4"> 28 | <control> 29 | <languageDeclaration> 30 | <language /> 31 | </languageDeclaration> 32 | </control> 33 | </eac-cpf> 34 |
    35 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /src/xml_cdata_node.js: -------------------------------------------------------------------------------- 1 | function XMLCDataNode(cdataNode, editor) { 2 | var nodeType = { 3 | cdata : true, 4 | type : "cdata" 5 | }; 6 | 7 | XMLTextNode.call(this, cdataNode, nodeType, editor); 8 | 9 | this.objectType = nodeType; 10 | } 11 | 12 | XMLCDataNode.prototype.constructor = XMLCDataNode; 13 | XMLCDataNode.prototype = Object.create( XMLTextNode.prototype ); 14 | 15 | XMLCDataNode.prototype.addXmlNode = function(prepend) { 16 | var textValue = ""; 17 | if (!this.textNode) { 18 | var parentNode = this.parentElement.xmlNode; 19 | this.textNode = parentNode[0].ownerDocument.createCDATASection(""); 20 | if (prepend) { 21 | parentNode.prepend(this.textNode); 22 | } else { 23 | parentNode[0].appendChild(this.textNode); 24 | } 25 | this.xmlNode = $(this.textNode); 26 | } else { 27 | textValue = this.textNode.nodeValue; 28 | } 29 | return textValue; 30 | }; 31 | 32 | XMLCDataNode.prototype.render = function(parentElement, prepend) { 33 | XMLTextNode.prototype.render.call(this, parentElement, prepend); 34 | this.domNode.addClass("xml_cdata_node"); 35 | 36 | var header = document.createElement('label'); 37 | header.className = 'xml_type_header'; 38 | header.appendChild(document.createTextNode('CDATA')); 39 | $(header).attr("for", this.domNodeID + "_text"); 40 | 41 | this.domNode.children(".xml_input_column").prepend(header); 42 | }; 43 | 44 | // Persist the input value back into the text node 45 | XMLCDataNode.prototype.syncText = function() { 46 | XMLTextNode.prototype.syncText.call(this); 47 | }; 48 | 49 | XMLCDataNode.prototype.remove = function() { 50 | AbstractXMLObject.prototype.remove.call(this); 51 | }; 52 | 53 | XMLCDataNode.prototype.select = function() { 54 | XMLTextNode.prototype.select.call(this); 55 | }; 56 | 57 | XMLCDataNode.prototype.swap = function(swapTarget) { 58 | AbstractXMLObject.prototype.swap.call(this, swapTarget); 59 | }; 60 | 61 | XMLCDataNode.prototype.moveUp = function() { 62 | AbstractXMLObject.prototype.moveUp.call(this); 63 | }; 64 | 65 | XMLCDataNode.prototype.moveDown = function() { 66 | AbstractXMLObject.prototype.moveDown.call(this); 67 | }; 68 | 69 | XMLCDataNode.prototype.focus = function() { 70 | AbstractXMLObject.prototype.focus.call(this); 71 | }; 72 | 73 | XMLCDataNode.prototype.isSelected = function() { 74 | return AbstractXMLObject.prototype.isSelected.call(this); 75 | }; -------------------------------------------------------------------------------- /src/xml_attribute_stub.js: -------------------------------------------------------------------------------- 1 | function XMLAttributeStub(xmlElement, editor) { 2 | this.objectType = { 3 | attrStub : true 4 | }; 5 | this.editor = editor; 6 | this.guiEditor = this.editor.guiEditor; 7 | // dom element header for this element 8 | this.elementHeader = null; 9 | this.tagName = ""; 10 | 11 | this.xmlElement = xmlElement; 12 | 13 | this.nameInput = null; 14 | } 15 | 16 | XMLAttributeStub.prototype.render = function() { 17 | this.domNodeID = "attr_stub_" + this.guiEditor.nextIndex(); 18 | 19 | this.domNode = $("
    ").attr({ 20 | 'id' : this.domNodeID + "_cont", 21 | 'class' : attributeContainerClass + " xml_attr_stub" 22 | }).data('xmlAttribute', this).appendTo(this.xmlElement.getAttributeContainer()); 23 | 24 | var self = this; 25 | var removeButton = document.createElement('a'); 26 | removeButton.appendChild(document.createTextNode('(x) ')); 27 | this.domNode[0].appendChild(removeButton); 28 | 29 | this.nameInput = document.createElement('label'); 30 | this.nameInput.className = "edit_title"; 31 | this.nameInput.setAttribute("contenteditable", "true"); 32 | this.domNode[0].appendChild(this.nameInput); 33 | this.nameInput = $(this.nameInput); 34 | 35 | var createLink = $("create attribute").appendTo(this.domNode).mouseup(function(e){ 36 | self.create(); 37 | }); 38 | 39 | stubNameInput.call(this, this.nameInput, this.xmlElement.objectType.attributes, 40 | $.proxy(this.xmlElement.attributeExists, this.xmlElement)); 41 | 42 | return this.domNode; 43 | }; 44 | 45 | XMLAttributeStub.prototype.remove = function() { 46 | this.domNode.remove(); 47 | }; 48 | 49 | XMLAttributeStub.prototype.create = function() { 50 | var attrName = this.nameInput.text(); 51 | var newAttr = this.editor.addAttribute(this.xmlElement, attrName); 52 | 53 | if (newAttr instanceof AbstractXMLObject) { 54 | this.remove(); 55 | } else { 56 | console.log(newAttr); 57 | } 58 | }; 59 | 60 | XMLAttributeStub.prototype.select = function() { 61 | this.domNode.addClass("selected"); 62 | }; 63 | 64 | XMLAttributeStub.prototype.deselect = function() { 65 | this.domNode.removeClass('selected'); 66 | }; 67 | 68 | XMLAttributeStub.prototype.isSelected = function() { 69 | return this.domNode.hasClass("selected"); 70 | }; 71 | 72 | XMLAttributeStub.prototype.focus = function() { 73 | this.nameInput.focus(); 74 | }; 75 | -------------------------------------------------------------------------------- /src/xml_comment_node.js: -------------------------------------------------------------------------------- 1 | function XMLCommentNode(cdataNode, editor) { 2 | var nodeType = { 3 | comment : true, 4 | type : "comment" 5 | }; 6 | 7 | XMLTextNode.call(this, cdataNode, nodeType, editor); 8 | 9 | this.objectType = nodeType; 10 | } 11 | 12 | XMLCommentNode.prototype.constructor = XMLCommentNode; 13 | XMLCommentNode.prototype = Object.create( XMLTextNode.prototype ); 14 | 15 | XMLCommentNode.prototype.addXmlNode = function(prepend) { 16 | var textValue = ""; 17 | if (!this.textNode) { 18 | var parentNode = this.parentElement.xmlNode; 19 | this.textNode = parentNode[0].ownerDocument.createComment(""); 20 | if (prepend) { 21 | parentNode.prepend(this.textNode); 22 | } else { 23 | parentNode[0].appendChild(this.textNode); 24 | } 25 | this.xmlNode = $(this.textNode); 26 | } else { 27 | textValue = this.textNode.nodeValue; 28 | } 29 | return textValue; 30 | }; 31 | 32 | XMLCommentNode.prototype.render = function(parentElement, prepend) { 33 | XMLTextNode.prototype.render.call(this, parentElement, prepend); 34 | this.domNode.addClass("xml_comment_node"); 35 | 36 | var header = document.createElement('label'); 37 | header.className = 'xml_type_header'; 38 | header.appendChild(document.createTextNode('comment')); 39 | $(header).attr("for", this.domNodeID + "_text"); 40 | 41 | this.domNode.children(".xml_input_column").prepend(header); 42 | }; 43 | 44 | // Persist the input value back into the text node 45 | XMLCommentNode.prototype.syncText = function() { 46 | XMLTextNode.prototype.syncText.call(this); 47 | }; 48 | 49 | XMLCommentNode.prototype.remove = function() { 50 | AbstractXMLObject.prototype.remove.call(this); 51 | }; 52 | 53 | XMLCommentNode.prototype.select = function() { 54 | XMLTextNode.prototype.select.call(this); 55 | }; 56 | 57 | XMLCommentNode.prototype.swap = function(swapTarget) { 58 | AbstractXMLObject.prototype.swap.call(this, swapTarget); 59 | }; 60 | 61 | XMLCommentNode.prototype.moveUp = function() { 62 | AbstractXMLObject.prototype.moveUp.call(this); 63 | }; 64 | 65 | XMLCommentNode.prototype.moveDown = function() { 66 | AbstractXMLObject.prototype.moveDown.call(this); 67 | }; 68 | 69 | XMLCommentNode.prototype.focus = function() { 70 | AbstractXMLObject.prototype.focus.call(this); 71 | }; 72 | 73 | XMLCommentNode.prototype.isSelected = function() { 74 | return AbstractXMLObject.prototype.isSelected.call(this); 75 | }; -------------------------------------------------------------------------------- /demo/templates.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | jQuery.xmleditor 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 26 | 27 | 28 | 29 |
    30 |
    31 |

    jQuery.xmleditor MODS Editing Demo

    32 | View 33 | the Project on GitHub UNC-Libraries/jquery.xmleditor 34 | 35 |
    36 |
    37 |
    38 |
    39 | 58 |
    59 |

    60 | This project is maintained by UNC-Libraries 62 |

    63 |
    64 | 65 | 66 | -------------------------------------------------------------------------------- /demo/atom.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |

    Atom example

    19 | 57 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/format_xml.js: -------------------------------------------------------------------------------- 1 | var XML_CHAR_MAP = { 2 | '<': '<', 3 | '>': '>', 4 | '&': '&', 5 | '"': '"', 6 | "'": ''' 7 | }; 8 | 9 | function escapeXml (s) { 10 | return s.replace(/[<>&"']/g, function (ch) { 11 | return XML_CHAR_MAP[ch]; 12 | }); 13 | } 14 | 15 | function formatXML(element, indent, options) { 16 | 17 | var children = element.childNodes; 18 | var prevNode = null; 19 | var whitespace = ""; 20 | var containsText = false; 21 | 22 | var contents = ""; 23 | var attrContents = ""; 24 | 25 | for (var index in children) { 26 | var childNode = children[index] 27 | switch (childNode.nodeType) { 28 | case 1 : // element 29 | var tagIndent = ""; 30 | var nextIndent = ""; 31 | if (!containsText) { 32 | if (element.nodeType != 9) { 33 | nextIndent = indent + " "; 34 | tagIndent = "\n"; 35 | } 36 | } 37 | 38 | contents += tagIndent + formatXML(childNode, nextIndent, options); 39 | containsText = false; 40 | break; 41 | case 3 : // text 42 | var value = childNode.nodeValue; 43 | if ($.trim(value)) { 44 | contents += whitespace + escapeXml(value); 45 | whitespace = ""; 46 | containsText = true; 47 | } else { 48 | whitespace = value; 49 | } 50 | break; 51 | case 4 : // cdata 52 | if (!containsText) { 53 | if (element.nodeType != 9) { 54 | contents += "\n" + indent + " "; 55 | } 56 | } 57 | contents += ""; 58 | break; 59 | case 8 : // comment 60 | if (!containsText) { 61 | if (element.nodeType != 9) { 62 | contents += "\n" + indent + " "; 63 | } 64 | } 65 | contents += ""; 66 | break; 67 | } 68 | 69 | prevNode = childNode; 70 | } 71 | 72 | var attributes = element.attributes; 73 | if (attributes) { 74 | var xmlnsPattern = /^xmlns:?(.*)$/; 75 | var previousWasNS = false; 76 | for (var index = 0; index < attributes.length; index++) { 77 | if (previousWasNS) { 78 | attrContents += "\n" + indent + " "; 79 | previousWasNS = false; 80 | } 81 | attrContents += " " + attributes[index].nodeName + '="' + escapeXml(attributes[index].nodeValue) +'"'; 82 | if (xmlnsPattern.test(attributes[index].nodeName)) 83 | previousWasNS = true; 84 | } 85 | } 86 | 87 | if (element.nodeType == 1) { 88 | if (contents) { 89 | var closingIndent = (!containsText)? "\n" + indent : ""; 90 | return indent + "<" + element.nodeName + attrContents + ">" + contents + closingIndent + ""; 91 | } else { 92 | return indent + "<" + element.nodeName + attrContents + " />"; 93 | } 94 | } else { 95 | return contents; 96 | } 97 | 98 | } -------------------------------------------------------------------------------- /src/attribute_menu.js: -------------------------------------------------------------------------------- 1 | function AttributeMenu(menuID, label, expanded, enabled, owner, editor) { 2 | ModifyElementMenu.call(this, menuID, label, expanded, enabled, owner, editor); 3 | } 4 | 5 | AttributeMenu.prototype.constructor = AttributeMenu; 6 | AttributeMenu.prototype = Object.create( ModifyElementMenu.prototype ); 7 | 8 | AttributeMenu.prototype.initEventHandlers = function() { 9 | var self = this; 10 | this.menuContent.on('click', 'li', function(event){ 11 | self.owner.editor.addAttributeButtonCallback(this); 12 | }); 13 | }; 14 | 15 | AttributeMenu.prototype.populate = function (xmlElement) { 16 | if (xmlElement == null || (this.target != null && xmlElement.domNode != null 17 | && this.target[0] === xmlElement.domNode[0])) 18 | return; 19 | 20 | if (this.expanded) 21 | this.menuContent.css("height", "auto"); 22 | var startingHeight = this.menuContent.outerHeight(); 23 | this.menuContent.empty(); 24 | 25 | this.target = xmlElement; 26 | 27 | var attributesArray = this.target.objectType.attributes; 28 | if (attributesArray) { 29 | var attributesPresent = {}; 30 | $(this.target.xmlNode[0].attributes).each(function() { 31 | var targetAttribute = this; 32 | $.each(attributesArray, function(){ 33 | if (this.name == targetAttribute.nodeName) { 34 | attributesPresent[this.name] = $("#" + xmlElement.domNodeID + "_" + targetAttribute.nodeName.replace(':', '-')); 35 | } 36 | }); 37 | }); 38 | 39 | var self = this; 40 | $.each(this.target.objectType.attributes, function(){ 41 | var attribute = this; 42 | // Using prefix according to the xml document namespace prefixes 43 | var nsPrefix = self.editor.xmlState.getNamespacePrefix(attribute.namespace); 44 | 45 | var attrName = nsPrefix + attribute.localName; 46 | var addButton = $("
  • ").attr({ 47 | title : 'Add ' + attrName, 48 | 'id' : xmlElement.domNodeID + "_" + attrName.replace(":", "_") + "_add" 49 | }).html(attrName) 50 | .data('xml', { 51 | "objectType": attribute, 52 | "target": xmlElement 53 | }).appendTo(self.menuContent); 54 | 55 | if (attribute.name in attributesPresent) { 56 | addButton.addClass("disabled"); 57 | if (attributesPresent[attribute.name].length > 0) 58 | attributesPresent[attribute.name].data('xmlAttribute').addButton = addButton; 59 | } 60 | }); 61 | } 62 | 63 | if (this.expanded) { 64 | var endingHeight = this.menuContent.outerHeight(); 65 | if (endingHeight == 0) 66 | endingHeight = 1; 67 | this.menuContent.css({height: startingHeight + "px"}).stop().animate({height: endingHeight + "px"}, menuExpandDuration).show(); 68 | } 69 | 70 | if (this.menuContent.children().length == 0) { 71 | this.menuHeader.addClass("disabled"); 72 | this.enabled = false; 73 | } else { 74 | this.menuHeader.removeClass("disabled"); 75 | this.enabled = true; 76 | } 77 | 78 | return this; 79 | }; 80 | -------------------------------------------------------------------------------- /lib/jquery.autosize-min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | jQuery Autosize v1.16.20 3 | (c) 2013 Jack Moore - jacklmoore.com 4 | updated: 2013-06-18 5 | license: http://www.opensource.org/licenses/mit-license.php 6 | */ 7 | (function(e){var t,o={className:"autosizejs",append:"",callback:!1,resizeDelay:10},i='