process_engine 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +37 -0
- data/app/assets/bower_components/process_engine/Snap.svg/CONTRIBUTING +3 -0
- data/app/assets/bower_components/process_engine/Snap.svg/Gruntfile.js +59 -0
- data/app/assets/bower_components/process_engine/Snap.svg/LICENSE +202 -0
- data/app/assets/bower_components/process_engine/Snap.svg/NOTICE +190 -0
- data/app/assets/bower_components/process_engine/Snap.svg/README.md +62 -0
- data/app/assets/bower_components/process_engine/Snap.svg/bower.json +25 -0
- data/app/assets/bower_components/process_engine/Snap.svg/component.json +13 -0
- data/app/assets/bower_components/process_engine/Snap.svg/dist/snap.svg-min.js +20 -0
- data/app/assets/bower_components/process_engine/Snap.svg/dist/snap.svg.js +7653 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/css/dr.css +144 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/css/main.css +508 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/css/prism.css +168 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/css/topcoat-desktop-light.css +3700 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/fonts/sourcecodepro-regular-webfont.eot +0 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/fonts/sourcecodepro-regular-webfont.svg +242 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/fonts/sourcecodepro-regular-webfont.ttf +0 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/fonts/sourcecodepro-regular-webfont.woff +0 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/fonts/sourcesanspro-light-webfont.eot +0 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/fonts/sourcesanspro-light-webfont.svg +243 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/fonts/sourcesanspro-light-webfont.ttf +0 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/fonts/sourcesanspro-light-webfont.woff +0 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/fonts/sourcesanspro-regular-webfont.eot +0 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/fonts/sourcesanspro-regular-webfont.svg +243 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/fonts/sourcesanspro-regular-webfont.ttf +0 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/fonts/sourcesanspro-regular-webfont.woff +0 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/fonts/sourcesanspro-semibold-webfont.eot +0 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/fonts/sourcesanspro-semibold-webfont.svg +243 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/fonts/sourcesanspro-semibold-webfont.ttf +0 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/fonts/sourcesanspro-semibold-webfont.woff +0 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/fonts/stylesheet.css +57 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/img/search.svg +11 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/img/search_dark.svg +16 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/js/prism.js +9 -0
- data/app/assets/bower_components/process_engine/Snap.svg/doc/reference.html +13633 -0
- data/app/assets/bower_components/process_engine/Snap.svg/dr.json +33 -0
- data/app/assets/bower_components/process_engine/Snap.svg/history.md +31 -0
- data/app/assets/bower_components/process_engine/Snap.svg/package.json +22 -0
- data/app/assets/bower_components/process_engine/Snap.svg/template.dot +157 -0
- data/app/assets/bower_components/process_engine/Snap.svg/test.html +75 -0
- data/app/assets/bower_components/process_engine/bpmn-js/LICENSE +22 -0
- data/app/assets/bower_components/process_engine/bpmn-js/README.md +46 -0
- data/app/assets/bower_components/process_engine/bpmn-js/bower.json +28 -0
- data/app/assets/bower_components/process_engine/bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css +40 -0
- data/app/assets/bower_components/process_engine/bpmn-js/dist/assets/bpmn-font/font/bpmn.eot +0 -0
- data/app/assets/bower_components/process_engine/bpmn-js/dist/assets/bpmn-font/font/bpmn.svg +21 -0
- data/app/assets/bower_components/process_engine/bpmn-js/dist/assets/bpmn-font/font/bpmn.ttf +0 -0
- data/app/assets/bower_components/process_engine/bpmn-js/dist/assets/bpmn-font/font/bpmn.woff +0 -0
- data/app/assets/bower_components/process_engine/bpmn-js/dist/assets/diagram-js.css +355 -0
- data/app/assets/bower_components/process_engine/bpmn-js/dist/bpmn-modeler.js +21552 -0
- data/app/assets/bower_components/process_engine/bpmn-js/dist/bpmn-modeler.js.map +1 -0
- data/app/assets/bower_components/process_engine/bpmn-js/dist/bpmn-modeler.min.js +8 -0
- data/app/assets/bower_components/process_engine/bpmn-js/dist/bpmn-navigated-viewer.js +13542 -0
- data/app/assets/bower_components/process_engine/bpmn-js/dist/bpmn-navigated-viewer.js.map +1 -0
- data/app/assets/bower_components/process_engine/bpmn-js/dist/bpmn-navigated-viewer.min.js +5 -0
- data/app/assets/bower_components/process_engine/bpmn-js/dist/bpmn-viewer.js +13294 -0
- data/app/assets/bower_components/process_engine/bpmn-js/dist/bpmn-viewer.js.map +1 -0
- data/app/assets/bower_components/process_engine/bpmn-js/dist/bpmn-viewer.min.js +5 -0
- data/app/assets/bower_components/process_engine/hammerjs/CHANGELOG.md +30 -0
- data/app/assets/bower_components/process_engine/hammerjs/CONTRIBUTING.md +41 -0
- data/app/assets/bower_components/process_engine/hammerjs/Gruntfile.coffee +123 -0
- data/app/assets/bower_components/process_engine/hammerjs/LICENSE.md +21 -0
- data/app/assets/bower_components/process_engine/hammerjs/README.md +6 -0
- data/app/assets/bower_components/process_engine/hammerjs/bower.json +9 -0
- data/app/assets/bower_components/process_engine/hammerjs/component.json +8 -0
- data/app/assets/bower_components/process_engine/hammerjs/hammer.js +2463 -0
- data/app/assets/bower_components/process_engine/hammerjs/hammer.min.js +7 -0
- data/app/assets/bower_components/process_engine/hammerjs/hammer.min.map +1 -0
- data/app/assets/bower_components/process_engine/hammerjs/package.json +50 -0
- data/app/assets/bower_components/process_engine/jquery/MIT-LICENSE.txt +21 -0
- data/app/assets/bower_components/process_engine/jquery/bower.json +27 -0
- data/app/assets/bower_components/process_engine/jquery/dist/jquery.js +9205 -0
- data/app/assets/bower_components/process_engine/jquery/dist/jquery.min.js +5 -0
- data/app/assets/bower_components/process_engine/jquery/dist/jquery.min.map +1 -0
- data/app/assets/bower_components/process_engine/jquery/src/ajax/jsonp.js +89 -0
- data/app/assets/bower_components/process_engine/jquery/src/ajax/load.js +75 -0
- data/app/assets/bower_components/process_engine/jquery/src/ajax/parseJSON.js +13 -0
- data/app/assets/bower_components/process_engine/jquery/src/ajax/parseXML.js +28 -0
- data/app/assets/bower_components/process_engine/jquery/src/ajax/script.js +64 -0
- data/app/assets/bower_components/process_engine/jquery/src/ajax/var/nonce.js +5 -0
- data/app/assets/bower_components/process_engine/jquery/src/ajax/var/rquery.js +3 -0
- data/app/assets/bower_components/process_engine/jquery/src/ajax/xhr.js +136 -0
- data/app/assets/bower_components/process_engine/jquery/src/ajax.js +786 -0
- data/app/assets/bower_components/process_engine/jquery/src/attributes/attr.js +141 -0
- data/app/assets/bower_components/process_engine/jquery/src/attributes/classes.js +158 -0
- data/app/assets/bower_components/process_engine/jquery/src/attributes/prop.js +94 -0
- data/app/assets/bower_components/process_engine/jquery/src/attributes/support.js +35 -0
- data/app/assets/bower_components/process_engine/jquery/src/attributes/val.js +161 -0
- data/app/assets/bower_components/process_engine/jquery/src/attributes.js +11 -0
- data/app/assets/bower_components/process_engine/jquery/src/callbacks.js +205 -0
- data/app/assets/bower_components/process_engine/jquery/src/core/access.js +60 -0
- data/app/assets/bower_components/process_engine/jquery/src/core/init.js +123 -0
- data/app/assets/bower_components/process_engine/jquery/src/core/parseHTML.js +39 -0
- data/app/assets/bower_components/process_engine/jquery/src/core/ready.js +97 -0
- data/app/assets/bower_components/process_engine/jquery/src/core/var/rsingleTag.js +4 -0
- data/app/assets/bower_components/process_engine/jquery/src/core.js +497 -0
- data/app/assets/bower_components/process_engine/jquery/src/css/addGetHookIf.js +22 -0
- data/app/assets/bower_components/process_engine/jquery/src/css/curCSS.js +57 -0
- data/app/assets/bower_components/process_engine/jquery/src/css/defaultDisplay.js +70 -0
- data/app/assets/bower_components/process_engine/jquery/src/css/hiddenVisibleSelectors.js +15 -0
- data/app/assets/bower_components/process_engine/jquery/src/css/support.js +96 -0
- data/app/assets/bower_components/process_engine/jquery/src/css/swap.js +28 -0
- data/app/assets/bower_components/process_engine/jquery/src/css/var/cssExpand.js +3 -0
- data/app/assets/bower_components/process_engine/jquery/src/css/var/getStyles.js +12 -0
- data/app/assets/bower_components/process_engine/jquery/src/css/var/isHidden.js +13 -0
- data/app/assets/bower_components/process_engine/jquery/src/css/var/rmargin.js +3 -0
- data/app/assets/bower_components/process_engine/jquery/src/css/var/rnumnonpx.js +5 -0
- data/app/assets/bower_components/process_engine/jquery/src/css.js +450 -0
- data/app/assets/bower_components/process_engine/jquery/src/data/Data.js +181 -0
- data/app/assets/bower_components/process_engine/jquery/src/data/accepts.js +20 -0
- data/app/assets/bower_components/process_engine/jquery/src/data/var/data_priv.js +5 -0
- data/app/assets/bower_components/process_engine/jquery/src/data/var/data_user.js +5 -0
- data/app/assets/bower_components/process_engine/jquery/src/data.js +178 -0
- data/app/assets/bower_components/process_engine/jquery/src/deferred.js +149 -0
- data/app/assets/bower_components/process_engine/jquery/src/deprecated.js +13 -0
- data/app/assets/bower_components/process_engine/jquery/src/dimensions.js +50 -0
- data/app/assets/bower_components/process_engine/jquery/src/effects/Tween.js +114 -0
- data/app/assets/bower_components/process_engine/jquery/src/effects/animatedSelector.js +13 -0
- data/app/assets/bower_components/process_engine/jquery/src/effects.js +648 -0
- data/app/assets/bower_components/process_engine/jquery/src/event/ajax.js +13 -0
- data/app/assets/bower_components/process_engine/jquery/src/event/alias.js +39 -0
- data/app/assets/bower_components/process_engine/jquery/src/event/support.js +9 -0
- data/app/assets/bower_components/process_engine/jquery/src/event.js +868 -0
- data/app/assets/bower_components/process_engine/jquery/src/exports/amd.js +24 -0
- data/app/assets/bower_components/process_engine/jquery/src/exports/global.js +32 -0
- data/app/assets/bower_components/process_engine/jquery/src/intro.js +44 -0
- data/app/assets/bower_components/process_engine/jquery/src/jquery.js +37 -0
- data/app/assets/bower_components/process_engine/jquery/src/manipulation/_evalUrl.js +18 -0
- data/app/assets/bower_components/process_engine/jquery/src/manipulation/support.js +32 -0
- data/app/assets/bower_components/process_engine/jquery/src/manipulation/var/rcheckableType.js +3 -0
- data/app/assets/bower_components/process_engine/jquery/src/manipulation.js +580 -0
- data/app/assets/bower_components/process_engine/jquery/src/offset.js +207 -0
- data/app/assets/bower_components/process_engine/jquery/src/outro.js +1 -0
- data/app/assets/bower_components/process_engine/jquery/src/queue/delay.js +22 -0
- data/app/assets/bower_components/process_engine/jquery/src/queue.js +142 -0
- data/app/assets/bower_components/process_engine/jquery/src/selector-native.js +172 -0
- data/app/assets/bower_components/process_engine/jquery/src/selector-sizzle.js +14 -0
- data/app/assets/bower_components/process_engine/jquery/src/selector.js +1 -0
- data/app/assets/bower_components/process_engine/jquery/src/serialize.js +111 -0
- data/app/assets/bower_components/process_engine/jquery/src/sizzle/dist/sizzle.js +2067 -0
- data/app/assets/bower_components/process_engine/jquery/src/sizzle/dist/sizzle.min.js +3 -0
- data/app/assets/bower_components/process_engine/jquery/src/sizzle/dist/sizzle.min.map +1 -0
- data/app/assets/bower_components/process_engine/jquery/src/traversing/findFilter.js +100 -0
- data/app/assets/bower_components/process_engine/jquery/src/traversing/var/rneedsContext.js +6 -0
- data/app/assets/bower_components/process_engine/jquery/src/traversing.js +199 -0
- data/app/assets/bower_components/process_engine/jquery/src/var/arr.js +3 -0
- data/app/assets/bower_components/process_engine/jquery/src/var/class2type.js +4 -0
- data/app/assets/bower_components/process_engine/jquery/src/var/concat.js +5 -0
- data/app/assets/bower_components/process_engine/jquery/src/var/hasOwn.js +5 -0
- data/app/assets/bower_components/process_engine/jquery/src/var/indexOf.js +5 -0
- data/app/assets/bower_components/process_engine/jquery/src/var/pnum.js +3 -0
- data/app/assets/bower_components/process_engine/jquery/src/var/push.js +5 -0
- data/app/assets/bower_components/process_engine/jquery/src/var/rnotwhite.js +3 -0
- data/app/assets/bower_components/process_engine/jquery/src/var/slice.js +5 -0
- data/app/assets/bower_components/process_engine/jquery/src/var/strundefined.js +3 -0
- data/app/assets/bower_components/process_engine/jquery/src/var/support.js +4 -0
- data/app/assets/bower_components/process_engine/jquery/src/var/toString.js +5 -0
- data/app/assets/bower_components/process_engine/jquery/src/wrap.js +79 -0
- data/app/assets/bower_components/process_engine/jquery-mousewheel/ChangeLog.md +141 -0
- data/app/assets/bower_components/process_engine/jquery-mousewheel/LICENSE.txt +20 -0
- data/app/assets/bower_components/process_engine/jquery-mousewheel/README.md +85 -0
- data/app/assets/bower_components/process_engine/jquery-mousewheel/bower.json +17 -0
- data/app/assets/bower_components/process_engine/jquery-mousewheel/jquery.mousewheel.js +221 -0
- data/app/assets/bower_components/process_engine/jquery-mousewheel/jquery.mousewheel.min.js +8 -0
- data/app/assets/bower_components/process_engine/lodash/LICENSE.txt +22 -0
- data/app/assets/bower_components/process_engine/lodash/bower.json +23 -0
- data/app/assets/bower_components/process_engine/lodash/dist/lodash.compat.js +7157 -0
- data/app/assets/bower_components/process_engine/lodash/dist/lodash.compat.min.js +61 -0
- data/app/assets/bower_components/process_engine/lodash/dist/lodash.js +6785 -0
- data/app/assets/bower_components/process_engine/lodash/dist/lodash.min.js +56 -0
- data/app/assets/bower_components/process_engine/lodash/dist/lodash.underscore.js +4979 -0
- data/app/assets/bower_components/process_engine/lodash/dist/lodash.underscore.min.js +39 -0
- data/app/assets/bower_components/process_engine/sax/AUTHORS +10 -0
- data/app/assets/bower_components/process_engine/sax/LICENSE +32 -0
- data/app/assets/bower_components/process_engine/sax/LICENSE-W3C.html +188 -0
- data/app/assets/bower_components/process_engine/sax/README.md +216 -0
- data/app/assets/bower_components/process_engine/sax/component.json +12 -0
- data/app/assets/bower_components/process_engine/sax/examples/big-not-pretty.xml +8002 -0
- data/app/assets/bower_components/process_engine/sax/examples/example.js +29 -0
- data/app/assets/bower_components/process_engine/sax/examples/get-products.js +58 -0
- data/app/assets/bower_components/process_engine/sax/examples/hello-world.js +4 -0
- data/app/assets/bower_components/process_engine/sax/examples/not-pretty.xml +8 -0
- data/app/assets/bower_components/process_engine/sax/examples/pretty-print.js +74 -0
- data/app/assets/bower_components/process_engine/sax/examples/shopping.xml +2 -0
- data/app/assets/bower_components/process_engine/sax/examples/strict.dtd +870 -0
- data/app/assets/bower_components/process_engine/sax/examples/test.html +15 -0
- data/app/assets/bower_components/process_engine/sax/examples/test.xml +1254 -0
- data/app/assets/bower_components/process_engine/sax/lib/sax.js +1410 -0
- data/app/assets/bower_components/process_engine/sax/package.json +12 -0
- data/app/assets/bower_components/process_engine/sax/test/attribute-name.js +33 -0
- data/app/assets/bower_components/process_engine/sax/test/attribute-no-space.js +75 -0
- data/app/assets/bower_components/process_engine/sax/test/buffer-overrun.js +26 -0
- data/app/assets/bower_components/process_engine/sax/test/case.js +50 -0
- data/app/assets/bower_components/process_engine/sax/test/cdata-chunked.js +11 -0
- data/app/assets/bower_components/process_engine/sax/test/cdata-end-split.js +15 -0
- data/app/assets/bower_components/process_engine/sax/test/cdata-fake-end.js +28 -0
- data/app/assets/bower_components/process_engine/sax/test/cdata-multiple.js +15 -0
- data/app/assets/bower_components/process_engine/sax/test/cdata.js +10 -0
- data/app/assets/bower_components/process_engine/sax/test/cyrillic.js +8 -0
- data/app/assets/bower_components/process_engine/sax/test/duplicate-attribute.js +13 -0
- data/app/assets/bower_components/process_engine/sax/test/emoji.js +12 -0
- data/app/assets/bower_components/process_engine/sax/test/end_empty_stream.js +5 -0
- data/app/assets/bower_components/process_engine/sax/test/entities.js +10 -0
- data/app/assets/bower_components/process_engine/sax/test/entity-mega.js +16 -0
- data/app/assets/bower_components/process_engine/sax/test/flush.js +13 -0
- data/app/assets/bower_components/process_engine/sax/test/index.js +86 -0
- data/app/assets/bower_components/process_engine/sax/test/issue-23.js +43 -0
- data/app/assets/bower_components/process_engine/sax/test/issue-30.js +24 -0
- data/app/assets/bower_components/process_engine/sax/test/issue-35.js +15 -0
- data/app/assets/bower_components/process_engine/sax/test/issue-47.js +12 -0
- data/app/assets/bower_components/process_engine/sax/test/issue-49.js +31 -0
- data/app/assets/bower_components/process_engine/sax/test/issue-84.js +13 -0
- data/app/assets/bower_components/process_engine/sax/test/parser-position.js +28 -0
- data/app/assets/bower_components/process_engine/sax/test/script-close-better.js +12 -0
- data/app/assets/bower_components/process_engine/sax/test/script.js +12 -0
- data/app/assets/bower_components/process_engine/sax/test/self-closing-child-strict.js +44 -0
- data/app/assets/bower_components/process_engine/sax/test/self-closing-child.js +44 -0
- data/app/assets/bower_components/process_engine/sax/test/self-closing-tag.js +25 -0
- data/app/assets/bower_components/process_engine/sax/test/stray-ending.js +17 -0
- data/app/assets/bower_components/process_engine/sax/test/trailing-attribute-no-value.js +10 -0
- data/app/assets/bower_components/process_engine/sax/test/trailing-non-whitespace.js +18 -0
- data/app/assets/bower_components/process_engine/sax/test/unclosed-root.js +11 -0
- data/app/assets/bower_components/process_engine/sax/test/unquoted.js +18 -0
- data/app/assets/bower_components/process_engine/sax/test/utf8-split.js +32 -0
- data/app/assets/bower_components/process_engine/sax/test/xmlns-as-tag-name.js +15 -0
- data/app/assets/bower_components/process_engine/sax/test/xmlns-issue-41.js +68 -0
- data/app/assets/bower_components/process_engine/sax/test/xmlns-rebinding.js +63 -0
- data/app/assets/bower_components/process_engine/sax/test/xmlns-strict.js +74 -0
- data/app/assets/bower_components/process_engine/sax/test/xmlns-unbound-element.js +33 -0
- data/app/assets/bower_components/process_engine/sax/test/xmlns-unbound.js +15 -0
- data/app/assets/bower_components/process_engine/sax/test/xmlns-xml-default-ns.js +31 -0
- data/app/assets/bower_components/process_engine/sax/test/xmlns-xml-default-prefix-attribute.js +36 -0
- data/app/assets/bower_components/process_engine/sax/test/xmlns-xml-default-prefix.js +21 -0
- data/app/assets/bower_components/process_engine/sax/test/xmlns-xml-default-redefine.js +41 -0
- data/app/assets/javascripts/process_engine/application.js +65 -0
- data/app/assets/stylesheets/process_engine/application.css +39 -0
- data/app/controllers/process_engine/application_controller.rb +28 -0
- data/app/controllers/process_engine/process_definitions_controller.rb +63 -0
- data/app/controllers/process_engine/process_instances_controller.rb +42 -0
- data/app/controllers/process_engine/process_tasks_controller.rb +23 -0
- data/app/helpers/process_engine/application_helper.rb +4 -0
- data/app/models/process_engine/consumer/consumer_task.rb +15 -0
- data/app/models/process_engine/error/false_task_state.rb +2 -0
- data/app/models/process_engine/listener/base.rb +49 -0
- data/app/models/process_engine/node_data_injection.rb +22 -0
- data/app/models/process_engine/parser/complex_gateway.rb +21 -0
- data/app/models/process_engine/parser/end_event.rb +23 -0
- data/app/models/process_engine/parser/exclusive_gateway.rb +25 -0
- data/app/models/process_engine/parser/extension/condition_expression.rb +39 -0
- data/app/models/process_engine/parser/extension/execution_listener.rb +15 -0
- data/app/models/process_engine/parser/extension/form_field.rb +50 -0
- data/app/models/process_engine/parser/extension/input_output.rb +28 -0
- data/app/models/process_engine/parser/extension/listener.rb +43 -0
- data/app/models/process_engine/parser/extension/property.rb +20 -0
- data/app/models/process_engine/parser/extension/task_listener.rb +15 -0
- data/app/models/process_engine/parser/extension/transitional_parameter.rb +53 -0
- data/app/models/process_engine/parser/inclusive_gateway.rb +25 -0
- data/app/models/process_engine/parser/parallel_gateway.rb +19 -0
- data/app/models/process_engine/parser/script_task.rb +37 -0
- data/app/models/process_engine/parser/sequence_flow.rb +36 -0
- data/app/models/process_engine/parser/start_event.rb +27 -0
- data/app/models/process_engine/parser/user_task.rb +36 -0
- data/app/models/process_engine/parser/xml_node.rb +125 -0
- data/app/models/process_engine/process_definition.rb +50 -0
- data/app/models/process_engine/process_instance.rb +72 -0
- data/app/models/process_engine/process_query.rb +52 -0
- data/app/models/process_engine/process_schema.rb +30 -0
- data/app/models/process_engine/process_task.rb +70 -0
- data/app/models/process_engine/schema/interceptor/exclusive_gateway.rb +39 -0
- data/app/models/process_engine/schema/node.rb +48 -0
- data/app/models/process_engine/schema/node_extension.rb +79 -0
- data/app/models/process_engine/schema/transition.rb +22 -0
- data/app/views/layouts/process_engine/application.html.erb +14 -0
- data/app/views/process_engine/layouts/_menu.html.haml +6 -0
- data/app/views/process_engine/layouts/application.html.haml +11 -0
- data/app/views/process_engine/process_definitions/_form.html.haml +6 -0
- data/app/views/process_engine/process_definitions/edit.html.haml +3 -0
- data/app/views/process_engine/process_definitions/index.html.haml +26 -0
- data/app/views/process_engine/process_definitions/new.html.haml +3 -0
- data/app/views/process_engine/process_definitions/show.html.haml +51 -0
- data/app/views/process_engine/process_instances/_form.html.haml +5 -0
- data/app/views/process_engine/process_instances/edit.html.haml +3 -0
- data/app/views/process_engine/process_instances/index.html.haml +29 -0
- data/app/views/process_engine/process_instances/show.html.haml +38 -0
- data/app/views/process_engine/process_tasks/index.html.haml +44 -0
- data/app/views/process_engine/share/_bpmn_canvas.html.haml +7 -0
- data/config/initializers/bower_rails.rb +16 -0
- data/config/initializers/simple_form.rb +166 -0
- data/config/initializers/simple_form_bootstrap.rb +135 -0
- data/config/locales/simple_form.en.yml +31 -0
- data/config/routes.rb +18 -0
- data/db/migrate/20150313063311_create_process_engine_process_definitions.rb +14 -0
- data/db/migrate/20150313063508_create_process_engine_process_instances.rb +15 -0
- data/db/migrate/20150313063633_create_process_engine_process_tasks.rb +30 -0
- data/lib/process_engine/engine.rb +12 -0
- data/lib/process_engine/version.rb +3 -0
- data/lib/process_engine.rb +8 -0
- data/lib/tasks/process_engine_tasks.rake +4 -0
- data/lib/templates/erb/scaffold/_form.html.erb +13 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/application.rb +26 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +85 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/schema.rb +66 -0
- data/test/dummy/log/development.log +9722 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/8afee1847b645742b0d2535a7c32f4f22e7926ec/bootstrap.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/b5911aa594334efca1023d6f01abce0758e9648a/bootstrap.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/014d8413350c7d85a5429f5e2c9ac911 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0cbd667d0fbf9e0e6f60b5ebf2f95fa3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0f7ba040a442530a6d4a5bc8307769c1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0fca2cc9aa38138660d8c7d492cf81e4 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0ff24903c54f534941fbc96ff862e475 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/11100f87277a2892323fe5581af75a7b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/18a34084783e8b7f9bc871bc64b13eed +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1a3821ce28e0196075ed0830fcb45f38 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1cf94b9a49ee68cb0f4065d48e9cbaf3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/21a6373d6c40614fd05be57194c68248 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/26276ae8df51c046f3adc0b50a1521ba +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2eea4a8f4854d438cd03cb23a89b6d8c +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3993bcd8bae4771e550d8fc91d1debbc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3ccc4edae36a9c4bd70fc330c9c83dc9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3e391b0f37505fffc40ba9ffa13330a2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/42e258b77f5dd532dfb9344a2d766de6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/43a5910cb7a330ece5856c0e9099efa2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4e65ec1149f01e749e1e372861210d4d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/501160bcee63ae68449a5a5eb78b6d41 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/517beb0bf366ec3c8649da9ac8a8a01e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/525a556b1eaacfa041722e1250d9859a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/56edbae38e4e0ff9f4b4fc576ae3d746 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5b04f4a7058d92f88f89f2248bcc16b0 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5c3c69f7c2520b57620931c150032d7e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5d1f8f2111e14084ebf711412c9230d2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5f9833d6835900c56d0e76a1b2924cc2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/67c653cc36eb639f7a7af5159e9f9de3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/704b33432a5ba417bcd5962ad999c671 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7301f83e8e67f30be13546a794a553ef +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7482c8f712712a79937caf41413bca15 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/761cb171e67ddca71e8b9c74f0220457 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7e23bd4385e166267961b6d936363042 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7e5100f290c9ba0d4c026e43b58d0d79 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/80743880e8d46958e9839ff9408c3113 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/8b8941aae968854bafb4638a86cad77b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9c292f3b6b577a92970303c351e1d4a1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a3435b13cfa60fb7469a19703350bda7 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a6ce1b2837383f1e8b62b7f1ddcc6820 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a7e90acc68ba69b7cd5c0a7005467c4b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/be4d00fb7bf467b370f0fda7e453ec68 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c4fbf44e63e40cbbf825fe750374728f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c593bacb8d3f003125f91763a7b36b10 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c5ae3bc69f7b1e1fdb51a667c9f3cdd6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cc843b336460771bf75c97cf0935301b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ce3b6127737ed36f7b62a54acec06b3e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d58931b13c55c146d21475e532b126ba +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/dc6bbdc1e385c7bb2743011e9c2a7407 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/dd7270e11b484ae10f601e1dd014445a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/de86beefc60e0cd84dd1525af863e64d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e0953e6e4a6c208e350f7f25d85bdce8 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ec3b479833be43bf164a3deb119c3aee +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ef2cb0afc9a61a3d5819b4dfc84720ad +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f0511bbd6f6cd5530acddebb6d7e7044 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7009bba030498129042e0c542d4f264 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/fixtures/process_engine/process_definitions.yml +17 -0
- data/test/fixtures/process_engine/process_instances.yml +11 -0
- data/test/fixtures/process_engine/process_tasks.yml +11 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/models/process_engine/process_definition_test.rb +9 -0
- data/test/models/process_engine/process_instance_test.rb +9 -0
- data/test/models/process_engine/process_task_test.rb +9 -0
- data/test/process_engine_test.rb +7 -0
- data/test/test_helper.rb +19 -0
- metadata +740 -0
|
@@ -0,0 +1,1410 @@
|
|
|
1
|
+
// wrapper for non-node envs
|
|
2
|
+
;(function (sax) {
|
|
3
|
+
|
|
4
|
+
sax.parser = function (strict, opt) { return new SAXParser(strict, opt) }
|
|
5
|
+
sax.SAXParser = SAXParser
|
|
6
|
+
sax.SAXStream = SAXStream
|
|
7
|
+
sax.createStream = createStream
|
|
8
|
+
|
|
9
|
+
// When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.
|
|
10
|
+
// When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),
|
|
11
|
+
// since that's the earliest that a buffer overrun could occur. This way, checks are
|
|
12
|
+
// as rare as required, but as often as necessary to ensure never crossing this bound.
|
|
13
|
+
// Furthermore, buffers are only tested at most once per write(), so passing a very
|
|
14
|
+
// large string into write() might have undesirable effects, but this is manageable by
|
|
15
|
+
// the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme
|
|
16
|
+
// edge case, result in creating at most one complete copy of the string passed in.
|
|
17
|
+
// Set to Infinity to have unlimited buffers.
|
|
18
|
+
sax.MAX_BUFFER_LENGTH = 64 * 1024
|
|
19
|
+
|
|
20
|
+
var buffers = [
|
|
21
|
+
"comment", "sgmlDecl", "textNode", "tagName", "doctype",
|
|
22
|
+
"procInstName", "procInstBody", "entity", "attribName",
|
|
23
|
+
"attribValue", "cdata", "script"
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
sax.EVENTS = // for discoverability.
|
|
27
|
+
[ "text"
|
|
28
|
+
, "processinginstruction"
|
|
29
|
+
, "sgmldeclaration"
|
|
30
|
+
, "doctype"
|
|
31
|
+
, "comment"
|
|
32
|
+
, "attribute"
|
|
33
|
+
, "opentag"
|
|
34
|
+
, "closetag"
|
|
35
|
+
, "opencdata"
|
|
36
|
+
, "cdata"
|
|
37
|
+
, "closecdata"
|
|
38
|
+
, "error"
|
|
39
|
+
, "end"
|
|
40
|
+
, "ready"
|
|
41
|
+
, "script"
|
|
42
|
+
, "opennamespace"
|
|
43
|
+
, "closenamespace"
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
function SAXParser (strict, opt) {
|
|
47
|
+
if (!(this instanceof SAXParser)) return new SAXParser(strict, opt)
|
|
48
|
+
|
|
49
|
+
var parser = this
|
|
50
|
+
clearBuffers(parser)
|
|
51
|
+
parser.q = parser.c = ""
|
|
52
|
+
parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH
|
|
53
|
+
parser.opt = opt || {}
|
|
54
|
+
parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags
|
|
55
|
+
parser.looseCase = parser.opt.lowercase ? "toLowerCase" : "toUpperCase"
|
|
56
|
+
parser.tags = []
|
|
57
|
+
parser.closed = parser.closedRoot = parser.sawRoot = false
|
|
58
|
+
parser.tag = parser.error = null
|
|
59
|
+
parser.strict = !!strict
|
|
60
|
+
parser.noscript = !!(strict || parser.opt.noscript)
|
|
61
|
+
parser.state = S.BEGIN
|
|
62
|
+
parser.ENTITIES = Object.create(sax.ENTITIES)
|
|
63
|
+
parser.attribList = []
|
|
64
|
+
|
|
65
|
+
// namespaces form a prototype chain.
|
|
66
|
+
// it always points at the current tag,
|
|
67
|
+
// which protos to its parent tag.
|
|
68
|
+
if (parser.opt.xmlns) parser.ns = Object.create(rootNS)
|
|
69
|
+
|
|
70
|
+
// mostly just for error reporting
|
|
71
|
+
parser.trackPosition = parser.opt.position !== false
|
|
72
|
+
if (parser.trackPosition) {
|
|
73
|
+
parser.position = parser.line = parser.column = 0
|
|
74
|
+
}
|
|
75
|
+
emit(parser, "onready")
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!Object.create) Object.create = function (o) {
|
|
79
|
+
function f () { this.__proto__ = o }
|
|
80
|
+
f.prototype = o
|
|
81
|
+
return new f
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!Object.getPrototypeOf) Object.getPrototypeOf = function (o) {
|
|
85
|
+
return o.__proto__
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!Object.keys) Object.keys = function (o) {
|
|
89
|
+
var a = []
|
|
90
|
+
for (var i in o) if (o.hasOwnProperty(i)) a.push(i)
|
|
91
|
+
return a
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function checkBufferLength (parser) {
|
|
95
|
+
var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10)
|
|
96
|
+
, maxActual = 0
|
|
97
|
+
for (var i = 0, l = buffers.length; i < l; i ++) {
|
|
98
|
+
var len = parser[buffers[i]].length
|
|
99
|
+
if (len > maxAllowed) {
|
|
100
|
+
// Text/cdata nodes can get big, and since they're buffered,
|
|
101
|
+
// we can get here under normal conditions.
|
|
102
|
+
// Avoid issues by emitting the text node now,
|
|
103
|
+
// so at least it won't get any bigger.
|
|
104
|
+
switch (buffers[i]) {
|
|
105
|
+
case "textNode":
|
|
106
|
+
closeText(parser)
|
|
107
|
+
break
|
|
108
|
+
|
|
109
|
+
case "cdata":
|
|
110
|
+
emitNode(parser, "oncdata", parser.cdata)
|
|
111
|
+
parser.cdata = ""
|
|
112
|
+
break
|
|
113
|
+
|
|
114
|
+
case "script":
|
|
115
|
+
emitNode(parser, "onscript", parser.script)
|
|
116
|
+
parser.script = ""
|
|
117
|
+
break
|
|
118
|
+
|
|
119
|
+
default:
|
|
120
|
+
error(parser, "Max buffer length exceeded: "+buffers[i])
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
maxActual = Math.max(maxActual, len)
|
|
124
|
+
}
|
|
125
|
+
// schedule the next check for the earliest possible buffer overrun.
|
|
126
|
+
parser.bufferCheckPosition = (sax.MAX_BUFFER_LENGTH - maxActual)
|
|
127
|
+
+ parser.position
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function clearBuffers (parser) {
|
|
131
|
+
for (var i = 0, l = buffers.length; i < l; i ++) {
|
|
132
|
+
parser[buffers[i]] = ""
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function flushBuffers (parser) {
|
|
137
|
+
closeText(parser)
|
|
138
|
+
if (parser.cdata !== "") {
|
|
139
|
+
emitNode(parser, "oncdata", parser.cdata)
|
|
140
|
+
parser.cdata = ""
|
|
141
|
+
}
|
|
142
|
+
if (parser.script !== "") {
|
|
143
|
+
emitNode(parser, "onscript", parser.script)
|
|
144
|
+
parser.script = ""
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
SAXParser.prototype =
|
|
149
|
+
{ end: function () { end(this) }
|
|
150
|
+
, write: write
|
|
151
|
+
, resume: function () { this.error = null; return this }
|
|
152
|
+
, close: function () { return this.write(null) }
|
|
153
|
+
, flush: function () { flushBuffers(this) }
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
try {
|
|
157
|
+
var Stream = require("stream").Stream
|
|
158
|
+
} catch (ex) {
|
|
159
|
+
var Stream = function () {}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
var streamWraps = sax.EVENTS.filter(function (ev) {
|
|
164
|
+
return ev !== "error" && ev !== "end"
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
function createStream (strict, opt) {
|
|
168
|
+
return new SAXStream(strict, opt)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function SAXStream (strict, opt) {
|
|
172
|
+
if (!(this instanceof SAXStream)) return new SAXStream(strict, opt)
|
|
173
|
+
|
|
174
|
+
Stream.apply(this)
|
|
175
|
+
|
|
176
|
+
this._parser = new SAXParser(strict, opt)
|
|
177
|
+
this.writable = true
|
|
178
|
+
this.readable = true
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
var me = this
|
|
182
|
+
|
|
183
|
+
this._parser.onend = function () {
|
|
184
|
+
me.emit("end")
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
this._parser.onerror = function (er) {
|
|
188
|
+
me.emit("error", er)
|
|
189
|
+
|
|
190
|
+
// if didn't throw, then means error was handled.
|
|
191
|
+
// go ahead and clear error, so we can write again.
|
|
192
|
+
me._parser.error = null
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
this._decoder = null;
|
|
196
|
+
|
|
197
|
+
streamWraps.forEach(function (ev) {
|
|
198
|
+
Object.defineProperty(me, "on" + ev, {
|
|
199
|
+
get: function () { return me._parser["on" + ev] },
|
|
200
|
+
set: function (h) {
|
|
201
|
+
if (!h) {
|
|
202
|
+
me.removeAllListeners(ev)
|
|
203
|
+
return me._parser["on"+ev] = h
|
|
204
|
+
}
|
|
205
|
+
me.on(ev, h)
|
|
206
|
+
},
|
|
207
|
+
enumerable: true,
|
|
208
|
+
configurable: false
|
|
209
|
+
})
|
|
210
|
+
})
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
SAXStream.prototype = Object.create(Stream.prototype,
|
|
214
|
+
{ constructor: { value: SAXStream } })
|
|
215
|
+
|
|
216
|
+
SAXStream.prototype.write = function (data) {
|
|
217
|
+
if (typeof Buffer === 'function' &&
|
|
218
|
+
typeof Buffer.isBuffer === 'function' &&
|
|
219
|
+
Buffer.isBuffer(data)) {
|
|
220
|
+
if (!this._decoder) {
|
|
221
|
+
var SD = require('string_decoder').StringDecoder
|
|
222
|
+
this._decoder = new SD('utf8')
|
|
223
|
+
}
|
|
224
|
+
data = this._decoder.write(data);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
this._parser.write(data.toString())
|
|
228
|
+
this.emit("data", data)
|
|
229
|
+
return true
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
SAXStream.prototype.end = function (chunk) {
|
|
233
|
+
if (chunk && chunk.length) this.write(chunk)
|
|
234
|
+
this._parser.end()
|
|
235
|
+
return true
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
SAXStream.prototype.on = function (ev, handler) {
|
|
239
|
+
var me = this
|
|
240
|
+
if (!me._parser["on"+ev] && streamWraps.indexOf(ev) !== -1) {
|
|
241
|
+
me._parser["on"+ev] = function () {
|
|
242
|
+
var args = arguments.length === 1 ? [arguments[0]]
|
|
243
|
+
: Array.apply(null, arguments)
|
|
244
|
+
args.splice(0, 0, ev)
|
|
245
|
+
me.emit.apply(me, args)
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return Stream.prototype.on.call(me, ev, handler)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
// character classes and tokens
|
|
255
|
+
var whitespace = "\r\n\t "
|
|
256
|
+
// this really needs to be replaced with character classes.
|
|
257
|
+
// XML allows all manner of ridiculous numbers and digits.
|
|
258
|
+
, number = "0124356789"
|
|
259
|
+
, letter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
260
|
+
// (Letter | "_" | ":")
|
|
261
|
+
, quote = "'\""
|
|
262
|
+
, entity = number+letter+"#"
|
|
263
|
+
, attribEnd = whitespace + ">"
|
|
264
|
+
, CDATA = "[CDATA["
|
|
265
|
+
, DOCTYPE = "DOCTYPE"
|
|
266
|
+
, XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace"
|
|
267
|
+
, XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/"
|
|
268
|
+
, rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE }
|
|
269
|
+
|
|
270
|
+
// turn all the string character sets into character class objects.
|
|
271
|
+
whitespace = charClass(whitespace)
|
|
272
|
+
number = charClass(number)
|
|
273
|
+
letter = charClass(letter)
|
|
274
|
+
|
|
275
|
+
// http://www.w3.org/TR/REC-xml/#NT-NameStartChar
|
|
276
|
+
// This implementation works on strings, a single character at a time
|
|
277
|
+
// as such, it cannot ever support astral-plane characters (10000-EFFFF)
|
|
278
|
+
// without a significant breaking change to either this parser, or the
|
|
279
|
+
// JavaScript language. Implementation of an emoji-capable xml parser
|
|
280
|
+
// is left as an exercise for the reader.
|
|
281
|
+
var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/
|
|
282
|
+
|
|
283
|
+
var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040\.\d-]/
|
|
284
|
+
|
|
285
|
+
quote = charClass(quote)
|
|
286
|
+
entity = charClass(entity)
|
|
287
|
+
attribEnd = charClass(attribEnd)
|
|
288
|
+
|
|
289
|
+
function charClass (str) {
|
|
290
|
+
return str.split("").reduce(function (s, c) {
|
|
291
|
+
s[c] = true
|
|
292
|
+
return s
|
|
293
|
+
}, {})
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function isRegExp (c) {
|
|
297
|
+
return Object.prototype.toString.call(c) === '[object RegExp]'
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function is (charclass, c) {
|
|
301
|
+
return isRegExp(charclass) ? !!c.match(charclass) : charclass[c]
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function not (charclass, c) {
|
|
305
|
+
return !is(charclass, c)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
var S = 0
|
|
309
|
+
sax.STATE =
|
|
310
|
+
{ BEGIN : S++
|
|
311
|
+
, TEXT : S++ // general stuff
|
|
312
|
+
, TEXT_ENTITY : S++ // & and such.
|
|
313
|
+
, OPEN_WAKA : S++ // <
|
|
314
|
+
, SGML_DECL : S++ // <!BLARG
|
|
315
|
+
, SGML_DECL_QUOTED : S++ // <!BLARG foo "bar
|
|
316
|
+
, DOCTYPE : S++ // <!DOCTYPE
|
|
317
|
+
, DOCTYPE_QUOTED : S++ // <!DOCTYPE "//blah
|
|
318
|
+
, DOCTYPE_DTD : S++ // <!DOCTYPE "//blah" [ ...
|
|
319
|
+
, DOCTYPE_DTD_QUOTED : S++ // <!DOCTYPE "//blah" [ "foo
|
|
320
|
+
, COMMENT_STARTING : S++ // <!-
|
|
321
|
+
, COMMENT : S++ // <!--
|
|
322
|
+
, COMMENT_ENDING : S++ // <!-- blah -
|
|
323
|
+
, COMMENT_ENDED : S++ // <!-- blah --
|
|
324
|
+
, CDATA : S++ // <![CDATA[ something
|
|
325
|
+
, CDATA_ENDING : S++ // ]
|
|
326
|
+
, CDATA_ENDING_2 : S++ // ]]
|
|
327
|
+
, PROC_INST : S++ // <?hi
|
|
328
|
+
, PROC_INST_BODY : S++ // <?hi there
|
|
329
|
+
, PROC_INST_ENDING : S++ // <?hi "there" ?
|
|
330
|
+
, OPEN_TAG : S++ // <strong
|
|
331
|
+
, OPEN_TAG_SLASH : S++ // <strong /
|
|
332
|
+
, ATTRIB : S++ // <a
|
|
333
|
+
, ATTRIB_NAME : S++ // <a foo
|
|
334
|
+
, ATTRIB_NAME_SAW_WHITE : S++ // <a foo _
|
|
335
|
+
, ATTRIB_VALUE : S++ // <a foo=
|
|
336
|
+
, ATTRIB_VALUE_QUOTED : S++ // <a foo="bar
|
|
337
|
+
, ATTRIB_VALUE_CLOSED : S++ // <a foo="bar"
|
|
338
|
+
, ATTRIB_VALUE_UNQUOTED : S++ // <a foo=bar
|
|
339
|
+
, ATTRIB_VALUE_ENTITY_Q : S++ // <foo bar="""
|
|
340
|
+
, ATTRIB_VALUE_ENTITY_U : S++ // <foo bar="
|
|
341
|
+
, CLOSE_TAG : S++ // </a
|
|
342
|
+
, CLOSE_TAG_SAW_WHITE : S++ // </a >
|
|
343
|
+
, SCRIPT : S++ // <script> ...
|
|
344
|
+
, SCRIPT_ENDING : S++ // <script> ... <
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
sax.ENTITIES =
|
|
348
|
+
{ "amp" : "&"
|
|
349
|
+
, "gt" : ">"
|
|
350
|
+
, "lt" : "<"
|
|
351
|
+
, "quot" : "\""
|
|
352
|
+
, "apos" : "'"
|
|
353
|
+
, "AElig" : 198
|
|
354
|
+
, "Aacute" : 193
|
|
355
|
+
, "Acirc" : 194
|
|
356
|
+
, "Agrave" : 192
|
|
357
|
+
, "Aring" : 197
|
|
358
|
+
, "Atilde" : 195
|
|
359
|
+
, "Auml" : 196
|
|
360
|
+
, "Ccedil" : 199
|
|
361
|
+
, "ETH" : 208
|
|
362
|
+
, "Eacute" : 201
|
|
363
|
+
, "Ecirc" : 202
|
|
364
|
+
, "Egrave" : 200
|
|
365
|
+
, "Euml" : 203
|
|
366
|
+
, "Iacute" : 205
|
|
367
|
+
, "Icirc" : 206
|
|
368
|
+
, "Igrave" : 204
|
|
369
|
+
, "Iuml" : 207
|
|
370
|
+
, "Ntilde" : 209
|
|
371
|
+
, "Oacute" : 211
|
|
372
|
+
, "Ocirc" : 212
|
|
373
|
+
, "Ograve" : 210
|
|
374
|
+
, "Oslash" : 216
|
|
375
|
+
, "Otilde" : 213
|
|
376
|
+
, "Ouml" : 214
|
|
377
|
+
, "THORN" : 222
|
|
378
|
+
, "Uacute" : 218
|
|
379
|
+
, "Ucirc" : 219
|
|
380
|
+
, "Ugrave" : 217
|
|
381
|
+
, "Uuml" : 220
|
|
382
|
+
, "Yacute" : 221
|
|
383
|
+
, "aacute" : 225
|
|
384
|
+
, "acirc" : 226
|
|
385
|
+
, "aelig" : 230
|
|
386
|
+
, "agrave" : 224
|
|
387
|
+
, "aring" : 229
|
|
388
|
+
, "atilde" : 227
|
|
389
|
+
, "auml" : 228
|
|
390
|
+
, "ccedil" : 231
|
|
391
|
+
, "eacute" : 233
|
|
392
|
+
, "ecirc" : 234
|
|
393
|
+
, "egrave" : 232
|
|
394
|
+
, "eth" : 240
|
|
395
|
+
, "euml" : 235
|
|
396
|
+
, "iacute" : 237
|
|
397
|
+
, "icirc" : 238
|
|
398
|
+
, "igrave" : 236
|
|
399
|
+
, "iuml" : 239
|
|
400
|
+
, "ntilde" : 241
|
|
401
|
+
, "oacute" : 243
|
|
402
|
+
, "ocirc" : 244
|
|
403
|
+
, "ograve" : 242
|
|
404
|
+
, "oslash" : 248
|
|
405
|
+
, "otilde" : 245
|
|
406
|
+
, "ouml" : 246
|
|
407
|
+
, "szlig" : 223
|
|
408
|
+
, "thorn" : 254
|
|
409
|
+
, "uacute" : 250
|
|
410
|
+
, "ucirc" : 251
|
|
411
|
+
, "ugrave" : 249
|
|
412
|
+
, "uuml" : 252
|
|
413
|
+
, "yacute" : 253
|
|
414
|
+
, "yuml" : 255
|
|
415
|
+
, "copy" : 169
|
|
416
|
+
, "reg" : 174
|
|
417
|
+
, "nbsp" : 160
|
|
418
|
+
, "iexcl" : 161
|
|
419
|
+
, "cent" : 162
|
|
420
|
+
, "pound" : 163
|
|
421
|
+
, "curren" : 164
|
|
422
|
+
, "yen" : 165
|
|
423
|
+
, "brvbar" : 166
|
|
424
|
+
, "sect" : 167
|
|
425
|
+
, "uml" : 168
|
|
426
|
+
, "ordf" : 170
|
|
427
|
+
, "laquo" : 171
|
|
428
|
+
, "not" : 172
|
|
429
|
+
, "shy" : 173
|
|
430
|
+
, "macr" : 175
|
|
431
|
+
, "deg" : 176
|
|
432
|
+
, "plusmn" : 177
|
|
433
|
+
, "sup1" : 185
|
|
434
|
+
, "sup2" : 178
|
|
435
|
+
, "sup3" : 179
|
|
436
|
+
, "acute" : 180
|
|
437
|
+
, "micro" : 181
|
|
438
|
+
, "para" : 182
|
|
439
|
+
, "middot" : 183
|
|
440
|
+
, "cedil" : 184
|
|
441
|
+
, "ordm" : 186
|
|
442
|
+
, "raquo" : 187
|
|
443
|
+
, "frac14" : 188
|
|
444
|
+
, "frac12" : 189
|
|
445
|
+
, "frac34" : 190
|
|
446
|
+
, "iquest" : 191
|
|
447
|
+
, "times" : 215
|
|
448
|
+
, "divide" : 247
|
|
449
|
+
, "OElig" : 338
|
|
450
|
+
, "oelig" : 339
|
|
451
|
+
, "Scaron" : 352
|
|
452
|
+
, "scaron" : 353
|
|
453
|
+
, "Yuml" : 376
|
|
454
|
+
, "fnof" : 402
|
|
455
|
+
, "circ" : 710
|
|
456
|
+
, "tilde" : 732
|
|
457
|
+
, "Alpha" : 913
|
|
458
|
+
, "Beta" : 914
|
|
459
|
+
, "Gamma" : 915
|
|
460
|
+
, "Delta" : 916
|
|
461
|
+
, "Epsilon" : 917
|
|
462
|
+
, "Zeta" : 918
|
|
463
|
+
, "Eta" : 919
|
|
464
|
+
, "Theta" : 920
|
|
465
|
+
, "Iota" : 921
|
|
466
|
+
, "Kappa" : 922
|
|
467
|
+
, "Lambda" : 923
|
|
468
|
+
, "Mu" : 924
|
|
469
|
+
, "Nu" : 925
|
|
470
|
+
, "Xi" : 926
|
|
471
|
+
, "Omicron" : 927
|
|
472
|
+
, "Pi" : 928
|
|
473
|
+
, "Rho" : 929
|
|
474
|
+
, "Sigma" : 931
|
|
475
|
+
, "Tau" : 932
|
|
476
|
+
, "Upsilon" : 933
|
|
477
|
+
, "Phi" : 934
|
|
478
|
+
, "Chi" : 935
|
|
479
|
+
, "Psi" : 936
|
|
480
|
+
, "Omega" : 937
|
|
481
|
+
, "alpha" : 945
|
|
482
|
+
, "beta" : 946
|
|
483
|
+
, "gamma" : 947
|
|
484
|
+
, "delta" : 948
|
|
485
|
+
, "epsilon" : 949
|
|
486
|
+
, "zeta" : 950
|
|
487
|
+
, "eta" : 951
|
|
488
|
+
, "theta" : 952
|
|
489
|
+
, "iota" : 953
|
|
490
|
+
, "kappa" : 954
|
|
491
|
+
, "lambda" : 955
|
|
492
|
+
, "mu" : 956
|
|
493
|
+
, "nu" : 957
|
|
494
|
+
, "xi" : 958
|
|
495
|
+
, "omicron" : 959
|
|
496
|
+
, "pi" : 960
|
|
497
|
+
, "rho" : 961
|
|
498
|
+
, "sigmaf" : 962
|
|
499
|
+
, "sigma" : 963
|
|
500
|
+
, "tau" : 964
|
|
501
|
+
, "upsilon" : 965
|
|
502
|
+
, "phi" : 966
|
|
503
|
+
, "chi" : 967
|
|
504
|
+
, "psi" : 968
|
|
505
|
+
, "omega" : 969
|
|
506
|
+
, "thetasym" : 977
|
|
507
|
+
, "upsih" : 978
|
|
508
|
+
, "piv" : 982
|
|
509
|
+
, "ensp" : 8194
|
|
510
|
+
, "emsp" : 8195
|
|
511
|
+
, "thinsp" : 8201
|
|
512
|
+
, "zwnj" : 8204
|
|
513
|
+
, "zwj" : 8205
|
|
514
|
+
, "lrm" : 8206
|
|
515
|
+
, "rlm" : 8207
|
|
516
|
+
, "ndash" : 8211
|
|
517
|
+
, "mdash" : 8212
|
|
518
|
+
, "lsquo" : 8216
|
|
519
|
+
, "rsquo" : 8217
|
|
520
|
+
, "sbquo" : 8218
|
|
521
|
+
, "ldquo" : 8220
|
|
522
|
+
, "rdquo" : 8221
|
|
523
|
+
, "bdquo" : 8222
|
|
524
|
+
, "dagger" : 8224
|
|
525
|
+
, "Dagger" : 8225
|
|
526
|
+
, "bull" : 8226
|
|
527
|
+
, "hellip" : 8230
|
|
528
|
+
, "permil" : 8240
|
|
529
|
+
, "prime" : 8242
|
|
530
|
+
, "Prime" : 8243
|
|
531
|
+
, "lsaquo" : 8249
|
|
532
|
+
, "rsaquo" : 8250
|
|
533
|
+
, "oline" : 8254
|
|
534
|
+
, "frasl" : 8260
|
|
535
|
+
, "euro" : 8364
|
|
536
|
+
, "image" : 8465
|
|
537
|
+
, "weierp" : 8472
|
|
538
|
+
, "real" : 8476
|
|
539
|
+
, "trade" : 8482
|
|
540
|
+
, "alefsym" : 8501
|
|
541
|
+
, "larr" : 8592
|
|
542
|
+
, "uarr" : 8593
|
|
543
|
+
, "rarr" : 8594
|
|
544
|
+
, "darr" : 8595
|
|
545
|
+
, "harr" : 8596
|
|
546
|
+
, "crarr" : 8629
|
|
547
|
+
, "lArr" : 8656
|
|
548
|
+
, "uArr" : 8657
|
|
549
|
+
, "rArr" : 8658
|
|
550
|
+
, "dArr" : 8659
|
|
551
|
+
, "hArr" : 8660
|
|
552
|
+
, "forall" : 8704
|
|
553
|
+
, "part" : 8706
|
|
554
|
+
, "exist" : 8707
|
|
555
|
+
, "empty" : 8709
|
|
556
|
+
, "nabla" : 8711
|
|
557
|
+
, "isin" : 8712
|
|
558
|
+
, "notin" : 8713
|
|
559
|
+
, "ni" : 8715
|
|
560
|
+
, "prod" : 8719
|
|
561
|
+
, "sum" : 8721
|
|
562
|
+
, "minus" : 8722
|
|
563
|
+
, "lowast" : 8727
|
|
564
|
+
, "radic" : 8730
|
|
565
|
+
, "prop" : 8733
|
|
566
|
+
, "infin" : 8734
|
|
567
|
+
, "ang" : 8736
|
|
568
|
+
, "and" : 8743
|
|
569
|
+
, "or" : 8744
|
|
570
|
+
, "cap" : 8745
|
|
571
|
+
, "cup" : 8746
|
|
572
|
+
, "int" : 8747
|
|
573
|
+
, "there4" : 8756
|
|
574
|
+
, "sim" : 8764
|
|
575
|
+
, "cong" : 8773
|
|
576
|
+
, "asymp" : 8776
|
|
577
|
+
, "ne" : 8800
|
|
578
|
+
, "equiv" : 8801
|
|
579
|
+
, "le" : 8804
|
|
580
|
+
, "ge" : 8805
|
|
581
|
+
, "sub" : 8834
|
|
582
|
+
, "sup" : 8835
|
|
583
|
+
, "nsub" : 8836
|
|
584
|
+
, "sube" : 8838
|
|
585
|
+
, "supe" : 8839
|
|
586
|
+
, "oplus" : 8853
|
|
587
|
+
, "otimes" : 8855
|
|
588
|
+
, "perp" : 8869
|
|
589
|
+
, "sdot" : 8901
|
|
590
|
+
, "lceil" : 8968
|
|
591
|
+
, "rceil" : 8969
|
|
592
|
+
, "lfloor" : 8970
|
|
593
|
+
, "rfloor" : 8971
|
|
594
|
+
, "lang" : 9001
|
|
595
|
+
, "rang" : 9002
|
|
596
|
+
, "loz" : 9674
|
|
597
|
+
, "spades" : 9824
|
|
598
|
+
, "clubs" : 9827
|
|
599
|
+
, "hearts" : 9829
|
|
600
|
+
, "diams" : 9830
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
Object.keys(sax.ENTITIES).forEach(function (key) {
|
|
604
|
+
var e = sax.ENTITIES[key]
|
|
605
|
+
var s = typeof e === 'number' ? String.fromCharCode(e) : e
|
|
606
|
+
sax.ENTITIES[key] = s
|
|
607
|
+
})
|
|
608
|
+
|
|
609
|
+
for (var S in sax.STATE) sax.STATE[sax.STATE[S]] = S
|
|
610
|
+
|
|
611
|
+
// shorthand
|
|
612
|
+
S = sax.STATE
|
|
613
|
+
|
|
614
|
+
function emit (parser, event, data) {
|
|
615
|
+
parser[event] && parser[event](data)
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
function emitNode (parser, nodeType, data) {
|
|
619
|
+
if (parser.textNode) closeText(parser)
|
|
620
|
+
emit(parser, nodeType, data)
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
function closeText (parser) {
|
|
624
|
+
parser.textNode = textopts(parser.opt, parser.textNode)
|
|
625
|
+
if (parser.textNode) emit(parser, "ontext", parser.textNode)
|
|
626
|
+
parser.textNode = ""
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
function textopts (opt, text) {
|
|
630
|
+
if (opt.trim) text = text.trim()
|
|
631
|
+
if (opt.normalize) text = text.replace(/\s+/g, " ")
|
|
632
|
+
return text
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
function error (parser, er) {
|
|
636
|
+
closeText(parser)
|
|
637
|
+
if (parser.trackPosition) {
|
|
638
|
+
er += "\nLine: "+parser.line+
|
|
639
|
+
"\nColumn: "+parser.column+
|
|
640
|
+
"\nChar: "+parser.c
|
|
641
|
+
}
|
|
642
|
+
er = new Error(er)
|
|
643
|
+
parser.error = er
|
|
644
|
+
emit(parser, "onerror", er)
|
|
645
|
+
return parser
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
function end (parser) {
|
|
649
|
+
if (!parser.closedRoot) strictFail(parser, "Unclosed root tag")
|
|
650
|
+
if ((parser.state !== S.BEGIN) && (parser.state !== S.TEXT)) error(parser, "Unexpected end")
|
|
651
|
+
closeText(parser)
|
|
652
|
+
parser.c = ""
|
|
653
|
+
parser.closed = true
|
|
654
|
+
emit(parser, "onend")
|
|
655
|
+
SAXParser.call(parser, parser.strict, parser.opt)
|
|
656
|
+
return parser
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
function strictFail (parser, message) {
|
|
660
|
+
if (typeof parser !== 'object' || !(parser instanceof SAXParser))
|
|
661
|
+
throw new Error('bad call to strictFail');
|
|
662
|
+
if (parser.strict) error(parser, message)
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
function newTag (parser) {
|
|
666
|
+
if (!parser.strict) parser.tagName = parser.tagName[parser.looseCase]()
|
|
667
|
+
var parent = parser.tags[parser.tags.length - 1] || parser
|
|
668
|
+
, tag = parser.tag = { name : parser.tagName, attributes : {} }
|
|
669
|
+
|
|
670
|
+
// will be overridden if tag contails an xmlns="foo" or xmlns:foo="bar"
|
|
671
|
+
if (parser.opt.xmlns) tag.ns = parent.ns
|
|
672
|
+
parser.attribList.length = 0
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
function qname (name, attribute) {
|
|
676
|
+
var i = name.indexOf(":")
|
|
677
|
+
, qualName = i < 0 ? [ "", name ] : name.split(":")
|
|
678
|
+
, prefix = qualName[0]
|
|
679
|
+
, local = qualName[1]
|
|
680
|
+
|
|
681
|
+
// <x "xmlns"="http://foo">
|
|
682
|
+
if (attribute && name === "xmlns") {
|
|
683
|
+
prefix = "xmlns"
|
|
684
|
+
local = ""
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
return { prefix: prefix, local: local }
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
function attrib (parser) {
|
|
691
|
+
if (!parser.strict) parser.attribName = parser.attribName[parser.looseCase]()
|
|
692
|
+
|
|
693
|
+
if (parser.attribList.indexOf(parser.attribName) !== -1 ||
|
|
694
|
+
parser.tag.attributes.hasOwnProperty(parser.attribName)) {
|
|
695
|
+
return parser.attribName = parser.attribValue = ""
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
if (parser.opt.xmlns) {
|
|
699
|
+
var qn = qname(parser.attribName, true)
|
|
700
|
+
, prefix = qn.prefix
|
|
701
|
+
, local = qn.local
|
|
702
|
+
|
|
703
|
+
if (prefix === "xmlns") {
|
|
704
|
+
// namespace binding attribute; push the binding into scope
|
|
705
|
+
if (local === "xml" && parser.attribValue !== XML_NAMESPACE) {
|
|
706
|
+
strictFail( parser
|
|
707
|
+
, "xml: prefix must be bound to " + XML_NAMESPACE + "\n"
|
|
708
|
+
+ "Actual: " + parser.attribValue )
|
|
709
|
+
} else if (local === "xmlns" && parser.attribValue !== XMLNS_NAMESPACE) {
|
|
710
|
+
strictFail( parser
|
|
711
|
+
, "xmlns: prefix must be bound to " + XMLNS_NAMESPACE + "\n"
|
|
712
|
+
+ "Actual: " + parser.attribValue )
|
|
713
|
+
} else {
|
|
714
|
+
var tag = parser.tag
|
|
715
|
+
, parent = parser.tags[parser.tags.length - 1] || parser
|
|
716
|
+
if (tag.ns === parent.ns) {
|
|
717
|
+
tag.ns = Object.create(parent.ns)
|
|
718
|
+
}
|
|
719
|
+
tag.ns[local] = parser.attribValue
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
// defer onattribute events until all attributes have been seen
|
|
724
|
+
// so any new bindings can take effect; preserve attribute order
|
|
725
|
+
// so deferred events can be emitted in document order
|
|
726
|
+
parser.attribList.push([parser.attribName, parser.attribValue])
|
|
727
|
+
} else {
|
|
728
|
+
// in non-xmlns mode, we can emit the event right away
|
|
729
|
+
parser.tag.attributes[parser.attribName] = parser.attribValue
|
|
730
|
+
emitNode( parser
|
|
731
|
+
, "onattribute"
|
|
732
|
+
, { name: parser.attribName
|
|
733
|
+
, value: parser.attribValue } )
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
parser.attribName = parser.attribValue = ""
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
function openTag (parser, selfClosing) {
|
|
740
|
+
if (parser.opt.xmlns) {
|
|
741
|
+
// emit namespace binding events
|
|
742
|
+
var tag = parser.tag
|
|
743
|
+
|
|
744
|
+
// add namespace info to tag
|
|
745
|
+
var qn = qname(parser.tagName)
|
|
746
|
+
tag.prefix = qn.prefix
|
|
747
|
+
tag.local = qn.local
|
|
748
|
+
tag.uri = tag.ns[qn.prefix] || ""
|
|
749
|
+
|
|
750
|
+
if (tag.prefix && !tag.uri) {
|
|
751
|
+
strictFail(parser, "Unbound namespace prefix: "
|
|
752
|
+
+ JSON.stringify(parser.tagName))
|
|
753
|
+
tag.uri = qn.prefix
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
var parent = parser.tags[parser.tags.length - 1] || parser
|
|
757
|
+
if (tag.ns && parent.ns !== tag.ns) {
|
|
758
|
+
Object.keys(tag.ns).forEach(function (p) {
|
|
759
|
+
emitNode( parser
|
|
760
|
+
, "onopennamespace"
|
|
761
|
+
, { prefix: p , uri: tag.ns[p] } )
|
|
762
|
+
})
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
// handle deferred onattribute events
|
|
766
|
+
// Note: do not apply default ns to attributes:
|
|
767
|
+
// http://www.w3.org/TR/REC-xml-names/#defaulting
|
|
768
|
+
for (var i = 0, l = parser.attribList.length; i < l; i ++) {
|
|
769
|
+
var nv = parser.attribList[i]
|
|
770
|
+
var name = nv[0]
|
|
771
|
+
, value = nv[1]
|
|
772
|
+
, qualName = qname(name, true)
|
|
773
|
+
, prefix = qualName.prefix
|
|
774
|
+
, local = qualName.local
|
|
775
|
+
, uri = prefix == "" ? "" : (tag.ns[prefix] || "")
|
|
776
|
+
, a = { name: name
|
|
777
|
+
, value: value
|
|
778
|
+
, prefix: prefix
|
|
779
|
+
, local: local
|
|
780
|
+
, uri: uri
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
// if there's any attributes with an undefined namespace,
|
|
784
|
+
// then fail on them now.
|
|
785
|
+
if (prefix && prefix != "xmlns" && !uri) {
|
|
786
|
+
strictFail(parser, "Unbound namespace prefix: "
|
|
787
|
+
+ JSON.stringify(prefix))
|
|
788
|
+
a.uri = prefix
|
|
789
|
+
}
|
|
790
|
+
parser.tag.attributes[name] = a
|
|
791
|
+
emitNode(parser, "onattribute", a)
|
|
792
|
+
}
|
|
793
|
+
parser.attribList.length = 0
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
parser.tag.isSelfClosing = !!selfClosing
|
|
797
|
+
|
|
798
|
+
// process the tag
|
|
799
|
+
parser.sawRoot = true
|
|
800
|
+
parser.tags.push(parser.tag)
|
|
801
|
+
emitNode(parser, "onopentag", parser.tag)
|
|
802
|
+
if (!selfClosing) {
|
|
803
|
+
// special case for <script> in non-strict mode.
|
|
804
|
+
if (!parser.noscript && parser.tagName.toLowerCase() === "script") {
|
|
805
|
+
parser.state = S.SCRIPT
|
|
806
|
+
} else {
|
|
807
|
+
parser.state = S.TEXT
|
|
808
|
+
}
|
|
809
|
+
parser.tag = null
|
|
810
|
+
parser.tagName = ""
|
|
811
|
+
}
|
|
812
|
+
parser.attribName = parser.attribValue = ""
|
|
813
|
+
parser.attribList.length = 0
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
function closeTag (parser) {
|
|
817
|
+
if (!parser.tagName) {
|
|
818
|
+
strictFail(parser, "Weird empty close tag.")
|
|
819
|
+
parser.textNode += "</>"
|
|
820
|
+
parser.state = S.TEXT
|
|
821
|
+
return
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
if (parser.script) {
|
|
825
|
+
if (parser.tagName !== "script") {
|
|
826
|
+
parser.script += "</" + parser.tagName + ">"
|
|
827
|
+
parser.tagName = ""
|
|
828
|
+
parser.state = S.SCRIPT
|
|
829
|
+
return
|
|
830
|
+
}
|
|
831
|
+
emitNode(parser, "onscript", parser.script)
|
|
832
|
+
parser.script = ""
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
// first make sure that the closing tag actually exists.
|
|
836
|
+
// <a><b></c></b></a> will close everything, otherwise.
|
|
837
|
+
var t = parser.tags.length
|
|
838
|
+
var tagName = parser.tagName
|
|
839
|
+
if (!parser.strict) tagName = tagName[parser.looseCase]()
|
|
840
|
+
var closeTo = tagName
|
|
841
|
+
while (t --) {
|
|
842
|
+
var close = parser.tags[t]
|
|
843
|
+
if (close.name !== closeTo) {
|
|
844
|
+
// fail the first time in strict mode
|
|
845
|
+
strictFail(parser, "Unexpected close tag")
|
|
846
|
+
} else break
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
// didn't find it. we already failed for strict, so just abort.
|
|
850
|
+
if (t < 0) {
|
|
851
|
+
strictFail(parser, "Unmatched closing tag: "+parser.tagName)
|
|
852
|
+
parser.textNode += "</" + parser.tagName + ">"
|
|
853
|
+
parser.state = S.TEXT
|
|
854
|
+
return
|
|
855
|
+
}
|
|
856
|
+
parser.tagName = tagName
|
|
857
|
+
var s = parser.tags.length
|
|
858
|
+
while (s --> t) {
|
|
859
|
+
var tag = parser.tag = parser.tags.pop()
|
|
860
|
+
parser.tagName = parser.tag.name
|
|
861
|
+
emitNode(parser, "onclosetag", parser.tagName)
|
|
862
|
+
|
|
863
|
+
var x = {}
|
|
864
|
+
for (var i in tag.ns) x[i] = tag.ns[i]
|
|
865
|
+
|
|
866
|
+
var parent = parser.tags[parser.tags.length - 1] || parser
|
|
867
|
+
if (parser.opt.xmlns && tag.ns !== parent.ns) {
|
|
868
|
+
// remove namespace bindings introduced by tag
|
|
869
|
+
Object.keys(tag.ns).forEach(function (p) {
|
|
870
|
+
var n = tag.ns[p]
|
|
871
|
+
emitNode(parser, "onclosenamespace", { prefix: p, uri: n })
|
|
872
|
+
})
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
if (t === 0) parser.closedRoot = true
|
|
876
|
+
parser.tagName = parser.attribValue = parser.attribName = ""
|
|
877
|
+
parser.attribList.length = 0
|
|
878
|
+
parser.state = S.TEXT
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
function parseEntity (parser) {
|
|
882
|
+
var entity = parser.entity
|
|
883
|
+
, entityLC = entity.toLowerCase()
|
|
884
|
+
, num
|
|
885
|
+
, numStr = ""
|
|
886
|
+
if (parser.ENTITIES[entity])
|
|
887
|
+
return parser.ENTITIES[entity]
|
|
888
|
+
if (parser.ENTITIES[entityLC])
|
|
889
|
+
return parser.ENTITIES[entityLC]
|
|
890
|
+
entity = entityLC
|
|
891
|
+
if (entity.charAt(0) === "#") {
|
|
892
|
+
if (entity.charAt(1) === "x") {
|
|
893
|
+
entity = entity.slice(2)
|
|
894
|
+
num = parseInt(entity, 16)
|
|
895
|
+
numStr = num.toString(16)
|
|
896
|
+
} else {
|
|
897
|
+
entity = entity.slice(1)
|
|
898
|
+
num = parseInt(entity, 10)
|
|
899
|
+
numStr = num.toString(10)
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
entity = entity.replace(/^0+/, "")
|
|
903
|
+
if (numStr.toLowerCase() !== entity) {
|
|
904
|
+
strictFail(parser, "Invalid character entity")
|
|
905
|
+
return "&"+parser.entity + ";"
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
return String.fromCodePoint(num)
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
function write (chunk) {
|
|
912
|
+
var parser = this
|
|
913
|
+
if (this.error) throw this.error
|
|
914
|
+
if (parser.closed) return error(parser,
|
|
915
|
+
"Cannot write after close. Assign an onready handler.")
|
|
916
|
+
if (chunk === null) return end(parser)
|
|
917
|
+
var i = 0, c = ""
|
|
918
|
+
while (parser.c = c = chunk.charAt(i++)) {
|
|
919
|
+
if (parser.trackPosition) {
|
|
920
|
+
parser.position ++
|
|
921
|
+
if (c === "\n") {
|
|
922
|
+
parser.line ++
|
|
923
|
+
parser.column = 0
|
|
924
|
+
} else parser.column ++
|
|
925
|
+
}
|
|
926
|
+
switch (parser.state) {
|
|
927
|
+
|
|
928
|
+
case S.BEGIN:
|
|
929
|
+
if (c === "<") {
|
|
930
|
+
parser.state = S.OPEN_WAKA
|
|
931
|
+
parser.startTagPosition = parser.position
|
|
932
|
+
} else if (not(whitespace,c)) {
|
|
933
|
+
// have to process this as a text node.
|
|
934
|
+
// weird, but happens.
|
|
935
|
+
strictFail(parser, "Non-whitespace before first tag.")
|
|
936
|
+
parser.textNode = c
|
|
937
|
+
parser.state = S.TEXT
|
|
938
|
+
}
|
|
939
|
+
continue
|
|
940
|
+
|
|
941
|
+
case S.TEXT:
|
|
942
|
+
if (parser.sawRoot && !parser.closedRoot) {
|
|
943
|
+
var starti = i-1
|
|
944
|
+
while (c && c!=="<" && c!=="&") {
|
|
945
|
+
c = chunk.charAt(i++)
|
|
946
|
+
if (c && parser.trackPosition) {
|
|
947
|
+
parser.position ++
|
|
948
|
+
if (c === "\n") {
|
|
949
|
+
parser.line ++
|
|
950
|
+
parser.column = 0
|
|
951
|
+
} else parser.column ++
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
parser.textNode += chunk.substring(starti, i-1)
|
|
955
|
+
}
|
|
956
|
+
if (c === "<") {
|
|
957
|
+
parser.state = S.OPEN_WAKA
|
|
958
|
+
parser.startTagPosition = parser.position
|
|
959
|
+
} else {
|
|
960
|
+
if (not(whitespace, c) && (!parser.sawRoot || parser.closedRoot))
|
|
961
|
+
strictFail(parser, "Text data outside of root node.")
|
|
962
|
+
if (c === "&") parser.state = S.TEXT_ENTITY
|
|
963
|
+
else parser.textNode += c
|
|
964
|
+
}
|
|
965
|
+
continue
|
|
966
|
+
|
|
967
|
+
case S.SCRIPT:
|
|
968
|
+
// only non-strict
|
|
969
|
+
if (c === "<") {
|
|
970
|
+
parser.state = S.SCRIPT_ENDING
|
|
971
|
+
} else parser.script += c
|
|
972
|
+
continue
|
|
973
|
+
|
|
974
|
+
case S.SCRIPT_ENDING:
|
|
975
|
+
if (c === "/") {
|
|
976
|
+
parser.state = S.CLOSE_TAG
|
|
977
|
+
} else {
|
|
978
|
+
parser.script += "<" + c
|
|
979
|
+
parser.state = S.SCRIPT
|
|
980
|
+
}
|
|
981
|
+
continue
|
|
982
|
+
|
|
983
|
+
case S.OPEN_WAKA:
|
|
984
|
+
// either a /, ?, !, or text is coming next.
|
|
985
|
+
if (c === "!") {
|
|
986
|
+
parser.state = S.SGML_DECL
|
|
987
|
+
parser.sgmlDecl = ""
|
|
988
|
+
} else if (is(whitespace, c)) {
|
|
989
|
+
// wait for it...
|
|
990
|
+
} else if (is(nameStart,c)) {
|
|
991
|
+
parser.state = S.OPEN_TAG
|
|
992
|
+
parser.tagName = c
|
|
993
|
+
} else if (c === "/") {
|
|
994
|
+
parser.state = S.CLOSE_TAG
|
|
995
|
+
parser.tagName = ""
|
|
996
|
+
} else if (c === "?") {
|
|
997
|
+
parser.state = S.PROC_INST
|
|
998
|
+
parser.procInstName = parser.procInstBody = ""
|
|
999
|
+
} else {
|
|
1000
|
+
strictFail(parser, "Unencoded <")
|
|
1001
|
+
// if there was some whitespace, then add that in.
|
|
1002
|
+
if (parser.startTagPosition + 1 < parser.position) {
|
|
1003
|
+
var pad = parser.position - parser.startTagPosition
|
|
1004
|
+
c = new Array(pad).join(" ") + c
|
|
1005
|
+
}
|
|
1006
|
+
parser.textNode += "<" + c
|
|
1007
|
+
parser.state = S.TEXT
|
|
1008
|
+
}
|
|
1009
|
+
continue
|
|
1010
|
+
|
|
1011
|
+
case S.SGML_DECL:
|
|
1012
|
+
if ((parser.sgmlDecl+c).toUpperCase() === CDATA) {
|
|
1013
|
+
emitNode(parser, "onopencdata")
|
|
1014
|
+
parser.state = S.CDATA
|
|
1015
|
+
parser.sgmlDecl = ""
|
|
1016
|
+
parser.cdata = ""
|
|
1017
|
+
} else if (parser.sgmlDecl+c === "--") {
|
|
1018
|
+
parser.state = S.COMMENT
|
|
1019
|
+
parser.comment = ""
|
|
1020
|
+
parser.sgmlDecl = ""
|
|
1021
|
+
} else if ((parser.sgmlDecl+c).toUpperCase() === DOCTYPE) {
|
|
1022
|
+
parser.state = S.DOCTYPE
|
|
1023
|
+
if (parser.doctype || parser.sawRoot) strictFail(parser,
|
|
1024
|
+
"Inappropriately located doctype declaration")
|
|
1025
|
+
parser.doctype = ""
|
|
1026
|
+
parser.sgmlDecl = ""
|
|
1027
|
+
} else if (c === ">") {
|
|
1028
|
+
emitNode(parser, "onsgmldeclaration", parser.sgmlDecl)
|
|
1029
|
+
parser.sgmlDecl = ""
|
|
1030
|
+
parser.state = S.TEXT
|
|
1031
|
+
} else if (is(quote, c)) {
|
|
1032
|
+
parser.state = S.SGML_DECL_QUOTED
|
|
1033
|
+
parser.sgmlDecl += c
|
|
1034
|
+
} else parser.sgmlDecl += c
|
|
1035
|
+
continue
|
|
1036
|
+
|
|
1037
|
+
case S.SGML_DECL_QUOTED:
|
|
1038
|
+
if (c === parser.q) {
|
|
1039
|
+
parser.state = S.SGML_DECL
|
|
1040
|
+
parser.q = ""
|
|
1041
|
+
}
|
|
1042
|
+
parser.sgmlDecl += c
|
|
1043
|
+
continue
|
|
1044
|
+
|
|
1045
|
+
case S.DOCTYPE:
|
|
1046
|
+
if (c === ">") {
|
|
1047
|
+
parser.state = S.TEXT
|
|
1048
|
+
emitNode(parser, "ondoctype", parser.doctype)
|
|
1049
|
+
parser.doctype = true // just remember that we saw it.
|
|
1050
|
+
} else {
|
|
1051
|
+
parser.doctype += c
|
|
1052
|
+
if (c === "[") parser.state = S.DOCTYPE_DTD
|
|
1053
|
+
else if (is(quote, c)) {
|
|
1054
|
+
parser.state = S.DOCTYPE_QUOTED
|
|
1055
|
+
parser.q = c
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
continue
|
|
1059
|
+
|
|
1060
|
+
case S.DOCTYPE_QUOTED:
|
|
1061
|
+
parser.doctype += c
|
|
1062
|
+
if (c === parser.q) {
|
|
1063
|
+
parser.q = ""
|
|
1064
|
+
parser.state = S.DOCTYPE
|
|
1065
|
+
}
|
|
1066
|
+
continue
|
|
1067
|
+
|
|
1068
|
+
case S.DOCTYPE_DTD:
|
|
1069
|
+
parser.doctype += c
|
|
1070
|
+
if (c === "]") parser.state = S.DOCTYPE
|
|
1071
|
+
else if (is(quote,c)) {
|
|
1072
|
+
parser.state = S.DOCTYPE_DTD_QUOTED
|
|
1073
|
+
parser.q = c
|
|
1074
|
+
}
|
|
1075
|
+
continue
|
|
1076
|
+
|
|
1077
|
+
case S.DOCTYPE_DTD_QUOTED:
|
|
1078
|
+
parser.doctype += c
|
|
1079
|
+
if (c === parser.q) {
|
|
1080
|
+
parser.state = S.DOCTYPE_DTD
|
|
1081
|
+
parser.q = ""
|
|
1082
|
+
}
|
|
1083
|
+
continue
|
|
1084
|
+
|
|
1085
|
+
case S.COMMENT:
|
|
1086
|
+
if (c === "-") parser.state = S.COMMENT_ENDING
|
|
1087
|
+
else parser.comment += c
|
|
1088
|
+
continue
|
|
1089
|
+
|
|
1090
|
+
case S.COMMENT_ENDING:
|
|
1091
|
+
if (c === "-") {
|
|
1092
|
+
parser.state = S.COMMENT_ENDED
|
|
1093
|
+
parser.comment = textopts(parser.opt, parser.comment)
|
|
1094
|
+
if (parser.comment) emitNode(parser, "oncomment", parser.comment)
|
|
1095
|
+
parser.comment = ""
|
|
1096
|
+
} else {
|
|
1097
|
+
parser.comment += "-" + c
|
|
1098
|
+
parser.state = S.COMMENT
|
|
1099
|
+
}
|
|
1100
|
+
continue
|
|
1101
|
+
|
|
1102
|
+
case S.COMMENT_ENDED:
|
|
1103
|
+
if (c !== ">") {
|
|
1104
|
+
strictFail(parser, "Malformed comment")
|
|
1105
|
+
// allow <!-- blah -- bloo --> in non-strict mode,
|
|
1106
|
+
// which is a comment of " blah -- bloo "
|
|
1107
|
+
parser.comment += "--" + c
|
|
1108
|
+
parser.state = S.COMMENT
|
|
1109
|
+
} else parser.state = S.TEXT
|
|
1110
|
+
continue
|
|
1111
|
+
|
|
1112
|
+
case S.CDATA:
|
|
1113
|
+
if (c === "]") parser.state = S.CDATA_ENDING
|
|
1114
|
+
else parser.cdata += c
|
|
1115
|
+
continue
|
|
1116
|
+
|
|
1117
|
+
case S.CDATA_ENDING:
|
|
1118
|
+
if (c === "]") parser.state = S.CDATA_ENDING_2
|
|
1119
|
+
else {
|
|
1120
|
+
parser.cdata += "]" + c
|
|
1121
|
+
parser.state = S.CDATA
|
|
1122
|
+
}
|
|
1123
|
+
continue
|
|
1124
|
+
|
|
1125
|
+
case S.CDATA_ENDING_2:
|
|
1126
|
+
if (c === ">") {
|
|
1127
|
+
if (parser.cdata) emitNode(parser, "oncdata", parser.cdata)
|
|
1128
|
+
emitNode(parser, "onclosecdata")
|
|
1129
|
+
parser.cdata = ""
|
|
1130
|
+
parser.state = S.TEXT
|
|
1131
|
+
} else if (c === "]") {
|
|
1132
|
+
parser.cdata += "]"
|
|
1133
|
+
} else {
|
|
1134
|
+
parser.cdata += "]]" + c
|
|
1135
|
+
parser.state = S.CDATA
|
|
1136
|
+
}
|
|
1137
|
+
continue
|
|
1138
|
+
|
|
1139
|
+
case S.PROC_INST:
|
|
1140
|
+
if (c === "?") parser.state = S.PROC_INST_ENDING
|
|
1141
|
+
else if (is(whitespace, c)) parser.state = S.PROC_INST_BODY
|
|
1142
|
+
else parser.procInstName += c
|
|
1143
|
+
continue
|
|
1144
|
+
|
|
1145
|
+
case S.PROC_INST_BODY:
|
|
1146
|
+
if (!parser.procInstBody && is(whitespace, c)) continue
|
|
1147
|
+
else if (c === "?") parser.state = S.PROC_INST_ENDING
|
|
1148
|
+
else parser.procInstBody += c
|
|
1149
|
+
continue
|
|
1150
|
+
|
|
1151
|
+
case S.PROC_INST_ENDING:
|
|
1152
|
+
if (c === ">") {
|
|
1153
|
+
emitNode(parser, "onprocessinginstruction", {
|
|
1154
|
+
name : parser.procInstName,
|
|
1155
|
+
body : parser.procInstBody
|
|
1156
|
+
})
|
|
1157
|
+
parser.procInstName = parser.procInstBody = ""
|
|
1158
|
+
parser.state = S.TEXT
|
|
1159
|
+
} else {
|
|
1160
|
+
parser.procInstBody += "?" + c
|
|
1161
|
+
parser.state = S.PROC_INST_BODY
|
|
1162
|
+
}
|
|
1163
|
+
continue
|
|
1164
|
+
|
|
1165
|
+
case S.OPEN_TAG:
|
|
1166
|
+
if (is(nameBody, c)) parser.tagName += c
|
|
1167
|
+
else {
|
|
1168
|
+
newTag(parser)
|
|
1169
|
+
if (c === ">") openTag(parser)
|
|
1170
|
+
else if (c === "/") parser.state = S.OPEN_TAG_SLASH
|
|
1171
|
+
else {
|
|
1172
|
+
if (not(whitespace, c)) strictFail(
|
|
1173
|
+
parser, "Invalid character in tag name")
|
|
1174
|
+
parser.state = S.ATTRIB
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
continue
|
|
1178
|
+
|
|
1179
|
+
case S.OPEN_TAG_SLASH:
|
|
1180
|
+
if (c === ">") {
|
|
1181
|
+
openTag(parser, true)
|
|
1182
|
+
closeTag(parser)
|
|
1183
|
+
} else {
|
|
1184
|
+
strictFail(parser, "Forward-slash in opening tag not followed by >")
|
|
1185
|
+
parser.state = S.ATTRIB
|
|
1186
|
+
}
|
|
1187
|
+
continue
|
|
1188
|
+
|
|
1189
|
+
case S.ATTRIB:
|
|
1190
|
+
// haven't read the attribute name yet.
|
|
1191
|
+
if (is(whitespace, c)) continue
|
|
1192
|
+
else if (c === ">") openTag(parser)
|
|
1193
|
+
else if (c === "/") parser.state = S.OPEN_TAG_SLASH
|
|
1194
|
+
else if (is(nameStart, c)) {
|
|
1195
|
+
parser.attribName = c
|
|
1196
|
+
parser.attribValue = ""
|
|
1197
|
+
parser.state = S.ATTRIB_NAME
|
|
1198
|
+
} else strictFail(parser, "Invalid attribute name")
|
|
1199
|
+
continue
|
|
1200
|
+
|
|
1201
|
+
case S.ATTRIB_NAME:
|
|
1202
|
+
if (c === "=") parser.state = S.ATTRIB_VALUE
|
|
1203
|
+
else if (c === ">") {
|
|
1204
|
+
strictFail(parser, "Attribute without value")
|
|
1205
|
+
parser.attribValue = parser.attribName
|
|
1206
|
+
attrib(parser)
|
|
1207
|
+
openTag(parser)
|
|
1208
|
+
}
|
|
1209
|
+
else if (is(whitespace, c)) parser.state = S.ATTRIB_NAME_SAW_WHITE
|
|
1210
|
+
else if (is(nameBody, c)) parser.attribName += c
|
|
1211
|
+
else strictFail(parser, "Invalid attribute name")
|
|
1212
|
+
continue
|
|
1213
|
+
|
|
1214
|
+
case S.ATTRIB_NAME_SAW_WHITE:
|
|
1215
|
+
if (c === "=") parser.state = S.ATTRIB_VALUE
|
|
1216
|
+
else if (is(whitespace, c)) continue
|
|
1217
|
+
else {
|
|
1218
|
+
strictFail(parser, "Attribute without value")
|
|
1219
|
+
parser.tag.attributes[parser.attribName] = ""
|
|
1220
|
+
parser.attribValue = ""
|
|
1221
|
+
emitNode(parser, "onattribute",
|
|
1222
|
+
{ name : parser.attribName, value : "" })
|
|
1223
|
+
parser.attribName = ""
|
|
1224
|
+
if (c === ">") openTag(parser)
|
|
1225
|
+
else if (is(nameStart, c)) {
|
|
1226
|
+
parser.attribName = c
|
|
1227
|
+
parser.state = S.ATTRIB_NAME
|
|
1228
|
+
} else {
|
|
1229
|
+
strictFail(parser, "Invalid attribute name")
|
|
1230
|
+
parser.state = S.ATTRIB
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
continue
|
|
1234
|
+
|
|
1235
|
+
case S.ATTRIB_VALUE:
|
|
1236
|
+
if (is(whitespace, c)) continue
|
|
1237
|
+
else if (is(quote, c)) {
|
|
1238
|
+
parser.q = c
|
|
1239
|
+
parser.state = S.ATTRIB_VALUE_QUOTED
|
|
1240
|
+
} else {
|
|
1241
|
+
strictFail(parser, "Unquoted attribute value")
|
|
1242
|
+
parser.state = S.ATTRIB_VALUE_UNQUOTED
|
|
1243
|
+
parser.attribValue = c
|
|
1244
|
+
}
|
|
1245
|
+
continue
|
|
1246
|
+
|
|
1247
|
+
case S.ATTRIB_VALUE_QUOTED:
|
|
1248
|
+
if (c !== parser.q) {
|
|
1249
|
+
if (c === "&") parser.state = S.ATTRIB_VALUE_ENTITY_Q
|
|
1250
|
+
else parser.attribValue += c
|
|
1251
|
+
continue
|
|
1252
|
+
}
|
|
1253
|
+
attrib(parser)
|
|
1254
|
+
parser.q = ""
|
|
1255
|
+
parser.state = S.ATTRIB_VALUE_CLOSED
|
|
1256
|
+
continue
|
|
1257
|
+
|
|
1258
|
+
case S.ATTRIB_VALUE_CLOSED:
|
|
1259
|
+
if (is(whitespace, c)) {
|
|
1260
|
+
parser.state = S.ATTRIB
|
|
1261
|
+
} else if (c === ">") openTag(parser)
|
|
1262
|
+
else if (c === "/") parser.state = S.OPEN_TAG_SLASH
|
|
1263
|
+
else if (is(nameStart, c)) {
|
|
1264
|
+
strictFail(parser, "No whitespace between attributes")
|
|
1265
|
+
parser.attribName = c
|
|
1266
|
+
parser.attribValue = ""
|
|
1267
|
+
parser.state = S.ATTRIB_NAME
|
|
1268
|
+
} else strictFail(parser, "Invalid attribute name")
|
|
1269
|
+
continue
|
|
1270
|
+
|
|
1271
|
+
case S.ATTRIB_VALUE_UNQUOTED:
|
|
1272
|
+
if (not(attribEnd,c)) {
|
|
1273
|
+
if (c === "&") parser.state = S.ATTRIB_VALUE_ENTITY_U
|
|
1274
|
+
else parser.attribValue += c
|
|
1275
|
+
continue
|
|
1276
|
+
}
|
|
1277
|
+
attrib(parser)
|
|
1278
|
+
if (c === ">") openTag(parser)
|
|
1279
|
+
else parser.state = S.ATTRIB
|
|
1280
|
+
continue
|
|
1281
|
+
|
|
1282
|
+
case S.CLOSE_TAG:
|
|
1283
|
+
if (!parser.tagName) {
|
|
1284
|
+
if (is(whitespace, c)) continue
|
|
1285
|
+
else if (not(nameStart, c)) {
|
|
1286
|
+
if (parser.script) {
|
|
1287
|
+
parser.script += "</" + c
|
|
1288
|
+
parser.state = S.SCRIPT
|
|
1289
|
+
} else {
|
|
1290
|
+
strictFail(parser, "Invalid tagname in closing tag.")
|
|
1291
|
+
}
|
|
1292
|
+
} else parser.tagName = c
|
|
1293
|
+
}
|
|
1294
|
+
else if (c === ">") closeTag(parser)
|
|
1295
|
+
else if (is(nameBody, c)) parser.tagName += c
|
|
1296
|
+
else if (parser.script) {
|
|
1297
|
+
parser.script += "</" + parser.tagName
|
|
1298
|
+
parser.tagName = ""
|
|
1299
|
+
parser.state = S.SCRIPT
|
|
1300
|
+
} else {
|
|
1301
|
+
if (not(whitespace, c)) strictFail(parser,
|
|
1302
|
+
"Invalid tagname in closing tag")
|
|
1303
|
+
parser.state = S.CLOSE_TAG_SAW_WHITE
|
|
1304
|
+
}
|
|
1305
|
+
continue
|
|
1306
|
+
|
|
1307
|
+
case S.CLOSE_TAG_SAW_WHITE:
|
|
1308
|
+
if (is(whitespace, c)) continue
|
|
1309
|
+
if (c === ">") closeTag(parser)
|
|
1310
|
+
else strictFail(parser, "Invalid characters in closing tag")
|
|
1311
|
+
continue
|
|
1312
|
+
|
|
1313
|
+
case S.TEXT_ENTITY:
|
|
1314
|
+
case S.ATTRIB_VALUE_ENTITY_Q:
|
|
1315
|
+
case S.ATTRIB_VALUE_ENTITY_U:
|
|
1316
|
+
switch(parser.state) {
|
|
1317
|
+
case S.TEXT_ENTITY:
|
|
1318
|
+
var returnState = S.TEXT, buffer = "textNode"
|
|
1319
|
+
break
|
|
1320
|
+
|
|
1321
|
+
case S.ATTRIB_VALUE_ENTITY_Q:
|
|
1322
|
+
var returnState = S.ATTRIB_VALUE_QUOTED, buffer = "attribValue"
|
|
1323
|
+
break
|
|
1324
|
+
|
|
1325
|
+
case S.ATTRIB_VALUE_ENTITY_U:
|
|
1326
|
+
var returnState = S.ATTRIB_VALUE_UNQUOTED, buffer = "attribValue"
|
|
1327
|
+
break
|
|
1328
|
+
}
|
|
1329
|
+
if (c === ";") {
|
|
1330
|
+
parser[buffer] += parseEntity(parser)
|
|
1331
|
+
parser.entity = ""
|
|
1332
|
+
parser.state = returnState
|
|
1333
|
+
}
|
|
1334
|
+
else if (is(entity, c)) parser.entity += c
|
|
1335
|
+
else {
|
|
1336
|
+
strictFail(parser, "Invalid character entity")
|
|
1337
|
+
parser[buffer] += "&" + parser.entity + c
|
|
1338
|
+
parser.entity = ""
|
|
1339
|
+
parser.state = returnState
|
|
1340
|
+
}
|
|
1341
|
+
continue
|
|
1342
|
+
|
|
1343
|
+
default:
|
|
1344
|
+
throw new Error(parser, "Unknown state: " + parser.state)
|
|
1345
|
+
}
|
|
1346
|
+
} // while
|
|
1347
|
+
// cdata blocks can get very big under normal conditions. emit and move on.
|
|
1348
|
+
// if (parser.state === S.CDATA && parser.cdata) {
|
|
1349
|
+
// emitNode(parser, "oncdata", parser.cdata)
|
|
1350
|
+
// parser.cdata = ""
|
|
1351
|
+
// }
|
|
1352
|
+
if (parser.position >= parser.bufferCheckPosition) checkBufferLength(parser)
|
|
1353
|
+
return parser
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
|
|
1357
|
+
if (!String.fromCodePoint) {
|
|
1358
|
+
(function() {
|
|
1359
|
+
var stringFromCharCode = String.fromCharCode;
|
|
1360
|
+
var floor = Math.floor;
|
|
1361
|
+
var fromCodePoint = function() {
|
|
1362
|
+
var MAX_SIZE = 0x4000;
|
|
1363
|
+
var codeUnits = [];
|
|
1364
|
+
var highSurrogate;
|
|
1365
|
+
var lowSurrogate;
|
|
1366
|
+
var index = -1;
|
|
1367
|
+
var length = arguments.length;
|
|
1368
|
+
if (!length) {
|
|
1369
|
+
return '';
|
|
1370
|
+
}
|
|
1371
|
+
var result = '';
|
|
1372
|
+
while (++index < length) {
|
|
1373
|
+
var codePoint = Number(arguments[index]);
|
|
1374
|
+
if (
|
|
1375
|
+
!isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
|
|
1376
|
+
codePoint < 0 || // not a valid Unicode code point
|
|
1377
|
+
codePoint > 0x10FFFF || // not a valid Unicode code point
|
|
1378
|
+
floor(codePoint) != codePoint // not an integer
|
|
1379
|
+
) {
|
|
1380
|
+
throw RangeError('Invalid code point: ' + codePoint);
|
|
1381
|
+
}
|
|
1382
|
+
if (codePoint <= 0xFFFF) { // BMP code point
|
|
1383
|
+
codeUnits.push(codePoint);
|
|
1384
|
+
} else { // Astral code point; split in surrogate halves
|
|
1385
|
+
// http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
|
|
1386
|
+
codePoint -= 0x10000;
|
|
1387
|
+
highSurrogate = (codePoint >> 10) + 0xD800;
|
|
1388
|
+
lowSurrogate = (codePoint % 0x400) + 0xDC00;
|
|
1389
|
+
codeUnits.push(highSurrogate, lowSurrogate);
|
|
1390
|
+
}
|
|
1391
|
+
if (index + 1 == length || codeUnits.length > MAX_SIZE) {
|
|
1392
|
+
result += stringFromCharCode.apply(null, codeUnits);
|
|
1393
|
+
codeUnits.length = 0;
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
return result;
|
|
1397
|
+
};
|
|
1398
|
+
if (Object.defineProperty) {
|
|
1399
|
+
Object.defineProperty(String, 'fromCodePoint', {
|
|
1400
|
+
'value': fromCodePoint,
|
|
1401
|
+
'configurable': true,
|
|
1402
|
+
'writable': true
|
|
1403
|
+
});
|
|
1404
|
+
} else {
|
|
1405
|
+
String.fromCodePoint = fromCodePoint;
|
|
1406
|
+
}
|
|
1407
|
+
}());
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
})(typeof exports === "undefined" ? sax = {} : exports)
|