open-agreements 0.7.5 → 0.7.6
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.
- package/README.de.md +300 -255
- package/README.es.md +301 -254
- package/README.md +389 -95
- package/README.pt-br.md +301 -254
- package/README.template.md +333 -0
- package/README.zh.md +300 -253
- package/SECURITY.md +34 -0
- package/content/recipes/nvca-stock-purchase-agreement/README.md +39 -0
- package/content/recipes/nvca-voting-agreement/README.md +43 -0
- package/content/templates/bonterms-mutual-nda/README.md +2 -2
- package/content/templates/bonterms-mutual-nda/metadata.yaml +5 -11
- package/content/templates/bonterms-professional-services-agreement/README.md +2 -2
- package/content/templates/bonterms-professional-services-agreement/metadata.yaml +2 -2
- package/content/templates/closing-checklist/template.docx +0 -0
- package/content/templates/closing-checklist/template.md +30 -0
- package/content/templates/common-paper-ai-addendum/template.docx +0 -0
- package/content/templates/common-paper-ai-addendum-in-app/template.docx +0 -0
- package/content/templates/common-paper-csa-with-ai/template.docx +0 -0
- package/content/templates/common-paper-independent-contractor-agreement/template.docx +0 -0
- package/content/templates/common-paper-mutual-nda/README.md +28 -0
- package/content/templates/common-paper-one-way-nda/metadata.yaml +1 -1
- package/content/templates/common-paper-term-sheet/template.docx +0 -0
- package/content/templates/openagreements-board-consent-safe/.template.generated.json +74 -0
- package/content/templates/openagreements-board-consent-safe/README.md +61 -0
- package/content/templates/openagreements-board-consent-safe/metadata.yaml +53 -0
- package/content/templates/openagreements-board-consent-safe/reference-source.docx +0 -0
- package/content/templates/openagreements-board-consent-safe/template.docx +0 -0
- package/content/templates/openagreements-board-consent-safe/template.md +66 -0
- package/content/templates/openagreements-due-diligence-request-list/README.md +68 -0
- package/content/templates/openagreements-due-diligence-request-list/metadata.yaml +300 -0
- package/content/templates/openagreements-due-diligence-request-list/template.docx +0 -0
- package/content/templates/openagreements-due-diligence-request-list/template.md +318 -0
- package/content/templates/openagreements-employee-ip-inventions-assignment/.template.generated.json +230 -0
- package/content/templates/openagreements-employee-ip-inventions-assignment/metadata.yaml +1 -1
- package/content/templates/openagreements-employee-ip-inventions-assignment/template.docx +0 -0
- package/content/templates/openagreements-employee-ip-inventions-assignment/template.md +96 -35
- package/content/templates/openagreements-employment-confidentiality-acknowledgement/README.md +1 -1
- package/content/templates/openagreements-employment-confidentiality-acknowledgement/metadata.yaml +2 -2
- package/content/templates/openagreements-employment-confidentiality-acknowledgement/template.docx +0 -0
- package/content/templates/openagreements-employment-confidentiality-acknowledgement/template.json +75 -0
- package/content/templates/openagreements-employment-confidentiality-acknowledgement/template.md +8 -4
- package/content/templates/openagreements-employment-offer-letter/.template.generated.json +224 -0
- package/content/templates/openagreements-employment-offer-letter/README.md +65 -1
- package/content/templates/openagreements-employment-offer-letter/metadata.yaml +1 -1
- package/content/templates/openagreements-employment-offer-letter/template.docx +0 -0
- package/content/templates/openagreements-employment-offer-letter/template.md +70 -30
- package/content/templates/openagreements-restrictive-covenant-florida/.template.generated.json +456 -0
- package/content/templates/openagreements-restrictive-covenant-florida/README.md +141 -0
- package/content/templates/openagreements-restrictive-covenant-florida/metadata.yaml +419 -0
- package/content/templates/openagreements-restrictive-covenant-florida/template.docx +0 -0
- package/content/templates/openagreements-restrictive-covenant-florida/template.md +233 -0
- package/content/templates/openagreements-restrictive-covenant-wyoming/.template.generated.json +399 -0
- package/content/templates/openagreements-restrictive-covenant-wyoming/metadata.yaml +69 -12
- package/content/templates/openagreements-restrictive-covenant-wyoming/template.docx +0 -0
- package/content/templates/openagreements-restrictive-covenant-wyoming/template.md +110 -59
- package/content/templates/openagreements-stockholder-consent-safe/.template.generated.json +74 -0
- package/content/templates/openagreements-stockholder-consent-safe/README.md +62 -0
- package/content/templates/openagreements-stockholder-consent-safe/metadata.yaml +53 -0
- package/content/templates/openagreements-stockholder-consent-safe/reference-source.docx +0 -0
- package/content/templates/openagreements-stockholder-consent-safe/template.docx +0 -0
- package/content/templates/openagreements-stockholder-consent-safe/template.md +62 -0
- package/content/templates/working-group-list/template.docx +0 -0
- package/content/templates/working-group-list/template.md +18 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/fill.d.ts +1 -1
- package/dist/commands/fill.d.ts.map +1 -1
- package/dist/commands/fill.js +4 -1
- package/dist/commands/fill.js.map +1 -1
- package/dist/commands/list.js +10 -0
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/recipe.js.map +1 -1
- package/dist/core/employment/jurisdiction-rules.js +2 -2
- package/dist/core/employment/jurisdiction-rules.js.map +1 -1
- package/dist/core/employment/memo.d.ts +1 -1
- package/dist/core/employment/memo.d.ts.map +1 -1
- package/dist/core/employment/memo.js +14 -6
- package/dist/core/employment/memo.js.map +1 -1
- package/dist/core/engine.d.ts.map +1 -1
- package/dist/core/engine.js +28 -0
- package/dist/core/engine.js.map +1 -1
- package/dist/core/fill-pipeline.d.ts +30 -5
- package/dist/core/fill-pipeline.d.ts.map +1 -1
- package/dist/core/fill-pipeline.js +173 -9
- package/dist/core/fill-pipeline.js.map +1 -1
- package/dist/core/humanize-docx.d.ts +21 -0
- package/dist/core/humanize-docx.d.ts.map +1 -0
- package/dist/core/humanize-docx.js +492 -0
- package/dist/core/humanize-docx.js.map +1 -0
- package/dist/core/metadata.d.ts +118 -65
- package/dist/core/metadata.d.ts.map +1 -1
- package/dist/core/metadata.js +268 -13
- package/dist/core/metadata.js.map +1 -1
- package/dist/core/recipe/bracket-normalizer.d.ts +1 -1
- package/dist/core/recipe/bracket-normalizer.d.ts.map +1 -1
- package/dist/core/recipe/bracket-normalizer.js +3 -0
- package/dist/core/recipe/bracket-normalizer.js.map +1 -1
- package/dist/core/recipe/computed.d.ts +1 -1
- package/dist/core/recipe/computed.d.ts.map +1 -1
- package/dist/core/recipe/index.d.ts.map +1 -1
- package/dist/core/recipe/index.js +22 -4
- package/dist/core/recipe/index.js.map +1 -1
- package/dist/core/recipe/types.d.ts +1 -1
- package/dist/core/recipe/types.d.ts.map +1 -1
- package/dist/core/template-listing.d.ts +6 -8
- package/dist/core/template-listing.d.ts.map +1 -1
- package/dist/core/template-listing.js +24 -0
- package/dist/core/template-listing.js.map +1 -1
- package/dist/core/unified-pipeline.d.ts +2 -0
- package/dist/core/unified-pipeline.d.ts.map +1 -1
- package/dist/core/unified-pipeline.js +19 -1
- package/dist/core/unified-pipeline.js.map +1 -1
- package/dist/core/validation/template.d.ts +32 -0
- package/dist/core/validation/template.d.ts.map +1 -1
- package/dist/core/validation/template.js +163 -3
- package/dist/core/validation/template.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +26 -12
- package/skills/canonical-markdown-authoring/CONNECTORS.md +67 -0
- package/skills/canonical-markdown-authoring/SKILL.md +565 -0
- package/skills/client-email/SKILL.md +2 -0
- package/skills/cloud-service-agreement/CONNECTORS.md +2 -2
- package/skills/cloud-service-agreement/SKILL.md +38 -1
- package/skills/cloud-service-agreement/template-filling-execution.md +2 -2
- package/skills/data-privacy-agreement/CONNECTORS.md +2 -2
- package/skills/data-privacy-agreement/SKILL.md +2 -0
- package/skills/delaware-franchise-tax/SKILL.md +2 -0
- package/skills/edit-docx-agreement/SKILL.md +2 -0
- package/skills/employment-contract/CONNECTORS.md +2 -2
- package/skills/employment-contract/SKILL.md +2 -0
- package/skills/iso-27001-evidence-collection/SKILL.md +2 -0
- package/skills/iso-27001-internal-audit/SKILL.md +2 -0
- package/skills/nda/CONNECTORS.md +2 -2
- package/skills/nda/SKILL.md +45 -1
- package/skills/nda/template-filling-execution.md +12 -6
- package/skills/non-compete-contract-explainer/SKILL.md +107 -0
- package/skills/non-compete-contract-explainer/content/wyoming.md +286 -0
- package/skills/non-compete-contract-explainer/manifest.json +18 -0
- package/skills/open-agreements/CONNECTORS.md +2 -2
- package/skills/open-agreements/SKILL.md +165 -67
- package/skills/open-agreements/template-filling-execution.md +2 -2
- package/skills/recipe-quality-audit/SKILL.md +2 -0
- package/skills/safe/CONNECTORS.md +2 -2
- package/skills/safe/SKILL.md +38 -1
- package/skills/safe/template-filling-execution.md +2 -2
- package/skills/services-agreement/CONNECTORS.md +2 -2
- package/skills/services-agreement/SKILL.md +40 -1
- package/skills/services-agreement/template-filling-execution.md +81 -0
- package/skills/shared/template-filling-execution.md +2 -2
- package/skills/soc2-readiness/SKILL.md +2 -0
- package/skills/unit-test-philosophy/SKILL.md +3 -0
- package/skills/venture-financing/CONNECTORS.md +2 -2
- package/skills/venture-financing/SKILL.md +2 -0
- package/content/templates/openagreements-restrictive-covenant-wyoming/practice-note.md +0 -103
- package/node_modules/@xmldom/xmldom/CHANGELOG.md +0 -939
- package/node_modules/@xmldom/xmldom/LICENSE +0 -8
- package/node_modules/@xmldom/xmldom/SECURITY.md +0 -50
- package/node_modules/@xmldom/xmldom/index.d.ts +0 -1664
- package/node_modules/@xmldom/xmldom/lib/.eslintrc.yml +0 -3
- package/node_modules/@xmldom/xmldom/lib/conventions.js +0 -429
- package/node_modules/@xmldom/xmldom/lib/dom-parser.js +0 -586
- package/node_modules/@xmldom/xmldom/lib/dom.js +0 -3192
- package/node_modules/@xmldom/xmldom/lib/entities.js +0 -2171
- package/node_modules/@xmldom/xmldom/lib/errors.js +0 -202
- package/node_modules/@xmldom/xmldom/lib/grammar.js +0 -533
- package/node_modules/@xmldom/xmldom/lib/index.js +0 -41
- package/node_modules/@xmldom/xmldom/lib/sax.js +0 -929
- package/node_modules/@xmldom/xmldom/package.json +0 -74
- package/node_modules/@xmldom/xmldom/readme.md +0 -364
- package/node_modules/core-util-is/LICENSE +0 -19
- package/node_modules/core-util-is/README.md +0 -3
- package/node_modules/core-util-is/lib/util.js +0 -107
- package/node_modules/core-util-is/package.json +0 -38
- package/node_modules/immediate/LICENSE.txt +0 -20
- package/node_modules/immediate/README.md +0 -93
- package/node_modules/immediate/dist/immediate.js +0 -75
- package/node_modules/immediate/dist/immediate.min.js +0 -1
- package/node_modules/immediate/lib/browser.js +0 -69
- package/node_modules/immediate/lib/index.js +0 -73
- package/node_modules/immediate/package.json +0 -42
- package/node_modules/inherits/LICENSE +0 -16
- package/node_modules/inherits/README.md +0 -42
- package/node_modules/inherits/inherits.js +0 -9
- package/node_modules/inherits/inherits_browser.js +0 -27
- package/node_modules/inherits/package.json +0 -29
- package/node_modules/isarray/.npmignore +0 -1
- package/node_modules/isarray/.travis.yml +0 -4
- package/node_modules/isarray/Makefile +0 -6
- package/node_modules/isarray/README.md +0 -60
- package/node_modules/isarray/component.json +0 -19
- package/node_modules/isarray/index.js +0 -5
- package/node_modules/isarray/package.json +0 -45
- package/node_modules/isarray/test.js +0 -20
- package/node_modules/jszip/.codeclimate.yml +0 -16
- package/node_modules/jszip/.editorconfig +0 -8
- package/node_modules/jszip/.eslintrc.js +0 -43
- package/node_modules/jszip/.github/workflows/pr.yaml +0 -58
- package/node_modules/jszip/.jekyll-metadata +0 -0
- package/node_modules/jszip/.travis.yml +0 -17
- package/node_modules/jszip/CHANGES.md +0 -204
- package/node_modules/jszip/LICENSE.markdown +0 -651
- package/node_modules/jszip/README.markdown +0 -33
- package/node_modules/jszip/deps.js +0 -37
- package/node_modules/jszip/dist/jszip.js +0 -11577
- package/node_modules/jszip/dist/jszip.min.js +0 -13
- package/node_modules/jszip/graph.svg +0 -601
- package/node_modules/jszip/index.d.ts +0 -330
- package/node_modules/jszip/lib/base64.js +0 -106
- package/node_modules/jszip/lib/compressedObject.js +0 -74
- package/node_modules/jszip/lib/compressions.js +0 -14
- package/node_modules/jszip/lib/crc32.js +0 -77
- package/node_modules/jszip/lib/defaults.js +0 -11
- package/node_modules/jszip/lib/external.js +0 -18
- package/node_modules/jszip/lib/flate.js +0 -85
- package/node_modules/jszip/lib/generate/ZipFileWorker.js +0 -539
- package/node_modules/jszip/lib/generate/index.js +0 -57
- package/node_modules/jszip/lib/index.js +0 -55
- package/node_modules/jszip/lib/license_header.js +0 -11
- package/node_modules/jszip/lib/load.js +0 -88
- package/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +0 -74
- package/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +0 -42
- package/node_modules/jszip/lib/nodejsUtils.js +0 -57
- package/node_modules/jszip/lib/object.js +0 -384
- package/node_modules/jszip/lib/readable-stream-browser.js +0 -10
- package/node_modules/jszip/lib/reader/ArrayReader.js +0 -57
- package/node_modules/jszip/lib/reader/DataReader.js +0 -116
- package/node_modules/jszip/lib/reader/NodeBufferReader.js +0 -19
- package/node_modules/jszip/lib/reader/StringReader.js +0 -38
- package/node_modules/jszip/lib/reader/Uint8ArrayReader.js +0 -22
- package/node_modules/jszip/lib/reader/readerFor.js +0 -28
- package/node_modules/jszip/lib/signature.js +0 -7
- package/node_modules/jszip/lib/stream/ConvertWorker.js +0 -26
- package/node_modules/jszip/lib/stream/Crc32Probe.js +0 -24
- package/node_modules/jszip/lib/stream/DataLengthProbe.js +0 -29
- package/node_modules/jszip/lib/stream/DataWorker.js +0 -116
- package/node_modules/jszip/lib/stream/GenericWorker.js +0 -263
- package/node_modules/jszip/lib/stream/StreamHelper.js +0 -214
- package/node_modules/jszip/lib/support.js +0 -38
- package/node_modules/jszip/lib/utf8.js +0 -275
- package/node_modules/jszip/lib/utils.js +0 -501
- package/node_modules/jszip/lib/zipEntries.js +0 -261
- package/node_modules/jszip/lib/zipEntry.js +0 -293
- package/node_modules/jszip/lib/zipObject.js +0 -133
- package/node_modules/jszip/package.json +0 -67
- package/node_modules/jszip/sponsors.md +0 -21
- package/node_modules/jszip/tsconfig.json +0 -101
- package/node_modules/jszip/vendor/FileSaver.js +0 -247
- package/node_modules/lie/README.md +0 -62
- package/node_modules/lie/dist/lie.js +0 -350
- package/node_modules/lie/dist/lie.min.js +0 -1
- package/node_modules/lie/dist/lie.polyfill.js +0 -358
- package/node_modules/lie/dist/lie.polyfill.min.js +0 -1
- package/node_modules/lie/lib/browser.js +0 -273
- package/node_modules/lie/lib/index.js +0 -298
- package/node_modules/lie/license.md +0 -7
- package/node_modules/lie/lie.d.ts +0 -244
- package/node_modules/lie/package.json +0 -69
- package/node_modules/lie/polyfill.js +0 -4
- package/node_modules/pako/LICENSE +0 -21
- package/node_modules/pako/README.md +0 -191
- package/node_modules/pako/dist/pako.js +0 -6818
- package/node_modules/pako/dist/pako.min.js +0 -1
- package/node_modules/pako/dist/pako_deflate.js +0 -3997
- package/node_modules/pako/dist/pako_deflate.min.js +0 -1
- package/node_modules/pako/dist/pako_inflate.js +0 -3300
- package/node_modules/pako/dist/pako_inflate.min.js +0 -1
- package/node_modules/pako/index.js +0 -14
- package/node_modules/pako/lib/deflate.js +0 -400
- package/node_modules/pako/lib/inflate.js +0 -423
- package/node_modules/pako/lib/utils/common.js +0 -105
- package/node_modules/pako/lib/utils/strings.js +0 -187
- package/node_modules/pako/lib/zlib/README +0 -59
- package/node_modules/pako/lib/zlib/adler32.js +0 -51
- package/node_modules/pako/lib/zlib/constants.js +0 -68
- package/node_modules/pako/lib/zlib/crc32.js +0 -59
- package/node_modules/pako/lib/zlib/deflate.js +0 -1874
- package/node_modules/pako/lib/zlib/gzheader.js +0 -58
- package/node_modules/pako/lib/zlib/inffast.js +0 -345
- package/node_modules/pako/lib/zlib/inflate.js +0 -1556
- package/node_modules/pako/lib/zlib/inftrees.js +0 -343
- package/node_modules/pako/lib/zlib/messages.js +0 -32
- package/node_modules/pako/lib/zlib/trees.js +0 -1222
- package/node_modules/pako/lib/zlib/zstream.js +0 -47
- package/node_modules/pako/package.json +0 -44
- package/node_modules/process-nextick-args/index.js +0 -45
- package/node_modules/process-nextick-args/license.md +0 -19
- package/node_modules/process-nextick-args/package.json +0 -25
- package/node_modules/process-nextick-args/readme.md +0 -18
- package/node_modules/readable-stream/.travis.yml +0 -34
- package/node_modules/readable-stream/CONTRIBUTING.md +0 -38
- package/node_modules/readable-stream/GOVERNANCE.md +0 -136
- package/node_modules/readable-stream/LICENSE +0 -47
- package/node_modules/readable-stream/README.md +0 -58
- package/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +0 -60
- package/node_modules/readable-stream/duplex-browser.js +0 -1
- package/node_modules/readable-stream/duplex.js +0 -1
- package/node_modules/readable-stream/lib/_stream_duplex.js +0 -131
- package/node_modules/readable-stream/lib/_stream_passthrough.js +0 -47
- package/node_modules/readable-stream/lib/_stream_readable.js +0 -1019
- package/node_modules/readable-stream/lib/_stream_transform.js +0 -214
- package/node_modules/readable-stream/lib/_stream_writable.js +0 -685
- package/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -78
- package/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -84
- package/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -1
- package/node_modules/readable-stream/lib/internal/streams/stream.js +0 -1
- package/node_modules/readable-stream/package.json +0 -52
- package/node_modules/readable-stream/passthrough.js +0 -1
- package/node_modules/readable-stream/readable-browser.js +0 -7
- package/node_modules/readable-stream/readable.js +0 -19
- package/node_modules/readable-stream/transform.js +0 -1
- package/node_modules/readable-stream/writable-browser.js +0 -1
- package/node_modules/readable-stream/writable.js +0 -8
- package/node_modules/safe-buffer/LICENSE +0 -21
- package/node_modules/safe-buffer/README.md +0 -584
- package/node_modules/safe-buffer/index.d.ts +0 -187
- package/node_modules/safe-buffer/index.js +0 -62
- package/node_modules/safe-buffer/package.json +0 -37
- package/node_modules/setimmediate/LICENSE.txt +0 -20
- package/node_modules/setimmediate/package.json +0 -30
- package/node_modules/setimmediate/setImmediate.js +0 -186
- package/node_modules/string_decoder/.travis.yml +0 -50
- package/node_modules/string_decoder/LICENSE +0 -48
- package/node_modules/string_decoder/README.md +0 -47
- package/node_modules/string_decoder/lib/string_decoder.js +0 -296
- package/node_modules/string_decoder/package.json +0 -31
- package/node_modules/util-deprecate/History.md +0 -16
- package/node_modules/util-deprecate/LICENSE +0 -24
- package/node_modules/util-deprecate/README.md +0 -53
- package/node_modules/util-deprecate/browser.js +0 -67
- package/node_modules/util-deprecate/node.js +0 -6
- package/node_modules/util-deprecate/package.json +0 -27
|
@@ -1,586 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var conventions = require('./conventions');
|
|
4
|
-
var dom = require('./dom');
|
|
5
|
-
var errors = require('./errors');
|
|
6
|
-
var entities = require('./entities');
|
|
7
|
-
var sax = require('./sax');
|
|
8
|
-
|
|
9
|
-
var DOMImplementation = dom.DOMImplementation;
|
|
10
|
-
|
|
11
|
-
var hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;
|
|
12
|
-
var isHTMLMimeType = conventions.isHTMLMimeType;
|
|
13
|
-
var isValidMimeType = conventions.isValidMimeType;
|
|
14
|
-
var MIME_TYPE = conventions.MIME_TYPE;
|
|
15
|
-
var NAMESPACE = conventions.NAMESPACE;
|
|
16
|
-
var ParseError = errors.ParseError;
|
|
17
|
-
|
|
18
|
-
var XMLReader = sax.XMLReader;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Normalizes line ending according to <https://www.w3.org/TR/xml11/#sec-line-ends>,
|
|
22
|
-
* including some Unicode "newline" characters:
|
|
23
|
-
*
|
|
24
|
-
* > XML parsed entities are often stored in computer files which,
|
|
25
|
-
* > for editing convenience, are organized into lines.
|
|
26
|
-
* > These lines are typically separated by some combination
|
|
27
|
-
* > of the characters CARRIAGE RETURN (#xD) and LINE FEED (#xA).
|
|
28
|
-
* >
|
|
29
|
-
* > To simplify the tasks of applications, the XML processor must behave
|
|
30
|
-
* > as if it normalized all line breaks in external parsed entities (including the document entity)
|
|
31
|
-
* > on input, before parsing, by translating the following to a single #xA character:
|
|
32
|
-
* >
|
|
33
|
-
* > 1. the two-character sequence #xD #xA,
|
|
34
|
-
* > 2. the two-character sequence #xD #x85,
|
|
35
|
-
* > 3. the single character #x85,
|
|
36
|
-
* > 4. the single character #x2028,
|
|
37
|
-
* > 5. the single character #x2029,
|
|
38
|
-
* > 6. any #xD character that is not immediately followed by #xA or #x85.
|
|
39
|
-
*
|
|
40
|
-
* @param {string} input
|
|
41
|
-
* @returns {string}
|
|
42
|
-
* @prettierignore
|
|
43
|
-
*/
|
|
44
|
-
function normalizeLineEndings(input) {
|
|
45
|
-
return input.replace(/\r[\n\u0085]/g, '\n').replace(/[\r\u0085\u2028\u2029]/g, '\n');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @typedef Locator
|
|
50
|
-
* @property {number} [columnNumber]
|
|
51
|
-
* @property {number} [lineNumber]
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @typedef DOMParserOptions
|
|
56
|
-
* @property {typeof assign} [assign]
|
|
57
|
-
* The method to use instead of `conventions.assign`, which is used to copy values from
|
|
58
|
-
* `options` before they are used for parsing.
|
|
59
|
-
* @property {typeof DOMHandler} [domHandler]
|
|
60
|
-
* For internal testing: The class for creating an instance for handling events from the SAX
|
|
61
|
-
* parser.
|
|
62
|
-
* *****Warning: By configuring a faulty implementation, the specified behavior can completely
|
|
63
|
-
* be broken.*****.
|
|
64
|
-
* @property {Function} [errorHandler]
|
|
65
|
-
* DEPRECATED! use `onError` instead.
|
|
66
|
-
* @property {function(level:ErrorLevel, message:string, context: DOMHandler):void}
|
|
67
|
-
* [onError]
|
|
68
|
-
* A function invoked for every error that occurs during parsing.
|
|
69
|
-
*
|
|
70
|
-
* If it is not provided, all errors are reported to `console.error`
|
|
71
|
-
* and only `fatalError`s are thrown as a `ParseError`,
|
|
72
|
-
* which prevents any further processing.
|
|
73
|
-
* If the provided method throws, a `ParserError` is thrown,
|
|
74
|
-
* which prevents any further processing.
|
|
75
|
-
*
|
|
76
|
-
* Be aware that many `warning`s are considered an error that prevents further processing in
|
|
77
|
-
* most implementations.
|
|
78
|
-
* @property {boolean} [locator=true]
|
|
79
|
-
* Configures if the nodes created during parsing will have a `lineNumber` and a `columnNumber`
|
|
80
|
-
* attribute describing their location in the XML string.
|
|
81
|
-
* Default is true.
|
|
82
|
-
* @property {(string) => string} [normalizeLineEndings]
|
|
83
|
-
* used to replace line endings before parsing, defaults to exported `normalizeLineEndings`,
|
|
84
|
-
* which normalizes line endings according to <https://www.w3.org/TR/xml11/#sec-line-ends>,
|
|
85
|
-
* including some Unicode "newline" characters.
|
|
86
|
-
* @property {Object} [xmlns]
|
|
87
|
-
* The XML namespaces that should be assumed when parsing.
|
|
88
|
-
* The default namespace can be provided by the key that is the empty string.
|
|
89
|
-
* When the `mimeType` for HTML, XHTML or SVG are passed to `parseFromString`,
|
|
90
|
-
* the default namespace that will be used,
|
|
91
|
-
* will be overridden according to the specification.
|
|
92
|
-
* @see {@link normalizeLineEndings}
|
|
93
|
-
*/
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* The DOMParser interface provides the ability to parse XML or HTML source code from a string
|
|
97
|
-
* into a DOM `Document`.
|
|
98
|
-
*
|
|
99
|
-
* ***xmldom is different from the spec in that it allows an `options` parameter,
|
|
100
|
-
* to control the behavior***.
|
|
101
|
-
*
|
|
102
|
-
* @class
|
|
103
|
-
* @param {DOMParserOptions} [options]
|
|
104
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
|
|
105
|
-
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
|
|
106
|
-
*/
|
|
107
|
-
function DOMParser(options) {
|
|
108
|
-
options = options || {};
|
|
109
|
-
if (options.locator === undefined) {
|
|
110
|
-
options.locator = true;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* The method to use instead of `conventions.assign`, which is used to copy values from
|
|
115
|
-
* `options`
|
|
116
|
-
* before they are used for parsing.
|
|
117
|
-
*
|
|
118
|
-
* @type {conventions.assign}
|
|
119
|
-
* @private
|
|
120
|
-
* @see {@link conventions.assign}
|
|
121
|
-
* @readonly
|
|
122
|
-
*/
|
|
123
|
-
this.assign = options.assign || conventions.assign;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* For internal testing: The class for creating an instance for handling events from the SAX
|
|
127
|
-
* parser.
|
|
128
|
-
* *****Warning: By configuring a faulty implementation, the specified behavior can completely
|
|
129
|
-
* be broken*****.
|
|
130
|
-
*
|
|
131
|
-
* @type {typeof DOMHandler}
|
|
132
|
-
* @private
|
|
133
|
-
* @readonly
|
|
134
|
-
*/
|
|
135
|
-
this.domHandler = options.domHandler || DOMHandler;
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* A function that is invoked for every error that occurs during parsing.
|
|
139
|
-
*
|
|
140
|
-
* If it is not provided, all errors are reported to `console.error`
|
|
141
|
-
* and only `fatalError`s are thrown as a `ParseError`,
|
|
142
|
-
* which prevents any further processing.
|
|
143
|
-
* If the provided method throws, a `ParserError` is thrown,
|
|
144
|
-
* which prevents any further processing.
|
|
145
|
-
*
|
|
146
|
-
* Be aware that many `warning`s are considered an error that prevents further processing in
|
|
147
|
-
* most implementations.
|
|
148
|
-
*
|
|
149
|
-
* @type {function(level:ErrorLevel, message:string, context: DOMHandler):void}
|
|
150
|
-
* @see {@link onErrorStopParsing}
|
|
151
|
-
* @see {@link onWarningStopParsing}
|
|
152
|
-
*/
|
|
153
|
-
this.onError = options.onError || options.errorHandler;
|
|
154
|
-
if (options.errorHandler && typeof options.errorHandler !== 'function') {
|
|
155
|
-
throw new TypeError('errorHandler object is no longer supported, switch to onError!');
|
|
156
|
-
} else if (options.errorHandler) {
|
|
157
|
-
options.errorHandler('warning', 'The `errorHandler` option has been deprecated, use `onError` instead!', this);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* used to replace line endings before parsing, defaults to `normalizeLineEndings`
|
|
162
|
-
*
|
|
163
|
-
* @type {(string) => string}
|
|
164
|
-
* @readonly
|
|
165
|
-
*/
|
|
166
|
-
this.normalizeLineEndings = options.normalizeLineEndings || normalizeLineEndings;
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Configures if the nodes created during parsing will have a `lineNumber` and a
|
|
170
|
-
* `columnNumber`
|
|
171
|
-
* attribute describing their location in the XML string.
|
|
172
|
-
* Default is true.
|
|
173
|
-
*
|
|
174
|
-
* @type {boolean}
|
|
175
|
-
* @readonly
|
|
176
|
-
*/
|
|
177
|
-
this.locator = !!options.locator;
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* The default namespace can be provided by the key that is the empty string.
|
|
181
|
-
* When the `mimeType` for HTML, XHTML or SVG are passed to `parseFromString`,
|
|
182
|
-
* the default namespace that will be used,
|
|
183
|
-
* will be overridden according to the specification.
|
|
184
|
-
*
|
|
185
|
-
* @type {Readonly<Object>}
|
|
186
|
-
* @readonly
|
|
187
|
-
*/
|
|
188
|
-
this.xmlns = this.assign(Object.create(null), options.xmlns);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Parses `source` using the options in the way configured by the `DOMParserOptions` of `this`
|
|
193
|
-
* `DOMParser`. If `mimeType` is `text/html` an HTML `Document` is created,
|
|
194
|
-
* otherwise an XML `Document` is created.
|
|
195
|
-
*
|
|
196
|
-
* __It behaves different from the description in the living standard__:
|
|
197
|
-
* - Uses the `options` passed to the `DOMParser` constructor to modify the behavior.
|
|
198
|
-
* - Any unexpected input is reported to `onError` with either a `warning`,
|
|
199
|
-
* `error` or `fatalError` level.
|
|
200
|
-
* - Any `fatalError` throws a `ParseError` which prevents further processing.
|
|
201
|
-
* - Any error thrown by `onError` is converted to a `ParseError` which prevents further
|
|
202
|
-
* processing - If no `Document` was created during parsing it is reported as a `fatalError`.
|
|
203
|
-
* *****Warning: By configuring a faulty DOMHandler implementation,
|
|
204
|
-
* the specified behavior can completely be broken*****.
|
|
205
|
-
*
|
|
206
|
-
* @param {string} source
|
|
207
|
-
* The XML mime type only allows string input!
|
|
208
|
-
* @param {string} [mimeType='application/xml']
|
|
209
|
-
* the mimeType or contentType of the document to be created determines the `type` of document
|
|
210
|
-
* created (XML or HTML)
|
|
211
|
-
* @returns {Document}
|
|
212
|
-
* The `Document` node.
|
|
213
|
-
* @throws {ParseError}
|
|
214
|
-
* for any `fatalError` or anything that is thrown by `onError`
|
|
215
|
-
* @throws {TypeError}
|
|
216
|
-
* for any invalid `mimeType`
|
|
217
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString
|
|
218
|
-
* @see https://html.spec.whatwg.org/#dom-domparser-parsefromstring-dev
|
|
219
|
-
*/
|
|
220
|
-
DOMParser.prototype.parseFromString = function (source, mimeType) {
|
|
221
|
-
if (!isValidMimeType(mimeType)) {
|
|
222
|
-
throw new TypeError('DOMParser.parseFromString: the provided mimeType "' + mimeType + '" is not valid.');
|
|
223
|
-
}
|
|
224
|
-
var defaultNSMap = this.assign(Object.create(null), this.xmlns);
|
|
225
|
-
var entityMap = entities.XML_ENTITIES;
|
|
226
|
-
var defaultNamespace = defaultNSMap[''] || null;
|
|
227
|
-
if (hasDefaultHTMLNamespace(mimeType)) {
|
|
228
|
-
entityMap = entities.HTML_ENTITIES;
|
|
229
|
-
defaultNamespace = NAMESPACE.HTML;
|
|
230
|
-
} else if (mimeType === MIME_TYPE.XML_SVG_IMAGE) {
|
|
231
|
-
defaultNamespace = NAMESPACE.SVG;
|
|
232
|
-
}
|
|
233
|
-
defaultNSMap[''] = defaultNamespace;
|
|
234
|
-
defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;
|
|
235
|
-
|
|
236
|
-
var domBuilder = new this.domHandler({
|
|
237
|
-
mimeType: mimeType,
|
|
238
|
-
defaultNamespace: defaultNamespace,
|
|
239
|
-
onError: this.onError,
|
|
240
|
-
});
|
|
241
|
-
var locator = this.locator ? {} : undefined;
|
|
242
|
-
if (this.locator) {
|
|
243
|
-
domBuilder.setDocumentLocator(locator);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
var sax = new XMLReader();
|
|
247
|
-
sax.errorHandler = domBuilder;
|
|
248
|
-
sax.domBuilder = domBuilder;
|
|
249
|
-
var isXml = !conventions.isHTMLMimeType(mimeType);
|
|
250
|
-
if (isXml && typeof source !== 'string') {
|
|
251
|
-
sax.errorHandler.fatalError('source is not a string');
|
|
252
|
-
}
|
|
253
|
-
sax.parse(this.normalizeLineEndings(String(source)), defaultNSMap, entityMap);
|
|
254
|
-
if (!domBuilder.doc.documentElement) {
|
|
255
|
-
sax.errorHandler.fatalError('missing root element');
|
|
256
|
-
}
|
|
257
|
-
return domBuilder.doc;
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* @typedef DOMHandlerOptions
|
|
262
|
-
* @property {string} [mimeType=MIME_TYPE.XML_APPLICATION]
|
|
263
|
-
* @property {string | null} [defaultNamespace=null]
|
|
264
|
-
*/
|
|
265
|
-
/**
|
|
266
|
-
* The class that is used to handle events from the SAX parser to create the related DOM
|
|
267
|
-
* elements.
|
|
268
|
-
*
|
|
269
|
-
* Some methods are only implemented as an empty function,
|
|
270
|
-
* since they are (at least currently) not relevant for xmldom.
|
|
271
|
-
*
|
|
272
|
-
* @class
|
|
273
|
-
* @param {DOMHandlerOptions} [options]
|
|
274
|
-
* @see http://www.saxproject.org/apidoc/org/xml/sax/ext/DefaultHandler2.html
|
|
275
|
-
*/
|
|
276
|
-
function DOMHandler(options) {
|
|
277
|
-
var opt = options || {};
|
|
278
|
-
/**
|
|
279
|
-
* The mime type is used to determine if the DOM handler will create an XML or HTML document.
|
|
280
|
-
* Only if it is set to `text/html` it will create an HTML document.
|
|
281
|
-
* It defaults to MIME_TYPE.XML_APPLICATION.
|
|
282
|
-
*
|
|
283
|
-
* @type {string}
|
|
284
|
-
* @see {@link MIME_TYPE}
|
|
285
|
-
* @readonly
|
|
286
|
-
*/
|
|
287
|
-
this.mimeType = opt.mimeType || MIME_TYPE.XML_APPLICATION;
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* The namespace to use to create an XML document.
|
|
291
|
-
* For the following reasons this is required:
|
|
292
|
-
* - The SAX API for `startDocument` doesn't offer any way to pass a namespace,
|
|
293
|
-
* since at that point there is no way for the parser to know what the default namespace from
|
|
294
|
-
* the document will be.
|
|
295
|
-
* - When creating using `DOMImplementation.createDocument` it is required to pass a
|
|
296
|
-
* namespace,
|
|
297
|
-
* to determine the correct `Document.contentType`, which should match `this.mimeType`.
|
|
298
|
-
* - When parsing an XML document with the `application/xhtml+xml` mimeType,
|
|
299
|
-
* the HTML namespace needs to be the default namespace.
|
|
300
|
-
*
|
|
301
|
-
* @type {string | null}
|
|
302
|
-
* @private
|
|
303
|
-
* @readonly
|
|
304
|
-
*/
|
|
305
|
-
this.defaultNamespace = opt.defaultNamespace || null;
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* @type {boolean}
|
|
309
|
-
* @private
|
|
310
|
-
*/
|
|
311
|
-
this.cdata = false;
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* The last `Element` that was created by `startElement`.
|
|
315
|
-
* `endElement` sets it to the `currentElement.parentNode`.
|
|
316
|
-
*
|
|
317
|
-
* Note: The sax parser currently sets it to white space text nodes between tags.
|
|
318
|
-
*
|
|
319
|
-
* @type {Element | Node | undefined}
|
|
320
|
-
* @private
|
|
321
|
-
*/
|
|
322
|
-
this.currentElement = undefined;
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* The Document that is created as part of `startDocument`,
|
|
326
|
-
* and returned by `DOMParser.parseFromString`.
|
|
327
|
-
*
|
|
328
|
-
* @type {Document | undefined}
|
|
329
|
-
* @readonly
|
|
330
|
-
*/
|
|
331
|
-
this.doc = undefined;
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* The locator is stored as part of setDocumentLocator.
|
|
335
|
-
* It is controlled and mutated by the SAX parser to store the current parsing position.
|
|
336
|
-
* It is used by DOMHandler to set `columnNumber` and `lineNumber`
|
|
337
|
-
* on the DOM nodes.
|
|
338
|
-
*
|
|
339
|
-
* @type {Readonly<Locator> | undefined}
|
|
340
|
-
* @private
|
|
341
|
-
* @readonly (the
|
|
342
|
-
* sax parser currently sometimes set's it)
|
|
343
|
-
*/
|
|
344
|
-
this.locator = undefined;
|
|
345
|
-
/**
|
|
346
|
-
* @type {function (level:ErrorLevel ,message:string, context:DOMHandler):void}
|
|
347
|
-
* @readonly
|
|
348
|
-
*/
|
|
349
|
-
this.onError = opt.onError;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
function position(locator, node) {
|
|
353
|
-
node.lineNumber = locator.lineNumber;
|
|
354
|
-
node.columnNumber = locator.columnNumber;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
DOMHandler.prototype = {
|
|
358
|
-
/**
|
|
359
|
-
* Either creates an XML or an HTML document and stores it under `this.doc`.
|
|
360
|
-
* If it is an XML document, `this.defaultNamespace` is used to create it,
|
|
361
|
-
* and it will not contain any `childNodes`.
|
|
362
|
-
* If it is an HTML document, it will be created without any `childNodes`.
|
|
363
|
-
*
|
|
364
|
-
* @see http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
|
|
365
|
-
*/
|
|
366
|
-
startDocument: function () {
|
|
367
|
-
var impl = new DOMImplementation();
|
|
368
|
-
this.doc = isHTMLMimeType(this.mimeType) ? impl.createHTMLDocument(false) : impl.createDocument(this.defaultNamespace, '');
|
|
369
|
-
},
|
|
370
|
-
startElement: function (namespaceURI, localName, qName, attrs) {
|
|
371
|
-
var doc = this.doc;
|
|
372
|
-
var el = doc.createElementNS(namespaceURI, qName || localName);
|
|
373
|
-
var len = attrs.length;
|
|
374
|
-
appendElement(this, el);
|
|
375
|
-
this.currentElement = el;
|
|
376
|
-
|
|
377
|
-
this.locator && position(this.locator, el);
|
|
378
|
-
for (var i = 0; i < len; i++) {
|
|
379
|
-
var namespaceURI = attrs.getURI(i);
|
|
380
|
-
var value = attrs.getValue(i);
|
|
381
|
-
var qName = attrs.getQName(i);
|
|
382
|
-
var attr = doc.createAttributeNS(namespaceURI, qName);
|
|
383
|
-
this.locator && position(attrs.getLocator(i), attr);
|
|
384
|
-
attr.value = attr.nodeValue = value;
|
|
385
|
-
el.setAttributeNode(attr);
|
|
386
|
-
}
|
|
387
|
-
},
|
|
388
|
-
endElement: function (namespaceURI, localName, qName) {
|
|
389
|
-
this.currentElement = this.currentElement.parentNode;
|
|
390
|
-
},
|
|
391
|
-
startPrefixMapping: function (prefix, uri) {},
|
|
392
|
-
endPrefixMapping: function (prefix) {},
|
|
393
|
-
processingInstruction: function (target, data) {
|
|
394
|
-
var ins = this.doc.createProcessingInstruction(target, data);
|
|
395
|
-
this.locator && position(this.locator, ins);
|
|
396
|
-
appendElement(this, ins);
|
|
397
|
-
},
|
|
398
|
-
ignorableWhitespace: function (ch, start, length) {},
|
|
399
|
-
characters: function (chars, start, length) {
|
|
400
|
-
chars = _toString.apply(this, arguments);
|
|
401
|
-
//console.log(chars)
|
|
402
|
-
if (chars) {
|
|
403
|
-
if (this.cdata) {
|
|
404
|
-
var charNode = this.doc.createCDATASection(chars);
|
|
405
|
-
} else {
|
|
406
|
-
var charNode = this.doc.createTextNode(chars);
|
|
407
|
-
}
|
|
408
|
-
if (this.currentElement) {
|
|
409
|
-
this.currentElement.appendChild(charNode);
|
|
410
|
-
} else if (/^\s*$/.test(chars)) {
|
|
411
|
-
this.doc.appendChild(charNode);
|
|
412
|
-
//process xml
|
|
413
|
-
}
|
|
414
|
-
this.locator && position(this.locator, charNode);
|
|
415
|
-
}
|
|
416
|
-
},
|
|
417
|
-
skippedEntity: function (name) {},
|
|
418
|
-
endDocument: function () {
|
|
419
|
-
this.doc.normalize();
|
|
420
|
-
},
|
|
421
|
-
/**
|
|
422
|
-
* Stores the locator to be able to set the `columnNumber` and `lineNumber`
|
|
423
|
-
* on the created DOM nodes.
|
|
424
|
-
*
|
|
425
|
-
* @param {Locator} locator
|
|
426
|
-
*/
|
|
427
|
-
setDocumentLocator: function (locator) {
|
|
428
|
-
if (locator) {
|
|
429
|
-
locator.lineNumber = 0;
|
|
430
|
-
}
|
|
431
|
-
this.locator = locator;
|
|
432
|
-
},
|
|
433
|
-
//LexicalHandler
|
|
434
|
-
comment: function (chars, start, length) {
|
|
435
|
-
chars = _toString.apply(this, arguments);
|
|
436
|
-
var comm = this.doc.createComment(chars);
|
|
437
|
-
this.locator && position(this.locator, comm);
|
|
438
|
-
appendElement(this, comm);
|
|
439
|
-
},
|
|
440
|
-
|
|
441
|
-
startCDATA: function () {
|
|
442
|
-
//used in characters() methods
|
|
443
|
-
this.cdata = true;
|
|
444
|
-
},
|
|
445
|
-
endCDATA: function () {
|
|
446
|
-
this.cdata = false;
|
|
447
|
-
},
|
|
448
|
-
|
|
449
|
-
startDTD: function (name, publicId, systemId, internalSubset) {
|
|
450
|
-
var impl = this.doc.implementation;
|
|
451
|
-
if (impl && impl.createDocumentType) {
|
|
452
|
-
var dt = impl.createDocumentType(name, publicId, systemId, internalSubset);
|
|
453
|
-
this.locator && position(this.locator, dt);
|
|
454
|
-
appendElement(this, dt);
|
|
455
|
-
this.doc.doctype = dt;
|
|
456
|
-
}
|
|
457
|
-
},
|
|
458
|
-
reportError: function (level, message) {
|
|
459
|
-
if (typeof this.onError === 'function') {
|
|
460
|
-
try {
|
|
461
|
-
this.onError(level, message, this);
|
|
462
|
-
} catch (e) {
|
|
463
|
-
throw new ParseError('Reporting ' + level + ' "' + message + '" caused ' + e, this.locator);
|
|
464
|
-
}
|
|
465
|
-
} else {
|
|
466
|
-
console.error('[xmldom ' + level + ']\t' + message, _locator(this.locator));
|
|
467
|
-
}
|
|
468
|
-
},
|
|
469
|
-
/**
|
|
470
|
-
* @see http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
|
|
471
|
-
*/
|
|
472
|
-
warning: function (message) {
|
|
473
|
-
this.reportError('warning', message);
|
|
474
|
-
},
|
|
475
|
-
error: function (message) {
|
|
476
|
-
this.reportError('error', message);
|
|
477
|
-
},
|
|
478
|
-
/**
|
|
479
|
-
* This function reports a fatal error and throws a ParseError.
|
|
480
|
-
*
|
|
481
|
-
* @param {string} message
|
|
482
|
-
* - The message to be used for reporting and throwing the error.
|
|
483
|
-
* @returns {never}
|
|
484
|
-
* This function always throws an error and never returns a value.
|
|
485
|
-
* @throws {ParseError}
|
|
486
|
-
* Always throws a ParseError with the provided message.
|
|
487
|
-
*/
|
|
488
|
-
fatalError: function (message) {
|
|
489
|
-
this.reportError('fatalError', message);
|
|
490
|
-
throw new ParseError(message, this.locator);
|
|
491
|
-
},
|
|
492
|
-
};
|
|
493
|
-
|
|
494
|
-
function _locator(l) {
|
|
495
|
-
if (l) {
|
|
496
|
-
return '\n@#[line:' + l.lineNumber + ',col:' + l.columnNumber + ']';
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
function _toString(chars, start, length) {
|
|
501
|
-
if (typeof chars == 'string') {
|
|
502
|
-
return chars.substr(start, length);
|
|
503
|
-
} else {
|
|
504
|
-
//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
|
|
505
|
-
if (chars.length >= start + length || start) {
|
|
506
|
-
return new java.lang.String(chars, start, length) + '';
|
|
507
|
-
}
|
|
508
|
-
return chars;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
/*
|
|
513
|
-
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
|
|
514
|
-
* used method of org.xml.sax.ext.LexicalHandler:
|
|
515
|
-
* #comment(chars, start, length)
|
|
516
|
-
* #startCDATA()
|
|
517
|
-
* #endCDATA()
|
|
518
|
-
* #startDTD(name, publicId, systemId)
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
* IGNORED method of org.xml.sax.ext.LexicalHandler:
|
|
522
|
-
* #endDTD()
|
|
523
|
-
* #startEntity(name)
|
|
524
|
-
* #endEntity(name)
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
|
|
528
|
-
* IGNORED method of org.xml.sax.ext.DeclHandler
|
|
529
|
-
* #attributeDecl(eName, aName, type, mode, value)
|
|
530
|
-
* #elementDecl(name, model)
|
|
531
|
-
* #externalEntityDecl(name, publicId, systemId)
|
|
532
|
-
* #internalEntityDecl(name, value)
|
|
533
|
-
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
|
|
534
|
-
* IGNORED method of org.xml.sax.EntityResolver2
|
|
535
|
-
* #resolveEntity(String name,String publicId,String baseURI,String systemId)
|
|
536
|
-
* #resolveEntity(publicId, systemId)
|
|
537
|
-
* #getExternalSubset(name, baseURI)
|
|
538
|
-
* @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
|
|
539
|
-
* IGNORED method of org.xml.sax.DTDHandler
|
|
540
|
-
* #notationDecl(name, publicId, systemId) {};
|
|
541
|
-
* #unparsedEntityDecl(name, publicId, systemId, notationName) {};
|
|
542
|
-
*/
|
|
543
|
-
'endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl'.replace(
|
|
544
|
-
/\w+/g,
|
|
545
|
-
function (key) {
|
|
546
|
-
DOMHandler.prototype[key] = function () {
|
|
547
|
-
return null;
|
|
548
|
-
};
|
|
549
|
-
}
|
|
550
|
-
);
|
|
551
|
-
|
|
552
|
-
/* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */
|
|
553
|
-
function appendElement(handler, node) {
|
|
554
|
-
if (!handler.currentElement) {
|
|
555
|
-
handler.doc.appendChild(node);
|
|
556
|
-
} else {
|
|
557
|
-
handler.currentElement.appendChild(node);
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
/**
|
|
562
|
-
* A method that prevents any further parsing when an `error`
|
|
563
|
-
* with level `error` is reported during parsing.
|
|
564
|
-
*
|
|
565
|
-
* @see {@link DOMParserOptions.onError}
|
|
566
|
-
* @see {@link onWarningStopParsing}
|
|
567
|
-
*/
|
|
568
|
-
function onErrorStopParsing(level) {
|
|
569
|
-
if (level === 'error') throw 'onErrorStopParsing';
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
/**
|
|
573
|
-
* A method that prevents any further parsing when any `error` is reported during parsing.
|
|
574
|
-
*
|
|
575
|
-
* @see {@link DOMParserOptions.onError}
|
|
576
|
-
* @see {@link onErrorStopParsing}
|
|
577
|
-
*/
|
|
578
|
-
function onWarningStopParsing() {
|
|
579
|
-
throw 'onWarningStopParsing';
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
exports.__DOMHandler = DOMHandler;
|
|
583
|
-
exports.DOMParser = DOMParser;
|
|
584
|
-
exports.normalizeLineEndings = normalizeLineEndings;
|
|
585
|
-
exports.onErrorStopParsing = onErrorStopParsing;
|
|
586
|
-
exports.onWarningStopParsing = onWarningStopParsing;
|