From 5bc8a05ad3fae8ac6af9fc45a821745c7a806b3c Mon Sep 17 00:00:00 2001 From: AlainCouthures Date: Tue, 31 Jan 2023 16:02:47 +0100 Subject: [PATCH] XSLTForms 1.7 --- .jshintrc | 15 +- build/css/postcss.config.js | 7 + build/css/xsltforms.css | 93 +- build/css/xsltforms.min.css | 2 +- build/js/xsltforms.js | 18535 ++++++++-------- build/js/xsltforms.min.js | 1095 +- build/xsl/xsltforms.xsl | 225 +- manager.js | 1002 +- public/direct/{1.6 => 1.7} | 0 public/direct/hello-standalone.htm | 1156 +- public/direct/hello-standalone.xhtml | 1137 + public/direct/hello.htm | 2 +- public/direct/xsltforms.css | 93 +- public/direct/xsltforms.js | 18535 ++++++++-------- public/direct/xsltforms.xsl | 225 +- public/direct/xsltforms.zip | Bin 278928 -> 396146 bytes public/samples/balance-table.xml | 8 +- public/samples/balance.xhtml | 2 +- public/samples/balance.xml | 268 +- public/samples/colors.xhtml | 76 +- public/samples/wikipediasearch.xml | 2 +- public/xquerytests/data/xqtests.json | 2203 ++ src/css/xsltforms.css/console.css | 8 +- src/css/xsltforms.css/dialog.css | 48 +- src/css/xsltforms.css/display.css | 25 +- src/css/xsltforms.css/project.json | 8 +- src/js/fleur.js/DOM/DOMParser.js | 4 +- src/js/fleur.js/DOM/Document.js | 842 +- src/js/fleur.js/DOM/Function.js | 27 +- src/js/fleur.js/DOM/Namespace.js | 110 +- src/js/fleur.js/DOM/Node.js | 18 + src/js/fleur.js/DOM/SequenceType.js | 182 + src/js/fleur.js/DOM/Serializer.js | 18 +- src/js/fleur.js/DOM/TypeInfo.js | 37 +- src/js/fleur.js/DOM/Types.js | 76 +- src/js/fleur.js/DOM/project.json | 79 +- src/js/fleur.js/XPath/Collations.js | 120 +- src/js/fleur.js/XPath/Context.js | 112 +- src/js/fleur.js/XPath/Transpiler.js | 84 +- src/js/fleur.js/XPath/XPathEvaluator.js | 6 +- .../XPath/XPathFunctions/file/write.js | 125 +- .../fleur.js/XPath/XPathFunctions/fn/QName.js | 36 +- .../fleur.js/XPath/XPathFunctions/fn/abs.js | 63 +- .../fn/adjust-date-to-timezone.js | 36 +- .../fn/adjust-dateTime-to-timezone.js | 50 +- .../fn/adjust-time-to-timezone.js | 40 +- .../fleur.js/XPath/XPathFunctions/fn/avg.js | 28 +- .../XPath/XPathFunctions/fn/base-uri.js | 31 +- .../XPath/XPathFunctions/fn/boolean.js | 21 +- .../XPath/XPathFunctions/fn/ceiling.js | 31 +- .../XPathFunctions/fn/codepoint-equal.js | 44 +- .../XPathFunctions/fn/codepoints-to-string.js | 40 +- .../XPath/XPathFunctions/fn/compare.js | 66 +- .../XPath/XPathFunctions/fn/concat.js | 32 +- .../XPath/XPathFunctions/fn/contains-token.js | 82 +- .../XPath/XPathFunctions/fn/contains.js | 69 +- .../fleur.js/XPath/XPathFunctions/fn/count.js | 23 +- .../XPath/XPathFunctions/fn/current-date.js | 26 +- .../XPathFunctions/fn/current-dateTime.js | 25 +- .../XPath/XPathFunctions/fn/current-time.js | 25 +- .../XPath/XPathFunctions/fn/current.js | 18 +- .../fleur.js/XPath/XPathFunctions/fn/data.js | 33 +- .../XPath/XPathFunctions/fn/dateTime.js | 50 +- .../XPath/XPathFunctions/fn/day-from-date.js | 32 +- .../XPathFunctions/fn/day-from-dateTime.js | 32 +- .../XPathFunctions/fn/days-from-duration.js | 40 +- .../XPath/XPathFunctions/fn/deep-equal.js | 97 +- .../XPathFunctions/fn/default-collation.js | 27 +- .../XPathFunctions/fn/default-language.js | 18 + .../XPathFunctions/fn/distinct-values.js | 58 +- .../fleur.js/XPath/XPathFunctions/fn/doc.js | 87 +- .../XPath/XPathFunctions/fn/document-uri.js | 40 +- .../fleur.js/XPath/XPathFunctions/fn/empty.js | 19 +- .../XPath/XPathFunctions/fn/encode-for-uri.js | 34 +- .../XPath/XPathFunctions/fn/ends-with.js | 68 +- .../fleur.js/XPath/XPathFunctions/fn/error.js | 90 +- .../XPathFunctions/fn/escape-html-uri.js | 34 +- .../XPath/XPathFunctions/fn/evaluate.js | 29 +- .../XPath/XPathFunctions/fn/exactly-one.js | 22 +- .../XPath/XPathFunctions/fn/exists.js | 25 +- .../fleur.js/XPath/XPathFunctions/fn/false.js | 20 +- .../fleur.js/XPath/XPathFunctions/fn/floor.js | 31 +- .../XPath/XPathFunctions/fn/format-date.js | 41 +- .../XPathFunctions/fn/format-dateTime.js | 199 +- .../XPath/XPathFunctions/fn/format-integer.js | 252 +- .../XPath/XPathFunctions/fn/format-number.js | 248 +- .../XPath/XPathFunctions/fn/format-time.js | 43 +- .../XPath/XPathFunctions/fn/function-arity.js | 29 +- .../XPathFunctions/fn/function-lookup.js | 21 +- .../XPath/XPathFunctions/fn/function-name.js | 17 +- .../XPath/XPathFunctions/fn/has-children.js | 45 +- .../fleur.js/XPath/XPathFunctions/fn/head.js | 21 +- .../XPathFunctions/fn/hours-from-dateTime.js | 34 +- .../XPathFunctions/fn/hours-from-duration.js | 40 +- .../XPathFunctions/fn/hours-from-time.js | 34 +- src/js/fleur.js/XPath/XPathFunctions/fn/id.js | 55 +- .../XPathFunctions/fn/implicit-timezone.js | 25 +- .../XPath/XPathFunctions/fn/index-of.js | 99 +- .../XPath/XPathFunctions/fn/insert-before.js | 23 +- .../XPath/XPathFunctions/fn/iri-to-uri.js | 35 +- .../fleur.js/XPath/XPathFunctions/fn/last.js | 20 +- .../XPath/XPathFunctions/fn/local-name.js | 49 +- .../XPath/XPathFunctions/fn/lower-case.js | 35 +- .../XPath/XPathFunctions/fn/matches.js | 58 +- .../fleur.js/XPath/XPathFunctions/fn/max.js | 50 +- .../fleur.js/XPath/XPathFunctions/fn/min.js | 50 +- .../fn/minutes-from-dateTime.js | 32 +- .../fn/minutes-from-duration.js | 40 +- .../XPathFunctions/fn/minutes-from-time.js | 32 +- .../XPathFunctions/fn/month-from-date.js | 32 +- .../XPathFunctions/fn/month-from-dateTime.js | 32 +- .../XPathFunctions/fn/months-from-duration.js | 40 +- .../fleur.js/XPath/XPathFunctions/fn/name.js | 48 +- .../XPath/XPathFunctions/fn/namespace-uri.js | 49 +- .../XPath/XPathFunctions/fn/nilled.js | 42 +- .../XPath/XPathFunctions/fn/node-name.js | 52 +- .../XPathFunctions/fn/normalize-empty.js | 47 +- .../XPathFunctions/fn/normalize-space.js | 52 +- .../XPathFunctions/fn/normalize-unicode.js | 80 +- .../fleur.js/XPath/XPathFunctions/fn/not.js | 22 +- .../XPath/XPathFunctions/fn/number.js | 46 +- .../XPath/XPathFunctions/fn/one-or-more.js | 21 +- .../XPathFunctions/fn/parse-ietf-date.js | 37 +- .../XPath/XPathFunctions/fn/parse-md.js | 28 +- .../XPathFunctions/fn/parse-xml-fragment.js | 24 + .../XPath/XPathFunctions/fn/parse-xml.js | 28 +- .../fleur.js/XPath/XPathFunctions/fn/parse.js | 38 +- .../XPath/XPathFunctions/fn/position.js | 22 +- .../XPath/XPathFunctions/fn/project.json | 2 + .../XPath/XPathFunctions/fn/remove.js | 21 +- .../XPath/XPathFunctions/fn/replace.js | 88 +- .../XPath/XPathFunctions/fn/reverse.js | 17 +- .../XPathFunctions/fn/round-half-to-even.js | 82 +- .../fleur.js/XPath/XPathFunctions/fn/round.js | 75 +- .../fn/seconds-from-dateTime.js | 32 +- .../fn/seconds-from-duration.js | 40 +- .../XPathFunctions/fn/seconds-from-time.js | 32 +- .../XPath/XPathFunctions/fn/serialize.js | 68 +- .../fleur.js/XPath/XPathFunctions/fn/sort.js | 90 +- .../XPath/XPathFunctions/fn/starts-with.js | 50 +- .../XPath/XPathFunctions/fn/string-join.js | 69 +- .../XPath/XPathFunctions/fn/string-length.js | 41 +- .../XPathFunctions/fn/string-to-codepoints.js | 41 +- .../XPath/XPathFunctions/fn/string.js | 41 +- .../XPath/XPathFunctions/fn/subsequence.js | 80 +- .../XPathFunctions/fn/substring-after.js | 95 +- .../XPathFunctions/fn/substring-before.js | 92 +- .../XPath/XPathFunctions/fn/substring.js | 83 +- .../fleur.js/XPath/XPathFunctions/fn/sum.js | 62 +- .../fleur.js/XPath/XPathFunctions/fn/tail.js | 18 +- .../XPathFunctions/fn/timezone-from-date.js | 26 +- .../fn/timezone-from-dateTime.js | 42 +- .../XPathFunctions/fn/timezone-from-time.js | 26 +- .../XPath/XPathFunctions/fn/tokenize.js | 87 +- .../fleur.js/XPath/XPathFunctions/fn/trace.js | 86 +- .../XPath/XPathFunctions/fn/translate.js | 51 +- .../fleur.js/XPath/XPathFunctions/fn/true.js | 19 +- .../XPath/XPathFunctions/fn/type-QName.js | 32 +- .../XPath/XPathFunctions/fn/unordered.js | 18 +- .../XPath/XPathFunctions/fn/unparsed-text.js | 50 +- .../XPath/XPathFunctions/fn/upper-case.js | 34 +- .../XPath/XPathFunctions/fn/xsi-type.js | 36 +- .../XPath/XPathFunctions/fn/year-from-date.js | 32 +- .../XPathFunctions/fn/year-from-dateTime.js | 32 +- .../XPathFunctions/fn/years-from-duration.js | 40 +- .../XPath/XPathFunctions/fn/zero-or-one.js | 23 +- src/js/fleur.js/XPath/XPathFunctions/main.js | 4 + .../XPath/XPathFunctions/math/acos.js | 35 +- .../XPath/XPathFunctions/math/asin.js | 35 +- .../XPath/XPathFunctions/math/atan.js | 35 +- .../XPath/XPathFunctions/math/atan2.js | 38 +- .../fleur.js/XPath/XPathFunctions/math/cos.js | 35 +- .../fleur.js/XPath/XPathFunctions/math/exp.js | 35 +- .../XPath/XPathFunctions/math/exp10.js | 35 +- .../fleur.js/XPath/XPathFunctions/math/log.js | 35 +- .../XPath/XPathFunctions/math/log10.js | 35 +- .../fleur.js/XPath/XPathFunctions/math/pi.js | 27 +- .../fleur.js/XPath/XPathFunctions/math/pow.js | 44 +- .../fleur.js/XPath/XPathFunctions/math/sin.js | 35 +- .../XPath/XPathFunctions/math/sqrt.js | 35 +- .../fleur.js/XPath/XPathFunctions/math/tan.js | 35 +- .../XPath/XPathFunctions/xf/choose.js | 28 +- .../XPath/XPathFunctions/xf/context.js | 13 +- .../fleur.js/XPath/XPathFunctions/xf/event.js | 23 +- src/js/fleur.js/XPath/XPathFunctions/xf/if.js | 22 +- .../XPath/XPathFunctions/xf/instance-ids.js | 17 +- .../XPath/XPathFunctions/xf/instance.js | 27 +- .../XPath/XPathFunctions/xf/js-eval.js | 28 +- .../fleur.js/XPath/XPathFunctions/xf/now.js | 17 +- .../XPath/XPathFunctions/xs/ENTITIES.js | 25 +- .../XPath/XPathFunctions/xs/ENTITY.js | 27 +- src/js/fleur.js/XPath/XPathFunctions/xs/ID.js | 25 +- .../fleur.js/XPath/XPathFunctions/xs/IDREF.js | 25 +- .../XPath/XPathFunctions/xs/IDREFS.js | 25 +- .../XPath/XPathFunctions/xs/NCName.js | 25 +- .../XPath/XPathFunctions/xs/NMTOKEN.js | 25 +- .../XPath/XPathFunctions/xs/NMTOKENS.js | 25 +- .../fleur.js/XPath/XPathFunctions/xs/Name.js | 25 +- .../fleur.js/XPath/XPathFunctions/xs/QName.js | 39 +- .../XPath/XPathFunctions/xs/anyURI.js | 35 +- .../XPath/XPathFunctions/xs/base64Binary.js | 25 +- .../XPath/XPathFunctions/xs/boolean.js | 23 +- .../fleur.js/XPath/XPathFunctions/xs/byte.js | 25 +- .../XPath/XPathFunctions/xs/codepoint.js | 14 + .../XPath/XPathFunctions/xs/collation.js | 14 + .../fleur.js/XPath/XPathFunctions/xs/date.js | 25 +- .../XPath/XPathFunctions/xs/dateTime.js | 25 +- .../XPath/XPathFunctions/xs/dateTimeStamp.js | 23 +- .../XPathFunctions/xs/dayTimeDuration.js | 25 +- .../XPath/XPathFunctions/xs/decimal.js | 25 +- .../XPath/XPathFunctions/xs/double.js | 25 +- .../XPath/XPathFunctions/xs/duration.js | 25 +- .../fleur.js/XPath/XPathFunctions/xs/float.js | 25 +- .../fleur.js/XPath/XPathFunctions/xs/gDay.js | 25 +- .../XPath/XPathFunctions/xs/gMonth.js | 25 +- .../XPath/XPathFunctions/xs/gMonthDay.js | 25 +- .../fleur.js/XPath/XPathFunctions/xs/gYear.js | 25 +- .../XPath/XPathFunctions/xs/gYearMonth.js | 25 +- .../XPath/XPathFunctions/xs/hexBinary.js | 25 +- .../fleur.js/XPath/XPathFunctions/xs/int.js | 25 +- .../XPath/XPathFunctions/xs/integer.js | 25 +- .../XPath/XPathFunctions/xs/language.js | 25 +- .../fleur.js/XPath/XPathFunctions/xs/long.js | 25 +- .../XPathFunctions/xs/negativeInteger.js | 25 +- .../XPathFunctions/xs/nonNegativeInteger.js | 25 +- .../XPathFunctions/xs/nonPositiveInteger.js | 25 +- .../XPathFunctions/xs/normalizedString.js | 25 +- .../XPath/XPathFunctions/xs/numeric.js | 21 +- .../XPathFunctions/xs/positiveInteger.js | 25 +- .../XPath/XPathFunctions/xs/project.json | 100 +- .../fleur.js/XPath/XPathFunctions/xs/short.js | 25 +- .../XPath/XPathFunctions/xs/string.js | 25 +- .../fleur.js/XPath/XPathFunctions/xs/time.js | 25 +- .../fleur.js/XPath/XPathFunctions/xs/token.js | 25 +- .../XPath/XPathFunctions/xs/unsignedByte.js | 25 +- .../XPath/XPathFunctions/xs/unsignedInt.js | 25 +- .../XPath/XPathFunctions/xs/unsignedLong.js | 25 +- .../XPath/XPathFunctions/xs/unsignedShort.js | 25 +- .../XPath/XPathFunctions/xs/untypedAtomic.js | 25 +- .../XPathFunctions/xs/yearMonthDuration.js | 25 +- src/js/fleur.js/XPath/XPathNSResolver.js | 138 +- src/js/fleur.js/XPath/project.json | 30 +- src/js/fleur.js/XPath/varMgr.js | 6 +- .../fleur.js/XQuery/Instructions/Wildcard.js | 2 +- .../{anyKindTest.js => anyKindTest-BROKEN.js} | 389 +- ...structor.js => arrayConstructor-BROKEN.js} | 64 +- .../{arrayTest.js => arrayTest-BROKEN.js} | 28 +- .../{atomicType.js => atomicType-BROKEN.js} | 44 +- .../Instructions/attributeConstructor.js | 10 +- ...tributeList.js => attributeList-BROKEN.js} | 52 +- ...tributeTest.js => attributeTest-BROKEN.js} | 24 +- ...ueExpr.js => attributeValueExpr-BROKEN.js} | 54 +- .../{castExpr.js => castExpr-BROKEN.js} | 76 +- ...castableExpr.js => castableExpr-BROKEN.js} | 68 +- .../{commentTest.js => commentTest-BROKEN.js} | 28 +- .../computedAttributeConstructor.js | 14 +- .../computedCommentConstructor.js | 12 +- .../computedDocumentConstructor.js | 10 +- .../computedElementConstructor.js | 5 +- .../Instructions/computedEntryConstructor.js | 64 +- .../Instructions/computedPIConstructor.js | 12 +- .../Instructions/computedTextConstructor.js | 7 +- .../XQuery/Instructions/constantExpr.js | 15 + .../XQuery/Instructions/contextItemExpr.js | 9 +- .../{countClause.js => countClause-BROKEN.js} | 38 +- .../Instructions/decimalConstantExpr.js | 34 +- ....js => defaultNamespaceCategory-BROKEN.js} | 20 +- ...Decl.js => defaultNamespaceDecl-BROKEN.js} | 24 +- .../{deleteExpr.js => deleteExpr-BROKEN.js} | 66 +- ...documentTest.js => documentTest-BROKEN.js} | 22 +- .../XQuery/Instructions/doubleConstantExpr.js | 34 +- ...ubleMapExpr.js => doubleMapExpr-BROKEN.js} | 234 +- ...> dynamicFunctionInvocationExpr-BROKEN.js} | 600 +- .../XQuery/Instructions/elementConstructor.js | 14 +- ...entContent.js => elementContent-BROKEN.js} | 54 +- .../{elementTest.js => elementTest-BROKEN.js} | 22 +- .../fleur.js/XQuery/Instructions/encoding.js | 14 +- .../fleur.js/XQuery/Instructions/entryTest.js | 3 +- .../XQuery/Instructions/filterExpr.js | 3 +- .../fleur.js/XQuery/Instructions/flworExpr.js | 14 +- .../fleur.js/XQuery/Instructions/forClause.js | 2 +- .../XQuery/Instructions/forClauseItem.js | 32 +- .../XQuery/Instructions/functionCallExpr.js | 64 +- .../XQuery/Instructions/functionDecl.js | 124 +- ...oupByClause.js => groupByClause-BROKEN.js} | 146 +- ...groupingSpec.js => groupingSpec-BROKEN.js} | 76 +- .../XQuery/Instructions/ifThenElseExpr.js | 21 +- ...onExpr.js => inlineFunctionExpr-BROKEN.js} | 94 +- .../{insertExpr.js => insertExpr-BROKEN.js} | 128 +- .../XQuery/Instructions/instanceOfExpr.js | 22 +- .../Instructions/integerConstantExpr.js | 36 +- ...ptImport.js => javascriptImport-BROKEN.js} | 110 +- .../fleur.js/XQuery/Instructions/letClause.js | 7 +- .../XQuery/Instructions/letClauseItem.js | 17 +- src/js/fleur.js/XQuery/Instructions/lookup.js | 91 +- .../XQuery/Instructions/mainModule.js | 21 +- .../XQuery/Instructions/mapConstructor.js | 33 +- .../Instructions/mapConstructorEntry.js | 31 +- .../fleur.js/XQuery/Instructions/mapTest.js | 3 +- src/js/fleur.js/XQuery/Instructions/module.js | 24 +- ...moduleImport.js => moduleImport-BROKEN.js} | 36 +- ...multidimExpr.js => multidimExpr-BROKEN.js} | 80 +- .../fleur.js/XQuery/Instructions/nameTest.js | 3 +- ...ctionRef.js => namedFunctionRef-BROKEN.js} | 62 +- ...mespaceDecl.js => namespaceDecl-BROKEN.js} | 24 +- .../Instructions/namespaceDeclaration.js | 2 +- .../{optionDecl.js => optionDecl-BROKEN.js} | 38 +- ...derByClause.js => orderByClause-BROKEN.js} | 114 +- .../{orderBySpec.js => orderBySpec-BROKEN.js} | 52 +- src/js/fleur.js/XQuery/Instructions/param.js | 12 + .../fleur.js/XQuery/Instructions/paramList.js | 16 + .../fleur.js/XQuery/Instructions/pathExpr.js | 12 +- src/js/fleur.js/XQuery/Instructions/piTest.js | 2 +- .../{predicate.js => predicate-BROKEN.js} | 212 +- .../XQuery/Instructions/predicateExpr.js | 2 +- .../{predicates.js => predicates-BROKEN.js} | 434 +- .../fleur.js/XQuery/Instructions/project.json | 4 + src/js/fleur.js/XQuery/Instructions/prolog.js | 21 +- ...tifiedExpr.js => quantifiedExpr-BROKEN.js} | 76 +- ...se.js => quantifiedExprInClause-BROKEN.js} | 86 +- .../fleur.js/XQuery/Instructions/queryBody.js | 11 +- .../XQuery/Instructions/rangeSequenceExpr.js | 9 +- .../{replaceExpr.js => replaceExpr-BROKEN.js} | 142 +- .../XQuery/Instructions/returnClause.js | 15 +- .../fleur.js/XQuery/Instructions/rootExpr.js | 3 +- ...maLocation.js => schemaLocation-BROKEN.js} | 22 +- .../XQuery/Instructions/sequenceExpr.js | 26 +- .../XQuery/Instructions/simpleMapExpr.js | 7 +- .../fleur.js/XQuery/Instructions/stepExpr.js | 3 +- .../XQuery/Instructions/stringConstantExpr.js | 35 +- .../fleur.js/XQuery/Instructions/textTest.js | 3 +- .../{treatExpr.js => treatExpr-BROKEN.js} | 112 +- ...tryCatchExpr.js => tryCatchExpr-BROKEN.js} | 116 +- .../{unaryLookup.js => unaryLookup-BROKEN.js} | 22 +- .../Instructions/{uri.js => uri-BROKEN.js} | 20 +- .../fleur.js/XQuery/Instructions/varDecl.js | 31 +- src/js/fleur.js/XQuery/Instructions/varRef.js | 23 +- .../fleur.js/XQuery/Instructions/version.js | 14 +- .../XQuery/Instructions/versionDecl.js | 16 +- .../{whereClause.js => whereClause-BROKEN.js} | 54 +- .../fleur.js/XQuery/Instructions/xpathAxis.js | 2 +- .../Instructions/{xqx.js => xqx-BROKEN.js} | 22 +- .../{xqxuf.js => xqxuf-BROKEN.js} | 22 +- .../Instructions/{xsi.js => xsi-BROKEN.js} | 22 +- src/js/fleur.js/XQuery/Operators/addOp.js | 80 +- src/js/fleur.js/XQuery/Operators/andOp.js | 43 +- src/js/fleur.js/XQuery/Operators/divOp.js | 92 +- src/js/fleur.js/XQuery/Operators/eqOp.js | 27 +- src/js/fleur.js/XQuery/Operators/equalOp.js | 28 +- src/js/fleur.js/XQuery/Operators/geOp.js | 29 +- .../fleur.js/XQuery/Operators/generalComp.js | 109 +- .../XQuery/Operators/greaterThanOp.js | 28 +- .../XQuery/Operators/greaterThanOrEqualOp.js | 28 +- src/js/fleur.js/XQuery/Operators/gtOp.js | 27 +- src/js/fleur.js/XQuery/Operators/idivOp.js | 36 +- src/js/fleur.js/XQuery/Operators/leOp.js | 27 +- .../fleur.js/XQuery/Operators/lessThanOp.js | 28 +- .../XQuery/Operators/lessThanOrEqualOp.js | 28 +- src/js/fleur.js/XQuery/Operators/ltOp.js | 27 +- src/js/fleur.js/XQuery/Operators/modOp.js | 43 +- .../fleur.js/XQuery/Operators/multiplyOp.js | 122 +- src/js/fleur.js/XQuery/Operators/neOp.js | 27 +- .../fleur.js/XQuery/Operators/notEqualOp.js | 28 +- src/js/fleur.js/XQuery/Operators/orOp.js | 43 +- .../XQuery/Operators/stringConcatenateOp.js | 46 +- .../fleur.js/XQuery/Operators/subtractOp.js | 87 +- .../fleur.js/XQuery/Operators/unaryMinusOp.js | 30 +- .../fleur.js/XQuery/Operators/unaryPlusOp.js | 4 +- src/js/fleur.js/XQuery/Operators/valueComp.js | 3 +- src/js/fleur.js/XQuery/XQueryError.js | 2 +- src/js/fleur.js/XQuery/XQueryParser.js | 316 +- src/js/fleur.js/XQuery/locale.js | 188 +- src/js/fleur.js/XQuery/toJS.js | 35 +- src/js/fleur.js/project.json | 2 +- src/js/fleur.js/scriptrun.js | 44 +- src/js/xsltforms.js/actions/abstractAction.js | 120 +- src/js/xsltforms.js/actions/action.js | 103 +- src/js/xsltforms.js/actions/confirm.js | 72 +- src/js/xsltforms.js/actions/delete.js | 139 +- src/js/xsltforms.js/actions/dispatch.js | 234 +- src/js/xsltforms.js/actions/insert.js | 179 +- src/js/xsltforms.js/actions/load.js | 333 +- src/js/xsltforms.js/actions/message.js | 56 +- src/js/xsltforms.js/actions/project.json | 42 +- src/js/xsltforms.js/actions/script.js | 76 +- src/js/xsltforms.js/actions/setindex.js | 74 +- src/js/xsltforms.js/actions/setnode.js | 76 +- src/js/xsltforms.js/actions/setproperty.js | 60 +- src/js/xsltforms.js/actions/setselection.js | 73 +- src/js/xsltforms.js/actions/setvalue.js | 59 +- src/js/xsltforms.js/actions/split.js | 65 +- src/js/xsltforms.js/actions/toggle.js | 102 +- src/js/xsltforms.js/actions/unload.js | 156 +- src/js/xsltforms.js/actions/wrap.js | 93 +- src/js/xsltforms.js/controls/AVT.js | 118 +- src/js/xsltforms.js/controls/Calendar.js | 432 +- src/js/xsltforms.js/controls/case.js | 10 +- src/js/xsltforms.js/controls/component.js | 238 +- src/js/xsltforms.js/controls/control.js | 436 +- src/js/xsltforms.js/controls/dialog.js | 32 +- src/js/xsltforms.js/controls/element.js | 285 +- src/js/xsltforms.js/controls/group.js | 152 +- src/js/xsltforms.js/controls/include.js | 96 +- src/js/xsltforms.js/controls/input.js | 947 +- src/js/xsltforms.js/controls/item.js | 266 +- src/js/xsltforms.js/controls/itemset.js | 436 +- src/js/xsltforms.js/controls/label.js | 46 +- src/js/xsltforms.js/controls/output.js | 324 +- src/js/xsltforms.js/controls/project.json | 50 +- src/js/xsltforms.js/controls/range.js | 366 +- src/js/xsltforms.js/controls/repeat.js | 704 +- src/js/xsltforms.js/controls/select.js | 850 +- src/js/xsltforms.js/controls/tree.js | 188 +- src/js/xsltforms.js/controls/trigger.js | 252 +- src/js/xsltforms.js/controls/upload.js | 7 +- src/js/xsltforms.js/controls/var.js | 79 +- src/js/xsltforms.js/coreelts/CoreElement.js | 60 +- src/js/xsltforms.js/coreelts/bind.js | 244 +- src/js/xsltforms.js/coreelts/form.js | 61 + src/js/xsltforms.js/coreelts/instance.js | 1911 +- src/js/xsltforms.js/coreelts/itext.js | 14 +- src/js/xsltforms.js/coreelts/model.js | 477 +- src/js/xsltforms.js/coreelts/options.js | 28 +- src/js/xsltforms.js/coreelts/project.json | 27 +- src/js/xsltforms.js/coreelts/submission.js | 20 +- src/js/xsltforms.js/coreelts/text.js | 10 +- src/js/xsltforms.js/coreelts/timer.js | 58 +- src/js/xsltforms.js/coreelts/translation.js | 10 +- src/js/xsltforms.js/main/Binding.js | 202 +- src/js/xsltforms.js/main/IdManager.js | 112 +- src/js/xsltforms.js/main/MIPBinding.js | 210 +- src/js/xsltforms.js/main/browser.js | 63 +- src/js/xsltforms.js/main/class.js | 257 +- src/js/xsltforms.js/main/constants.js | 47 +- src/js/xsltforms.js/main/debugger.js | 10 +- src/js/xsltforms.js/main/fleur.js | 4124 ++-- src/js/xsltforms.js/main/globals.js | 32 +- src/js/xsltforms.js/main/in_script.js | 49 +- src/js/xsltforms.js/main/project.json | 26 +- src/js/xsltforms.js/main/subform.js | 200 +- src/js/xsltforms.js/project.json | 8 +- src/js/xsltforms.js/types/AtomicType.js | 300 +- src/js/xsltforms.js/types/ListType.js | 102 +- src/js/xsltforms.js/types/Schema.js | 344 +- src/js/xsltforms.js/types/Type.js | 109 +- src/js/xsltforms.js/types/TypeDefs.js | 1574 +- src/js/xsltforms.js/types/UnionType.js | 80 +- src/js/xsltforms.js/types/project.json | 20 +- src/js/xsltforms.js/xmlevtmngt/Listener.js | 286 +- src/js/xsltforms.js/xmlevtmngt/XMLEvents.js | 522 +- src/js/xsltforms.js/xmlevtmngt/project.json | 10 +- src/js/xsltforms.js/xpathexpr/ArrayExpr.js | 29 +- src/js/xsltforms.js/xpathexpr/BinaryExpr.js | 204 +- src/js/xsltforms.js/xpathexpr/ExprContext.js | 108 +- src/js/xsltforms.js/xpathexpr/Exprs.js | 70 +- src/js/xsltforms.js/xpathexpr/FilterExpr.js | 62 +- src/js/xsltforms.js/xpathexpr/FleurConv.js | 284 +- .../xpathexpr/FunctionCallExpr.js | 66 +- src/js/xsltforms.js/xpathexpr/LocationExpr.js | 92 +- src/js/xsltforms.js/xpathexpr/NSResolver.js | 105 +- src/js/xsltforms.js/xpathexpr/NodeTestAny.js | 21 +- src/js/xsltforms.js/xpathexpr/NodeTestName.js | 65 +- src/js/xsltforms.js/xpathexpr/NodeTestPI.js | 24 +- src/js/xsltforms.js/xpathexpr/NodeTestType.js | 21 +- src/js/xsltforms.js/xpathexpr/PathExpr.js | 56 +- .../xsltforms.js/xpathexpr/PredicateExpr.js | 24 +- src/js/xsltforms.js/xpathexpr/StepExpr.js | 292 +- src/js/xsltforms.js/xpathexpr/UnionExpr.js | 70 +- src/js/xsltforms.js/xpathexpr/VarRef.js | 70 +- src/js/xsltforms.js/xpathexpr/XPath.js | 8 +- src/js/xsltforms.js/xpathexpr/XPath.min.js | 12 - .../xpathexpr/XPathCoreFunctions.js | 2 - .../xsltforms.js/xpathexpr/XPathFunction.js | 98 +- .../xsltforms.js/xpathexpr/XPathNSResolver.js | 228 +- src/js/xsltforms.js/xpathexpr/project.json | 48 +- src/js/xsltforms.js/xpathexpr/utils.js | 198 +- src/xsl/xsltforms.xsl/elements/document.xml | 2 +- src/xsl/xsltforms.xsl/elements/html.xml | 265 +- src/xsl/xsltforms.xsl/elements/ignored.xml | 7 +- src/xsl/xsltforms.xsl/elements/project.json | 72 +- src/xsl/xsltforms.xsl/project.json | 10 +- tmp/fleur.js | 14107 ++++-------- 482 files changed, 49420 insertions(+), 48990 deletions(-) create mode 100644 build/css/postcss.config.js rename public/direct/{1.6 => 1.7} (100%) create mode 100644 public/direct/hello-standalone.xhtml create mode 100644 public/xquerytests/data/xqtests.json create mode 100644 src/js/fleur.js/DOM/SequenceType.js create mode 100644 src/js/fleur.js/XPath/XPathFunctions/fn/default-language.js create mode 100644 src/js/fleur.js/XPath/XPathFunctions/fn/parse-xml-fragment.js create mode 100644 src/js/fleur.js/XPath/XPathFunctions/xs/codepoint.js create mode 100644 src/js/fleur.js/XPath/XPathFunctions/xs/collation.js rename src/js/fleur.js/XQuery/Instructions/{anyKindTest.js => anyKindTest-BROKEN.js} (96%) rename src/js/fleur.js/XQuery/Instructions/{arrayConstructor.js => arrayConstructor-BROKEN.js} (96%) rename src/js/fleur.js/XQuery/Instructions/{arrayTest.js => arrayTest-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{atomicType.js => atomicType-BROKEN.js} (92%) rename src/js/fleur.js/XQuery/Instructions/{attributeList.js => attributeList-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{attributeTest.js => attributeTest-BROKEN.js} (98%) rename src/js/fleur.js/XQuery/Instructions/{attributeValueExpr.js => attributeValueExpr-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{castExpr.js => castExpr-BROKEN.js} (96%) rename src/js/fleur.js/XQuery/Instructions/{castableExpr.js => castableExpr-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{commentTest.js => commentTest-BROKEN.js} (97%) create mode 100644 src/js/fleur.js/XQuery/Instructions/constantExpr.js rename src/js/fleur.js/XQuery/Instructions/{countClause.js => countClause-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{defaultNamespaceCategory.js => defaultNamespaceCategory-BROKEN.js} (96%) rename src/js/fleur.js/XQuery/Instructions/{defaultNamespaceDecl.js => defaultNamespaceDecl-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{deleteExpr.js => deleteExpr-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{documentTest.js => documentTest-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{doubleMapExpr.js => doubleMapExpr-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{dynamicFunctionInvocationExpr.js => dynamicFunctionInvocationExpr-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{elementContent.js => elementContent-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{elementTest.js => elementTest-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{groupByClause.js => groupByClause-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{groupingSpec.js => groupingSpec-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{inlineFunctionExpr.js => inlineFunctionExpr-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{insertExpr.js => insertExpr-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{javascriptImport.js => javascriptImport-BROKEN.js} (96%) rename src/js/fleur.js/XQuery/Instructions/{moduleImport.js => moduleImport-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{multidimExpr.js => multidimExpr-BROKEN.js} (96%) rename src/js/fleur.js/XQuery/Instructions/{namedFunctionRef.js => namedFunctionRef-BROKEN.js} (98%) rename src/js/fleur.js/XQuery/Instructions/{namespaceDecl.js => namespaceDecl-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{optionDecl.js => optionDecl-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{orderByClause.js => orderByClause-BROKEN.js} (96%) rename src/js/fleur.js/XQuery/Instructions/{orderBySpec.js => orderBySpec-BROKEN.js} (97%) create mode 100644 src/js/fleur.js/XQuery/Instructions/param.js create mode 100644 src/js/fleur.js/XQuery/Instructions/paramList.js rename src/js/fleur.js/XQuery/Instructions/{predicate.js => predicate-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{predicates.js => predicates-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{quantifiedExpr.js => quantifiedExpr-BROKEN.js} (96%) rename src/js/fleur.js/XQuery/Instructions/{quantifiedExprInClause.js => quantifiedExprInClause-BROKEN.js} (96%) rename src/js/fleur.js/XQuery/Instructions/{replaceExpr.js => replaceExpr-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{schemaLocation.js => schemaLocation-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{treatExpr.js => treatExpr-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{tryCatchExpr.js => tryCatchExpr-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{unaryLookup.js => unaryLookup-BROKEN.js} (97%) rename src/js/fleur.js/XQuery/Instructions/{uri.js => uri-BROKEN.js} (96%) rename src/js/fleur.js/XQuery/Instructions/{whereClause.js => whereClause-BROKEN.js} (96%) rename src/js/fleur.js/XQuery/Instructions/{xqx.js => xqx-BROKEN.js} (96%) rename src/js/fleur.js/XQuery/Instructions/{xqxuf.js => xqxuf-BROKEN.js} (96%) rename src/js/fleur.js/XQuery/Instructions/{xsi.js => xsi-BROKEN.js} (96%) create mode 100644 src/js/xsltforms.js/coreelts/form.js delete mode 100644 src/js/xsltforms.js/xpathexpr/XPath.min.js diff --git a/.jshintrc b/.jshintrc index 62038b5..872ee53 100644 --- a/.jshintrc +++ b/.jshintrc @@ -42,7 +42,7 @@ "boss" : false, // true: Tolerate assignments where comparisons would be expected "debug" : false, // true: Allow debugger statements e.g. browser breakpoints. "eqnull" : false, // true: Tolerate use of `== null` - "esversion" : 10, // {int} Specify the ECMAScript version to which the code must adhere. + "esversion" : 8, // {int} Specify the ECMAScript version to which the code must adhere. "moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features) // (ex: `for each`, multiple try/catch, function expression…) "evil" : false, // true: Tolerate use of `eval` and `new Function()` @@ -87,5 +87,16 @@ "yui" : false, // Yahoo User Interface // Custom Globals - "globals" : {"Fleur" : true} // additional predefined global variables + "globals" : { + "document" : true, + "Fleur" : true, + "XsltForms_abstractAction" : true, + "XsltForms_binding" : true, + "XsltForms_browser" : true, + "XsltForms_class" : true, + "XsltForms_coreElement" : true, + "XsltForms_globals" : true, + "XsltForms_subform" : true, + "XsltForms_xmlevents" : true + } // additional predefined global variables } \ No newline at end of file diff --git a/build/css/postcss.config.js b/build/css/postcss.config.js new file mode 100644 index 0000000..c8e77a8 --- /dev/null +++ b/build/css/postcss.config.js @@ -0,0 +1,7 @@ +module.exports = { + plugins: [ + require('/users/alain.couthures/appdata/roaming/npm/node_modules/cssnano')({ + preset: 'default', + }), + ], +}; \ No newline at end of file diff --git a/build/css/xsltforms.css b/build/css/xsltforms.css index 637304f..4cebb04 100644 --- a/build/css/xsltforms.css +++ b/build/css/xsltforms.css @@ -1,8 +1,8 @@ /* -XSLTForms 1.6 (663) +XSLTForms 1.7 (664) XForms 1.1+ Engine -Copyright (C) 2022 agenceXML - Alain Couthures +Copyright (C) 2023 agenceXML - Alain Couthures Contact at : xsltforms@agencexml.com This library is free software; you can redistribute it and/or @@ -194,10 +194,10 @@ xforms-label:hover + xforms-help[xf-appearance="minimal"]:not([href]) { cursor: pointer; } #xsltforms-console { - font-size: 0.8em; - color: #888888; - border-top: thin solid #888888; - display: none; + font-size: 0.8em; + color: #888888; + border-top: thin solid #888888; + display: none; } xforms-debugger { display: flex; @@ -247,32 +247,41 @@ xforms-expression { display: block; } xforms-dialog { - display: none; - position: absolute; - width: 400px; - height: 300px; - background-color: white; - border-top: 1px solid black; - border-left: 1px solid black; - border-bottom: 3px solid black; - border-right: 3px solid black; - padding: 10px; - z-index: 10; - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; - box-sizing: border-box; + display: none; + position: absolute; + width: 400px; + height: 300px; + background-color: white; + border-top: 1px solid black; + border-left: 1px solid black; + border-bottom: 3px solid black; + border-right: 3px solid black; + padding: 10px; + z-index: 10; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; } xforms-dialog-surround { - display: none; - position: absolute; - left: 0; - top: 0; - width: 100%; - height: 100%; - background-color: green; - filter:alpha(opacity=40); - opacity:0.4; - -moz-opacity:0.4; + display: none; + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 100%; + background-color: green; + filter:alpha(opacity=40); + opacity:0.4; + -moz-opacity:0.4; +} +xforms-form > xforms-body > form { + display: inline; +} +xforms-status-panel { + display: none; + z-index: 99; + top: 294.5px; + left: 490px; } xforms-action, xforms-alert-mark, @@ -342,7 +351,7 @@ xforms-select1:not([xf-appearance="full"]) > xforms-body > xforms-item, xforms-select1:not([xf-appearance="full"]) > xforms-body > xforms-itemset, xforms-select1:not([xf-appearance="full"]) > xforms-body > xforms-choices, xforms-itemset > xforms-label { - display: none; + display: none; } xforms-group:not([xf-ref]):not([xf-bind]), xforms-group[xf-bound]:not([xf-notrelevant]), @@ -358,26 +367,10 @@ xforms-select1[xf-appearance="full"] > xforms-body > xforms-itemset > xforms-ite xforms-select1[xf-appearance="full"] > xforms-body > xforms-choices > xforms-label, xforms-select1[xf-appearance="full"] > xforms-body > xforms-choices > xforms-item, xforms-select1[xf-appearance="full"] > xforms-body > xforms-choices > xforms-itemset > xforms-item { - display: block; + display: block; } xforms-repeat[xf-bound]:not([xf-notrelevant]) > xforms-repeat-item { - display: table-row; -} -xforms-repeat-item > xforms-output[xf-value], -xforms-repeat-item > xforms-output[xf-bound]:not([xf-notrelevant]), -xforms-repeat-item > xforms-input[xf-bound]:not([xf-notrelevant]), -xforms-repeat-item > xforms-textarea[xf-bound]:not([xf-notrelevant]), -xforms-repeat-item > xforms-secret[xf-bound]:not([xf-notrelevant]), -xforms-repeat-item > xforms-upload[xf-bound]:not([xf-notrelevant]), -xforms-repeat-item > xforms-range[xf-bound]:not([xf-notrelevant]), -xforms-repeat-item > xforms-trigger:not([xf-ref]):not([xf-bind]), -xforms-repeat-item > xforms-trigger[xf-bound]:not([xf-notrelevant]), -xforms-repeat-item > xforms-submit, -xforms-repeat-item > xforms-select[xf-bound]:not([xf-notrelevant])[xf-appearance="full"], -xforms-repeat-item > xforms-select1[xf-bound]:not([xf-notrelevant])[xf-appearance="full"], -xforms-repeat-item > xforms-select[xf-bound]:not([xf-notrelevant]):not([xf-appearance="full"]), -xforms-repeat-item > xforms-select1[xf-bound]:not([xf-notrelevant]):not([xf-appearance="full"]) { - display: inline-table; + display: inherit; } xforms-output[xf-value], xforms-output[xf-bound]:not([xf-notrelevant]), @@ -401,7 +394,7 @@ xforms-select1[xf-appearance="full"] > xforms-body > xforms-item > xforms-label, xforms-select1[xf-appearance="full"] > xforms-body > xforms-itemset > xforms-item > xforms-label, xforms-select1[xf-appearance="full"] > xforms-body > xforms-choices > xforms-item > xforms-label, xforms-select1[xf-appearance="full"] > xforms-body > xforms-choices > xforms-itemset > xforms-item > xforms-label { - display: inline-block; + display: inline-block; } xforms-select[xf-appearance="full"] > xforms-body > xforms-choices > xforms-label, xforms-select1[xf-appearance="full"] > xforms-body > xforms-choices > xforms-label { diff --git a/build/css/xsltforms.min.css b/build/css/xsltforms.min.css index 6efc0b8..c203836 100644 --- a/build/css/xsltforms.min.css +++ b/build/css/xsltforms.min.css @@ -1 +1 @@ -.xsltforms-aid-button{padding:0}xforms-alert,xforms-help,xforms-hint{display:none;position:absolute;border:thin solid #000;margin-left:.5ex;padding:.2px;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}xforms-alert{color:#fff;background-color:red}xforms-help{background-color:#eef}xforms-hint{z-index:2;background-color:#ff8}xforms-input[xf-invalid]>xforms-alert-mark{display:none}xforms-alert-mark::after{content:' \2716';color:red}xforms-alert-mark:hover+xforms-alert{display:inline;cursor:help}xforms-input:hover xforms-hint,xforms-trigger:hover xforms-hint{display:block;cursor:help}xforms-help-mark::after{content:' \2754';color:green}xforms-help-mark:hover+xforms-help{display:inline;cursor:help}xforms-label:hover+xforms-help[xf-appearance=minimal]:not([href]){display:inline;cursor:help}.xsltforms-calendar,.xsltforms-calendarList{border-top:1px solid #000;border-right:2px solid #000;border-bottom:2px solid #000;border-left:1px solid #000;padding:1px 0 0 1px;font-family:tahoma,verdana,sans-serif;font-size:12px;color:#000;background:#f8f8f8;display:none;position:absolute;z-index:9}.xsltforms-calendar button{text-align:center;padding:1px;border:1px solid;border-color:#fff #000 #000 #fff}.xsltforms-calendar thead .xsltforms-listHover{border:2px solid;border-color:#fff #000 #000 #fff;padding:0;background-color:#d8e0e4}.xsltforms-calendar .xsltforms-calendar-title,.xsltforms-calendar .xsltforms-calendar-title input,.xsltforms-calendar .xsltforms-calendar-title select,.xsltforms-calendar tfoot{font-weight:700;padding:1px;border:1px solid #000;color:#000;text-align:center;background-color:#f8f8f8;background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAoCAYAAAA/tpB3AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1gUBDAgfNCTDHgAAAFlJREFUeNpVjskRgDAMA5WVof+6oAbaMMcnPCAJ/OTZlcZa1q1yHJfI3MWep8i83lSrhD0JWwIQtgWfs4iIeIFdGoiWoHxl22IOtalHpss/MHUwumMvIp5fbsP7FTL17XHsAAAAAElFTkSuQmCC')}.xsltforms-calendar .xsltforms-calendar-title input{width:3em;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;background:#f8f8f8}.xsltforms-calendar-date tfoot{display:none}.xsltforms-calendar tfoot input{width:2em;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;text-align:center;background:#f0f0f0}.xsltforms-calendar .xsltforms-calendar-names{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAUCAIAAADDbMD2AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1gUBDAcldbAGYwAAAENJREFUeNoFwQESgCAIAEE6C2ym//+0SRClXcnchCfuwfBF+GLEZoxgzuR7hczkYGPWsH5idmG9oao894GqyoySqvoBAwEj81+5NlEAAAAASUVORK5CYII=')}.xsltforms-calendar .xsltforms-calendar-name{border-bottom:1px solid #000;padding:2px;text-align:center}.xsltforms-calendar .xsltforms-calendar-day{width:2em;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;text-align:right;padding:2px 4px 2px 2px}.xsltforms-calendar tbody .xsltforms-listHover{padding:1px 3px 1px 1px;border:1px solid;border-color:#fff #000 #000 #fff;background-color:#ddd}.xsltforms-calendar .xsltforms-calendar-today{font-weight:700;color:#00f}.xsltforms-calendar .xsltforms-calendar-selected{font-weight:700;padding:2px 2px 0 2px;border:1px solid;border-color:#000 #fff #fff #000;background:#ccc}.xsltforms-calendar .xsltforms-calendar-weekend{color:red}.xsltforms-calendarList{padding:0;margin:0;width:55px;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.xsltforms-calendarList li{list-style-type:none;text-align:center;padding:1px}.xsltforms-calendarList li.xsltforms-listHover{border:1px solid;border-color:#fff #000 #000 #fff;padding:0;background-color:#ddd;width:100%}.xforms-group-label-collapsed::before{content:'\23F5\00A0'}.xforms-group-label-collapsed:hover{cursor:pointer}.xforms-group-label-expanded::before{content:'\23F7\00A0'}.xforms-group-label-expanded:hover{cursor:pointer}#xsltforms-console{font-size:.8em;color:#888;border-top:thin solid #888;display:none}xforms-debugger{display:flex;flex-direction:column;padding:0;margin-left:0;margin-top:-1ex}xforms-board,xforms-debugger>xforms-body{box-sizing:border-box;flex:1 1 auto;overflow-y:auto;padding:0;margin:0}xforms-debugger>xforms-body{min-height:200px}xforms-board{padding:0;font-size:12px}xforms-gutter{height:4px;padding:0;cursor:ns-resize;flex:0 0 auto}xforms-gutter::before{content:'';display:block;width:100%;height:4px;background:grey;margin:0 auto}xforms-board>xforms-body>textarea{border:0;resize:none;outline:0;width:90%}xforms-console-history{display:block}xforms-expression{display:block}xforms-dialog{display:none;position:absolute;width:400px;height:300px;background-color:#fff;border-top:1px solid #000;border-left:1px solid #000;border-bottom:3px solid #000;border-right:3px solid #000;padding:10px;z-index:10;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}xforms-dialog-surround{display:none;position:absolute;left:0;top:0;width:100%;height:100%;background-color:green;opacity:.4;-moz-opacity:0.4}[data-xf-repeat-bind]:not([xf-bound]),[data-xf-repeat-ref]:not([xf-bound]),[xf-repeat-bind]:not([xf-bound]),[xf-repeat-ref]:not([xf-bound]),xforms-action,xforms-alert-mark,xforms-bind,xforms-case:not([xf-selected = "true"]),xforms-component,xforms-delete,xforms-dialog,xforms-dispatch,xforms-filename,xforms-group,xforms-group[xf-bind]:not([xf-bound]),xforms-group[xf-ref]:not([xf-bound]),xforms-hide,xforms-input,xforms-insert,xforms-instance,xforms-itemset>xforms-label,xforms-itext,xforms-load,xforms-mediatype,xforms-message,xforms-model,xforms-options,xforms-output,xforms-range,xforms-rebuild,xforms-recalculate,xforms-refresh,xforms-repeat,xforms-reset,xforms-revalidate,xforms-script,xforms-secret,xforms-select,xforms-select1,xforms-select1:not([xf-appearance=full])>xforms-body>xforms-choices,xforms-select1:not([xf-appearance=full])>xforms-body>xforms-item,xforms-select1:not([xf-appearance=full])>xforms-body>xforms-itemset,xforms-select:not([xf-appearance=full])>xforms-body>xforms-choices,xforms-select:not([xf-appearance=full])>xforms-body>xforms-item,xforms-select:not([xf-appearance=full])>xforms-body>xforms-itemset,xforms-send,xforms-setfocus,xforms-setindex,xforms-setnode,xforms-setselection,xforms-setvalue,xforms-show,xforms-split,xforms-submission,xforms-text,xforms-textarea,xforms-timer,xforms-toggle,xforms-translation,xforms-tree,xforms-trigger[xf-bind]:not([xf-bound]),xforms-trigger[xf-notrelevant],xforms-trigger[xf-ref]:not([xf-bound]),xforms-unload,xforms-upload,xforms-value,xforms-var,xforms-wrap{display:none}xforms-case[xf-selected=true],xforms-group:not([xf-ref]):not([xf-bind]),xforms-group[xf-bound]:not([xf-notrelevant]),xforms-repeat[xf-bound]:not([xf-notrelevant]),xforms-select1[xf-appearance=full]>xforms-body>xforms-choices>xforms-item,xforms-select1[xf-appearance=full]>xforms-body>xforms-choices>xforms-itemset>xforms-item,xforms-select1[xf-appearance=full]>xforms-body>xforms-choices>xforms-label,xforms-select1[xf-appearance=full]>xforms-body>xforms-item,xforms-select1[xf-appearance=full]>xforms-body>xforms-itemset>xforms-item,xforms-select[xf-appearance=full]>xforms-body>xforms-choices>xforms-item,xforms-select[xf-appearance=full]>xforms-body>xforms-choices>xforms-itemset>xforms-item,xforms-select[xf-appearance=full]>xforms-body>xforms-choices>xforms-label,xforms-select[xf-appearance=full]>xforms-body>xforms-item,xforms-select[xf-appearance=full]>xforms-body>xforms-itemset>xforms-item{display:block}xforms-repeat[xf-bound]:not([xf-notrelevant])>xforms-repeat-item{display:table-row}xforms-repeat-item>xforms-input[xf-bound]:not([xf-notrelevant]),xforms-repeat-item>xforms-output[xf-bound]:not([xf-notrelevant]),xforms-repeat-item>xforms-output[xf-value],xforms-repeat-item>xforms-range[xf-bound]:not([xf-notrelevant]),xforms-repeat-item>xforms-secret[xf-bound]:not([xf-notrelevant]),xforms-repeat-item>xforms-select1[xf-bound]:not([xf-notrelevant]):not([xf-appearance=full]),xforms-repeat-item>xforms-select1[xf-bound]:not([xf-notrelevant])[xf-appearance=full],xforms-repeat-item>xforms-select[xf-bound]:not([xf-notrelevant]):not([xf-appearance=full]),xforms-repeat-item>xforms-select[xf-bound]:not([xf-notrelevant])[xf-appearance=full],xforms-repeat-item>xforms-submit,xforms-repeat-item>xforms-textarea[xf-bound]:not([xf-notrelevant]),xforms-repeat-item>xforms-trigger:not([xf-ref]):not([xf-bind]),xforms-repeat-item>xforms-trigger[xf-bound]:not([xf-notrelevant]),xforms-repeat-item>xforms-upload[xf-bound]:not([xf-notrelevant]){display:inline-table}xforms-input[xf-bound]:not([xf-notrelevant]),xforms-output[xf-bound]:not([xf-notrelevant]),xforms-output[xf-value],xforms-range[xf-bound]:not([xf-notrelevant]),xforms-secret[xf-bound]:not([xf-notrelevant]),xforms-select1[xf-appearance=full]>xforms-body>xforms-choices>xforms-item>xforms-label,xforms-select1[xf-appearance=full]>xforms-body>xforms-choices>xforms-itemset>xforms-item>xforms-label,xforms-select1[xf-appearance=full]>xforms-body>xforms-item>xforms-label,xforms-select1[xf-appearance=full]>xforms-body>xforms-itemset>xforms-item>xforms-label,xforms-select1[xf-bound]:not([xf-notrelevant]):not([xf-appearance=full]),xforms-select1[xf-bound]:not([xf-notrelevant])[xf-appearance=full],xforms-select[xf-appearance=full]>xforms-body>xforms-choices>xforms-item>xforms-label,xforms-select[xf-appearance=full]>xforms-body>xforms-choices>xforms-itemset>xforms-item>xforms-label,xforms-select[xf-appearance=full]>xforms-body>xforms-item>xforms-label,xforms-select[xf-appearance=full]>xforms-body>xforms-itemset>xforms-item>xforms-label,xforms-select[xf-bound]:not([xf-notrelevant]):not([xf-appearance=full]),xforms-select[xf-bound]:not([xf-notrelevant])[xf-appearance=full],xforms-submit,xforms-textarea[xf-bound]:not([xf-notrelevant]),xforms-trigger:not([xf-ref]):not([xf-bind]),xforms-trigger[xf-bound]:not([xf-notrelevant]),xforms-upload[xf-bound]:not([xf-notrelevant]){display:inline-block}xforms-select1[xf-appearance=full]>xforms-body>xforms-choices>xforms-label,xforms-select[xf-appearance=full]>xforms-body>xforms-choices>xforms-label{font-weight:700;font-style:italic}xforms-select1[xf-appearance=full]>xforms-body>xforms-choices>xforms-item>xforms-label,xforms-select1[xf-appearance=full]>xforms-body>xforms-choices>xforms-itemset>xforms-item>xforms-label,xforms-select1[xf-appearance=full]>xforms-body>xforms-item>xforms-label,xforms-select1[xf-appearance=full]>xforms-body>xforms-itemset>xforms-item>xforms-label,xforms-select[xf-appearance=full]>xforms-body>xforms-choices>xforms-item>xforms-label,xforms-select[xf-appearance=full]>xforms-body>xforms-choices>xforms-itemset>xforms-item>xforms-label,xforms-select[xf-appearance=full]>xforms-body>xforms-item>xforms-label,xforms-select[xf-appearance=full]>xforms-body>xforms-itemset>xforms-item>xforms-label{font-weight:400}body{margin:1ex;font-family:tahoma,verdana,sans-serif}input{font-size:100%}input[type=checkbox]{width:1ex;height:1ex}input[xf-numeric]{text-align:right}textarea{font-family:tahoma,verdana,sans-serif;font-size:100%}select{font-size:100%}a[appearance=minimal]{cursor:default}xforms-input[xf-readonly]>xforms-body{background-color:#f8f8f8;color:#333}xforms-input[xf-numeric]{text-align:right}xforms-item[xf-appearance=full]{display:block!important}xforms-label{font-weight:700;display:block;margin:0;padding-right:.5ex}xforms-label img{border:none!important}xforms-submit xforms-label,xforms-trigger xforms-label{padding-right:0}xform-select1>xforms-label,xforms-select>xforms-label,xforms-textarea>xforms-label{vertical-align:top}xforms-range-rail{width:200px;height:4px;border:1px solid #999;position:relative;margin:6px 15px 0 10px;display:inline-block}xforms-range-cursor{margin:0;margin-top:-8px;margin-left:-5px;width:17px;height:17px;position:absolute;background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOwwAADsMBx2+oZAAAAAd0SU1FB9wEBhMoKuFF9b0AAAB0SURBVDjL3ZRRDsAgCEMp2bU4PQfrvkwYQzMNX+uv8izEApJSCcDrgCSqu9es2N2n4AxDdAKAVXGWmT1AugsYLmO7uguoQCoNgohsu8jzaXHyNwhJmNnxUEmir50TN/Hra0zoV1DODvIqWKV4PLJM8ek+uQGc+lDIra5tbwAAAABJRU5ErkJggg==');outline-style:none}xforms-input[xf-bound][xf-required]:not([xf-invalid])>xforms-label::after{content:"*";color:red}xforms-input:not([xf-required])[xf-invalid]>xforms-label::after{content:"\2716";color:red}xforms-input[xf-bound][xf-required][xf-invalid]>xforms-label::after{content:"*\2716";color:red}xforms-input[xf-invalid]:not([xf-required])>xforms-body>input,xforms-input[xf-invalid][xf-required]>xforms-body>input,xforms-textarea[xf-invalid]:not([xf-required])>xforms-body>textarea{background-color:#fcc;border-style:solid;border-width:thin}#xsltforms-status-panel{display:none;position:absolute;width:300px;min-width:300px;min-height:20px;padding:10px;text-align:center;background-color:#eee;opacity:.85;border:1px solid #000;font:bold 20px Arial,Verdana;z-index:11;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:content-box}xforms-trigger{margin-top:1px}xforms-trigger a,xforms-trigger a:hover,xforms-trigger a:link,xforms-trigger a:visited{text-decoration:none;color:#000;border:none!important;cursor:pointer} \ No newline at end of file +.xsltforms-aid-button{padding:0}xforms-alert,xforms-help,xforms-hint{border:thin solid #000;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;display:none;margin-left:.5ex;padding:.2px;position:absolute}xforms-alert{background-color:red;color:#fff}xforms-help{background-color:#eef}xforms-hint{background-color:#ff8;z-index:2}xforms-input[xf-invalid]>xforms-alert-mark{display:none}xforms-alert-mark:after{color:red;content:" \2716"}xforms-alert-mark:hover+xforms-alert{cursor:help;display:inline}xforms-input:hover xforms-hint,xforms-trigger:hover xforms-hint{cursor:help;display:block}xforms-help-mark:after{color:green;content:" \2754"}xforms-help-mark:hover+xforms-help,xforms-label:hover+xforms-help[xf-appearance=minimal]:not([href]){cursor:help;display:inline}.xsltforms-calendar,.xsltforms-calendarList{background:#f8f8f8;border-color:#000;border-style:solid;border-width:1px 2px 2px 1px;color:#000;display:none;font-family:tahoma,verdana,sans-serif;font-size:12px;padding:1px 0 0 1px;position:absolute;z-index:9}.xsltforms-calendar button{border-color:#fff #000 #000 #fff;border-style:solid;border-width:1px;padding:1px;text-align:center}.xsltforms-calendar thead .xsltforms-listHover{background-color:#d8e0e4;border-color:#fff #000 #000 #fff;border-style:solid;border-width:2px;padding:0}.xsltforms-calendar .xsltforms-calendar-title,.xsltforms-calendar .xsltforms-calendar-title input,.xsltforms-calendar .xsltforms-calendar-title select,.xsltforms-calendar tfoot{background-color:#f8f8f8;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAoCAYAAAA/tpB3AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1gUBDAgfNCTDHgAAAFlJREFUeNpVjskRgDAMA5WVof+6oAbaMMcnPCAJ/OTZlcZa1q1yHJfI3MWep8i83lSrhD0JWwIQtgWfs4iIeIFdGoiWoHxl22IOtalHpss/MHUwumMvIp5fbsP7FTL17XHsAAAAAElFTkSuQmCC");border:1px solid #000;color:#000;font-weight:700;padding:1px;text-align:center}.xsltforms-calendar .xsltforms-calendar-title input{background:#f8f8f8;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;width:3em}.xsltforms-calendar-date tfoot{display:none}.xsltforms-calendar tfoot input{background:#f0f0f0;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;text-align:center;width:2em}.xsltforms-calendar .xsltforms-calendar-names{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAUCAIAAADDbMD2AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1gUBDAcldbAGYwAAAENJREFUeNoFwQESgCAIAEE6C2ym//+0SRClXcnchCfuwfBF+GLEZoxgzuR7hczkYGPWsH5idmG9oao894GqyoySqvoBAwEj81+5NlEAAAAASUVORK5CYII=")}.xsltforms-calendar .xsltforms-calendar-name{border-bottom:1px solid #000;padding:2px;text-align:center}.xsltforms-calendar .xsltforms-calendar-day{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;padding:2px 4px 2px 2px;text-align:right;width:2em}.xsltforms-calendar tbody .xsltforms-listHover{background-color:#ddd;border-color:#fff #000 #000 #fff;border-style:solid;border-width:1px;padding:1px 3px 1px 1px}.xsltforms-calendar .xsltforms-calendar-today{color:#00f;font-weight:700}.xsltforms-calendar .xsltforms-calendar-selected{background:#ccc;border-color:#000 #fff #fff #000;border-style:solid;border-width:1px;font-weight:700;padding:2px 2px 0}.xsltforms-calendar .xsltforms-calendar-weekend{color:red}.xsltforms-calendarList{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;margin:0;padding:0;width:55px}.xsltforms-calendarList li{list-style-type:none;padding:1px;text-align:center}.xsltforms-calendarList li.xsltforms-listHover{background-color:#ddd;border-color:#fff #000 #000 #fff;border-style:solid;border-width:1px;padding:0;width:100%}.xforms-group-label-collapsed:before{content:"\23F5\00A0"}.xforms-group-label-collapsed:hover{cursor:pointer}.xforms-group-label-expanded:before{content:"\23F7\00A0"}.xforms-group-label-expanded:hover{cursor:pointer}#xsltforms-console{border-top:thin solid #888;color:#888;display:none;font-size:.8em}xforms-debugger{display:flex;flex-direction:column;margin-left:0;margin-top:-1ex;padding:0}xforms-board,xforms-debugger>xforms-body{box-sizing:border-box;flex:1 1 auto;margin:0;overflow-y:auto;padding:0}xforms-debugger>xforms-body{min-height:200px}xforms-board{font-size:12px;padding:0}xforms-gutter{cursor:ns-resize;flex:0 0 auto;height:4px;padding:0}xforms-gutter:before{background:grey;content:"";display:block;height:4px;margin:0 auto;width:100%}xforms-board>xforms-body>textarea{border:0;outline:none;resize:none;width:90%}xforms-console-history,xforms-expression{display:block}xforms-dialog{background-color:#fff;border-color:#000;border-style:solid;border-width:1px 3px 3px 1px;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;display:none;height:300px;padding:10px;position:absolute;width:400px;z-index:10}xforms-dialog-surround{background-color:green;display:none;filter:alpha(opacity=40);height:100%;left:0;opacity:.4;-moz-opacity:.4;position:absolute;top:0;width:100%}xforms-form>xforms-body>form{display:inline}xforms-status-panel{display:none;left:490px;top:294.5px;z-index:99}[data-xf-repeat-bind]:not([xf-bound]),[data-xf-repeat-ref]:not([xf-bound]),[xf-repeat-bind]:not([xf-bound]),[xf-repeat-ref]:not([xf-bound]),xforms-action,xforms-alert-mark,xforms-bind,xforms-case:not([xf-selected=true]),xforms-component,xforms-delete,xforms-dialog,xforms-dispatch,xforms-filename,xforms-group,xforms-group[xf-bind]:not([xf-bound]),xforms-group[xf-ref]:not([xf-bound]),xforms-hide,xforms-input,xforms-insert,xforms-instance,xforms-itemset>xforms-label,xforms-itext,xforms-load,xforms-mediatype,xforms-message,xforms-model,xforms-options,xforms-output,xforms-range,xforms-rebuild,xforms-recalculate,xforms-refresh,xforms-repeat,xforms-reset,xforms-revalidate,xforms-script,xforms-secret,xforms-select,xforms-select1,xforms-select1:not([xf-appearance=full])>xforms-body>xforms-choices,xforms-select1:not([xf-appearance=full])>xforms-body>xforms-item,xforms-select1:not([xf-appearance=full])>xforms-body>xforms-itemset,xforms-select:not([xf-appearance=full])>xforms-body>xforms-choices,xforms-select:not([xf-appearance=full])>xforms-body>xforms-item,xforms-select:not([xf-appearance=full])>xforms-body>xforms-itemset,xforms-send,xforms-setfocus,xforms-setindex,xforms-setnode,xforms-setselection,xforms-setvalue,xforms-show,xforms-split,xforms-submission,xforms-text,xforms-textarea,xforms-timer,xforms-toggle,xforms-translation,xforms-tree,xforms-trigger[xf-bind]:not([xf-bound]),xforms-trigger[xf-notrelevant],xforms-trigger[xf-ref]:not([xf-bound]),xforms-unload,xforms-upload,xforms-value,xforms-var,xforms-wrap{display:none}xforms-case[xf-selected=true],xforms-group:not([xf-ref]):not([xf-bind]),xforms-group[xf-bound]:not([xf-notrelevant]),xforms-repeat[xf-bound]:not([xf-notrelevant]),xforms-select1[xf-appearance=full]>xforms-body>xforms-choices>xforms-item,xforms-select1[xf-appearance=full]>xforms-body>xforms-choices>xforms-itemset>xforms-item,xforms-select1[xf-appearance=full]>xforms-body>xforms-choices>xforms-label,xforms-select1[xf-appearance=full]>xforms-body>xforms-item,xforms-select1[xf-appearance=full]>xforms-body>xforms-itemset>xforms-item,xforms-select[xf-appearance=full]>xforms-body>xforms-choices>xforms-item,xforms-select[xf-appearance=full]>xforms-body>xforms-choices>xforms-itemset>xforms-item,xforms-select[xf-appearance=full]>xforms-body>xforms-choices>xforms-label,xforms-select[xf-appearance=full]>xforms-body>xforms-item,xforms-select[xf-appearance=full]>xforms-body>xforms-itemset>xforms-item{display:block}xforms-repeat[xf-bound]:not([xf-notrelevant])>xforms-repeat-item{display:inherit}xforms-input[xf-bound]:not([xf-notrelevant]),xforms-output[xf-bound]:not([xf-notrelevant]),xforms-output[xf-value],xforms-range[xf-bound]:not([xf-notrelevant]),xforms-secret[xf-bound]:not([xf-notrelevant]),xforms-select1[xf-appearance=full]>xforms-body>xforms-choices>xforms-item>xforms-label,xforms-select1[xf-appearance=full]>xforms-body>xforms-choices>xforms-itemset>xforms-item>xforms-label,xforms-select1[xf-appearance=full]>xforms-body>xforms-item>xforms-label,xforms-select1[xf-appearance=full]>xforms-body>xforms-itemset>xforms-item>xforms-label,xforms-select1[xf-bound]:not([xf-notrelevant]):not([xf-appearance=full]),xforms-select1[xf-bound]:not([xf-notrelevant])[xf-appearance=full],xforms-select[xf-appearance=full]>xforms-body>xforms-choices>xforms-item>xforms-label,xforms-select[xf-appearance=full]>xforms-body>xforms-choices>xforms-itemset>xforms-item>xforms-label,xforms-select[xf-appearance=full]>xforms-body>xforms-item>xforms-label,xforms-select[xf-appearance=full]>xforms-body>xforms-itemset>xforms-item>xforms-label,xforms-select[xf-bound]:not([xf-notrelevant]):not([xf-appearance=full]),xforms-select[xf-bound]:not([xf-notrelevant])[xf-appearance=full],xforms-submit,xforms-textarea[xf-bound]:not([xf-notrelevant]),xforms-trigger:not([xf-ref]):not([xf-bind]),xforms-trigger[xf-bound]:not([xf-notrelevant]),xforms-upload[xf-bound]:not([xf-notrelevant]){display:inline-block}xforms-select1[xf-appearance=full]>xforms-body>xforms-choices>xforms-label,xforms-select[xf-appearance=full]>xforms-body>xforms-choices>xforms-label{font-style:italic;font-weight:700}xforms-select1[xf-appearance=full]>xforms-body>xforms-choices>xforms-item>xforms-label,xforms-select1[xf-appearance=full]>xforms-body>xforms-choices>xforms-itemset>xforms-item>xforms-label,xforms-select1[xf-appearance=full]>xforms-body>xforms-item>xforms-label,xforms-select1[xf-appearance=full]>xforms-body>xforms-itemset>xforms-item>xforms-label,xforms-select[xf-appearance=full]>xforms-body>xforms-choices>xforms-item>xforms-label,xforms-select[xf-appearance=full]>xforms-body>xforms-choices>xforms-itemset>xforms-item>xforms-label,xforms-select[xf-appearance=full]>xforms-body>xforms-item>xforms-label,xforms-select[xf-appearance=full]>xforms-body>xforms-itemset>xforms-item>xforms-label{font-weight:400}body{font-family:tahoma,verdana,sans-serif;margin:1ex}input{font-size:100%}input[type=checkbox]{height:1ex;width:1ex}input[xf-numeric]{text-align:right}textarea{font-family:tahoma,verdana,sans-serif}select,textarea{font-size:100%}a[appearance=minimal]{cursor:default}xforms-input[xf-readonly]>xforms-body{background-color:#f8f8f8;color:#333}xforms-input[xf-numeric]{text-align:right}xforms-item[xf-appearance=full]{display:block!important}xforms-label{display:block;font-weight:700;margin:0;padding-right:.5ex}xforms-label img{border:none!important}xforms-submit xforms-label,xforms-trigger xforms-label{padding-right:0}xform-select1>xforms-label,xforms-select>xforms-label,xforms-textarea>xforms-label{vertical-align:top}xforms-range-rail{border:1px solid #999;display:inline-block;height:4px;margin:6px 15px 0 10px;position:relative;width:200px}xforms-range-cursor{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOwwAADsMBx2+oZAAAAAd0SU1FB9wEBhMoKuFF9b0AAAB0SURBVDjL3ZRRDsAgCEMp2bU4PQfrvkwYQzMNX+uv8izEApJSCcDrgCSqu9es2N2n4AxDdAKAVXGWmT1AugsYLmO7uguoQCoNgohsu8jzaXHyNwhJmNnxUEmir50TN/Hra0zoV1DODvIqWKV4PLJM8ek+uQGc+lDIra5tbwAAAABJRU5ErkJggg==");height:17px;margin:-8px 0 0 -5px;outline-style:none;position:absolute;width:17px}xforms-input[xf-bound][xf-required]:not([xf-invalid])>xforms-label:after{color:red;content:"*"}xforms-input:not([xf-required])[xf-invalid]>xforms-label:after{color:red;content:"\2716"}xforms-input[xf-bound][xf-required][xf-invalid]>xforms-label:after{color:red;content:"*\2716"}xforms-input[xf-invalid]:not([xf-required])>xforms-body>input,xforms-input[xf-invalid][xf-required]>xforms-body>input,xforms-textarea[xf-invalid]:not([xf-required])>xforms-body>textarea{background-color:#fcc;border-style:solid;border-width:thin}#xsltforms-status-panel{background-color:#eee;border:1px solid #000;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:content-box;display:none;filter:alpha(opacity=85);font:700 20px Arial,Verdana;min-height:20px;min-width:300px;opacity:.85;padding:10px;position:absolute;text-align:center;width:300px;z-index:11}xforms-trigger{margin-top:1px}xforms-trigger a,xforms-trigger a:hover,xforms-trigger a:link,xforms-trigger a:visited{border:none!important;color:#000;cursor:pointer;text-decoration:none} \ No newline at end of file diff --git a/build/js/xsltforms.js b/build/js/xsltforms.js index e86941d..06e1147 100644 --- a/build/js/xsltforms.js +++ b/build/js/xsltforms.js @@ -1,8 +1,8 @@ /* -XSLTForms 1.6 (663) +XSLTForms 1.7 (664) XForms 1.1+ Engine -Copyright (C) 2022 agenceXML - Alain Couthures +Copyright (C) 2023 agenceXML - Alain Couthures Contact at xsltforms@agencexml.com This library is free software; you can redistribute it and/or @@ -22,2053 +22,2053 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA "use strict"; if (typeof Fleur === "undefined") { - console.info('Fleur 1.0 (15), XPath 1.0 Parser, copyright (C) 2022 agenceXML - Alain Couthures, contact at fleur@agencexml.com'); - (function(Fleur) { - Fleur.Node = function() {}; - Fleur.Node.ELEMENT_NODE = 1; - Fleur.Node.ATTRIBUTE_NODE = 2; - Fleur.Node.TEXT_NODE = 3; - Fleur.Node.CDATA_NODE = 4; - Fleur.Node.ENTITY_REFERENCE_NODE = 5; - Fleur.Node.ENTITY_NODE = 6; - Fleur.Node.PROCESSING_INSTRUCTION_NODE = 7; - Fleur.Node.COMMENT_NODE = 8; - Fleur.Node.DOCUMENT_NODE = 9; - Fleur.Node.DOCUMENT_TYPE_NODE = 10; - Fleur.Node.DOCUMENT_FRAGMENT_NODE = 11; - Fleur.Node.NOTATION_NODE = 12; - Fleur.Node.NAMESPACE_NODE = 129; - Fleur.Node.ATOMIC_NODE = Fleur.Node.TEXT_NODE; - Fleur.Node.SEQUENCE_NODE = 130; - Fleur.Node.ARRAY_NODE = 131; - Fleur.Node.MAP_NODE = 132; - Fleur.Node.ENTRY_NODE = 133; - Fleur.minimal = true; - Fleur.DocumentType = function() {}; - Fleur.DocumentType.resolveEntities = function(doctype, s) { - var offset = 0, index, entityname, entityvalue = null; - while ((index = s.indexOf("&", offset)) !== -1) { - entityname = s.substring(index + 1, s.indexOf(";", index + 1)); - switch (entityname) { - case "amp": - entityvalue = "&"; - break; - case "lt": - entityvalue = "<"; - break; - case "gt": - entityvalue = ">"; - break; - case "apos": - entityvalue = "'"; - break; - case "quot": - entityvalue = '"'; - break; - default: - if (entityname.charAt(0) === "#") { - entityvalue = String.fromCharCode(parseInt(entityname.charAt(1).toLowerCase() === 'x' ? "0" + entityname.substr(1).toLowerCase() : entityname.substr(1), entityname.charAt(1).toLowerCase() === 'x' ? 16 : 10)); - } else if (doctype) { - entityvalue = doctype.getEntity(entityname); - } - } - if (entityvalue) { - s = s.substr(0, index) + entityvalue + s.substr(index + entityname.length + 2); - offset = index + entityvalue.length; - entityvalue = null; - } else { - break; - } - } - return s.split("\r\n").join("\n"); - }; - Fleur.Serializer = function() {}; - Fleur.Serializer.escapeXML = function(s) { - return s.replace(/&/g, "&").replace(//g, ">"); - }; - Fleur.Serializer.prototype._serializeXMLToString = function(node, indent, offset, cdataSectionElements) { - var s, i, l; - switch (node.nodeType) { - case Fleur.Node.ELEMENT_NODE: - s = (indent ? offset + "\x3C" : "\x3C") + node.nodeName; - if (indent) { - var names = []; - for (i = 0, l = node.attributes.length; i < l; i++) { - names.push(node.attributes[i].nodeName); - } - names.sort(); - for (i = 0, l = names.length; i < l; i++) { - s += " " + names[i] + "=\"" + Fleur.Serializer.escapeXML(node.getAttribute(names[i])).replace('"', """) + "\""; - } - } else { - for (i = 0, l = node.attributes.length; i < l; i++) { - s += " " + node.attributes[i].nodeName + "=\"" + Fleur.Serializer.escapeXML(node.attributes[i].nodeValue).replace('"', """) + "\""; - } - } - if (node.childNodes.length === 0) { - return s + (indent ? "/\x3E\n" : "/\x3E"); - } - s += indent && (node.childNodes[0].nodeType !== Fleur.Node.TEXT_NODE || node.childNodes[0].data.match(/^[ \t\n\r]*$/)) ? "\x3E\n" : "\x3E"; - if (cdataSectionElements.indexOf(" " + node.nodeName + " ") !== -1) { - for (i = 0, l = node.childNodes.length; i < l; i++) { - if (node.childNodes[i].nodeType === Fleur.Node.TEXT_NODE) { - s += "\x3C![CDATA["; - s += node.childNodes[i].data; - s += "]]\x3E"; - } else { - s += this._serializeXMLToString(node.childNodes[i], indent, offset + " ", cdataSectionElements); - } - } - } else { - for (i = 0, l = node.childNodes.length; i < l; i++) { - s += this._serializeXMLToString(node.childNodes[i], indent, offset + " ", cdataSectionElements); - } - } - return s + (indent && (node.childNodes[0].nodeType !== Fleur.Node.TEXT_NODE || node.childNodes[0].data.match(/^[ \t\n\r]*$/)) ? offset + "\x3C/" : "\x3C/") + node.nodeName + (indent ? "\x3E\n" : "\x3E"); - case Fleur.Node.TEXT_NODE: - if (indent && node.data.match(/^[ \t\n\r]*$/) && node.parentNode.childNodes.length !== 1) { - return ""; - } - return Fleur.Serializer.escapeXML(node.data); - case Fleur.Node.CDATA_NODE: - return (indent ? offset + "\x3C![CDATA[" : "\x3C![CDATA[") + node.data + (indent ? "]]\x3E\n" : "]]\x3E"); - case Fleur.Node.PROCESSING_INSTRUCTION_NODE: - return (indent ? offset + "\x3C?" : "\x3C?") + node.nodeName + " " + node.nodeValue + (indent ? "?\x3E\n" : "?\x3E"); - case Fleur.Node.COMMENT_NODE: - return (indent ? offset + "\x3C!--" : "\x3C!--") + node.data + (indent ? "--\x3E\n" : "--\x3E"); - case Fleur.Node.DOCUMENT_NODE: - s = '\x3C?xml version="1.0" encoding="UTF-8"?\x3E\r\n'; - for (i = 0, l = node.childNodes.length; i < l; i++) { - s += this._serializeXMLToString(node.childNodes[i], indent, offset, cdataSectionElements); - } - return s; - } - }; - Fleur.Serializer.prototype.serializeToString = function(node, mediatype, indent, cdataSectionElements) { - var media = mediatype.split(";"), config = {}, param, paramreg = /^\s*(\S*)\s*=\s*(\S*)\s*$/, i = 1, l = media.length, ser; - while (i < l) { - param = paramreg.exec(media[i]); - config[param[1]] = param[2]; - i++; - } - switch (media[0].replace(/^\s+|\s+$/gm,'')) { - case "text/xml": - case "application/xml": - ser = this._serializeXMLToString(node, indent, "", " " + cdataSectionElements + " "); - if (indent && ser.charAt(ser.length - 1) === "\n") { - ser = ser.substr(0, ser.length - 1); - } - return ser; - } - }; - Fleur.XMLSerializer = function() {}; - Fleur.XMLSerializer.prototype = new Fleur.Serializer(); - Fleur.XMLSerializer.prototype.serializeToString = function(node, indent, cdataSectionElements) { - return Fleur.Serializer.prototype.serializeToString.call(this, node, "application/xml", indent, cdataSectionElements); - }; - Fleur.Xlength = 0; - Fleur.XQueryXNames = [["http://www.w3.org/2005/XQueryX", "http://www.w3.org/2000/xmlns/", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/2007/xquery-update-10"], []]; - Fleur.XQueryX = {}; - Fleur.XQueryXNames[1][Fleur.XQueryX.NCName = Fleur.Xlength++] = [1, 0, "xqx:NCName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.QName = Fleur.Xlength++] = [1, 0, "xqx:QName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.URIExpr = Fleur.Xlength++] = [1, 0, "xqx:URIExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.Wildcard = Fleur.Xlength++] = [1, 0, "xqx:Wildcard"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.addOp = Fleur.Xlength++] = [1, 0, "xqx:addOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.allowingEmpty = Fleur.Xlength++] = [1, 0, "xqx:allowingEmpty"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.andOp = Fleur.Xlength++] = [1, 0, "xqx:andOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.annotation = Fleur.Xlength++] = [1, 0, "xqx:annotation"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.annotationName = Fleur.Xlength++] = [1, 0, "xqx:annotationName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.anyElementTest = Fleur.Xlength++] = [1, 0, "xqx:anyElementTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.anyFunctionTest = Fleur.Xlength++] = [1, 0, "xqx:anyFunctionTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.anyItemType = Fleur.Xlength++] = [1, 0, "xqx:anyItemType"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.anyKindTest = Fleur.Xlength++] = [1, 0, "xqx:anyKindTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.arrayConstructor = Fleur.Xlength++] = [1, 0, "xqx:arrayConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.argExpr = Fleur.Xlength++] = [1, 0, "xqx:argExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.argumentPlaceholder = Fleur.Xlength++] = [1, 0, "xqx:argumentPlaceholder"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.arguments = Fleur.Xlength++] = [1, 0, "xqx:arguments"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.arithmeticOp = Fleur.Xlength++] = [1, 0, "xqx:arithmeticOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.arrayTest = Fleur.Xlength++] = [1, 0, "xqx:arrayTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.atomicType = Fleur.Xlength++] = [1, 0, "xqx:atomicType"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.attributeConstructor = Fleur.Xlength++] = [1, 0, "xqx:attributeConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.attributeList = Fleur.Xlength++] = [1, 0, "xqx:attributeList"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.attributeName = Fleur.Xlength++] = [1, 0, "xqx:attributeName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.attributeTest = Fleur.Xlength++] = [1, 0, "xqx:attributeTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.attributeValue = Fleur.Xlength++] = [1, 0, "xqx:attributeValue"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.attributeValueExpr = Fleur.Xlength++] = [1, 0, "xqx:attributeValueExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.baseUriDecl = Fleur.Xlength++] = [1, 0, "xqx:baseUriDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.bindingSequence = Fleur.Xlength++] = [1, 0, "xqx:bindingSequence"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.boundarySpaceDecl = Fleur.Xlength++] = [1, 0, "xqx:boundarySpaceDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.castExpr = Fleur.Xlength++] = [1, 0, "xqx:castExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.castableExpr = Fleur.Xlength++] = [1, 0, "xqx:castableExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.catchClause = Fleur.Xlength++] = [1, 0, "xqx:catchClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.catchErrorList = Fleur.Xlength++] = [1, 0, "xqx:catchErrorList"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.catchExpr = Fleur.Xlength++] = [1, 0, "xqx:catchExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.collation = Fleur.Xlength++] = [1, 0, "xqx:collation"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.commentTest = Fleur.Xlength++] = [1, 0, "xqx:commentTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.comparisonOp = Fleur.Xlength++] = [1, 0, "xqx:comparisonOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.computedAttributeConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedAttributeConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.computedCommentConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedCommentConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.computedDocumentConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedDocumentConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.computedElementConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedElementConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.computedEntryConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedEntryConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.computedNamespaceConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedNamespaceConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.computedPIConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedPIConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.computedTextConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedTextConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.constantExpr = Fleur.Xlength++] = [1, 0, "xqx:constantExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.constructionDecl = Fleur.Xlength++] = [1, 0, "xqx:constructionDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.constructorFunctionExpr = Fleur.Xlength++] = [1, 0, "xqx:constructorFunctionExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.contentExpr = Fleur.Xlength++] = [1, 0, "xqx:contentExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.contextItemDecl = Fleur.Xlength++] = [1, 0, "xqx:contextItemDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.contextItemExpr = Fleur.Xlength++] = [1, 0, "xqx:contextItemExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.copyNamespacesDecl = Fleur.Xlength++] = [1, 0, "xqx:copyNamespacesDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.countClause = Fleur.Xlength++] = [1, 0, "xqx:countClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.currentItem = Fleur.Xlength++] = [1, 0, "xqx:currentItem"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.decimalConstantExpr = Fleur.Xlength++] = [1, 0, "xqx:decimalConstantExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatDecl = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatName = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatParam = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatParam"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatParamName = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatParamName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatParamValue = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatParamValue"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.defaultCollationDecl = Fleur.Xlength++] = [1, 0, "xqx:defaultCollationDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.defaultElementNamespace = Fleur.Xlength++] = [1, 0, "xqx:defaultElementNamespace"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.defaultNamespaceCategory = Fleur.Xlength++] = [1, 0, "xqx:defaultNamespaceCategory"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.defaultNamespaceDecl = Fleur.Xlength++] = [1, 0, "xqx:defaultNamespaceDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.divOp = Fleur.Xlength++] = [1, 0, "xqx:divOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.documentTest = Fleur.Xlength++] = [1, 0, "xqx:documentTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.doubleConstantExpr = Fleur.Xlength++] = [1, 0, "xqx:doubleConstantExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.doubleMapExpr = Fleur.Xlength++] = [1, 0, "xqx:doubleMapExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.dynamicFunctionInvocationExpr = Fleur.Xlength++] = [1, 0, "xqx:dynamicFunctionInvocationExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.elementConstructor = Fleur.Xlength++] = [1, 0, "xqx:elementConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.elementContent = Fleur.Xlength++] = [1, 0, "xqx:elementContent"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.elementName = Fleur.Xlength++] = [1, 0, "xqx:elementName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.elementTest = Fleur.Xlength++] = [1, 0, "xqx:elementTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.elseClause = Fleur.Xlength++] = [1, 0, "xqx:elseClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.emptyOrderingDecl = Fleur.Xlength++] = [1, 0, "xqx:emptyOrderingDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.emptyOrderingMode = Fleur.Xlength++] = [1, 0, "xqx:emptyOrderingMode"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.encoding = Fleur.Xlength++] = [1, 0, "xqx:encoding"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.endExpr = Fleur.Xlength++] = [1, 0, "xqx:endExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.entryTest = Fleur.Xlength++] = [1, 0, "xqx:entryTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.eqOp = Fleur.Xlength++] = [1, 0, "xqx:eqOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.equalOp = Fleur.Xlength++] = [1, 0, "xqx:equalOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.exceptOp = Fleur.Xlength++] = [1, 0, "xqx:exceptOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.expr = Fleur.Xlength++] = [1, 0, "xqx:expr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.extensionExpr = Fleur.Xlength++] = [1, 0, "xqx:extensionExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.external = Fleur.Xlength++] = [1, 0, "xqx:external"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.externalDefinition = Fleur.Xlength++] = [1, 0, "xqx:externalDefinition"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.filterExpr = Fleur.Xlength++] = [1, 0, "xqx:filterExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.firstOperand = Fleur.Xlength++] = [1, 0, "xqx:firstOperand"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.flworExpr = Fleur.Xlength++] = [1, 0, "xqx:flworExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.forClause = Fleur.Xlength++] = [1, 0, "xqx:forClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.forClauseItem = Fleur.Xlength++] = [1, 0, "xqx:forClauseItem"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.forExpr = Fleur.Xlength++] = [1, 0, "xqx:forExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.forLetClauseItemExtensions = Fleur.Xlength++] = [1, 0, "xqx:forLetClauseItemExtensions"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.functionBody = Fleur.Xlength++] = [1, 0, "xqx:functionBody"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.functionCallExpr = Fleur.Xlength++] = [1, 0, "xqx:functionCallExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.functionDecl = Fleur.Xlength++] = [1, 0, "xqx:functionDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.functionItem = Fleur.Xlength++] = [1, 0, "xqx:functionItem"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.functionName = Fleur.Xlength++] = [1, 0, "xqx:functionName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.geOp = Fleur.Xlength++] = [1, 0, "xqx:geOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.generalComparisonOp = Fleur.Xlength++] = [1, 0, "xqx:generalComparisonOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.greaterThanOp = Fleur.Xlength++] = [1, 0, "xqx:greaterThanOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.greaterThanOrEqualOp = Fleur.Xlength++] = [1, 0, "xqx:greaterThanOrEqualOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.groupByClause = Fleur.Xlength++] = [1, 0, "xqx:groupByClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.groupVarInitialize = Fleur.Xlength++] = [1, 0, "xqx:groupVarInitialize"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.groupingSpec = Fleur.Xlength++] = [1, 0, "xqx:groupingSpec"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.gtOp = Fleur.Xlength++] = [1, 0, "xqx:gtOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.idivOp = Fleur.Xlength++] = [1, 0, "xqx:idivOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.ifClause = Fleur.Xlength++] = [1, 0, "xqx:ifClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.ifThenElseExpr = Fleur.Xlength++] = [1, 0, "xqx:ifThenElseExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.inheritMode = Fleur.Xlength++] = [1, 0, "xqx:inheritMode"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.inlineFunctionExpr = Fleur.Xlength++] = [1, 0, "xqx:inlineFunctionExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.instanceOfExpr = Fleur.Xlength++] = [1, 0, "xqx:instanceOfExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.integerConstantExpr = Fleur.Xlength++] = [1, 0, "xqx:integerConstantExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.intersectOp = Fleur.Xlength++] = [1, 0, "xqx:intersectOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.isOp = Fleur.Xlength++] = [1, 0, "xqx:isOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.itemType = Fleur.Xlength++] = [1, 0, "xqx:itemType"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.javascriptImport = Fleur.Xlength++] = [1, 0, "xqx:javascriptImport"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.kindTest = Fleur.Xlength++] = [1, 0, "xqx:kindTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.leOp = Fleur.Xlength++] = [1, 0, "xqx:leOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.lessThanOp = Fleur.Xlength++] = [1, 0, "xqx:lessThanOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.lessThanOrEqualOp = Fleur.Xlength++] = [1, 0, "xqx:lessThanOrEqualOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.letClause = Fleur.Xlength++] = [1, 0, "xqx:letClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.letClauseItem = Fleur.Xlength++] = [1, 0, "xqx:letClauseItem"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.letExpr = Fleur.Xlength++] = [1, 0, "xqx:letExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.libraryModule = Fleur.Xlength++] = [1, 0, "xqx:libraryModule"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.logicalOp = Fleur.Xlength++] = [1, 0, "xqx:logicalOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.lookup = Fleur.Xlength++] = [1, 0, "xqx:lookup"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.ltOp = Fleur.Xlength++] = [1, 0, "xqx:ltOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.mainModule = Fleur.Xlength++] = [1, 0, "xqx:mainModule"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.mapConstructor = Fleur.Xlength++] = [1, 0, "xqx:mapConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.mapConstructorEntry = Fleur.Xlength++] = [1, 0, "xqx:mapConstructorEntry"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.mapKeyExpr = Fleur.Xlength++] = [1, 0, "xqx:mapKeyExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.mapTest = Fleur.Xlength++] = [1, 0, "xqx:mapTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.mapValueExpr = Fleur.Xlength++] = [1, 0, "xqx:mapValueExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.modOp = Fleur.Xlength++] = [1, 0, "xqx:modOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.module = Fleur.Xlength++] = [1, 0, "xqx:module"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.moduleDecl = Fleur.Xlength++] = [1, 0, "xqx:moduleDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.moduleImport = Fleur.Xlength++] = [1, 0, "xqx:moduleImport"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.multidimExpr = Fleur.Xlength++] = [1, 0, "xqx:multidimExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.multiplyOp = Fleur.Xlength++] = [1, 0, "xqx:multiplyOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.name = Fleur.Xlength++] = [1, 0, "xqx:name"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.nameTest = Fleur.Xlength++] = [1, 0, "xqx:nameTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.namedFunctionRef = Fleur.Xlength++] = [1, 0, "xqx:namedFunctionRef"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.namespaceDecl = Fleur.Xlength++] = [1, 0, "xqx:namespaceDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.namespaceDeclaration = Fleur.Xlength++] = [1, 0, "xqx:namespaceDeclaration"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.namespacePrefix = Fleur.Xlength++] = [1, 0, "xqx:namespacePrefix"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.namespaceTest = Fleur.Xlength++] = [1, 0, "xqx:namespaceTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.neOp = Fleur.Xlength++] = [1, 0, "xqx:neOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.nextItem = Fleur.Xlength++] = [1, 0, "xqx:nextItem"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.nillable = Fleur.Xlength++] = [1, 0, "xqx:nillable"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.nodeAfterOp = Fleur.Xlength++] = [1, 0, "xqx:nodeAfterOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.nodeBeforeOp = Fleur.Xlength++] = [1, 0, "xqx:nodeBeforeOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.nodeComparisonOp = Fleur.Xlength++] = [1, 0, "xqx:nodeComparisonOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.notEqualOp = Fleur.Xlength++] = [1, 0, "xqx:notEqualOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.occurrenceIndicator = Fleur.Xlength++] = [1, 0, "xqx:occurrenceIndicator"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.operand = Fleur.Xlength++] = [1, 0, "xqx:operand"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.operatorExpr = Fleur.Xlength++] = [1, 0, "xqx:operatorExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.optionContents = Fleur.Xlength++] = [1, 0, "xqx:optionContents"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.optionDecl = Fleur.Xlength++] = [1, 0, "xqx:optionDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.optionName = Fleur.Xlength++] = [1, 0, "xqx:optionName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.optional = Fleur.Xlength++] = [1, 0, "xqx:optional"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.orOp = Fleur.Xlength++] = [1, 0, "xqx:orOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.orderByClause = Fleur.Xlength++] = [1, 0, "xqx:orderByClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.orderByExpr = Fleur.Xlength++] = [1, 0, "xqx:orderByExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.orderBySpec = Fleur.Xlength++] = [1, 0, "xqx:orderBySpec"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.orderComparisonOp = Fleur.Xlength++] = [1, 0, "xqx:orderComparisonOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.orderModifier = Fleur.Xlength++] = [1, 0, "xqx:orderModifier"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.orderedExpr = Fleur.Xlength++] = [1, 0, "xqx:orderedExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.orderingKind = Fleur.Xlength++] = [1, 0, "xqx:orderingKind"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.orderingModeDecl = Fleur.Xlength++] = [1, 0, "xqx:orderingModeDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.param = Fleur.Xlength++] = [1, 0, "xqx:param"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.paramList = Fleur.Xlength++] = [1, 0, "xqx:paramList"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.paramTypeList = Fleur.Xlength++] = [1, 0, "xqx:paramTypeList"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.parenthesizedItemType = Fleur.Xlength++] = [1, 0, "xqx:parenthesizedItemType"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.pathExpr = Fleur.Xlength++] = [1, 0, "xqx:pathExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.piTarget = Fleur.Xlength++] = [1, 0, "xqx:piTarget"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.piTargetExpr = Fleur.Xlength++] = [1, 0, "xqx:piTargetExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.piTest = Fleur.Xlength++] = [1, 0, "xqx:piTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.piValueExpr = Fleur.Xlength++] = [1, 0, "xqx:piValueExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.positionalVariableBinding = Fleur.Xlength++] = [1, 0, "xqx:positionalVariableBinding"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.pragma = Fleur.Xlength++] = [1, 0, "xqx:pragma"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.pragmaContents = Fleur.Xlength++] = [1, 0, "xqx:pragmaContents"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.pragmaName = Fleur.Xlength++] = [1, 0, "xqx:pragmaName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.predicate = Fleur.Xlength++] = [1, 0, "xqx:predicate"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.predicateExpr = Fleur.Xlength++] = [1, 0, "xqx:predicateExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.predicates = Fleur.Xlength++] = [1, 0, "xqx:predicates"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.prefixElt = Fleur.Xlength++] = [1, 0, "xqx:prefix"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.prefixExpr = Fleur.Xlength++] = [1, 0, "xqx:prefixExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.preserveMode = Fleur.Xlength++] = [1, 0, "xqx:preserveMode"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.previousItem = Fleur.Xlength++] = [1, 0, "xqx:previousItem"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.prolog = Fleur.Xlength++] = [1, 0, "xqx:prolog"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.prologPartOneItem = Fleur.Xlength++] = [1, 0, "xqx:prologPartOneItem"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.prologPartTwoItem = Fleur.Xlength++] = [1, 0, "xqx:prologPartTwoItem"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.quantifiedExpr = Fleur.Xlength++] = [1, 0, "xqx:quantifiedExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.quantifiedExprInClause = Fleur.Xlength++] = [1, 0, "xqx:quantifiedExprInClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.quantifier = Fleur.Xlength++] = [1, 0, "xqx:quantifier"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.queryBody = Fleur.Xlength++] = [1, 0, "xqx:queryBody"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.rangeSequenceExpr = Fleur.Xlength++] = [1, 0, "xqx:rangeSequenceExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.resultExpr = Fleur.Xlength++] = [1, 0, "xqx:resultExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.returnClause = Fleur.Xlength++] = [1, 0, "xqx:returnClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.rootExpr = Fleur.Xlength++] = [1, 0, "xqx:rootExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.schemaAttributeTest = Fleur.Xlength++] = [1, 0, "xqx:schemaAttributeTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.schemaElementTest = Fleur.Xlength++] = [1, 0, "xqx:schemaElementTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.schemaImport = Fleur.Xlength++] = [1, 0, "xqx:schemaImport"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.secondOperand = Fleur.Xlength++] = [1, 0, "xqx:secondOperand"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.sequenceExpr = Fleur.Xlength++] = [1, 0, "xqx:sequenceExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.sequenceType = Fleur.Xlength++] = [1, 0, "xqx:sequenceType"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.sequenceTypeUnion = Fleur.Xlength++] = [1, 0, "xqx:sequenceTypeUnion"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.setOp = Fleur.Xlength++] = [1, 0, "xqx:setOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.simpleMapExpr = Fleur.Xlength++] = [1, 0, "xqx:simpleMapExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.singleType = Fleur.Xlength++] = [1, 0, "xqx:singleType"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.slidingWindowClause = Fleur.Xlength++] = [1, 0, "xqx:slidingWindowClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.sourceExpr = Fleur.Xlength++] = [1, 0, "xqx:sourceExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.stable = Fleur.Xlength++] = [1, 0, "xqx:stable"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.star = Fleur.Xlength++] = [1, 0, "xqx:star"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.startExpr = Fleur.Xlength++] = [1, 0, "xqx:startExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.stepExpr = Fleur.Xlength++] = [1, 0, "xqx:stepExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.stringConcatenateOp = Fleur.Xlength++] = [1, 0, "xqx:stringConcatenateOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.stringConstantExpr = Fleur.Xlength++] = [1, 0, "xqx:stringConstantExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.stringOp = Fleur.Xlength++] = [1, 0, "xqx:stringOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.subtractOp = Fleur.Xlength++] = [1, 0, "xqx:subtractOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.switchCaseExpr = Fleur.Xlength++] = [1, 0, "xqx:switchCaseExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.switchExpr = Fleur.Xlength++] = [1, 0, "xqx:switchExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.switchExprCaseClause = Fleur.Xlength++] = [1, 0, "xqx:switchExprCaseClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.switchExprDefaultClause = Fleur.Xlength++] = [1, 0, "xqx:switchExprDefaultClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.tagName = Fleur.Xlength++] = [1, 0, "xqx:tagName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.tagNameExpr = Fleur.Xlength++] = [1, 0, "xqx:tagNameExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.targetLocation = Fleur.Xlength++] = [1, 0, "xqx:targetLocation"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.targetLocationExpr = Fleur.Xlength++] = [1, 0, "xqx:targetLocationExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.targetNamespace = Fleur.Xlength++] = [1, 0, "xqx:targetNamespace"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.textTest = Fleur.Xlength++] = [1, 0, "xqx:textTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.thenClause = Fleur.Xlength++] = [1, 0, "xqx:thenClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.treatExpr = Fleur.Xlength++] = [1, 0, "xqx:treatExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.tryCatchExpr = Fleur.Xlength++] = [1, 0, "xqx:tryCatchExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.tryClause = Fleur.Xlength++] = [1, 0, "xqx:tryClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.tumblingWindowClause = Fleur.Xlength++] = [1, 0, "xqx:tumblingWindowClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.typeDeclaration = Fleur.Xlength++] = [1, 0, "xqx:typeDeclaration"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.typeName = Fleur.Xlength++] = [1, 0, "xqx:typeName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.typedFunctionTest = Fleur.Xlength++] = [1, 0, "xqx:typedFunctionTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.typedVariableBinding = Fleur.Xlength++] = [1, 0, "xqx:typedVariableBinding"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.typeswitchExpr = Fleur.Xlength++] = [1, 0, "xqx:typeswitchExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.typeswitchExprCaseClause = Fleur.Xlength++] = [1, 0, "xqx:typeswitchExprCaseClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.typeswitchExprDefaultClause = Fleur.Xlength++] = [1, 0, "xqx:typeswitchExprDefaultClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.unaryMinusOp = Fleur.Xlength++] = [1, 0, "xqx:unaryMinusOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.unaryPlusOp = Fleur.Xlength++] = [1, 0, "xqx:unaryPlusOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.unionOp = Fleur.Xlength++] = [1, 0, "xqx:unionOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.unorderedExpr = Fleur.Xlength++] = [1, 0, "xqx:unorderedExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.unaryLookup = Fleur.Xlength++] = [1, 0, "xqx:unaryLookup"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.uri = Fleur.Xlength++] = [1, 0, "xqx:uri"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.validateExpr = Fleur.Xlength++] = [1, 0, "xqx:validateExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.validationMode = Fleur.Xlength++] = [1, 0, "xqx:validationMode"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.value = Fleur.Xlength++] = [1, 0, "xqx:value"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.valueComparisonOp = Fleur.Xlength++] = [1, 0, "xqx:valueComparisonOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.valueExpr = Fleur.Xlength++] = [1, 0, "xqx:valueExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.varDecl = Fleur.Xlength++] = [1, 0, "xqx:varDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.varName = Fleur.Xlength++] = [1, 0, "xqx:varName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.varRef = Fleur.Xlength++] = [1, 0, "xqx:varRef"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.varValue = Fleur.Xlength++] = [1, 0, "xqx:varValue"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.variableBinding = Fleur.Xlength++] = [1, 0, "xqx:variableBinding"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.version = Fleur.Xlength++] = [1, 0, "xqx:version"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.versionDecl = Fleur.Xlength++] = [1, 0, "xqx:versionDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.voidSequenceType = Fleur.Xlength++] = [1, 0, "xqx:voidSequenceType"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.whereClause = Fleur.Xlength++] = [1, 0, "xqx:whereClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.winEndExpr = Fleur.Xlength++] = [1, 0, "xqx:winEndExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.winStartExpr = Fleur.Xlength++] = [1, 0, "xqx:winStartExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.windowClause = Fleur.Xlength++] = [1, 0, "xqx:windowClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.windowEndCondition = Fleur.Xlength++] = [1, 0, "xqx:windowEndCondition"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.windowStartCondition = Fleur.Xlength++] = [1, 0, "xqx:windowStartCondition"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.windowVars = Fleur.Xlength++] = [1, 0, "xqx:windowVars"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.xpathAxis = Fleur.Xlength++] = [1, 0, "xqx:xpathAxis"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.URI = Fleur.Xlength++] = [2, 0, "xqx:URI"]; - Fleur.XQueryXNames[1][Fleur.XQueryX["default"] = Fleur.Xlength++] = [2, 0, "xqx:default"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.nondeterministic = Fleur.Xlength++] = [2, 0, "xqx:nondeterministic"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.onlyEnd = Fleur.Xlength++] = [2, 0, "xqx:onlyEnd"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.prefix = Fleur.Xlength++] = [2, 0, "xqx:prefix"]; - Fleur.XQueryXNames[1][Fleur.XQueryX["private"] = Fleur.Xlength++] = [2, 0, "xqx:private"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.sequentialFunction = Fleur.Xlength++] = [2, 0, "xqx:sequentialFunction"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.updatingFunction = Fleur.Xlength++] = [2, 0, "xqx:updatingFunction"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.xqx = Fleur.Xlength++] = [2, 1, "xmlns:xqx"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.xsi = Fleur.Xlength++] = [2, 1, "xmlns:xsi"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.schemaLocation = Fleur.Xlength++] = [2, 2, "xsi:schemaLocation"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.xqxuf = Fleur.Xlength++] = [2, 1, "xmlns:xqxuf"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.copyModifyExpr = Fleur.Xlength++] = [1, 3, "xqxuf:copyModifyExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.copySource = Fleur.Xlength++] = [1, 3, "xqxuf:copySource"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.deleteExpr = Fleur.Xlength++] = [1, 3, "xqxuf:deleteExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.insertAfter = Fleur.Xlength++] = [1, 3, "xqxuf:insertAfter"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.insertAsFirst = Fleur.Xlength++] = [1, 3, "xqxuf:insertAsFirst"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.insertAsLast = Fleur.Xlength++] = [1, 3, "xqxuf:insertAsLast"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.insertBefore = Fleur.Xlength++] = [1, 3, "xqxuf:insertBefore"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.insertExpr = Fleur.Xlength++] = [1, 3, "xqxuf:insertExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.insertInto = Fleur.Xlength++] = [1, 3, "xqxuf:insertInto"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.modifyExpr = Fleur.Xlength++] = [1, 3, "xqxuf:modifyExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.newNameExpr = Fleur.Xlength++] = [1, 3, "xqxuf:newNameExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.renameExpr = Fleur.Xlength++] = [1, 3, "xqxuf:renameExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.replaceExpr = Fleur.Xlength++] = [1, 3, "xqxuf:replaceExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.replaceValue = Fleur.Xlength++] = [1, 3, "xqxuf:replaceValue"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.replacementExpr = Fleur.Xlength++] = [1, 3, "xqxuf:replacementExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.returnExpr = Fleur.Xlength++] = [1, 3, "xqxuf:returnExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.revalidationDecl = Fleur.Xlength++] = [1, 3, "xqxuf:revalidationDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.sourceExprUf = Fleur.Xlength++] = [1, 3, "xqxuf:sourceExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.targetExpr = Fleur.Xlength++] = [1, 3, "xqxuf:targetExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.transformCopies = Fleur.Xlength++] = [1, 3, "xqxuf:transformCopies"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.transformCopy = Fleur.Xlength++] = [1, 3, "xqxuf:transformCopy"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.transformExpr = Fleur.Xlength++] = [1, 3, "xqxuf:transformExpr"]; - Fleur.XPathEvaluator = function() {}; - Fleur.XPathEvaluator._precedence = "././/.:.as.&0.!.!!.&1.~+.~-.&2.cast as.&3.castable as.&4.treat as.&5.instance of.&6.intersect.except.&7.|.union.&8.div.mod.*.idiv.&9.+.-.&10.to.&11.||.&12.eq.ne.lt.le.gt.ge.<.>.<=.>=.is.<<.>>.=.!=.&13.and.&14.or.&15.allowing.&16.at.&17.:=.in.&18.after.before.into.with.value.&19.node.nodes.&20.~~ascending.~~descending.empty.&28.~,.&29.for.let.group by.order by.stable order by.count.where.some.every.&30.then.catch.&31.else.return.satisfies.&32.,.&50.;.&51."; - Fleur.XPathEvaluator._rightgrouping1 = Fleur.XPathEvaluator._precedence.substr(Fleur.XPathEvaluator._precedence.indexOf(".then.") + 6); - Fleur.XPathEvaluator._rightgrouping1 = Fleur.XPathEvaluator._rightgrouping1.substr(Fleur.XPathEvaluator._rightgrouping1.indexOf("&") + 1); - Fleur.XPathEvaluator._rightgrouping1 = parseInt(Fleur.XPathEvaluator._rightgrouping1.substr(0, Fleur.XPathEvaluator._rightgrouping1.indexOf(".")), 10); - Fleur.XPathEvaluator._rightgrouping2 = Fleur.XPathEvaluator._precedence.substr(Fleur.XPathEvaluator._precedence.indexOf(".return.") + 6); - Fleur.XPathEvaluator._rightgrouping2 = Fleur.XPathEvaluator._rightgrouping2.substr(Fleur.XPathEvaluator._rightgrouping2.indexOf("&") + 1); - Fleur.XPathEvaluator._rightgrouping2 = parseInt(Fleur.XPathEvaluator._rightgrouping2.substr(0, Fleur.XPathEvaluator._rightgrouping2.indexOf(".")), 10); - Fleur.XPathEvaluator._opcodes = "./;stepExpr.|;unionOp.union;unionOp.div;divOp.mod;modOp.*;multiplyOp.idiv;idivOp.+;addOp.-;subtractOp.to;toOp.||;stringConcatenateOp.eq;eqOp.ne;neOp.lt;ltOp.le;leOp.gt;gtOp.ge;geOp.<;lessThanOp.>;greaterThanOp.<=;lessThanOrEqualOp.>=;greaterThanOrEqualOp.is;isOp.<<;nodeBeforeOp.>>;nodeAfterOp.=;equalOp.!=;notEqualOp.and;andOp.or;orOp.,;argExpr."; - Fleur.XPathEvaluator._skipComment = function(s, offset) { - var i = offset; - var c = s.charAt(i); - var d = s.charAt(i + 1); - var l = s.length; - do { - if (c === "(" && d === ":") { - i = Fleur.XPathEvaluator._skipComment(s, i + 2); - } else if (c === ":" && d === ")") { - return i + 1; - } - c = s.charAt(++i); - d = s.charAt(i + 1); - } while (i < l); - }; - Fleur.XPathEvaluator._skipSpaces = function(s, offset) { - var i = offset; - var c = s.charAt(i); - var l = s.length; - do { - if (c === "(" && s.charAt(i + 1) === ":") { - i = Fleur.XPathEvaluator._skipComment(s, i + 2); - } else if (c !== "\n" && c !== "\r" && c !== "\t" && c !== " ") { - return i; - } - c = s.charAt(++i); - } while (i < l); - return i; - }; - Fleur.XPathEvaluator._getName = function(s) { - var i = 0; - var o = s.charAt(0); - var prev = ""; - while (o !== "" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:*{".indexOf(o) !== -1) { - if (o === "*") { - if (i > 0 && (s.charAt(i - 1) === ":" || s.charAt(i - 1) === "}")) { - i++; - break; - } else if (s.charAt(i + 1) !== ":") { - if (i === 0) { - i++; - } - break; - } - } - if (o === "{") { - if (prev !== "Q") { - return s.substr(0, i); - } - while (o !== "" && o !== "}") { - o = s.charAt(++i); - } - } - prev = o; - o = s.charAt(++i); - } - if (o === "#") { - o = s.charAt(++i); - while (o !== "" && "0123456789".indexOf(o) !== -1) { - o = s.charAt(++i); - } - } - return s.substr(0, i); - }; - Fleur.XPathEvaluator._getNameStep = function(s, attr) { - var n = Fleur.XPathEvaluator._getName(s); - var fctind = n.indexOf("#"); - if (fctind !== -1) { - var pindex = n.indexOf(":"); - if (pindex === -1) { - return n.length + ".[Fleur.XQueryX.namedFunctionRef,[[Fleur.XQueryX.functionName,['" + n.substr(0, fctind) + "']],[Fleur.XQueryX.integerConstantExpr,[[Fleur.XQueryX.value,['" + n.substr(fctind + 1) + "']]]]]]"; - } - return n.length + ".[Fleur.XQueryX.namedFunctionRef,[[Fleur.XQueryX.functionName,['" + n.substr(0, fctind).substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + n.substr(0, pindex) + "']]]],[Fleur.XQueryX.integerConstantExpr,[[Fleur.XQueryX.value,['" + n.substr(fctind + 1) + "']]]]]]"; - } - var aind = n.indexOf("::"); - var axis = aind !== -1 ? n.substr(0, aind) : attr ? "attribute" : "child"; - var n2 = aind !== -1 ? n.substr(aind + 2) : n; - var eq = n2.substr(0, 2) === "Q{"; - var sind = eq ? n2.indexOf("}") : n2.indexOf(":"); - var n3 = sind !== -1 ? n2.substr(sind + 1) : n2; - var nsp = eq ? n2.substr(2, sind - 2) : sind !== -1 ? n2.substr(0, sind) : ""; - var ntest = n3 === "*" || nsp === "*" ? "[Fleur.XQueryX.Wildcard,[" + (n3 !== "*" ? "[Fleur.XQueryX.star,[]],[Fleur.XQueryX.NCName,['" + n3 + "']]" : "") + "]]" : "[Fleur.XQueryX.nameTest,['" + n3 + "'" + (eq || sind !== -1 ? ",[" + (eq ? "Fleur.XQueryX.URI" : "Fleur.XQueryX.prefix") + ",['" + nsp + "']]" : "") + "]]"; - return (n.length + attr) + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['" + axis + "']]," + ntest + "]]]]"; - }; - Fleur.XPathEvaluator._pathExprFormat = function(s, p) { - if (s.substr(0, 25) === "[Fleur.XQueryX.pathExpr,[") { - return s.substr(25, s.length - 29) + p + "]]"; - } - return "[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[" + s + "]]" + p + "]]"; - }; - Fleur.XPathEvaluator._calc = function(args, ops, opprec) { - var curop = parseInt(ops.split(".")[1], 10); - if ((ops === "" || curop > opprec || opprec === 31) || (curop >= opprec && (curop === Fleur.XPathEvaluator._rightgrouping1 || curop === Fleur.XPathEvaluator._rightgrouping2))) { - return args.length + "." + args + ops.length + "." + ops; - } - var op0 = ops.substr(ops.indexOf(".") + 1, parseInt(ops.split(".")[0], 10)); - var op = op0.substr(op0.indexOf(".") + 1); - var arg2len = args.substr(0, args.indexOf(".")); - var arg2val = args.substr(args.indexOf(".") + 1).substr(0, parseInt(arg2len, 10)); - var arg2val2, arg2val3; - var args3, arg1len, arg1val, arg1val2, arg1val3; - if (op.startsWith("~~")) { - args3 = args; - arg1len = arg2len; - arg1val = arg2val; - } else { - args3 = args.substr(arg2len.length + 1 + parseInt(arg2len, 10)); - arg1len = args3.substr(0, args3.indexOf(".")); - arg1val = args3.substr(args3.indexOf(".") + 1).substr(0, parseInt(arg1len, 10)); - } - var arg; - var occ; - switch (op) { - case ";": - if (arg1val.substr(0, 58) === "[Fleur.XQueryX.sequenceExpr,[[Fleur.XQueryX.multidimExpr,[") { - arg = "[Fleur.XQueryX.sequenceExpr,[[Fleur.XQueryX.multidimExpr,[" + arg1val.substr(58, arg1val.length - 62) + "," + arg2val + "]]]]"; - } else { - arg = "[Fleur.XQueryX.sequenceExpr,[[Fleur.XQueryX.multidimExpr,[" + arg1val + "," + arg2val + "]]]]"; - } - break; - case ",": - if (ops.substr(0, 13) === "4.50.,5.999.(") { - if (arg1val.substr(0, 26) === "[Fleur.XQueryX.arguments,[") { - arg = arg1val.substr(0, arg1val.length - 2) + "," + arg2val + "]]"; - } else { - arg = "[Fleur.XQueryX.arguments,[" + arg1val + "," + arg2val + "]]"; - } - } else if (ops.substr(0, 13) === "4.50.,5.999.q") { - arg = arg1val + "," + arg2val; - } else if (ops.startsWith("4.50.,")) { - if (arg1val.substr(0, 36) === "[Fleur.XQueryX.mapConstructorEntry,[") { - arg = arg1val + "," + arg2val; - } else if (arg1val.substr(0, 29) === "[Fleur.XQueryX.sequenceExpr,[" && arg1val !== "[Fleur.XQueryX.sequenceExpr,[]]") { - arg = arg1val.substr(0, arg1val.length - 2) + "," + arg2val + "]]"; - } else { - arg = "[Fleur.XQueryX.sequenceExpr,[" + arg1val + "," + arg2val + "]]"; - } - } else { - arg = arg1val + "," + arg2val; - } - break; - case "~,": - if (arg1val.substr(0, 29) === "[Fleur.XQueryX.letClauseItem," || arg1val.substr(0, 27) === "[Fleur.XQueryX.groupBySpec,") { - arg = arg1val + "," + arg2val; - } else if (arg1val.substr(0, 25) === "[Fleur.XQueryX.letClause,") { - if (arg2val.substr(0, 25) === "Fleur.XQueryX.letClause,") { - arg = arg1val.substr(0, arg1val.length - 2) + "," + arg2val.substr(25); - } else { - arg = arg1val.substr(0, arg1val.length - 2) + "," + arg2val + "]]"; - } - } else { - if (arg1val.substr(0, 27) !== "[Fleur.XQueryX.orderBySpec,") { - arg = "[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg1val + "]]]]"; - } else { - arg = arg1val; - } - arg += ","; - if (arg2val.substr(0, 27) !== "[Fleur.XQueryX.orderBySpec,") { - arg += "[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg2val + "]]]]"; - } else { - arg += arg2val; - } - } - break; - case "//": - arg = "[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg1val, "") + ",[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['descendant-or-self']],[Fleur.XQueryX.anyKindTest,[]]]]," + Fleur.XPathEvaluator._pathExprFormat(arg2val, "") + "]]"; - break; - case "/": - arg = "[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg1val, "") + (arg2val !== "" ? "," + Fleur.XPathEvaluator._pathExprFormat(arg2val, "") : "") + "]]"; - break; - case "!!": - arg = "[Fleur.XQueryX.doubleMapExpr,[[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg1val, "") + "]],[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg2val, "") + "]]]]"; - break; - case "!": - arg = "[Fleur.XQueryX.simpleMapExpr,[[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg1val, "") + "]],[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg2val, "") + "]]]]"; - break; - case "|": - if (ops.startsWith("3.8.|8.31.catch")) { - if (arg1val.substr(0, 24) === "[Fleur.XQueryX.pathExpr,") { - arg1val2 = arg1val.substr(86); - arg1val = arg1val2.substr(0, arg1val2.length - 4); - } - if (arg2val.substr(0, 24) === "[Fleur.XQueryX.pathExpr,") { - arg2val2 = arg2val.substr(86); - arg2val = arg2val2.substr(0, arg2val2.length - 4); - arg = arg1val + "," + arg2val; - } else { - arg = "[Fleur.XQueryX.catchErrorList,[" + arg1val + "," + arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.catchErrorList,[") + 31); - } - } else { - arg = "[Fleur.XQueryX.unionOp,[[Fleur.XQueryX.firstOperand,[" + arg1val + "]],[Fleur.XQueryX.secondOperand,[" + arg2val + "]]]]"; - } - break; - case ":": - arg = "[Fleur.XQueryX.mapConstructorEntry,[[Fleur.XQueryX.mapKeyExpr,[" + arg1val + "]],[Fleur.XQueryX.mapValueExpr,[" + arg2val + "]]]]"; - break; - case "?": - break; - case "to": - arg = "[Fleur.XQueryX.rangeSequenceExpr,[[Fleur.XQueryX.startExpr,[" + arg1val + "]],[Fleur.XQueryX.endExpr,[" + arg2val + "]]]]"; - break; - case "~-": - arg = "[Fleur.XQueryX.unaryMinusOp,[[Fleur.XQueryX.operand,[" + arg2val + "]]]]"; - break; - case "~+": - arg = "[Fleur.XQueryX.unaryPlusOp,[[Fleur.XQueryX.operand,[" + arg2val + "]]]]"; - break; - case "allowing": - arg = "[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.allowingEmpty,[]]"; - break; - case "at": - if (arg1val.substr(0, 36) === "[Fleur.XQueryX.typedVariableBinding,") { - arg = arg1val + ",[Fleur.XQueryX.positionalVariableBinding,[" + arg2val.substr(0, arg2val.length - 4).substr(44) + "]]"; - } else { - arg = "[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.positionalVariableBinding,[" + arg2val.substr(0, arg2val.length - 4).substr(44) + "]]"; - } - break; - case "in": - if (ops.substr(ops.length - 7) === "5.999.q") { - arg = "[Fleur.XQueryX.quantifiedExprInClause,[[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.sourceExpr,[" + arg2val + "]]]]"; - } else if (arg1val.substr(0, 36) === "[Fleur.XQueryX.typedVariableBinding,") { - arg = "[Fleur.XQueryX.forClause,[[Fleur.XQueryX.forClauseItem,[" + arg1val + ",[Fleur.XQueryX.forExpr,[" + arg2val + "]]]]]]"; - } else { - arg = "[Fleur.XQueryX.forClause,[[Fleur.XQueryX.forClauseItem,[[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.forExpr,[" + arg2val + "]]]]]]"; - } - break; - case "as": - if (arg2val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['last']]]]]]") { - arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertInto,[[Fleur.XQueryX.insertAsLast,[]]]]"; - } else if (arg2val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['first']]]]]]") { - arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertInto,[[Fleur.XQueryX.insertAsFirst,[]]]]"; - } else { - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); - arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); - arg = "[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]],[Fleur.XQueryX.typeDeclaration,[" + arg2val3 + "]]"; - } - break; - case ":=": - if (ops.startsWith("5.18.:=11.30.group by") || ops.startsWith("5.18.:=5.29.~,11.30.group by")) { - if (arg1val.substr(0, 28) === "[Fleur.XQueryX.groupingSpec,") { - arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.groupVarInitialize,[[Fleur.XQueryX.varValue,[" + arg2val + "]]]]]]"; - } else { - arg = "[Fleur.XQueryX.groupingSpec,[[Fleur.XQueryX.varName,[" + arg1val.substr(44, arg1val.length - 48) + "]],[Fleur.XQueryX.groupVarInitialize,[[Fleur.XQueryX.varValue,[" + arg2val + "]]]]]]"; - } - } else if (arg1val.substr(0, 23) === "[Fleur.XQueryX.varName,") { - arg = "[Fleur.XQueryX.letClause,[[Fleur.XQueryX.letClauseItem,[[Fleur.XQueryX.typedVariableBinding,[" + arg1val + "]],[Fleur.XQueryX.letExpr,[" + arg2val + "]]]]]]"; - } else { - arg = "[Fleur.XQueryX.letClause,[[Fleur.XQueryX.letClauseItem,[[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.letExpr,[" + arg2val + "]]]]]]"; - } - break; - case "return": - arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.returnClause,[" + arg2val + "]]]]"; - break; - case "satisfies": - arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.predicateExpr,[" + arg2val + "]]]]"; - break; - case "cast as": - case "cast as?": - occ = op.charAt(7); - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); - arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); - arg = "[Fleur.XQueryX.castExpr,[[Fleur.XQueryX.argExpr,[" + arg1val + "]],[Fleur.XQueryX.singleType,[" + arg2val3 + (occ === "?" ? ",[Fleur.XQueryX.optional,[]]" : "") + "]]]]"; - break; - case "castable as": - case "castable as?": - occ = op.charAt(11); - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); - arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); - arg = "[Fleur.XQueryX.castableExpr,[[Fleur.XQueryX.argExpr,[" + arg1val + "]],[Fleur.XQueryX.singleType,[" + arg2val3 + (occ === "?" ? ",[Fleur.XQueryX.optional,[]]" : "") + "]]]]"; - break; - case "treat as": - case "treat as+": - case "treat as?": - case "treat as*": - occ = op.charAt(8); - if (arg2val.indexOf("[Fleur.XQueryX.nameTest,") !== -1) { - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); - arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); - } else if (arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") !== -1) { - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") + 86); - arg2val3 = arg2val2.substr(0, arg2val2.length - 4); - } else { - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['attribute']],") + 90); - arg2val3 = arg2val2.substr(0, arg2val2.length - 4); - } - arg = "[Fleur.XQueryX.treatExpr,[[Fleur.XQueryX.argExpr,[" + arg1val + "]],[Fleur.XQueryX.sequenceType,[" + arg2val3 + (occ !== "" ? ",[Fleur.XQueryX.occurrenceIndicator,['" + occ + "']]" : "") + "]]]]"; - break; - case "instance of": - case "instance of+": - case "instance of?": - case "instance of*": - occ = op.charAt(11); - if (arg2val.indexOf("[Fleur.XQueryX.nameTest,") !== -1) { - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); - arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); - } else if (arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") !== -1) { - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") + 86); - arg2val3 = arg2val2.substr(0, arg2val2.length - 4); - } else { - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['attribute']],") + 90); - arg2val3 = arg2val2.substr(0, arg2val2.length - 4); - } - arg = "[Fleur.XQueryX.instanceOfExpr,[[Fleur.XQueryX.argExpr,[" + arg1val + "]],[Fleur.XQueryX.sequenceType,[" + arg2val3 + (occ !== "" ? ",[Fleur.XQueryX.occurrenceIndicator,['" + occ + "']]" : "") + "]]]]"; - break; - case "then": - if (arg1val.substr(0, 95) === "[Fleur.XQueryX.functionCallExpr,[[Fleur.XQueryX.functionName,['if']],[Fleur.XQueryX.arguments,[") { - arg = "[Fleur.XQueryX.ifThenElseExpr,[[Fleur.XQueryX.ifClause,[" + arg1val.substr(0, arg1val.length - 4).substr(arg1val.indexOf(",[Fleur.XQueryX.arguments,[") + 27) + "]],[Fleur.XQueryX.thenClause,[" + arg2val + "]]]]"; - } - opprec = -1; - break; - case "else": - if (arg1val.substr(0, 30) === "[Fleur.XQueryX.ifThenElseExpr,") { - arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.elseClause,[" + arg2val + "]]]]"; - } - break; - case "catch": - if (arg1val.substr(0, 28) === "[Fleur.XQueryX.tryCatchExpr,") { - arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.catchClause,[" + arg2val + "]]]]"; - } - break; - case "let": - arg = arg1val + "," + arg2val; - break; - case "for": - arg = arg1val + "," + arg2val; - break; - case "group by": - arg = arg1val + ",[Fleur.XQueryX.groupByClause,[" + arg2val + "]]"; - break; - case "order by": - if (arg2val.substr(0, 27) === "[Fleur.XQueryX.orderBySpec,") { - arg = arg1val + ",[Fleur.XQueryX.orderByClause,[" + arg2val + "]]"; - } else { - arg = arg1val + ",[Fleur.XQueryX.orderByClause,[[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg2val + "]]]]]]"; - } - break; - case "~~ascending": - case "~~descending": - arg = "[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg1val + "]],[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.orderingKind,['" + op.substr(2) + "']]]]]]"; - break; - case "empty": - if (arg1val.substr(0,27) === "[Fleur.XQueryX.orderBySpec,") { - if (arg1val.endsWith(",[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.orderingKind,['ascending']]]]]]") || arg1val.endsWith(",[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.orderingKind,['descending']]]]]]")) { - arg = arg1val.substr(0, arg1val.length - 4) + ",[Fleur.XQueryX.emptyOrderingMode,['empty " + arg2val.substr(112, arg2val.length - 119) + "']]]]]]"; - } else { - arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.emptyOrderingMode,['empty " + arg2val.substr(112, arg2val.length - 119) + "']]]]]]"; - } - } else { - arg = "[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg1val + "]],[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.emptyOrderingMode,['empty " + arg2val.substr(112, arg2val.length - 119) + "']]]]]]"; - } - break; - case "where": - arg = arg1val + ",[Fleur.XQueryX.whereClause,[" + arg2val + "]]"; - break; - case "count": - arg = arg1val + ",[Fleur.XQueryX.countClause,[" + arg2val + "]]"; - break; - case "nodes": - if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['delete']]]]]]") { - arg = "[Fleur.XQueryX.deleteExpr,[[Fleur.XQueryX.targetExpr,[" + arg2val + "]]]]"; - } else if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['insert']]]]]]") { - arg = "[Fleur.XQueryX.insertExpr,[" + arg2val + "]]"; - } - break; - case "node": - if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['delete']]]]]]") { - arg = "[Fleur.XQueryX.deleteExpr,[[Fleur.XQueryX.targetExpr,[" + arg2val + "]]]]"; - } else if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['insert']]]]]]") { - arg = "[Fleur.XQueryX.insertExpr,[" + arg2val + "]]"; - } else if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['replace']]]]]]") { - arg = "[Fleur.XQueryX.replaceExpr,[" + arg2val + "]]"; - } else if (arg1val === "[Fleur.XQueryX.replaceValue,[]]") { - arg = "[Fleur.XQueryX.replaceExpr,[[Fleur.XQueryX.replaceValue,[]]," + arg2val + "]]"; - } - break; - case "into": - if (arg1val.substr(0, 28) === "[Fleur.XQueryX.sourceExprUf,") { - arg = arg1val + ",[Fleur.XQueryX.targetExpr,[" + arg2val + "]]"; - } else { - arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertInto,[]],[Fleur.XQueryX.targetExpr,[" + arg2val + "]]"; - } - break; - case "after": - arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertAfter,[]],[Fleur.XQueryX.targetExpr,[" + arg2val + "]]"; - break; - case "before": - arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertBefore,[]],[Fleur.XQueryX.targetExpr,[" + arg2val + "]]"; - break; - case "value": - if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['replace']]]]]]" && arg2val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['of']]]]]]") { - arg = "[Fleur.XQueryX.replaceValue,[]]"; - } - break; - case "with": - arg = "[Fleur.XQueryX.targetExpr,[" + arg1val + "]],[Fleur.XQueryX.replacementExpr,[" + arg2val + "]]"; - break; - default: - var opcode0 = Fleur.XPathEvaluator._opcodes.substr(Fleur.XPathEvaluator._opcodes.indexOf("." + op + ";") + op.length + 2); - var opcode = opcode0.substr(0, opcode0.indexOf(".")); - arg = "[Fleur.XQueryX." + opcode + ",[[Fleur.XQueryX.firstOperand,[" + arg1val + "]],[Fleur.XQueryX.secondOperand,[" + arg2val + "]]]]"; - } - var args2 = arg.length + "." + arg + args3.substr(arg1len.length + 1 + parseInt(arg1len, 10)); - return Fleur.XPathEvaluator._calc(args2, ops.substr(ops.indexOf(".") + 1).substr(parseInt(ops.substr(0, ops.indexOf(".")), 10)), opprec); - }; - Fleur.XPathEvaluator._testFormat = function(s, namecode) { - var arg1, arg2, arg20, arg200; - if (s === "") { - return ""; - } - if (s.indexOf(",[Fleur.XQueryX.pathExpr,[") !== -1) { - arg1 = s.substr(0, s.indexOf(",[Fleur.XQueryX.pathExpr,[")); - arg20 = s.substr(s.indexOf(",[Fleur.XQueryX.pathExpr,[") + 1); - arg200 = arg20.substr(arg20.indexOf("[Fleur.XQueryX.nameTest,['") + 25); - arg2 = "," + "[Fleur.XQueryX.typeName,[" + arg200.substr(0, arg200.length - 6) + "]]"; - } else { - arg1 = s; - arg2 = ""; - } - var arg120 = arg1.indexOf("[Fleur.XQueryX.nameTest,['") !== -1 ? arg1.substr(arg1.indexOf("[Fleur.XQueryX.nameTest,['") + 25) : "[Fleur.XQueryX.star,[]]"; - var arg12 = "[" + namecode + ",[" + (arg120 === "[Fleur.XQueryX.star,[]]" ? arg120 : "[Fleur.XQueryX.QName,[" + arg120.substr(0, arg120.length - 6) + "]]") + "]]"; - return arg12 + arg2; - }; - Fleur.XPathEvaluator._getNodeConstructor = function(s) { - var ii, text, texts, entityname, index, offset = 0, end = s.length, nodename, attrname, attrvalue, attrvalues, attrs, parents = [], currnodename = "", c, c0, c1, c2, braces, - seps_pi = " \t\n\r?", seps_close = " \t\n\r>", seps_elt = " \t\n\r/>", seps_attr = " \t\n\r=/<>", seps = " \t\n\r", rseps = /^\s*$/gm, - namespaces = {}, newnamespaces = {}, pindex, prefix, localName, r0, r = "", nextsep = ""; - while (offset !== end) { - text = ""; - texts = []; - c1 = " "; - c = s.charAt(offset); - braces = 0; - while ((c !== "<" || braces !== 0) && offset !== end) { - if (c === "{") { - if (braces === 0 && text !== "") { - if (/\S/.test(text.replace("\\n", "\n").replace("\\r", "\r"))) { - texts.push([0, text]); - } - text = ""; - } - if (braces !== 0) { - text += "{"; - } - if (c1 === c) { - braces--; - if (braces === 0) { - text = (texts.length > 0 ? texts.pop()[1] : "") + "{"; - } - } else { - braces++; - } - } else if (c === "}") { - if (braces === 1 && text !== "") { - texts.push([1, text]); - text = ""; - } - if (braces !== 1 && braces !== -1) { - text += "}"; - } - if (c1 === c) { - braces++; - } else { - braces--; - } - } else if (c === "&") { - c = s.charAt(++offset); - entityname = ""; - while (c !== ";" && offset !== end) { - entityname += c; - c = s.charAt(++offset); - } - if (offset === end) { - break; - } - if (entityname.charAt(0) === "#") { - text += String.fromCharCode(parseInt(entityname.charAt(1).toLowerCase() === 'x' ? "0" + entityname.substr(1).toLowerCase() : entityname.substr(1), entityname.charAt(1).toLowerCase() === 'x' ? 16 : 10)); - } else { - text += Fleur.encchars[entityname]; - } - } else if (braces === 0 && c === "\n") { - text += "\\n"; - } else if (braces === 0 && c === "\r") { - text += "\\r"; - } else { - text += c; - } - c1 = c; - c = s.charAt(++offset); - } - if (/\S/.test(text.replace("\\n", "\n").replace("\\r", "\r")) && texts.length === 0) { - r += nextsep + "[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + text.replace(/'/gm,"\\'") + "']]]]"; - nextsep = ","; - } else if (texts.length > 0) { - if (/\S/.test(text.replace("\\n", "\n").replace("\\r", "\r"))) { - texts.push([0, text]); - } - texts.forEach(function(t) { - r += nextsep; - if (t[0] === 0) { - r += "[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + t[1].replace(/'/gm,"\\'") + "']]]]"; - } else { - r += Fleur.XPathEvaluator._xp2js(t[1], "", ""); - } - nextsep = ","; - }); - } - if (offset === end) { - break; - } - offset++; - if (s.charAt(offset) === "!") { - offset++; - if (s.substr(offset, 2) === "--") { - offset += 2; - index = s.indexOf("-->", offset); - if (index !== offset) { - if (index === -1) { - index = end; - } - text = ""; - ii = offset; - while (ii < index) { - text += s.charAt(ii++); - } - text = text.replace(/\x01/gm,"<"); - r0 = "[Fleur.XQueryX.computedCommentConstructor,[[Fleur.XQueryX.argExpr,[[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + text + "']]]]]]]]"; - if (r === "") { - return offset + "." + r0; - } - r += nextsep + r0; - nextsep = ","; - if (index === end) { - break; - } - offset = index; - } - offset += 3; - } else if (s.substr(offset, 7) === "[CDATA[") { - offset += 7; - index = s.indexOf("]]>", offset); - if (index !== offset) { - if (index === -1) { - index = end; - } - text = ""; - ii = offset; - while (ii < index) { - text += s.charAt(ii++); - } - text = text.replace(/\x01/gm,"<"); - if (text !== "") { - r += nextsep + "[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + text + "']]]]"; - nextsep = ","; - } - if (index === end) { - break; - } - offset = index; - } - offset += 3; - } - } else if (s.charAt(offset) === "?") { - offset++; - c = s.charAt(offset++); - nodename = ""; - while (seps_pi.indexOf(c) === -1) { - nodename += c; - c = s.charAt(offset++); - } - index = s.indexOf("?>", offset - 1); - if (index === -1) { - index = end; - } - if (nodename.toLowerCase() === "xml") { - throw Error("Invalid processing instruction"); - } else if (nodename !== "") { - text = ""; - ii = offset; - while (ii < index) { - text += s.charAt(ii++); - } - text = text.replace(/\x01/gm,"<"); - r0 = "[Fleur.XQueryX.computedPIConstructor,[[Fleur.XQueryX.piTarget,['" + nodename + "']],[Fleur.XQueryX.piValueExpr,[[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + text + "']]]]]]]]"; - if (r === "") { - return String(index + 2) + "." + r0; - } - r += nextsep + r0; - nextsep = ","; - } - if (index === end) { - break; - } - offset = index + 2; - } else if (s.charAt(offset) === "/") { - offset++; - c = s.charAt(offset++); - nodename = ""; - while (seps_close.indexOf(c) === -1 && offset <= end) { - nodename += c; - c = s.charAt(offset++); - } - if (nodename === currnodename) { - if (nextsep !== ",") { - r += "]]"; - } else { - r += "]]]]"; - } - nextsep = ","; - if (parents.length === 1) { - return offset + "." + r; - } - currnodename = parents.pop(); - } else { - throw Error("Malformed XML fragment"); - } - offset = s.indexOf(">", offset - 1) + 1; - if (offset === 0) { - break; - } - } else { - c = s.charAt(offset++); - nodename = ""; - while (seps_elt.indexOf(c) === -1 && offset <= end) { - nodename += c; - c = s.charAt(offset++); - } - index = s.indexOf(">", offset - 1); - if (nodename !== "") { - newnamespaces = {}; - for (prefix in namespaces) { - if (namespaces.hasOwnProperty(prefix)) { - newnamespaces[prefix] = namespaces[prefix]; - } - } - attrs = {}; - while (offset <= end) { - while (seps.indexOf(c) !== -1 && offset <= end) { - c = s.charAt(offset++); - } - if (c === "/" || c === ">" || offset === end) { - break; - } - attrname = ""; - while (seps_attr.indexOf(c) === -1 && offset <= end) { - attrname += c; - c = s.charAt(offset++); - } - if (attrname === "") { - throw new Error("Invalid character: " + c); - } - while (seps.indexOf(c) !== -1 && offset <= end) { - c = s.charAt(offset++); - } - if (c === "=") { - c = s.charAt(offset++); - while (seps.indexOf(c) !== -1 && offset <= end) { - c = s.charAt(offset++); - } - attrvalue = ""; - attrvalues = []; - if (c === "'" || c === "\"") { - c0 = c; - c1 = c; - c = s.charAt(offset++); - c2 = s.charAt(offset); - braces = 0; - attrvalue = ""; - ii = offset; - while ((c !== c0 || c2 === c0 || braces !== 0) && offset <= end) { - if (c === "{") { - if (braces === 0 && attrvalue !== "") { - attrvalues.push([0, attrvalue]); - attrvalue = ""; - } - if (c1 === c) { - braces--; - if (braces === 0) { - attrvalue = (attrvalues.length > 0 ? attrvalues.pop()[1] : "") + "{"; - } - } else { - braces++; - } - } else if (c === "}") { - if (braces === 1 && attrvalue !== "") { - attrvalues.push([1, attrvalue]); - attrvalue = ""; - } - if (c1 === c) { - braces++; - if (braces === 0) { - attrvalue += "}"; - } - } else { - braces--; - } - } else if (c === c2 && c === c0) { - attrvalue += c; - c1 = c; - c = s.charAt(++offset); - c2 = s.charAt(++offset); - continue; - } else { - attrvalue += c; - } - c1 = c; - c = c2; - c2 = s.charAt(++offset); - } - if (attrvalue !== "") { - attrvalues.push([0, attrvalue]); - } - c = c2; - offset++; - } else { - while (seps_elt.indexOf(c) === -1 && offset <= end) { - attrvalue += c; - c = s.charAt(offset++); - } - attrvalues = [[0, attrvalue]]; - } - } else { - attrvalues = [[0, attrname]]; - } - pindex = attrname.indexOf(":"); - prefix = pindex !== -1 ? attrname.substr(0, pindex) : " "; - localName = pindex !== -1 ? attrname.substr(pindex + 1) : attrname; - if (!attrs[prefix]) { - attrs[prefix] = {}; - } - attrs[prefix][localName] = attrvalues; - if (prefix === "xmlns") { - newnamespaces[localName] = attrvalues; - } else if (prefix === " " && localName === "xmlns") { - newnamespaces[" "] = attrvalues; - } - } - pindex = nodename.indexOf(":"); - if (pindex === -1) { - r0 = nextsep + "[Fleur.XQueryX.elementConstructor,[[Fleur.XQueryX.tagName,['" + nodename + "']]"; - } else { - r0 = nextsep + "[Fleur.XQueryX.elementConstructor,[[Fleur.XQueryX.tagName,['" + nodename.substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + nodename.substr(0, pindex) + "']]]]"; - } - if (Object.keys(attrs).length) { - nextsep = ",[Fleur.XQueryX.attributeList,["; - if (attrs[" "] && attrs[" "].xmlns) { - r0 += nextsep + "[Fleur.XQueryX.namespaceDeclaration,[[Fleur.XQueryX.uri,[" + (attrs[" "].xmlns.length !== 0 ? "'" + attrs[" "].xmlns[0][1] + "'" : "") + "]]]]"; - nextsep = ","; - delete attrs[" "].xmlns; - } - for (attrname in attrs.xmlns) { - if (attrs.xmlns.hasOwnProperty(attrname)) { - r0 += nextsep + "[Fleur.XQueryX.namespaceDeclaration,[[Fleur.XQueryX.prefixElt,['" + attrname + "']],[Fleur.XQueryX.uri,['" + attrs.xmlns[attrname][0][1] + "']]]]"; - nextsep = ","; - } - } - delete attrs.xmlns; - for (prefix in attrs) { - if (attrs.hasOwnProperty(prefix)) { - for (attrname in attrs[prefix]) { - if (attrs[prefix].hasOwnProperty(attrname)) { - r0 += nextsep + "[Fleur.XQueryX.attributeConstructor,[[Fleur.XQueryX.attributeName,['" + attrname + "'"; - if (prefix !== " ") { - r0 += ",[Fleur.XQueryX.prefix,['" + prefix + "']]"; - } - r0 += "]],"; - if (attrs[prefix][attrname].length === 0) { - r0 += "[Fleur.XQueryX.attributeValue,[]]"; - nextsep = ","; - } else if (attrs[prefix][attrname].length === 1 && attrs[prefix][attrname][0][0] === 0) { - r0 += "[Fleur.XQueryX.attributeValue,['" + Fleur.DocumentType.resolveEntities(null, attrs[prefix][attrname][0][1]).replace(/'/gm,"\\'").replace(/\x01/gm,"<") + "']]"; - nextsep = ","; - } else { - nextsep = "[Fleur.XQueryX.attributeValueExpr,["; - attrs[prefix][attrname].forEach(function(v) { - r0 += nextsep; - if (v[0] === 0) { - r0 += "[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + Fleur.DocumentType.resolveEntities(null, v[1]).replace(/'/gm,"\\'") + "']]]]"; - } else { - r0 += Fleur.XPathEvaluator._xp2js(v[1], "", ""); - } - nextsep = ","; - }); - r0 += "]]"; - } - r0 += "]]"; - } - } - } - } - r0 += "]]"; - } - if (s.charAt(offset - 1) !== "/") { - nextsep = ",[Fleur.XQueryX.elementContent,["; - parents.push(currnodename); - currnodename = nodename; - r += r0; - } else { - if (r === "") { - return String(offset + 1) + "." + r0 + "]]"; - } - r += r0 + "]]"; - nextsep = ","; - } - } else { - throw Error("Invalid element name"); - } - offset = index + 1; - if (offset === 0) { - break; - } - } - } - }; - Fleur.XPathEvaluator._getPredParam = function(c, s, l, arg, allowpredicates, predstart, predarr, ops) { - var t; - l = l || 0; - var p, plen, arg20, arg2; - var isret = false; - if (c === "?") { - var i = Fleur.XPathEvaluator._skipSpaces(s, 0); - var c2 = s.charAt(i); - var d = s.substr(i + 1); - var r, t1; - if (c2 !== "" && "0123456789".indexOf(c2) !== -1) { - t1 = Fleur.XPathEvaluator._getNumber(c2 + d); - r = "[Fleur.XQueryX.lookup,[[Fleur.XQueryX.integerConstantExpr,[[Fleur.XQueryX.value,['" + t1.replace(/e\+/, "e") + "']]]]]]"; - t = (t1.length + 1) + "." + r; - plen = t1.length + 1; - } else if (c2 !== "" && "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(c2) !== -1) { - t1 = Fleur.XPathEvaluator._getName(c2 + d); - r = "[Fleur.XQueryX.lookup,[[Fleur.XQueryX.NCName,['" + t1 + "']]]]"; - t = (t1.length + 1) + "." + r; - plen = t1.length + 1; - } else if (c2 === "*") { - t = "2.[Fleur.XQueryX.lookup,[[Fleur.XQueryX.star,[]]]]"; - plen = 2; - } else if (c2 === "(") { - t = Fleur.XPathEvaluator._xp2js(s.substr(i + 1), "", "5.999.("); - plen = s.length - parseInt(t.substr(0, t.indexOf(".")), 10) + 1 + i; - t = String(plen) + "." + "[Fleur.XQueryX.lookup,[[Fleur.XQueryX.expr,[" + t.substr(t.indexOf(".") + 1) + "]]]]"; - } - } else { - var func = ""; - if (arg.indexOf("[Fleur.XQueryX.nameTest,['") !== -1) { - var func0 = arg.substr(arg.indexOf("[Fleur.XQueryX.nameTest,['") + 25); - func = func0.substr(0, func0.length - 6); - } - if (func === "'function'") { - t = "function"; - plen = s.length; - } else { - t = Fleur.XPathEvaluator._xp2js(s, "", l === 0 ? "" : arg.substr(0, 57) === "[Fleur.XQueryX.quantifiedExpr,[[Fleur.XQueryX.quantifier," ? "5.999.q" : "5.999.("); - plen = s.length - parseInt(t.substr(0, t.indexOf(".")), 10) + 1; - } - } - if (t.indexOf("~~~~") !== -1) { - var t0 = t + "~#~#"; - t0 = t0.substr(0, t0.indexOf("~#~#")); - t0 = t0.replace('"', ""); - var msg = '"~~~~' + t0.substr(t0.indexOf("~~~~") + 4) + "in '" + s + "'~#~#" + '"'; - p = plen + "." + msg; - throw Error(t0.substr(t0.indexOf("~~~~") + 4) + "in '" + s + "'"); - } else if (t === "") { - var msg2 = '"' + "~~~~Unrecognized expression '" + s + "'~#~#" + '"'; - p = plen + "." + msg2; - throw Error("Unrecognized expression '" + s + "'"); - } else if (c === "{") { - var cargs = t.substr(t.indexOf(".") + 1); - if (cargs.substr(0, 25) === "[Fleur.XQueryX.arguments,") { - cargs = "[Fleur.XQueryX.sequenceExpr," + cargs.substr(25); - } - if (arg.substr(0, 40) === "[Fleur.XQueryX.computedEntryConstructor," || arg.substr(0, 42) === "[Fleur.XQueryX.computedElementConstructor," || arg.substr(0, 44) === "[Fleur.XQueryX.computedAttributeConstructor,") { - p = plen + "." + arg.substr(0, arg.length - 2) + ",[Fleur.XQueryX.valueExpr,[" + cargs + "]]]]"; - } else if (arg.substr(0, 37) === "[Fleur.XQueryX.computedPIConstructor,") { - p = plen + "." + arg.substr(0, arg.length - 2) + ",[Fleur.XQueryX.piValueExpr,[" + cargs + "]]]]"; - } else { - var cname0 = arg.substr(arg.indexOf("[Fleur.XQueryX.nameTest,['") + 25); - var cname = cname0.substr(0, cname0.length - 6); - switch (cname) { - case "'document'": - p = plen + "." + "[Fleur.XQueryX.computedDocumentConstructor,[[Fleur.XQueryX.argExpr,[" + cargs + "]]]]"; - break; - case "'comment'": - p = plen + "." + "[Fleur.XQueryX.computedCommentConstructor,[[Fleur.XQueryX.argExpr,[" + cargs + "]]]]"; - break; - case "'map'": - var cargs2 = cargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? cargs.substr(26, cargs.length - 28) : cargs; - p = plen + "." + "[Fleur.XQueryX.mapConstructor,[" + cargs2 + "]]"; - break; - case "'array'": - var cargs3 = cargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? cargs.substr(26, cargs.length - 28) : cargs; - p = plen + "." + "[Fleur.XQueryX.arrayConstructor,[" + cargs3 + "]]"; - break; - case "'entry'": - p = plen + "." + "[Fleur.XQueryX.computedEntryConstructor,[[Fleur.XQueryX.tagNameExpr,[" + cargs + "]]]]"; - break; - case "'element'": - p = plen + "." + "[Fleur.XQueryX.computedElementConstructor,[[Fleur.XQueryX.tagNameExpr,[" + cargs + "]]]]"; - break; - case "'attribute'": - p = plen + "." + "[Fleur.XQueryX.computedAttributeConstructor,[[Fleur.XQueryX.tagNameExpr,[" + cargs + "]]]]"; - break; - case "'processing-instruction'": - p = plen + "." + "[Fleur.XQueryX.computedPIConstructor,[[Fleur.XQueryX.piTargetExpr,[" + cargs + "]]]]"; - break; - case "'text'": - p = plen + "." + "[Fleur.XQueryX.computedTextConstructor,[[Fleur.XQueryX.argExpr,[" + cargs + "]]]]"; - break; - case "'try'": - p = plen + "." + "[Fleur.XQueryX.tryCatchExpr,[[Fleur.XQueryX.tryClause,[" + cargs + "]]]]"; - break; - default: - if (ops.startsWith("8.31.catch") || ops.startsWith("3.8.|8.31.catch")) { - arg20 = arg.substr(86); - arg2 = arg20.substr(0, arg20.length - 4); - p = plen + "." + "[Fleur.XQueryX.catchErrorList,[" + arg2 + "]],[Fleur.XQueryX.catchExpr,[" + cargs + "]]"; - } - break; - } - } - } else if (c === "(") { - if (arg.substr(0, 77) === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['") { - var fname0 = arg.substr(arg.indexOf("[Fleur.XQueryX.nameTest,['") + 25); - var fname = fname0.substr(0, fname0.length - 6); - var fargs = t.substr(t.indexOf(".") + 1); - var fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; - var parg0, parg; - switch (fname) { - case "'array'": - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['array']]]]")) + "[Fleur.XQueryX.arrayTest,[]]]]]]"; - break; - case "'attribute'": - parg = Fleur.XPathEvaluator._testFormat(fargs2, "Fleur.XQueryX.attributeName"); - p = plen + "." + "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['attribute']],[Fleur.XQueryX.attributeTest,[" + parg + "]]]]]]"; - break; - case "'comment'": - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['comment']]]]")) + "[Fleur.XQueryX.commentTest,[]]]]]]"; - break; - case "'document-node'": - if (fargs2 !== "") { - parg0 = fargs2.substr(fargs2.indexOf("[Fleur.XQueryX.elementTest,[")); - parg = parg0.substr(0, parg0.length - 4); - } else { - parg = ""; - } - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['document-node']]]]")) + "[Fleur.XQueryX.documentTest,[" + parg + "]]]]]]"; - break; - case "'element'": - parg = Fleur.XPathEvaluator._testFormat(fargs2, "Fleur.XQueryX.elementName"); - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['element']]]]")) + "[Fleur.XQueryX.elementTest,[" + parg + "]]]]]]"; - break; - case "'entry'": - parg = Fleur.XPathEvaluator._testFormat(fargs2, "Fleur.XQueryX.entryName"); - p = plen + "." + "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['entry']],[Fleur.XQueryX.entryTest,[" + parg + "]]]]]]"; - break; - case "'function'": - var j = -1; - var xq = s; - var pindex, np, nbpar = 0; - var fres = "[Fleur.XQueryX.paramList,["; - var end = xq.length; - do { - j = Fleur.XPathEvaluator._skipSpaces(xq, j + 1); - c = xq.charAt(j); - if (c !== ")") { - if (c !== "$") { - throw Error("Unexpected char at '" + xq.substr(j) + "'"); - } - j++; - c = xq.charAt(j); - d = xq.substr(j + 1); - if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) === -1) { - throw Error("Unexpected char at '" + xq.substr(j) + "'"); - } - var pname = Fleur.XPathEvaluator._getName(c + d); - j = Fleur.XPathEvaluator._skipSpaces(xq, j + pname.length); - c = xq.charAt(j); - var tdecl = ""; - if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) !== -1) { - d = xq.substr(j + 1); - r = Fleur.XPathEvaluator._getName(c + d); - if (r === "as") { - j = Fleur.XPathEvaluator._skipSpaces(xq, j + r.length); - c = xq.charAt(j); - if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) !== -1) { - d = xq.substr(j + 1); - var ptype = Fleur.XPathEvaluator._getName(c + d); - pindex = ptype.indexOf(":"); - np = pindex === -1 ? "'" + ptype + "'" : "'" + ptype.substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + ptype.substr(0, pindex) + "']]"; - c = xq.charAt(j + ptype.length); - tdecl = ",[Fleur.XQueryX.typeDeclaration,[[Fleur.XQueryX.atomicType,[" + np + "]]"; - if ("?+*".indexOf(c) !== -1) { - tdecl += ",[Fleur.XQueryX.occurrenceIndicator,['" + c + "']]"; - j++; - } - tdecl += "]]"; - j = Fleur.XPathEvaluator._skipSpaces(xq, j + ptype.length); - c = xq.charAt(j); - } - } - } - if (nbpar !== 0) { - fres += ","; - } - fres += "[Fleur.XQueryX.param,[[Fleur.XQueryX.varName,['" + pname + "']]" + tdecl + "]]"; - nbpar++; - } - } while (c === ","); - if (c !== ")") { - throw Error("Unexpected char at '" + xq.substr(j) + "'"); - } - fres += "]]"; - j = Fleur.XPathEvaluator._skipSpaces(xq, j + 1); - c = xq.charAt(j); - if (c === "a") { - d = xq.substr(j + 1); - r = Fleur.XPathEvaluator._getName(c + d); - if (r === "as") { - j = Fleur.XPathEvaluator._skipSpaces(xq, j + r.length); - c = xq.charAt(j); - if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) !== -1) { - d = xq.substr(j + 1); - ptype = Fleur.XPathEvaluator._getName(c + d); - pindex = ptype.indexOf(":"); - np = pindex === -1 ? "'" + ptype + "'" : "'" + ptype.substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + ptype.substr(0, pindex) + "']]"; - c = xq.charAt(j + ptype.length); - fres += ",[Fleur.XQueryX.typeDeclaration,[[Fleur.XQueryX.atomicType,[" + np + "]]"; - if ("?+*".indexOf(c) !== -1) { - fres += ",[Fleur.XQueryX.occurrenceIndicator,['" + c + "']]"; - j++; - } - fres += "]]"; - j = Fleur.XPathEvaluator._skipSpaces(xq, j + ptype.length); - c = xq.charAt(j); - } - } - } - if (c === "{") { - fres += ",[Fleur.XQueryX.functionBody,["; - var braces = 1; - var body = ""; - while ((c !== "}" || braces !== 0) && j !== end) { - c = xq.charAt(++j); - if (c === "{") { - braces++; - } else if (c === "}") { - braces--; - } - if (braces !== 0) { - body += c; - } - } - if (body !== "") { - fres += Fleur.XPathEvaluator._xp2js(body, "", ""); - } - fres += "]]"; - } else { - throw Error("Unexpected char at '" + xq.substr(j) + "'"); - } - plen = j + 2; - p = plen + ".[Fleur.XQueryX.inlineFunctionExpr,[" + fres + "]]"; - break; - case "'item'": - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['item']]]]")) + "[Fleur.XQueryX.anyItemType,[]]]]]]"; - break; - case "'map'": - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['map']]]]")) + "[Fleur.XQueryX.mapTest,[]]]]]]"; - break; - case "'namespace-node'": - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['namespace-node']]]]")) + "[Fleur.XQueryX.namespaceTest,[]]]]]]"; - break; - case "'node'": - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['node']]]]")) + "[Fleur.XQueryX.anyKindTest,[]]]]]]"; - break; - case "'processing-instruction'": - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['processing-instruction']]]]")) + "[Fleur.XQueryX.piTest,[" + (fargs2 ? "[Fleur.XQueryX.piTarget,[" + fargs2.substr(57) : "]]") + "]]]]"; - break; - case "'schema-attribute'": - parg0 = fargs.substr(fargs.indexOf("[Fleur.XQueryX.nameTest,['") + 25); - parg = parg0.substr(0, parg0.length - 6); - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['schema-attribute']]]]")) + "[Fleur.XQueryX.schemaAttributeTest,[" + parg + "]]]]]]"; - break; - case "'schema-element'": - parg0 = fargs.substr(fargs.indexOf("[Fleur.XQueryX.nameTest,['") + 25); - parg = parg0.substr(0, parg0.length - 6); - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['schema-element']]]]")) + "[Fleur.XQueryX.schemaElementTest,[" + parg + "]]]]]]"; - break; - case "'text'": - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['text']]]]")) + "[Fleur.XQueryX.textTest,[]]]]]]"; - break; - default: - p = plen + ".[Fleur.XQueryX.functionCallExpr,[[Fleur.XQueryX.functionName,[" + fname + "]],[Fleur.XQueryX.arguments,[" + fargs2 + "]]]]"; - } - } else if (arg.substr(0, 77) === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[") { - var arg1, lookup = false; - if (arg.indexOf(",[Fleur.XQueryX.predicates,[") !== -1) { - arg1 = arg.substr(0, arg.indexOf(",[Fleur.XQueryX.predicates,[")).substr(77); - arg20 = arg.substr(arg.indexOf(",[Fleur.XQueryX.predicates,[") + 28); - arg2 = arg20.substr(0, arg20.length - 6); - } else if (arg.indexOf(",[Fleur.XQueryX.lookup,[") !== -1) { - lookup = true; - arg1 = arg.substr(0, arg.indexOf(",[Fleur.XQueryX.lookup,[")).substr(77); - arg20 = arg.substr(arg.indexOf(",[Fleur.XQueryX.lookup,[") + 24); - arg2 = arg20.substr(0, arg20.length - 6); - } else { - arg1 = arg.substr(0, arg.length - 8).substr(77); - arg2 = ""; - } - fargs = t.substr(t.indexOf(".") + 1); - fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; - p = plen + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[[Fleur.XQueryX.dynamicFunctionInvocationExpr,[[Fleur.XQueryX.functionItem,[" + arg1 + (arg2 === "" ? "" : (lookup ? ",[Fleur.XQueryX.lookup,[" : ",[Fleur.XQueryX.predicates,[")+ arg2 + "]]") + (fargs2 === "" ? "" : ",[Fleur.XQueryX.arguments,[" + fargs2 + "]]") + "]]]]]]]]"; - } else if (arg.substr(0, 32) === "[Fleur.XQueryX.namedFunctionRef,") { - p = plen + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[[Fleur.XQueryX.dynamicFunctionInvocationExpr,[[Fleur.XQueryX.functionItem,[" + arg + "]]]]]]]]]]"; - } else if (arg === "[Fleur.XQueryX.flworExpr,[]]") { - fargs = t.substr(t.indexOf(".") + 1); - fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; - p = plen + ".[Fleur.XQueryX.flworExpr,[" + fargs2 + "]]"; - isret = true; - } else if (arg.substr(0, 57) === "[Fleur.XQueryX.quantifiedExpr,[[Fleur.XQueryX.quantifier,") { - fargs = t.substr(t.indexOf(".") + 1); - fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; - p = plen + "." + arg.substr(0, arg.length - 2) + "," + fargs2 + "]]"; - isret = true; - } else if (arg !== "") { - fargs = t.substr(t.indexOf(".") + 1); - fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; - p = plen + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[[Fleur.XQueryX.dynamicFunctionInvocationExpr,[[Fleur.XQueryX.functionItem,[" + arg + "]]" + (fargs2 === "" ? "" : ",[Fleur.XQueryX.arguments,[" + fargs2 + "]]") + "]]]]]]]]"; - } else { - p = plen + "." + t.substr(t.indexOf(".") + 1); - } - } else { - if (arg.substr(0, 25) !== "[Fleur.XQueryX.pathExpr,[") { - arg = "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[" + arg + "]]]]]]"; - } - if (c === "?") { - if (arg.indexOf(",[Fleur.XQueryX.predicates,[") === -1) { - p = plen + "." + arg.substr(0, arg.length - 4) + "," + t.substr(t.indexOf(".") + 1) + "]]]]"; - } else { - p = plen + "." + arg.substr(0, predstart) + predarr.reduce(function(s, pr) {return s + ",[Fleur.XQueryX.predicate,[" + pr + "]]";}, "") + "," + t.substr(t.indexOf(".") + 1) + "]]]]";; - } - allowpredicates = false; - } else if (arg.indexOf(",[Fleur.XQueryX.predicates,[") === -1) { - if (allowpredicates) { - predarr = []; - predarr.push(t.substr(t.indexOf(".") + 1)); - predstart = arg.length - 4; - } - p = plen + "." + arg.substr(0, arg.length - 4) + ",[" + (allowpredicates ? "Fleur.XQueryX.predicates" : "Fleur.XQueryX.predicate") + ",[" + t.substr(t.indexOf(".") + 1) + "]]]]]]"; - } else { - if (allowpredicates) { - predarr.push(t.substr(t.indexOf(".") + 1)); - } - p = plen + "." + arg.substr(0, arg.length - 6) + "," + t.substr(t.indexOf(".") + 1) + "]]]]]]"; - } - } - if (!isret) { - var inext = Fleur.XPathEvaluator._skipSpaces(s, plen - 1); - var cnext = s.charAt(inext); - if (cnext === "(" || cnext === "[" || cnext === "{" || cnext === "?") { - return Fleur.XPathEvaluator._getPredParam(cnext, s.substr(inext + 1), l + inext + 1, p.substr(p.indexOf(".") + 1), allowpredicates, predstart, predarr, ops); - } - } - return (l + plen) + "." + p.substr(p.indexOf(".") + 1); - }; - Fleur.XPathEvaluator._getPredParams = function(s, len, arg, ops) { - var i = Fleur.XPathEvaluator._skipSpaces(s, 0); - if (s.charAt(i) === "(" || s.charAt(i) === "[" || s.charAt(i) === "{" || (s.charAt(i) === "?" && ops.substr(0, 16) !== "13.6.instance of" && ops.substr(0, 16) !== "9.3.cast as" && ops.substr(0, 16) !== "13.4.castable as")) { - return Fleur.XPathEvaluator._getPredParam(s.charAt(i), s.substr(i + 1), len + i, arg, true, 0, [], ops); - } - return (len + i) + "." + arg; - }; - Fleur.XPathEvaluator._getStringLiteral = function(s) { - var i = Fleur.XPathEvaluator._skipSpaces(s, 0); - var d = s.substr(i + 1); - if (s.charAt(i) === "'") { - var sep2 = d.indexOf("'"); - var t2 = d.substr(0, d.indexOf("'")); - while (d.substr(sep2 + 1, 1) === "'") { - var d2 = d.substr(sep2 + 2); - t2 += "\\'" + d2.substr(0, d2.indexOf("'")); - sep2 += 2 + d2.indexOf("'"); - } - var t2b = "'" + Fleur.DocumentType.resolveEntities(null, t2) + "'"; - if (t2b === "''") { - t2b = ""; - } - return (sep2 + 2) + "." + t2b; - } else if (s.charAt(i) === '"') { - var sep3 = d.indexOf('"'); - var t3 = d.substr(0, d.indexOf('"')); - while (d.substr(sep3 + 1, 1) === '"') { - var d3 = d.substr(sep3 + 2); - t3 += '\\"' + d3.substr(0, d3.indexOf('"')); - sep3 += 2 + d3.indexOf('"'); - } - var t3b = '"' + Fleur.DocumentType.resolveEntities(null, t3) + '"'; - if (t3b === '""') { - t3b = ""; - } - return (sep3 + 2) + "." + t3b; - } - }; - Fleur.XPathEvaluator._getNumber = function(s, r) { - r = r || ""; - if (s === "") { - return r; - } - var c = s.charAt(0); - if (c === "E") { - c = "e"; - } - if ("0123456789".indexOf(c) !== -1 || ((c === "." || c === "e") && r.indexOf(c) === -1) || - ((c === "-" || c === "+") && r.endsWith("e"))) { - return Fleur.XPathEvaluator._getNumber(s.substr(1), r + c); - } - return r; - }; - Fleur.XPathEvaluator._xp2js = function(xp, args, ops) { - var i = Fleur.XPathEvaluator._skipSpaces(xp, 0); - var c = xp.charAt(i); - var d = xp.substr(i + 1); - var d2; - var r = ""; - if (c === "." && (d === "" || "0123456789".indexOf(d.charAt(0)) === -1)) { - if (d.charAt(0) === ".") { - r = "2.[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['parent']],[Fleur.XQueryX.anyKindTest,[]]]]]]"; - } else { - r = "1.[Fleur.XQueryX.contextItemExpr,[]]"; - } - } else if (c === ")" || c === "}") { - r = "0."; - } else if (c === "/") { - var ir = Fleur.XPathEvaluator._skipSpaces(d, 0); - r = (d.charAt(0) === "" || "/@*.(_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(d.charAt(ir)) === -1 ? "1" : "0") + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.rootExpr,[]]]]"; - } else if (c === "@") { - r = Fleur.XPathEvaluator._getNameStep(d, 1); - } else if (c === "'") { - var sep2 = d.indexOf("'"); - var t2 = Fleur.DocumentType.resolveEntities(null, d.substr(0, d.indexOf("'"))).replace(/[\\]/g, '\\\\').replace(/[\"]/g, '\\\"').replace(/[\/]/g, '\\/').replace(/[\b]/g, '\\b').replace(/[\f]/g, '\\f').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r').replace(/[\t]/g, '\\t'); - while (d.substr(sep2 + 1, 1) === "'") { - d2 = d.substr(sep2 + 2); - t2 += "\\'" + Fleur.DocumentType.resolveEntities(null, d2.substr(0, d2.indexOf("'"))).replace(/[\\]/g, '\\\\').replace(/[\"]/g, '\\\"').replace(/[\/]/g, '\\/').replace(/[\b]/g, '\\b').replace(/[\f]/g, '\\f').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r').replace(/[\t]/g, '\\t'); - sep2 += 2 + d2.indexOf("'"); - } - var t2b = "'" + t2 + "'"; - if (t2b === "''") { - t2b = ""; - } - r = (sep2 + 2) + ".[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,[" + t2b + "]]]]"; - } else if (c === '"') { - var sep3 = d.indexOf('"'); - var t3 = Fleur.DocumentType.resolveEntities(null, d.substr(0, d.indexOf('"'))).replace(/[\\]/g, '\\\\').replace(/[\']/g, "\\\'").replace(/[\/]/g, '\\/').replace(/[\b]/g, '\\b').replace(/[\f]/g, '\\f').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r').replace(/[\t]/g, '\\t'); - while (d.substr(sep3 + 1, 1) === '"') { - var d3 = d.substr(sep3 + 2); - t3 += '\\"' + Fleur.DocumentType.resolveEntities(null, d3.substr(0, d3.indexOf('"'))).replace(/[\\]/g, '\\\\').replace(/[\']/g, "\\\'").replace(/[\/]/g, '\\/').replace(/[\b]/g, '\\b').replace(/[\f]/g, '\\f').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r').replace(/[\t]/g, '\\t'); - sep3 += 2 + d3.indexOf('"'); - } - var t3b = '"' + t3 + '"'; - if (t3b === '""') { - t3b = ""; - } - r = (sep3 + 2) + ".[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,[" + t3b + "]]]]"; - } else if (c === "(") { - var endseq = Fleur.XPathEvaluator._skipSpaces(d, 0); - if (d.charAt(endseq) === ")") { - r = String(2 + endseq) + ".[Fleur.XQueryX.sequenceExpr,[]]"; - } else { - r = "0."; - } - } else if (c === "-" || c === "+") { - c = "~" + c; - r = "0."; - } else if (c !== "" && ".0123456789".indexOf(c) !== -1) { - var t5 = Fleur.XPathEvaluator._getNumber(c + d); - r = t5.length + ".[" + (t5.indexOf("e") !== -1 ? "Fleur.XQueryX.doubleConstantExpr" : t5.indexOf(".") !== -1 ? "Fleur.XQueryX.decimalConstantExpr" : "Fleur.XQueryX.integerConstantExpr") + ",[[Fleur.XQueryX.value,['" + t5.replace(/e\+/, "e") + "']]]]"; - } else if (c === "$") { - var t51 = Fleur.XPathEvaluator._getName(d); - var pt51 = (t51.indexOf(":") === -1 ? ":" : "") + t51; - var instr; - if (ops.startsWith("11.30.group by") || ops.startsWith("5.29.~,11.30.group by")) { - instr = "[Fleur.XQueryX.groupingSpec,[[Fleur.XQueryX.varName,["; - } else { - instr = "[Fleur.XQueryX.varRef,[[Fleur.XQueryX.name,["; - } - r = (t51.length + 1) + "." + instr + "'" + pt51.substr(pt51.indexOf(":") + 1) + "'" + (pt51.charAt(0) === ":" ? "" : ",[Fleur.XQueryX.prefix,['" + pt51.substr(0, pt51.indexOf(":")) + "']]") + "]]]]"; - } else if (c === "?") { - var c2 = d.charAt(0); - d = d.substr(1); - var t52; - if (c2 !== "" && "0123456789".indexOf(c2) !== -1) { - t52 = Fleur.XPathEvaluator._getNumber(c2 + d); - r = String(t52.length) + ".[Fleur.XQueryX.unaryLookup,[[Fleur.XQueryX.integerConstantExpr,[[Fleur.XQueryX.value,['" + t52.replace(/e\+/, "e") + "']]]]]]"; - } else if (c2 !== "" && "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(c2) !== -1) { - t52 = Fleur.XPathEvaluator._getName(c2 + d); - r = String(t52.length) + ".[Fleur.XQueryX.unaryLookup,[[Fleur.XQueryX.NCName,['" + t52 + "']]]]"; - } else if (c2 === "*") { - r = "1.[Fleur.XQueryX.unaryLookup,[[Fleur.XQueryX.star,[]]]]"; - } else if (c2 === "(") { - t52 = Fleur.XPathEvaluator._xp2js(d, "", "5.999.("); - var plen52 = d.length - parseInt(t52.substr(0, t52.indexOf(".")), 10) + 1; - r = String(plen52) + "." + "[Fleur.XQueryX.unaryLookup,[[Fleur.XQueryX.expr,[" + t52.substr(t52.indexOf(".") + 1) + "]]]]"; - } - } else if (c !== "" && "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz*".indexOf(c) !== -1) { - var t61 = Fleur.XPathEvaluator._getName(c+d); - if (["element","attribute","entry","processing-instruction"].indexOf(t61) !== -1) { - var i61 = Fleur.XPathEvaluator._skipSpaces(xp, i + t61.length); - var c61 = xp.charAt(i61); - if (c61 !== "" && "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(c61) !== -1) { - var d61 = xp.substr(i61 + 1); - var t62 = Fleur.XPathEvaluator._getName(c61 + d61); - switch(t61) { - case "element": - r = String(i61 - i + t62.length) + ".[Fleur.XQueryX.computedElementConstructor,[[Fleur.XQueryX.tagName,['" + t62 + "']]]]"; - break; - case "attribute": - r = String(i61 - i + t62.length) + ".[Fleur.XQueryX.computedAttributeConstructor,[[Fleur.XQueryX.tagName,['" + t62 + "']]]]"; - break; - case "processing-instruction": - r = String(i61 - i + t62.length) + ".[Fleur.XQueryX.computedPIConstructor,[[Fleur.XQueryX.piTarget,['" + t62 + "']]]]"; - break; - case "entry": - r = String(i61 - i + t62.length) + ".[Fleur.XQueryX.computedEntryConstructor,[[Fleur.XQueryX.tagName,['" + t62 + "']]]]"; - } - } else { - r = Fleur.XPathEvaluator._getNameStep(c + d, 0); - } - } else { - r = Fleur.XPathEvaluator._getNameStep(c + d, 0); - } - } else if (c === "<") { - r = Fleur.XPathEvaluator._getNodeConstructor(c + d); - } else { - r = "~~~~Unexpected char at '" + c + d + "'~#~#"; - throw Error("Unexpected char at '" + c + d + "'"); - } - if (r.indexOf("~~~~") !== -1) { - return r; - } - var rlen = parseInt(r.substr(0, r.indexOf(".")), 10); - var rval = r.substr(r.indexOf(".") + 1); - d2 = rlen === 0 ? c + d : d.substr(rlen - 1); - r = Fleur.XPathEvaluator._getPredParams(d2, rlen, rval, ops); - rlen = parseInt(r.substr(0, r.indexOf(".")), 10); - rval = r.substr(r.indexOf(".") + 1); - var args2 = rval.length + "." + rval + args; - var f = rlen === 0 ? c + d : d.substr(rlen - 1); - var i4 = Fleur.XPathEvaluator._skipSpaces(f, 0); - var o = f.charAt(i4); - var p = f.substr(f.indexOf(o)); - var op = "null"; - var op2 = "null"; - if ((p.substr(0, 9) === "ascending" || p.substr(0, 10) === "descending") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(o === "a" ? 9 : 10)) === -1) { - var postprec0 = Fleur.XPathEvaluator._precedence.substr(Fleur.XPathEvaluator._precedence.indexOf(".~~" + (o === "a" ? "ascending" : "descending") + ".") + (o === "a" ? 13 : 14)); - var postprec00 = postprec0.substr(postprec0.indexOf("&") + 1); - var postprec = postprec00.substr(0, postprec00.indexOf(".")); - var poststacks = Fleur.XPathEvaluator._calc(args2, ops, parseInt(postprec, 10)); - var postargslen = poststacks.substr(0, poststacks.indexOf(".")); - args2 = poststacks.substr(poststacks.indexOf(".") + 1).substr(0, parseInt(postargslen, 10)); - var postnextstack = poststacks.substr(postargslen.length + 1 + parseInt(postargslen, 10)); - var postopslen = postnextstack.substr(0, postnextstack.indexOf(".")); - ops = (postprec.length + 1 + (o === "a" ? 11 : 12)) + "." + postprec + ".~~" + (o === "a" ? "ascending" : "descending") + postnextstack.substr(postnextstack.indexOf(".") + 1).substr(0, parseInt(postopslen, 10)); - f = f.substr(i4 + (o === "a" ? 9 : 10)); - i4 = Fleur.XPathEvaluator._skipSpaces(f, 0); - o = f.charAt(i4); - p = f.substr(f.indexOf(o)); - } - if (ops.substr(0, 16) === "13.6.instance of") { - if (o === "+" || o === "?" || o === "*") { - ops = "14.6.instance of" + o + ops.substr(16); - i4 = Fleur.XPathEvaluator._skipSpaces(f, 1); - o = f.charAt(i4); - p = f.substr(f.indexOf(o)); - } - } else if (ops.substr(0, 13) === "10.5.treat as") { - if (o === "+" || o === "?" || o === "*") { - ops = "11.5.treat as" + o + ops.substr(13); - i4 = Fleur.XPathEvaluator._skipSpaces(f, 1); - o = f.charAt(i4); - p = f.substr(f.indexOf(o)); - } - } else if (ops.substr(0, 11) === "9.3.cast as") { - if (o === "?") { - ops = "10.3.cast as" + o + ops.substr(11); - i4 = Fleur.XPathEvaluator._skipSpaces(f, 1); - o = f.charAt(i4); - p = f.substr(f.indexOf(o)); - } - } else if (ops.substr(0, 16) === "13.4.castable as") { - if (o === "?") { - ops = "14.4.castable as" + o + ops.substr(16); - i4 = Fleur.XPathEvaluator._skipSpaces(f, 1); - o = f.charAt(i4); - p = f.substr(f.indexOf(o)); - } - } - if (o === "") { - var stacks = Fleur.XPathEvaluator._calc(args2, ops, 9999999); - var reslen0 = stacks.substr(stacks.indexOf(".") + 1); - var reslen = reslen0.substr(0, reslen0.indexOf(".")); - var ret0 = stacks.substr(stacks.indexOf(".") + 1); - return ret0.substr(ret0.indexOf(".") + 1).substr(0, parseInt(reslen, 10)); - } - if (o === "]" || o === ")" || o === "}" || (p.substr(0, 6) === "return" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(6)) === -1) || (p.substr(0, 9) === "satisfies" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(9)) === -1)) { - var stacks2 = Fleur.XPathEvaluator._calc(args2, ops, 998); - var reslen20 = stacks2.substr(stacks2.indexOf(".") + 1); - var reslen2 = reslen20.substr(0, reslen20.indexOf(".")); - var ret20 = stacks2.substr(stacks2.indexOf(".") + 1); - return (f.substr(f.indexOf(o) + 1).length - (o === "r" ? 5 : o === "s" ? 8 : 0)) + "." + ret20.substr(ret20.indexOf(".") + 1).substr(0, parseInt(reslen2, 10)); - } - if (o === "$") { - switch(rval) { - case "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['for']]]]]]": - rval = "[Fleur.XQueryX.flworExpr,[]]"; - op = "for"; - break; - case "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['let']]]]]]": - rval = "[Fleur.XQueryX.flworExpr,[]]"; - op = "let"; - break; - case "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['every']]]]]]": - rval = "[Fleur.XQueryX.quantifiedExpr,[[Fleur.XQueryX.quantifier,['every']]]]"; - op = "every"; - break; - case "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['some']]]]]]": - rval = "[Fleur.XQueryX.quantifiedExpr,[[Fleur.XQueryX.quantifier,['some']]]]"; - op = "some"; - break; - } - if (op !== "null") { - r = Fleur.XPathEvaluator._getPredParams("(" + f, rlen, rval); - rlen = parseInt(r.substr(0, r.indexOf(".")), 10); - rval = r.substr(r.indexOf(".") + 1); - args2 = rval.length + "." + rval + args; - op = op === "for" || op === "let" ? "return" : "satisfies"; - f = d.substr(rlen - 2 - op.length); - p = f.substr(1); - } - } else if (p.substr(0, 9) === "intersect" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(9)) === -1) { - op = p.substr(0, 9); - } else if (p.substr(0, 8) === "allowing" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(8)) === -1) { - op = p.substr(0, 8); - } else if (p.substr(0, 8) === "instance" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(8)) === -1) { - op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 8) + 2); - op2 = "instance of"; - } else if (p.substr(0, 8) === "castable" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(8)) === -1) { - op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 8) + 2); - op2 = "castable as"; - } else if ((p.substr(0, 6) === "except" || p.substr(0, 6) === "before") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(6)) === -1) { - op = p.substr(0, 6); - } else if (p.substr(0, 5) === "treat" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(5)) === -1) { - op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 5) + 2); - op2 = "treat as"; - } else if (p.substr(0, 5) === "group" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(5)) === -1) { - op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 5) + 2); - op2 = "group by"; - } else if (p.substr(0, 5) === "order" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(5)) === -1) { - op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 5) + 2); - op2 = "order by"; - } else if ((p.substr(0, 5) === "union" || p.substr(0, 5) === "every" || p.substr(0, 5) === "nodes" || p.substr(0, 5) === "after" || p.substr(0, 5) === "value" || p.substr(0, 5) === "count" || p.substr(0, 5) === "where" || p.substr(0, 5) === "empty" || p.substr(0, 5) === "catch") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(5)) === -1) { - op = p.substr(0, 5); - } else if (p.substr(0, 4) === "cast" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(4)) === -1) { - op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 4) + 2); - op2 = "cast as"; - } else if ((p.substr(0, 4) === "idiv" || p.substr(0, 4) === "some" || p.substr(0, 4) === "then" || p.substr(0, 4) === "else" || p.substr(0, 4) === "node" || p.substr(0, 4) === "with" || p.substr(0, 4) === "into") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(4)) === -1) { - op = p.substr(0, 4); - } else if ((p.substr(0, 3) === "div" || p.substr(0, 3) === "and" || p.substr(0, 3) === "mod" || p.substr(0, 3) === "let" || p.substr(0, 3) === "for") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(3)) === -1) { - op = p.substr(0, 3); - } else if ((p.substr(0, 2) === "or" || p.substr(0, 2) === "eq" || p.substr(0, 2) === "ne" || p.substr(0, 2) === "lt" || p.substr(0, 2) === "le" || p.substr(0, 2) === "gt" || p.substr(0, 2) === "ge" || p.substr(0, 2) === "is" || p.substr(0, 2) === "to" || p.substr(0, 2) === "in" || p.substr(0, 2) === "as" || p.substr(0, 2) === "at" || p.substr(0, 2) === "by") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(2)) === -1) { - op = p.substr(0, 2); - } else if (p.substr(0, 2) === "!=" || p.substr(0, 2) === "<=" || p.substr(0, 2) === ">=" || p.substr(0, 2) === "<<" || p.substr(0, 2) === ">>" || p.substr(0, 2) === "//" || p.substr(0, 2) === "~+" || p.substr(0, 2) === "~-" || p.substr(0, 2) === ":=" || p.substr(0, 2) === "||" || p.substr(0, 2) === "!!") { - op = p.substr(0, 2); - } else if ("+-*=|,;<>/!{:".indexOf(o) !== -1) { - op = o; - if (op === ",") { - if (ops.startsWith("5.18.:=") || ops.startsWith("11.30.group by") || ops.startsWith("5.29.~,11.30.group by")) { - op2 = "~,"; - } else { - var optrack = ops; - while (optrack !== "") { - if (optrack.startsWith("11.30.order by")) { - op2 = "~,"; - break; - } - var optracklen = parseInt(optrack.substr(0, optrack.indexOf(".")), 10); - var optrackprec0 = optrack.substring(optrack.indexOf(".") + 1, optracklen); - var optrackprec = parseInt(optrackprec0.substr(0, optrackprec0.indexOf(".")), 10); - if (optrackprec > 30) { - break; - } - optrack = optrack.substr(optrack.indexOf(".") + 1 + optracklen); - } - } - } - } - if (op !== "null") { - var opprec0 = Fleur.XPathEvaluator._precedence.substr(Fleur.XPathEvaluator._precedence.indexOf("." + (op2 !== "null" ? op2 : op) + ".") + (op2 !== "null" ? op2 : op).length + 2); - var opprec00 = opprec0.substr(opprec0.indexOf("&") + 1); - var opprec = opprec00.substr(0, opprec00.indexOf(".")); - var stacks3 = Fleur.XPathEvaluator._calc(args2, ops, parseInt(opprec, 10)); - var args3len = stacks3.substr(0, stacks3.indexOf(".")); - var args3 = stacks3.substr(stacks3.indexOf(".") + 1).substr(0, parseInt(args3len, 10)); - var nextstack = stacks3.substr(args3len.length + 1 + parseInt(args3len, 10)); - var ops3len = nextstack.substr(0, nextstack.indexOf(".")); - var ops3 = nextstack.substr(nextstack.indexOf(".") + 1).substr(0, parseInt(ops3len, 10)); - var xp3 = p.substr(op.length); - return Fleur.XPathEvaluator._xp2js(xp3, args3, (opprec.length + 1 + (op2 !== "null" ? op2 : op).length) + "." + opprec + "." + (op2 !== "null" ? op2 : op) + ops3); - } - throw Error("Unknown operator at '" + f + "'"); - }; - Fleur.XPathEvaluator._getVersion = function(xq) { - var i = Fleur.XPathEvaluator._skipSpaces(xq, 0); - var c = xq.charAt(i); - var d = xq.substr(i + 1); - var r = ""; - var v, e; - if (c === "" || "abcdefghijklmnopqrstuvwxyz".indexOf(c) === -1) { - return i + "."; - } - r = Fleur.XPathEvaluator._getName(c + d); - if (r === "xquery") { - var j = Fleur.XPathEvaluator._skipSpaces(xq, i + r.length); - c = xq.charAt(j); - d = xq.substr(j + 1); - if (c === "" || "abcdefghijklmnopqrstuvwxyz".indexOf(c) === -1) { - return i + "."; - } - r = Fleur.XPathEvaluator._getName(c + d); - if (r === "version") { - j = Fleur.XPathEvaluator._skipSpaces(xq, j + r.length); - c = xq.charAt(j); - d = xq.substr(j + 1); - if (c !== "'" && c !== '"') { - return i + "."; - } - r = Fleur.XPathEvaluator._getStringLiteral(c + d); - var vl = r.substr(0, r.indexOf(".")); - v = r.substr(vl.length + 1); - j = Fleur.XPathEvaluator._skipSpaces(xq, j + parseInt(vl, 10)); - c = xq.charAt(j); - if (c === ";") { - return (j + 1) + ".[Fleur.XQueryX.versionDecl,[[Fleur.XQueryX.version,[" + v + "]]]],"; - } - d = xq.substr(j + 1); - r = Fleur.XPathEvaluator._getName(c + d); - } - if (r === "encoding") { - j = Fleur.XPathEvaluator._skipSpaces(xq, j + r.length); - c = xq.charAt(j); - d = xq.substr(j + 1); - if (c !== "'" && c !== '"') { - return i + "."; - } - r = Fleur.XPathEvaluator._getStringLiteral(c + d); - var el = r.substr(0, r.indexOf(".")); - e = r.substr(el.length + 1); - j = Fleur.XPathEvaluator._skipSpaces(xq, j + parseInt(el, 10)); - c = xq.charAt(j); - if (c === ";") { - return (j + 1) + ".[Fleur.XQueryX.versionDecl,[" + (v ? "[Fleur.XQueryX.version,[" + v + "]]," : "") + "[Fleur.XQueryX.encoding,[" + e + "]]]],"; - } - } - } - return i + "."; - }; - })(typeof exports === 'undefined'? this.Fleur = {}: exports); + console.info('Fleur 1.0 (15), XPath 1.0 Parser, copyright (C) 2023 agenceXML - Alain Couthures, contact at fleur@agencexml.com'); + (function(Fleur) { + Fleur.Node = function() {}; + Fleur.Node.ELEMENT_NODE = 1; + Fleur.Node.ATTRIBUTE_NODE = 2; + Fleur.Node.TEXT_NODE = 3; + Fleur.Node.CDATA_NODE = 4; + Fleur.Node.ENTITY_REFERENCE_NODE = 5; + Fleur.Node.ENTITY_NODE = 6; + Fleur.Node.PROCESSING_INSTRUCTION_NODE = 7; + Fleur.Node.COMMENT_NODE = 8; + Fleur.Node.DOCUMENT_NODE = 9; + Fleur.Node.DOCUMENT_TYPE_NODE = 10; + Fleur.Node.DOCUMENT_FRAGMENT_NODE = 11; + Fleur.Node.NOTATION_NODE = 12; + Fleur.Node.NAMESPACE_NODE = 129; + Fleur.Node.ATOMIC_NODE = Fleur.Node.TEXT_NODE; + Fleur.Node.SEQUENCE_NODE = 130; + Fleur.Node.ARRAY_NODE = 131; + Fleur.Node.MAP_NODE = 132; + Fleur.Node.ENTRY_NODE = 133; + Fleur.minimal = true; + Fleur.DocumentType = function() {}; + Fleur.DocumentType.resolveEntities = function(doctype, s) { + var offset = 0, index, entityname, entityvalue = null; + while ((index = s.indexOf("&", offset)) !== -1) { + entityname = s.substring(index + 1, s.indexOf(";", index + 1)); + switch (entityname) { + case "amp": + entityvalue = "&"; + break; + case "lt": + entityvalue = "<"; + break; + case "gt": + entityvalue = ">"; + break; + case "apos": + entityvalue = "'"; + break; + case "quot": + entityvalue = '"'; + break; + default: + if (entityname.charAt(0) === "#") { + entityvalue = String.fromCharCode(parseInt(entityname.charAt(1).toLowerCase() === 'x' ? "0" + entityname.substr(1).toLowerCase() : entityname.substr(1), entityname.charAt(1).toLowerCase() === 'x' ? 16 : 10)); + } else if (doctype) { + entityvalue = doctype.getEntity(entityname); + } + } + if (entityvalue) { + s = s.substr(0, index) + entityvalue + s.substr(index + entityname.length + 2); + offset = index + entityvalue.length; + entityvalue = null; + } else { + break; + } + } + return s.split("\r\n").join("\n"); + }; + Fleur.Serializer = function() {}; + Fleur.Serializer.escapeXML = function(s) { + return s.replace(/&/g, "&").replace(//g, ">"); + }; + Fleur.Serializer.prototype._serializeXMLToString = function(node, indent, offset, cdataSectionElements) { + var s, i, l; + switch (node.nodeType) { + case Fleur.Node.ELEMENT_NODE: + s = (indent ? offset + "\x3C" : "\x3C") + node.nodeName; + if (indent) { + var names = []; + for (i = 0, l = node.attributes.length; i < l; i++) { + names.push(node.attributes[i].nodeName); + } + names.sort(); + for (i = 0, l = names.length; i < l; i++) { + s += " " + names[i] + "=\"" + Fleur.Serializer.escapeXML(node.getAttribute(names[i])).replace('"', """) + "\""; + } + } else { + for (i = 0, l = node.attributes.length; i < l; i++) { + s += " " + node.attributes[i].nodeName + "=\"" + Fleur.Serializer.escapeXML(node.attributes[i].nodeValue).replace('"', """) + "\""; + } + } + if (node.childNodes.length === 0) { + return s + (indent ? "/\x3E\n" : "/\x3E"); + } + s += indent && (node.childNodes[0].nodeType !== Fleur.Node.TEXT_NODE || node.childNodes[0].data.match(/^[ \t\n\r]*$/)) ? "\x3E\n" : "\x3E"; + if (cdataSectionElements.indexOf(" " + node.nodeName + " ") !== -1) { + for (i = 0, l = node.childNodes.length; i < l; i++) { + if (node.childNodes[i].nodeType === Fleur.Node.TEXT_NODE) { + s += "\x3C![CDATA["; + s += node.childNodes[i].data; + s += "]]\x3E"; + } else { + s += this._serializeXMLToString(node.childNodes[i], indent, offset + " ", cdataSectionElements); + } + } + } else { + for (i = 0, l = node.childNodes.length; i < l; i++) { + s += this._serializeXMLToString(node.childNodes[i], indent, offset + " ", cdataSectionElements); + } + } + return s + (indent && (node.childNodes[0].nodeType !== Fleur.Node.TEXT_NODE || node.childNodes[0].data.match(/^[ \t\n\r]*$/)) ? offset + "\x3C/" : "\x3C/") + node.nodeName + (indent ? "\x3E\n" : "\x3E"); + case Fleur.Node.TEXT_NODE: + if (indent && node.data.match(/^[ \t\n\r]*$/) && node.parentNode.childNodes.length !== 1) { + return ""; + } + return Fleur.Serializer.escapeXML(node.data); + case Fleur.Node.CDATA_NODE: + return (indent ? offset + "\x3C![CDATA[" : "\x3C![CDATA[") + node.data + (indent ? "]]\x3E\n" : "]]\x3E"); + case Fleur.Node.PROCESSING_INSTRUCTION_NODE: + return (indent ? offset + "\x3C?" : "\x3C?") + node.nodeName + " " + node.nodeValue + (indent ? "?\x3E\n" : "?\x3E"); + case Fleur.Node.COMMENT_NODE: + return (indent ? offset + "\x3C!--" : "\x3C!--") + node.data + (indent ? "--\x3E\n" : "--\x3E"); + case Fleur.Node.DOCUMENT_NODE: + s = '\x3C?xml version="1.0" encoding="UTF-8"?\x3E\r\n'; + for (i = 0, l = node.childNodes.length; i < l; i++) { + s += this._serializeXMLToString(node.childNodes[i], indent, offset, cdataSectionElements); + } + return s; + } + }; + Fleur.Serializer.prototype.serializeToString = function(node, mediatype, indent, cdataSectionElements) { + var media = mediatype.split(";"), config = {}, param, paramreg = /^\s*(\S*)\s*=\s*(\S*)\s*$/, i = 1, l = media.length, ser; + while (i < l) { + param = paramreg.exec(media[i]); + config[param[1]] = param[2]; + i++; + } + switch (media[0].replace(/^\s+|\s+$/gm,'')) { + case "text/xml": + case "application/xml": + ser = this._serializeXMLToString(node, indent, "", " " + cdataSectionElements + " "); + if (indent && ser.charAt(ser.length - 1) === "\n") { + ser = ser.substr(0, ser.length - 1); + } + return ser; + } + }; + Fleur.XMLSerializer = function() {}; + Fleur.XMLSerializer.prototype = new Fleur.Serializer(); + Fleur.XMLSerializer.prototype.serializeToString = function(node, indent, cdataSectionElements) { + return Fleur.Serializer.prototype.serializeToString.call(this, node, "application/xml", indent, cdataSectionElements); + }; + Fleur.Xlength = 0; + Fleur.XQueryXNames = [["http://www.w3.org/2005/XQueryX", "http://www.w3.org/2000/xmlns/", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/2007/xquery-update-10"], []]; + Fleur.XQueryX = {}; + Fleur.XQueryXNames[1][Fleur.XQueryX.NCName = Fleur.Xlength++] = [1, 0, "xqx:NCName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.QName = Fleur.Xlength++] = [1, 0, "xqx:QName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.URIExpr = Fleur.Xlength++] = [1, 0, "xqx:URIExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.Wildcard = Fleur.Xlength++] = [1, 0, "xqx:Wildcard"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.addOp = Fleur.Xlength++] = [1, 0, "xqx:addOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.allowingEmpty = Fleur.Xlength++] = [1, 0, "xqx:allowingEmpty"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.andOp = Fleur.Xlength++] = [1, 0, "xqx:andOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.annotation = Fleur.Xlength++] = [1, 0, "xqx:annotation"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.annotationName = Fleur.Xlength++] = [1, 0, "xqx:annotationName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.anyElementTest = Fleur.Xlength++] = [1, 0, "xqx:anyElementTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.anyFunctionTest = Fleur.Xlength++] = [1, 0, "xqx:anyFunctionTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.anyItemType = Fleur.Xlength++] = [1, 0, "xqx:anyItemType"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.anyKindTest = Fleur.Xlength++] = [1, 0, "xqx:anyKindTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.arrayConstructor = Fleur.Xlength++] = [1, 0, "xqx:arrayConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.argExpr = Fleur.Xlength++] = [1, 0, "xqx:argExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.argumentPlaceholder = Fleur.Xlength++] = [1, 0, "xqx:argumentPlaceholder"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.arguments = Fleur.Xlength++] = [1, 0, "xqx:arguments"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.arithmeticOp = Fleur.Xlength++] = [1, 0, "xqx:arithmeticOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.arrayTest = Fleur.Xlength++] = [1, 0, "xqx:arrayTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.atomicType = Fleur.Xlength++] = [1, 0, "xqx:atomicType"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.attributeConstructor = Fleur.Xlength++] = [1, 0, "xqx:attributeConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.attributeList = Fleur.Xlength++] = [1, 0, "xqx:attributeList"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.attributeName = Fleur.Xlength++] = [1, 0, "xqx:attributeName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.attributeTest = Fleur.Xlength++] = [1, 0, "xqx:attributeTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.attributeValue = Fleur.Xlength++] = [1, 0, "xqx:attributeValue"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.attributeValueExpr = Fleur.Xlength++] = [1, 0, "xqx:attributeValueExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.baseUriDecl = Fleur.Xlength++] = [1, 0, "xqx:baseUriDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.bindingSequence = Fleur.Xlength++] = [1, 0, "xqx:bindingSequence"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.boundarySpaceDecl = Fleur.Xlength++] = [1, 0, "xqx:boundarySpaceDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.castExpr = Fleur.Xlength++] = [1, 0, "xqx:castExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.castableExpr = Fleur.Xlength++] = [1, 0, "xqx:castableExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.catchClause = Fleur.Xlength++] = [1, 0, "xqx:catchClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.catchErrorList = Fleur.Xlength++] = [1, 0, "xqx:catchErrorList"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.catchExpr = Fleur.Xlength++] = [1, 0, "xqx:catchExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.collation = Fleur.Xlength++] = [1, 0, "xqx:collation"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.commentTest = Fleur.Xlength++] = [1, 0, "xqx:commentTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.comparisonOp = Fleur.Xlength++] = [1, 0, "xqx:comparisonOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.computedAttributeConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedAttributeConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.computedCommentConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedCommentConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.computedDocumentConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedDocumentConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.computedElementConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedElementConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.computedEntryConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedEntryConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.computedNamespaceConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedNamespaceConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.computedPIConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedPIConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.computedTextConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedTextConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.constantExpr = Fleur.Xlength++] = [1, 0, "xqx:constantExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.constructionDecl = Fleur.Xlength++] = [1, 0, "xqx:constructionDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.constructorFunctionExpr = Fleur.Xlength++] = [1, 0, "xqx:constructorFunctionExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.contentExpr = Fleur.Xlength++] = [1, 0, "xqx:contentExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.contextItemDecl = Fleur.Xlength++] = [1, 0, "xqx:contextItemDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.contextItemExpr = Fleur.Xlength++] = [1, 0, "xqx:contextItemExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.copyNamespacesDecl = Fleur.Xlength++] = [1, 0, "xqx:copyNamespacesDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.countClause = Fleur.Xlength++] = [1, 0, "xqx:countClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.currentItem = Fleur.Xlength++] = [1, 0, "xqx:currentItem"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.decimalConstantExpr = Fleur.Xlength++] = [1, 0, "xqx:decimalConstantExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatDecl = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatName = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatParam = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatParam"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatParamName = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatParamName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatParamValue = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatParamValue"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.defaultCollationDecl = Fleur.Xlength++] = [1, 0, "xqx:defaultCollationDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.defaultElementNamespace = Fleur.Xlength++] = [1, 0, "xqx:defaultElementNamespace"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.defaultNamespaceCategory = Fleur.Xlength++] = [1, 0, "xqx:defaultNamespaceCategory"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.defaultNamespaceDecl = Fleur.Xlength++] = [1, 0, "xqx:defaultNamespaceDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.divOp = Fleur.Xlength++] = [1, 0, "xqx:divOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.documentTest = Fleur.Xlength++] = [1, 0, "xqx:documentTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.doubleConstantExpr = Fleur.Xlength++] = [1, 0, "xqx:doubleConstantExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.doubleMapExpr = Fleur.Xlength++] = [1, 0, "xqx:doubleMapExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.dynamicFunctionInvocationExpr = Fleur.Xlength++] = [1, 0, "xqx:dynamicFunctionInvocationExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.elementConstructor = Fleur.Xlength++] = [1, 0, "xqx:elementConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.elementContent = Fleur.Xlength++] = [1, 0, "xqx:elementContent"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.elementName = Fleur.Xlength++] = [1, 0, "xqx:elementName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.elementTest = Fleur.Xlength++] = [1, 0, "xqx:elementTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.elseClause = Fleur.Xlength++] = [1, 0, "xqx:elseClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.emptyOrderingDecl = Fleur.Xlength++] = [1, 0, "xqx:emptyOrderingDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.emptyOrderingMode = Fleur.Xlength++] = [1, 0, "xqx:emptyOrderingMode"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.encoding = Fleur.Xlength++] = [1, 0, "xqx:encoding"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.endExpr = Fleur.Xlength++] = [1, 0, "xqx:endExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.entryTest = Fleur.Xlength++] = [1, 0, "xqx:entryTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.eqOp = Fleur.Xlength++] = [1, 0, "xqx:eqOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.equalOp = Fleur.Xlength++] = [1, 0, "xqx:equalOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.exceptOp = Fleur.Xlength++] = [1, 0, "xqx:exceptOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.expr = Fleur.Xlength++] = [1, 0, "xqx:expr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.extensionExpr = Fleur.Xlength++] = [1, 0, "xqx:extensionExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.external = Fleur.Xlength++] = [1, 0, "xqx:external"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.externalDefinition = Fleur.Xlength++] = [1, 0, "xqx:externalDefinition"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.filterExpr = Fleur.Xlength++] = [1, 0, "xqx:filterExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.firstOperand = Fleur.Xlength++] = [1, 0, "xqx:firstOperand"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.flworExpr = Fleur.Xlength++] = [1, 0, "xqx:flworExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.forClause = Fleur.Xlength++] = [1, 0, "xqx:forClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.forClauseItem = Fleur.Xlength++] = [1, 0, "xqx:forClauseItem"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.forExpr = Fleur.Xlength++] = [1, 0, "xqx:forExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.forLetClauseItemExtensions = Fleur.Xlength++] = [1, 0, "xqx:forLetClauseItemExtensions"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.functionBody = Fleur.Xlength++] = [1, 0, "xqx:functionBody"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.functionCallExpr = Fleur.Xlength++] = [1, 0, "xqx:functionCallExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.functionDecl = Fleur.Xlength++] = [1, 0, "xqx:functionDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.functionItem = Fleur.Xlength++] = [1, 0, "xqx:functionItem"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.functionName = Fleur.Xlength++] = [1, 0, "xqx:functionName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.geOp = Fleur.Xlength++] = [1, 0, "xqx:geOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.generalComparisonOp = Fleur.Xlength++] = [1, 0, "xqx:generalComparisonOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.greaterThanOp = Fleur.Xlength++] = [1, 0, "xqx:greaterThanOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.greaterThanOrEqualOp = Fleur.Xlength++] = [1, 0, "xqx:greaterThanOrEqualOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.groupByClause = Fleur.Xlength++] = [1, 0, "xqx:groupByClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.groupVarInitialize = Fleur.Xlength++] = [1, 0, "xqx:groupVarInitialize"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.groupingSpec = Fleur.Xlength++] = [1, 0, "xqx:groupingSpec"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.gtOp = Fleur.Xlength++] = [1, 0, "xqx:gtOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.idivOp = Fleur.Xlength++] = [1, 0, "xqx:idivOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.ifClause = Fleur.Xlength++] = [1, 0, "xqx:ifClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.ifThenElseExpr = Fleur.Xlength++] = [1, 0, "xqx:ifThenElseExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.inheritMode = Fleur.Xlength++] = [1, 0, "xqx:inheritMode"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.inlineFunctionExpr = Fleur.Xlength++] = [1, 0, "xqx:inlineFunctionExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.instanceOfExpr = Fleur.Xlength++] = [1, 0, "xqx:instanceOfExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.integerConstantExpr = Fleur.Xlength++] = [1, 0, "xqx:integerConstantExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.intersectOp = Fleur.Xlength++] = [1, 0, "xqx:intersectOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.isOp = Fleur.Xlength++] = [1, 0, "xqx:isOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.itemType = Fleur.Xlength++] = [1, 0, "xqx:itemType"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.javascriptImport = Fleur.Xlength++] = [1, 0, "xqx:javascriptImport"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.kindTest = Fleur.Xlength++] = [1, 0, "xqx:kindTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.leOp = Fleur.Xlength++] = [1, 0, "xqx:leOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.lessThanOp = Fleur.Xlength++] = [1, 0, "xqx:lessThanOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.lessThanOrEqualOp = Fleur.Xlength++] = [1, 0, "xqx:lessThanOrEqualOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.letClause = Fleur.Xlength++] = [1, 0, "xqx:letClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.letClauseItem = Fleur.Xlength++] = [1, 0, "xqx:letClauseItem"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.letExpr = Fleur.Xlength++] = [1, 0, "xqx:letExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.libraryModule = Fleur.Xlength++] = [1, 0, "xqx:libraryModule"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.logicalOp = Fleur.Xlength++] = [1, 0, "xqx:logicalOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.lookup = Fleur.Xlength++] = [1, 0, "xqx:lookup"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.ltOp = Fleur.Xlength++] = [1, 0, "xqx:ltOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.mainModule = Fleur.Xlength++] = [1, 0, "xqx:mainModule"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.mapConstructor = Fleur.Xlength++] = [1, 0, "xqx:mapConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.mapConstructorEntry = Fleur.Xlength++] = [1, 0, "xqx:mapConstructorEntry"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.mapKeyExpr = Fleur.Xlength++] = [1, 0, "xqx:mapKeyExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.mapTest = Fleur.Xlength++] = [1, 0, "xqx:mapTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.mapValueExpr = Fleur.Xlength++] = [1, 0, "xqx:mapValueExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.modOp = Fleur.Xlength++] = [1, 0, "xqx:modOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.module = Fleur.Xlength++] = [1, 0, "xqx:module"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.moduleDecl = Fleur.Xlength++] = [1, 0, "xqx:moduleDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.moduleImport = Fleur.Xlength++] = [1, 0, "xqx:moduleImport"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.multidimExpr = Fleur.Xlength++] = [1, 0, "xqx:multidimExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.multiplyOp = Fleur.Xlength++] = [1, 0, "xqx:multiplyOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.name = Fleur.Xlength++] = [1, 0, "xqx:name"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.nameTest = Fleur.Xlength++] = [1, 0, "xqx:nameTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.namedFunctionRef = Fleur.Xlength++] = [1, 0, "xqx:namedFunctionRef"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.namespaceDecl = Fleur.Xlength++] = [1, 0, "xqx:namespaceDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.namespaceDeclaration = Fleur.Xlength++] = [1, 0, "xqx:namespaceDeclaration"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.namespacePrefix = Fleur.Xlength++] = [1, 0, "xqx:namespacePrefix"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.namespaceTest = Fleur.Xlength++] = [1, 0, "xqx:namespaceTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.neOp = Fleur.Xlength++] = [1, 0, "xqx:neOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.nextItem = Fleur.Xlength++] = [1, 0, "xqx:nextItem"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.nillable = Fleur.Xlength++] = [1, 0, "xqx:nillable"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.nodeAfterOp = Fleur.Xlength++] = [1, 0, "xqx:nodeAfterOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.nodeBeforeOp = Fleur.Xlength++] = [1, 0, "xqx:nodeBeforeOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.nodeComparisonOp = Fleur.Xlength++] = [1, 0, "xqx:nodeComparisonOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.notEqualOp = Fleur.Xlength++] = [1, 0, "xqx:notEqualOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.occurrenceIndicator = Fleur.Xlength++] = [1, 0, "xqx:occurrenceIndicator"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.operand = Fleur.Xlength++] = [1, 0, "xqx:operand"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.operatorExpr = Fleur.Xlength++] = [1, 0, "xqx:operatorExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.optionContents = Fleur.Xlength++] = [1, 0, "xqx:optionContents"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.optionDecl = Fleur.Xlength++] = [1, 0, "xqx:optionDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.optionName = Fleur.Xlength++] = [1, 0, "xqx:optionName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.optional = Fleur.Xlength++] = [1, 0, "xqx:optional"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.orOp = Fleur.Xlength++] = [1, 0, "xqx:orOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.orderByClause = Fleur.Xlength++] = [1, 0, "xqx:orderByClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.orderByExpr = Fleur.Xlength++] = [1, 0, "xqx:orderByExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.orderBySpec = Fleur.Xlength++] = [1, 0, "xqx:orderBySpec"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.orderComparisonOp = Fleur.Xlength++] = [1, 0, "xqx:orderComparisonOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.orderModifier = Fleur.Xlength++] = [1, 0, "xqx:orderModifier"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.orderedExpr = Fleur.Xlength++] = [1, 0, "xqx:orderedExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.orderingKind = Fleur.Xlength++] = [1, 0, "xqx:orderingKind"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.orderingModeDecl = Fleur.Xlength++] = [1, 0, "xqx:orderingModeDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.param = Fleur.Xlength++] = [1, 0, "xqx:param"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.paramList = Fleur.Xlength++] = [1, 0, "xqx:paramList"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.paramTypeList = Fleur.Xlength++] = [1, 0, "xqx:paramTypeList"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.parenthesizedItemType = Fleur.Xlength++] = [1, 0, "xqx:parenthesizedItemType"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.pathExpr = Fleur.Xlength++] = [1, 0, "xqx:pathExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.piTarget = Fleur.Xlength++] = [1, 0, "xqx:piTarget"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.piTargetExpr = Fleur.Xlength++] = [1, 0, "xqx:piTargetExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.piTest = Fleur.Xlength++] = [1, 0, "xqx:piTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.piValueExpr = Fleur.Xlength++] = [1, 0, "xqx:piValueExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.positionalVariableBinding = Fleur.Xlength++] = [1, 0, "xqx:positionalVariableBinding"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.pragma = Fleur.Xlength++] = [1, 0, "xqx:pragma"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.pragmaContents = Fleur.Xlength++] = [1, 0, "xqx:pragmaContents"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.pragmaName = Fleur.Xlength++] = [1, 0, "xqx:pragmaName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.predicate = Fleur.Xlength++] = [1, 0, "xqx:predicate"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.predicateExpr = Fleur.Xlength++] = [1, 0, "xqx:predicateExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.predicates = Fleur.Xlength++] = [1, 0, "xqx:predicates"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.prefixElt = Fleur.Xlength++] = [1, 0, "xqx:prefix"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.prefixExpr = Fleur.Xlength++] = [1, 0, "xqx:prefixExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.preserveMode = Fleur.Xlength++] = [1, 0, "xqx:preserveMode"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.previousItem = Fleur.Xlength++] = [1, 0, "xqx:previousItem"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.prolog = Fleur.Xlength++] = [1, 0, "xqx:prolog"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.prologPartOneItem = Fleur.Xlength++] = [1, 0, "xqx:prologPartOneItem"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.prologPartTwoItem = Fleur.Xlength++] = [1, 0, "xqx:prologPartTwoItem"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.quantifiedExpr = Fleur.Xlength++] = [1, 0, "xqx:quantifiedExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.quantifiedExprInClause = Fleur.Xlength++] = [1, 0, "xqx:quantifiedExprInClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.quantifier = Fleur.Xlength++] = [1, 0, "xqx:quantifier"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.queryBody = Fleur.Xlength++] = [1, 0, "xqx:queryBody"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.rangeSequenceExpr = Fleur.Xlength++] = [1, 0, "xqx:rangeSequenceExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.resultExpr = Fleur.Xlength++] = [1, 0, "xqx:resultExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.returnClause = Fleur.Xlength++] = [1, 0, "xqx:returnClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.rootExpr = Fleur.Xlength++] = [1, 0, "xqx:rootExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.schemaAttributeTest = Fleur.Xlength++] = [1, 0, "xqx:schemaAttributeTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.schemaElementTest = Fleur.Xlength++] = [1, 0, "xqx:schemaElementTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.schemaImport = Fleur.Xlength++] = [1, 0, "xqx:schemaImport"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.secondOperand = Fleur.Xlength++] = [1, 0, "xqx:secondOperand"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.sequenceExpr = Fleur.Xlength++] = [1, 0, "xqx:sequenceExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.sequenceType = Fleur.Xlength++] = [1, 0, "xqx:sequenceType"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.sequenceTypeUnion = Fleur.Xlength++] = [1, 0, "xqx:sequenceTypeUnion"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.setOp = Fleur.Xlength++] = [1, 0, "xqx:setOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.simpleMapExpr = Fleur.Xlength++] = [1, 0, "xqx:simpleMapExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.singleType = Fleur.Xlength++] = [1, 0, "xqx:singleType"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.slidingWindowClause = Fleur.Xlength++] = [1, 0, "xqx:slidingWindowClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.sourceExpr = Fleur.Xlength++] = [1, 0, "xqx:sourceExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.stable = Fleur.Xlength++] = [1, 0, "xqx:stable"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.star = Fleur.Xlength++] = [1, 0, "xqx:star"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.startExpr = Fleur.Xlength++] = [1, 0, "xqx:startExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.stepExpr = Fleur.Xlength++] = [1, 0, "xqx:stepExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.stringConcatenateOp = Fleur.Xlength++] = [1, 0, "xqx:stringConcatenateOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.stringConstantExpr = Fleur.Xlength++] = [1, 0, "xqx:stringConstantExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.stringOp = Fleur.Xlength++] = [1, 0, "xqx:stringOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.subtractOp = Fleur.Xlength++] = [1, 0, "xqx:subtractOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.switchCaseExpr = Fleur.Xlength++] = [1, 0, "xqx:switchCaseExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.switchExpr = Fleur.Xlength++] = [1, 0, "xqx:switchExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.switchExprCaseClause = Fleur.Xlength++] = [1, 0, "xqx:switchExprCaseClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.switchExprDefaultClause = Fleur.Xlength++] = [1, 0, "xqx:switchExprDefaultClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.tagName = Fleur.Xlength++] = [1, 0, "xqx:tagName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.tagNameExpr = Fleur.Xlength++] = [1, 0, "xqx:tagNameExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.targetLocation = Fleur.Xlength++] = [1, 0, "xqx:targetLocation"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.targetLocationExpr = Fleur.Xlength++] = [1, 0, "xqx:targetLocationExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.targetNamespace = Fleur.Xlength++] = [1, 0, "xqx:targetNamespace"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.textTest = Fleur.Xlength++] = [1, 0, "xqx:textTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.thenClause = Fleur.Xlength++] = [1, 0, "xqx:thenClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.treatExpr = Fleur.Xlength++] = [1, 0, "xqx:treatExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.tryCatchExpr = Fleur.Xlength++] = [1, 0, "xqx:tryCatchExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.tryClause = Fleur.Xlength++] = [1, 0, "xqx:tryClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.tumblingWindowClause = Fleur.Xlength++] = [1, 0, "xqx:tumblingWindowClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.typeDeclaration = Fleur.Xlength++] = [1, 0, "xqx:typeDeclaration"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.typeName = Fleur.Xlength++] = [1, 0, "xqx:typeName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.typedFunctionTest = Fleur.Xlength++] = [1, 0, "xqx:typedFunctionTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.typedVariableBinding = Fleur.Xlength++] = [1, 0, "xqx:typedVariableBinding"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.typeswitchExpr = Fleur.Xlength++] = [1, 0, "xqx:typeswitchExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.typeswitchExprCaseClause = Fleur.Xlength++] = [1, 0, "xqx:typeswitchExprCaseClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.typeswitchExprDefaultClause = Fleur.Xlength++] = [1, 0, "xqx:typeswitchExprDefaultClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.unaryMinusOp = Fleur.Xlength++] = [1, 0, "xqx:unaryMinusOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.unaryPlusOp = Fleur.Xlength++] = [1, 0, "xqx:unaryPlusOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.unionOp = Fleur.Xlength++] = [1, 0, "xqx:unionOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.unorderedExpr = Fleur.Xlength++] = [1, 0, "xqx:unorderedExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.unaryLookup = Fleur.Xlength++] = [1, 0, "xqx:unaryLookup"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.uri = Fleur.Xlength++] = [1, 0, "xqx:uri"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.validateExpr = Fleur.Xlength++] = [1, 0, "xqx:validateExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.validationMode = Fleur.Xlength++] = [1, 0, "xqx:validationMode"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.value = Fleur.Xlength++] = [1, 0, "xqx:value"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.valueComparisonOp = Fleur.Xlength++] = [1, 0, "xqx:valueComparisonOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.valueExpr = Fleur.Xlength++] = [1, 0, "xqx:valueExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.varDecl = Fleur.Xlength++] = [1, 0, "xqx:varDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.varName = Fleur.Xlength++] = [1, 0, "xqx:varName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.varRef = Fleur.Xlength++] = [1, 0, "xqx:varRef"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.varValue = Fleur.Xlength++] = [1, 0, "xqx:varValue"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.variableBinding = Fleur.Xlength++] = [1, 0, "xqx:variableBinding"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.version = Fleur.Xlength++] = [1, 0, "xqx:version"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.versionDecl = Fleur.Xlength++] = [1, 0, "xqx:versionDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.voidSequenceType = Fleur.Xlength++] = [1, 0, "xqx:voidSequenceType"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.whereClause = Fleur.Xlength++] = [1, 0, "xqx:whereClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.winEndExpr = Fleur.Xlength++] = [1, 0, "xqx:winEndExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.winStartExpr = Fleur.Xlength++] = [1, 0, "xqx:winStartExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.windowClause = Fleur.Xlength++] = [1, 0, "xqx:windowClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.windowEndCondition = Fleur.Xlength++] = [1, 0, "xqx:windowEndCondition"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.windowStartCondition = Fleur.Xlength++] = [1, 0, "xqx:windowStartCondition"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.windowVars = Fleur.Xlength++] = [1, 0, "xqx:windowVars"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.xpathAxis = Fleur.Xlength++] = [1, 0, "xqx:xpathAxis"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.URI = Fleur.Xlength++] = [2, 0, "xqx:URI"]; + Fleur.XQueryXNames[1][Fleur.XQueryX["default"] = Fleur.Xlength++] = [2, 0, "xqx:default"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.nondeterministic = Fleur.Xlength++] = [2, 0, "xqx:nondeterministic"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.onlyEnd = Fleur.Xlength++] = [2, 0, "xqx:onlyEnd"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.prefix = Fleur.Xlength++] = [2, 0, "xqx:prefix"]; + Fleur.XQueryXNames[1][Fleur.XQueryX["private"] = Fleur.Xlength++] = [2, 0, "xqx:private"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.sequentialFunction = Fleur.Xlength++] = [2, 0, "xqx:sequentialFunction"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.updatingFunction = Fleur.Xlength++] = [2, 0, "xqx:updatingFunction"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.xqx = Fleur.Xlength++] = [2, 1, "xmlns:xqx"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.xsi = Fleur.Xlength++] = [2, 1, "xmlns:xsi"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.schemaLocation = Fleur.Xlength++] = [2, 2, "xsi:schemaLocation"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.xqxuf = Fleur.Xlength++] = [2, 1, "xmlns:xqxuf"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.copyModifyExpr = Fleur.Xlength++] = [1, 3, "xqxuf:copyModifyExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.copySource = Fleur.Xlength++] = [1, 3, "xqxuf:copySource"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.deleteExpr = Fleur.Xlength++] = [1, 3, "xqxuf:deleteExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.insertAfter = Fleur.Xlength++] = [1, 3, "xqxuf:insertAfter"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.insertAsFirst = Fleur.Xlength++] = [1, 3, "xqxuf:insertAsFirst"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.insertAsLast = Fleur.Xlength++] = [1, 3, "xqxuf:insertAsLast"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.insertBefore = Fleur.Xlength++] = [1, 3, "xqxuf:insertBefore"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.insertExpr = Fleur.Xlength++] = [1, 3, "xqxuf:insertExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.insertInto = Fleur.Xlength++] = [1, 3, "xqxuf:insertInto"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.modifyExpr = Fleur.Xlength++] = [1, 3, "xqxuf:modifyExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.newNameExpr = Fleur.Xlength++] = [1, 3, "xqxuf:newNameExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.renameExpr = Fleur.Xlength++] = [1, 3, "xqxuf:renameExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.replaceExpr = Fleur.Xlength++] = [1, 3, "xqxuf:replaceExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.replaceValue = Fleur.Xlength++] = [1, 3, "xqxuf:replaceValue"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.replacementExpr = Fleur.Xlength++] = [1, 3, "xqxuf:replacementExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.returnExpr = Fleur.Xlength++] = [1, 3, "xqxuf:returnExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.revalidationDecl = Fleur.Xlength++] = [1, 3, "xqxuf:revalidationDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.sourceExprUf = Fleur.Xlength++] = [1, 3, "xqxuf:sourceExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.targetExpr = Fleur.Xlength++] = [1, 3, "xqxuf:targetExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.transformCopies = Fleur.Xlength++] = [1, 3, "xqxuf:transformCopies"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.transformCopy = Fleur.Xlength++] = [1, 3, "xqxuf:transformCopy"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.transformExpr = Fleur.Xlength++] = [1, 3, "xqxuf:transformExpr"]; + Fleur.XPathEvaluator = function() {}; + Fleur.XPathEvaluator._precedence = "././/.:.as.&0.!.!!.&1.~+.~-.&2.cast as.&3.castable as.&4.treat as.&5.instance of.&6.intersect.except.&7.|.union.&8.div.mod.*.idiv.&9.+.-.&10.to.&11.||.&12.eq.ne.lt.le.gt.ge.<.>.<=.>=.is.<<.>>.=.!=.&13.and.&14.or.&15.allowing.&16.at.&17.:=.in.&18.after.before.into.with.value.&19.node.nodes.&20.~~ascending.~~descending.empty.&28.~,.&29.for.let.group by.order by.stable order by.count.where.some.every.&30.then.catch.&31.else.return.satisfies.&32.,.&50.;.&51."; + Fleur.XPathEvaluator._rightgrouping1 = Fleur.XPathEvaluator._precedence.substr(Fleur.XPathEvaluator._precedence.indexOf(".then.") + 6); + Fleur.XPathEvaluator._rightgrouping1 = Fleur.XPathEvaluator._rightgrouping1.substr(Fleur.XPathEvaluator._rightgrouping1.indexOf("&") + 1); + Fleur.XPathEvaluator._rightgrouping1 = parseInt(Fleur.XPathEvaluator._rightgrouping1.substr(0, Fleur.XPathEvaluator._rightgrouping1.indexOf(".")), 10); + Fleur.XPathEvaluator._rightgrouping2 = Fleur.XPathEvaluator._precedence.substr(Fleur.XPathEvaluator._precedence.indexOf(".return.") + 6); + Fleur.XPathEvaluator._rightgrouping2 = Fleur.XPathEvaluator._rightgrouping2.substr(Fleur.XPathEvaluator._rightgrouping2.indexOf("&") + 1); + Fleur.XPathEvaluator._rightgrouping2 = parseInt(Fleur.XPathEvaluator._rightgrouping2.substr(0, Fleur.XPathEvaluator._rightgrouping2.indexOf(".")), 10); + Fleur.XPathEvaluator._opcodes = "./;stepExpr.|;unionOp.union;unionOp.div;divOp.mod;modOp.*;multiplyOp.idiv;idivOp.+;addOp.-;subtractOp.to;toOp.||;stringConcatenateOp.eq;eqOp.ne;neOp.lt;ltOp.le;leOp.gt;gtOp.ge;geOp.<;lessThanOp.>;greaterThanOp.<=;lessThanOrEqualOp.>=;greaterThanOrEqualOp.is;isOp.<<;nodeBeforeOp.>>;nodeAfterOp.=;equalOp.!=;notEqualOp.and;andOp.or;orOp.,;argExpr."; + Fleur.XPathEvaluator._skipComment = function(s, offset) { + var i = offset; + var c = s.charAt(i); + var d = s.charAt(i + 1); + var l = s.length; + do { + if (c === "(" && d === ":") { + i = Fleur.XPathEvaluator._skipComment(s, i + 2); + } else if (c === ":" && d === ")") { + return i + 1; + } + c = s.charAt(++i); + d = s.charAt(i + 1); + } while (i < l); + }; + Fleur.XPathEvaluator._skipSpaces = function(s, offset) { + var i = offset; + var c = s.charAt(i); + var l = s.length; + do { + if (c === "(" && s.charAt(i + 1) === ":") { + i = Fleur.XPathEvaluator._skipComment(s, i + 2); + } else if (c !== "\n" && c !== "\r" && c !== "\t" && c !== " ") { + return i; + } + c = s.charAt(++i); + } while (i < l); + return i; + }; + Fleur.XPathEvaluator._getName = function(s) { + var i = 0; + var o = s.charAt(0); + var prev = ""; + while (o !== "" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:*{".indexOf(o) !== -1) { + if (o === "*") { + if (i > 0 && (s.charAt(i - 1) === ":" || s.charAt(i - 1) === "}")) { + i++; + break; + } else if (s.charAt(i + 1) !== ":") { + if (i === 0) { + i++; + } + break; + } + } + if (o === "{") { + if (prev !== "Q") { + return s.substr(0, i); + } + while (o !== "" && o !== "}") { + o = s.charAt(++i); + } + } + prev = o; + o = s.charAt(++i); + } + if (o === "#") { + o = s.charAt(++i); + while (o !== "" && "0123456789".indexOf(o) !== -1) { + o = s.charAt(++i); + } + } + return s.substr(0, i); + }; + Fleur.XPathEvaluator._getNameStep = function(s, attr) { + var n = Fleur.XPathEvaluator._getName(s); + var fctind = n.indexOf("#"); + if (fctind !== -1) { + var pindex = n.indexOf(":"); + if (pindex === -1) { + return n.length + ".[Fleur.XQueryX.namedFunctionRef,[[Fleur.XQueryX.functionName,['" + n.substr(0, fctind) + "']],[Fleur.XQueryX.integerConstantExpr,[[Fleur.XQueryX.value,['" + n.substr(fctind + 1) + "']]]]]]"; + } + return n.length + ".[Fleur.XQueryX.namedFunctionRef,[[Fleur.XQueryX.functionName,['" + n.substr(0, fctind).substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + n.substr(0, pindex) + "']]]],[Fleur.XQueryX.integerConstantExpr,[[Fleur.XQueryX.value,['" + n.substr(fctind + 1) + "']]]]]]"; + } + var aind = n.indexOf("::"); + var axis = aind !== -1 ? n.substr(0, aind) : attr ? "attribute" : "child"; + var n2 = aind !== -1 ? n.substr(aind + 2) : n; + var eq = n2.substr(0, 2) === "Q{"; + var sind = eq ? n2.indexOf("}") : n2.indexOf(":"); + var n3 = sind !== -1 ? n2.substr(sind + 1) : n2; + var nsp = eq ? n2.substr(2, sind - 2) : sind !== -1 ? n2.substr(0, sind) : ""; + var ntest = n3 === "*" || nsp === "*" ? "[Fleur.XQueryX.Wildcard,[" + (n3 !== "*" ? "[Fleur.XQueryX.star,[]],[Fleur.XQueryX.NCName,['" + n3 + "']]" : "") + "]]" : "[Fleur.XQueryX.nameTest,['" + n3 + "'" + (eq || sind !== -1 ? ",[" + (eq ? "Fleur.XQueryX.URI" : "Fleur.XQueryX.prefix") + ",['" + nsp + "']]" : "") + "]]"; + return (n.length + attr) + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['" + axis + "']]," + ntest + "]]]]"; + }; + Fleur.XPathEvaluator._pathExprFormat = function(s, p) { + if (s.substr(0, 25) === "[Fleur.XQueryX.pathExpr,[") { + return s.substr(25, s.length - 29) + p + "]]"; + } + return "[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[" + s + "]]" + p + "]]"; + }; + Fleur.XPathEvaluator._calc = function(args, ops, opprec) { + var curop = parseInt(ops.split(".")[1], 10); + if ((ops === "" || curop > opprec || opprec === 31) || (curop >= opprec && (curop === Fleur.XPathEvaluator._rightgrouping1 || curop === Fleur.XPathEvaluator._rightgrouping2))) { + return args.length + "." + args + ops.length + "." + ops; + } + var op0 = ops.substr(ops.indexOf(".") + 1, parseInt(ops.split(".")[0], 10)); + var op = op0.substr(op0.indexOf(".") + 1); + var arg2len = args.substr(0, args.indexOf(".")); + var arg2val = args.substr(args.indexOf(".") + 1).substr(0, parseInt(arg2len, 10)); + var arg2val2, arg2val3; + var args3, arg1len, arg1val, arg1val2, arg1val3; + if (op.startsWith("~~")) { + args3 = args; + arg1len = arg2len; + arg1val = arg2val; + } else { + args3 = args.substr(arg2len.length + 1 + parseInt(arg2len, 10)); + arg1len = args3.substr(0, args3.indexOf(".")); + arg1val = args3.substr(args3.indexOf(".") + 1).substr(0, parseInt(arg1len, 10)); + } + var arg; + var occ; + switch (op) { + case ";": + if (arg1val.substr(0, 58) === "[Fleur.XQueryX.sequenceExpr,[[Fleur.XQueryX.multidimExpr,[") { + arg = "[Fleur.XQueryX.sequenceExpr,[[Fleur.XQueryX.multidimExpr,[" + arg1val.substr(58, arg1val.length - 62) + "," + arg2val + "]]]]"; + } else { + arg = "[Fleur.XQueryX.sequenceExpr,[[Fleur.XQueryX.multidimExpr,[" + arg1val + "," + arg2val + "]]]]"; + } + break; + case ",": + if (ops.substr(0, 13) === "4.50.,5.999.(") { + if (arg1val.substr(0, 26) === "[Fleur.XQueryX.arguments,[") { + arg = arg1val.substr(0, arg1val.length - 2) + "," + arg2val + "]]"; + } else { + arg = "[Fleur.XQueryX.arguments,[" + arg1val + "," + arg2val + "]]"; + } + } else if (ops.substr(0, 13) === "4.50.,5.999.q") { + arg = arg1val + "," + arg2val; + } else if (ops.startsWith("4.50.,")) { + if (arg1val.substr(0, 36) === "[Fleur.XQueryX.mapConstructorEntry,[") { + arg = arg1val + "," + arg2val; + } else if (arg1val.substr(0, 29) === "[Fleur.XQueryX.sequenceExpr,[" && arg1val !== "[Fleur.XQueryX.sequenceExpr,[]]") { + arg = arg1val.substr(0, arg1val.length - 2) + "," + arg2val + "]]"; + } else { + arg = "[Fleur.XQueryX.sequenceExpr,[" + arg1val + "," + arg2val + "]]"; + } + } else { + arg = arg1val + "," + arg2val; + } + break; + case "~,": + if (arg1val.substr(0, 29) === "[Fleur.XQueryX.letClauseItem," || arg1val.substr(0, 27) === "[Fleur.XQueryX.groupBySpec,") { + arg = arg1val + "," + arg2val; + } else if (arg1val.substr(0, 25) === "[Fleur.XQueryX.letClause,") { + if (arg2val.substr(0, 25) === "Fleur.XQueryX.letClause,") { + arg = arg1val.substr(0, arg1val.length - 2) + "," + arg2val.substr(25); + } else { + arg = arg1val.substr(0, arg1val.length - 2) + "," + arg2val + "]]"; + } + } else { + if (arg1val.substr(0, 27) !== "[Fleur.XQueryX.orderBySpec,") { + arg = "[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg1val + "]]]]"; + } else { + arg = arg1val; + } + arg += ","; + if (arg2val.substr(0, 27) !== "[Fleur.XQueryX.orderBySpec,") { + arg += "[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg2val + "]]]]"; + } else { + arg += arg2val; + } + } + break; + case "//": + arg = "[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg1val, "") + ",[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['descendant-or-self']],[Fleur.XQueryX.anyKindTest,[]]]]," + Fleur.XPathEvaluator._pathExprFormat(arg2val, "") + "]]"; + break; + case "/": + arg = "[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg1val, "") + (arg2val !== "" ? "," + Fleur.XPathEvaluator._pathExprFormat(arg2val, "") : "") + "]]"; + break; + case "!!": + arg = "[Fleur.XQueryX.doubleMapExpr,[[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg1val, "") + "]],[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg2val, "") + "]]]]"; + break; + case "!": + arg = "[Fleur.XQueryX.simpleMapExpr,[[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg1val, "") + "]],[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg2val, "") + "]]]]"; + break; + case "|": + if (ops.startsWith("3.8.|8.31.catch")) { + if (arg1val.substr(0, 24) === "[Fleur.XQueryX.pathExpr,") { + arg1val2 = arg1val.substr(86); + arg1val = arg1val2.substr(0, arg1val2.length - 4); + } + if (arg2val.substr(0, 24) === "[Fleur.XQueryX.pathExpr,") { + arg2val2 = arg2val.substr(86); + arg2val = arg2val2.substr(0, arg2val2.length - 4); + arg = arg1val + "," + arg2val; + } else { + arg = "[Fleur.XQueryX.catchErrorList,[" + arg1val + "," + arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.catchErrorList,[") + 31); + } + } else { + arg = "[Fleur.XQueryX.unionOp,[[Fleur.XQueryX.firstOperand,[" + arg1val + "]],[Fleur.XQueryX.secondOperand,[" + arg2val + "]]]]"; + } + break; + case ":": + arg = "[Fleur.XQueryX.mapConstructorEntry,[[Fleur.XQueryX.mapKeyExpr,[" + arg1val + "]],[Fleur.XQueryX.mapValueExpr,[" + arg2val + "]]]]"; + break; + case "?": + break; + case "to": + arg = "[Fleur.XQueryX.rangeSequenceExpr,[[Fleur.XQueryX.startExpr,[" + arg1val + "]],[Fleur.XQueryX.endExpr,[" + arg2val + "]]]]"; + break; + case "~-": + arg = "[Fleur.XQueryX.unaryMinusOp,[[Fleur.XQueryX.operand,[" + arg2val + "]]]]"; + break; + case "~+": + arg = "[Fleur.XQueryX.unaryPlusOp,[[Fleur.XQueryX.operand,[" + arg2val + "]]]]"; + break; + case "allowing": + arg = "[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.allowingEmpty,[]]"; + break; + case "at": + if (arg1val.substr(0, 36) === "[Fleur.XQueryX.typedVariableBinding,") { + arg = arg1val + ",[Fleur.XQueryX.positionalVariableBinding,[" + arg2val.substr(0, arg2val.length - 4).substr(44) + "]]"; + } else { + arg = "[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.positionalVariableBinding,[" + arg2val.substr(0, arg2val.length - 4).substr(44) + "]]"; + } + break; + case "in": + if (ops.substr(ops.length - 7) === "5.999.q") { + arg = "[Fleur.XQueryX.quantifiedExprInClause,[[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.sourceExpr,[" + arg2val + "]]]]"; + } else if (arg1val.substr(0, 36) === "[Fleur.XQueryX.typedVariableBinding,") { + arg = "[Fleur.XQueryX.forClause,[[Fleur.XQueryX.forClauseItem,[" + arg1val + ",[Fleur.XQueryX.forExpr,[" + arg2val + "]]]]]]"; + } else { + arg = "[Fleur.XQueryX.forClause,[[Fleur.XQueryX.forClauseItem,[[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.forExpr,[" + arg2val + "]]]]]]"; + } + break; + case "as": + if (arg2val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['last']]]]]]") { + arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertInto,[[Fleur.XQueryX.insertAsLast,[]]]]"; + } else if (arg2val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['first']]]]]]") { + arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertInto,[[Fleur.XQueryX.insertAsFirst,[]]]]"; + } else { + arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); + arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); + arg = "[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]],[Fleur.XQueryX.typeDeclaration,[" + arg2val3 + "]]"; + } + break; + case ":=": + if (ops.startsWith("5.18.:=11.30.group by") || ops.startsWith("5.18.:=5.29.~,11.30.group by")) { + if (arg1val.substr(0, 28) === "[Fleur.XQueryX.groupingSpec,") { + arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.groupVarInitialize,[[Fleur.XQueryX.varValue,[" + arg2val + "]]]]]]"; + } else { + arg = "[Fleur.XQueryX.groupingSpec,[[Fleur.XQueryX.varName,[" + arg1val.substr(44, arg1val.length - 48) + "]],[Fleur.XQueryX.groupVarInitialize,[[Fleur.XQueryX.varValue,[" + arg2val + "]]]]]]"; + } + } else if (arg1val.substr(0, 23) === "[Fleur.XQueryX.varName,") { + arg = "[Fleur.XQueryX.letClause,[[Fleur.XQueryX.letClauseItem,[[Fleur.XQueryX.typedVariableBinding,[" + arg1val + "]],[Fleur.XQueryX.letExpr,[" + arg2val + "]]]]]]"; + } else { + arg = "[Fleur.XQueryX.letClause,[[Fleur.XQueryX.letClauseItem,[[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.letExpr,[" + arg2val + "]]]]]]"; + } + break; + case "return": + arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.returnClause,[" + arg2val + "]]]]"; + break; + case "satisfies": + arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.predicateExpr,[" + arg2val + "]]]]"; + break; + case "cast as": + case "cast as?": + occ = op.charAt(7); + arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); + arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); + arg = "[Fleur.XQueryX.castExpr,[[Fleur.XQueryX.argExpr,[" + arg1val + "]],[Fleur.XQueryX.singleType,[" + arg2val3 + (occ === "?" ? ",[Fleur.XQueryX.optional,[]]" : "") + "]]]]"; + break; + case "castable as": + case "castable as?": + occ = op.charAt(11); + arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); + arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); + arg = "[Fleur.XQueryX.castableExpr,[[Fleur.XQueryX.argExpr,[" + arg1val + "]],[Fleur.XQueryX.singleType,[" + arg2val3 + (occ === "?" ? ",[Fleur.XQueryX.optional,[]]" : "") + "]]]]"; + break; + case "treat as": + case "treat as+": + case "treat as?": + case "treat as*": + occ = op.charAt(8); + if (arg2val.indexOf("[Fleur.XQueryX.nameTest,") !== -1) { + arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); + arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); + } else if (arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") !== -1) { + arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") + 86); + arg2val3 = arg2val2.substr(0, arg2val2.length - 4); + } else { + arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['attribute']],") + 90); + arg2val3 = arg2val2.substr(0, arg2val2.length - 4); + } + arg = "[Fleur.XQueryX.treatExpr,[[Fleur.XQueryX.argExpr,[" + arg1val + "]],[Fleur.XQueryX.sequenceType,[" + arg2val3 + (occ !== "" ? ",[Fleur.XQueryX.occurrenceIndicator,['" + occ + "']]" : "") + "]]]]"; + break; + case "instance of": + case "instance of+": + case "instance of?": + case "instance of*": + occ = op.charAt(11); + if (arg2val.indexOf("[Fleur.XQueryX.nameTest,") !== -1) { + arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); + arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); + } else if (arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") !== -1) { + arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") + 86); + arg2val3 = arg2val2.substr(0, arg2val2.length - 4); + } else { + arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['attribute']],") + 90); + arg2val3 = arg2val2.substr(0, arg2val2.length - 4); + } + arg = "[Fleur.XQueryX.instanceOfExpr,[[Fleur.XQueryX.argExpr,[" + arg1val + "]],[Fleur.XQueryX.sequenceType,[" + arg2val3 + (occ !== "" ? ",[Fleur.XQueryX.occurrenceIndicator,['" + occ + "']]" : "") + "]]]]"; + break; + case "then": + if (arg1val.substr(0, 95) === "[Fleur.XQueryX.functionCallExpr,[[Fleur.XQueryX.functionName,['if']],[Fleur.XQueryX.arguments,[") { + arg = "[Fleur.XQueryX.ifThenElseExpr,[[Fleur.XQueryX.ifClause,[" + arg1val.substr(0, arg1val.length - 4).substr(arg1val.indexOf(",[Fleur.XQueryX.arguments,[") + 27) + "]],[Fleur.XQueryX.thenClause,[" + arg2val + "]]]]"; + } + opprec = -1; + break; + case "else": + if (arg1val.substr(0, 30) === "[Fleur.XQueryX.ifThenElseExpr,") { + arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.elseClause,[" + arg2val + "]]]]"; + } + break; + case "catch": + if (arg1val.substr(0, 28) === "[Fleur.XQueryX.tryCatchExpr,") { + arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.catchClause,[" + arg2val + "]]]]"; + } + break; + case "let": + arg = arg1val + "," + arg2val; + break; + case "for": + arg = arg1val + "," + arg2val; + break; + case "group by": + arg = arg1val + ",[Fleur.XQueryX.groupByClause,[" + arg2val + "]]"; + break; + case "order by": + if (arg2val.substr(0, 27) === "[Fleur.XQueryX.orderBySpec,") { + arg = arg1val + ",[Fleur.XQueryX.orderByClause,[" + arg2val + "]]"; + } else { + arg = arg1val + ",[Fleur.XQueryX.orderByClause,[[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg2val + "]]]]]]"; + } + break; + case "~~ascending": + case "~~descending": + arg = "[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg1val + "]],[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.orderingKind,['" + op.substr(2) + "']]]]]]"; + break; + case "empty": + if (arg1val.substr(0,27) === "[Fleur.XQueryX.orderBySpec,") { + if (arg1val.endsWith(",[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.orderingKind,['ascending']]]]]]") || arg1val.endsWith(",[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.orderingKind,['descending']]]]]]")) { + arg = arg1val.substr(0, arg1val.length - 4) + ",[Fleur.XQueryX.emptyOrderingMode,['empty " + arg2val.substr(112, arg2val.length - 119) + "']]]]]]"; + } else { + arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.emptyOrderingMode,['empty " + arg2val.substr(112, arg2val.length - 119) + "']]]]]]"; + } + } else { + arg = "[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg1val + "]],[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.emptyOrderingMode,['empty " + arg2val.substr(112, arg2val.length - 119) + "']]]]]]"; + } + break; + case "where": + arg = arg1val + ",[Fleur.XQueryX.whereClause,[" + arg2val + "]]"; + break; + case "count": + arg = arg1val + ",[Fleur.XQueryX.countClause,[" + arg2val + "]]"; + break; + case "nodes": + if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['delete']]]]]]") { + arg = "[Fleur.XQueryX.deleteExpr,[[Fleur.XQueryX.targetExpr,[" + arg2val + "]]]]"; + } else if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['insert']]]]]]") { + arg = "[Fleur.XQueryX.insertExpr,[" + arg2val + "]]"; + } + break; + case "node": + if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['delete']]]]]]") { + arg = "[Fleur.XQueryX.deleteExpr,[[Fleur.XQueryX.targetExpr,[" + arg2val + "]]]]"; + } else if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['insert']]]]]]") { + arg = "[Fleur.XQueryX.insertExpr,[" + arg2val + "]]"; + } else if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['replace']]]]]]") { + arg = "[Fleur.XQueryX.replaceExpr,[" + arg2val + "]]"; + } else if (arg1val === "[Fleur.XQueryX.replaceValue,[]]") { + arg = "[Fleur.XQueryX.replaceExpr,[[Fleur.XQueryX.replaceValue,[]]," + arg2val + "]]"; + } + break; + case "into": + if (arg1val.substr(0, 28) === "[Fleur.XQueryX.sourceExprUf,") { + arg = arg1val + ",[Fleur.XQueryX.targetExpr,[" + arg2val + "]]"; + } else { + arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertInto,[]],[Fleur.XQueryX.targetExpr,[" + arg2val + "]]"; + } + break; + case "after": + arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertAfter,[]],[Fleur.XQueryX.targetExpr,[" + arg2val + "]]"; + break; + case "before": + arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertBefore,[]],[Fleur.XQueryX.targetExpr,[" + arg2val + "]]"; + break; + case "value": + if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['replace']]]]]]" && arg2val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['of']]]]]]") { + arg = "[Fleur.XQueryX.replaceValue,[]]"; + } + break; + case "with": + arg = "[Fleur.XQueryX.targetExpr,[" + arg1val + "]],[Fleur.XQueryX.replacementExpr,[" + arg2val + "]]"; + break; + default: + var opcode0 = Fleur.XPathEvaluator._opcodes.substr(Fleur.XPathEvaluator._opcodes.indexOf("." + op + ";") + op.length + 2); + var opcode = opcode0.substr(0, opcode0.indexOf(".")); + arg = "[Fleur.XQueryX." + opcode + ",[[Fleur.XQueryX.firstOperand,[" + arg1val + "]],[Fleur.XQueryX.secondOperand,[" + arg2val + "]]]]"; + } + var args2 = arg.length + "." + arg + args3.substr(arg1len.length + 1 + parseInt(arg1len, 10)); + return Fleur.XPathEvaluator._calc(args2, ops.substr(ops.indexOf(".") + 1).substr(parseInt(ops.substr(0, ops.indexOf(".")), 10)), opprec); + }; + Fleur.XPathEvaluator._testFormat = function(s, namecode) { + var arg1, arg2, arg20, arg200; + if (s === "") { + return ""; + } + if (s.indexOf(",[Fleur.XQueryX.pathExpr,[") !== -1) { + arg1 = s.substr(0, s.indexOf(",[Fleur.XQueryX.pathExpr,[")); + arg20 = s.substr(s.indexOf(",[Fleur.XQueryX.pathExpr,[") + 1); + arg200 = arg20.substr(arg20.indexOf("[Fleur.XQueryX.nameTest,['") + 25); + arg2 = "," + "[Fleur.XQueryX.typeName,[" + arg200.substr(0, arg200.length - 6) + "]]"; + } else { + arg1 = s; + arg2 = ""; + } + var arg120 = arg1.indexOf("[Fleur.XQueryX.nameTest,['") !== -1 ? arg1.substr(arg1.indexOf("[Fleur.XQueryX.nameTest,['") + 25) : "[Fleur.XQueryX.star,[]]"; + var arg12 = "[" + namecode + ",[" + (arg120 === "[Fleur.XQueryX.star,[]]" ? arg120 : "[Fleur.XQueryX.QName,[" + arg120.substr(0, arg120.length - 6) + "]]") + "]]"; + return arg12 + arg2; + }; + Fleur.XPathEvaluator._getNodeConstructor = function(s) { + var ii, text, texts, entityname, index, offset = 0, end = s.length, nodename, attrname, attrvalue, attrvalues, attrs, parents = [], currnodename = "", c, c0, c1, c2, braces, + seps_pi = " \t\n\r?", seps_close = " \t\n\r>", seps_elt = " \t\n\r/>", seps_attr = " \t\n\r=/<>", seps = " \t\n\r", rseps = /^\s*$/gm, + namespaces = {}, newnamespaces = {}, pindex, prefix, localName, r0, r = "", nextsep = ""; + while (offset !== end) { + text = ""; + texts = []; + c1 = " "; + c = s.charAt(offset); + braces = 0; + while ((c !== "<" || braces !== 0) && offset !== end) { + if (c === "{") { + if (braces === 0 && text !== "") { + if (/\S/.test(text.replace("\\n", "\n").replace("\\r", "\r"))) { + texts.push([0, text]); + } + text = ""; + } + if (braces !== 0) { + text += "{"; + } + if (c1 === c) { + braces--; + if (braces === 0) { + text = (texts.length > 0 ? texts.pop()[1] : "") + "{"; + } + } else { + braces++; + } + } else if (c === "}") { + if (braces === 1 && text !== "") { + texts.push([1, text]); + text = ""; + } + if (braces !== 1 && braces !== -1) { + text += "}"; + } + if (c1 === c) { + braces++; + } else { + braces--; + } + } else if (c === "&") { + c = s.charAt(++offset); + entityname = ""; + while (c !== ";" && offset !== end) { + entityname += c; + c = s.charAt(++offset); + } + if (offset === end) { + break; + } + if (entityname.charAt(0) === "#") { + text += String.fromCharCode(parseInt(entityname.charAt(1).toLowerCase() === 'x' ? "0" + entityname.substr(1).toLowerCase() : entityname.substr(1), entityname.charAt(1).toLowerCase() === 'x' ? 16 : 10)); + } else { + text += Fleur.encchars[entityname]; + } + } else if (braces === 0 && c === "\n") { + text += "\\n"; + } else if (braces === 0 && c === "\r") { + text += "\\r"; + } else { + text += c; + } + c1 = c; + c = s.charAt(++offset); + } + if (/\S/.test(text.replace("\\n", "\n").replace("\\r", "\r")) && texts.length === 0) { + r += nextsep + "[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + text.replace(/'/gm,"\\'") + "']]]]"; + nextsep = ","; + } else if (texts.length > 0) { + if (/\S/.test(text.replace("\\n", "\n").replace("\\r", "\r"))) { + texts.push([0, text]); + } + texts.forEach(function(t) { + r += nextsep; + if (t[0] === 0) { + r += "[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + t[1].replace(/'/gm,"\\'") + "']]]]"; + } else { + r += Fleur.XPathEvaluator._xp2js(t[1], "", ""); + } + nextsep = ","; + }); + } + if (offset === end) { + break; + } + offset++; + if (s.charAt(offset) === "!") { + offset++; + if (s.substr(offset, 2) === "--") { + offset += 2; + index = s.indexOf("-->", offset); + if (index !== offset) { + if (index === -1) { + index = end; + } + text = ""; + ii = offset; + while (ii < index) { + text += s.charAt(ii++); + } + text = text.replace(/\x01/gm,"<"); + r0 = "[Fleur.XQueryX.computedCommentConstructor,[[Fleur.XQueryX.argExpr,[[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + text + "']]]]]]]]"; + if (r === "") { + return offset + "." + r0; + } + r += nextsep + r0; + nextsep = ","; + if (index === end) { + break; + } + offset = index; + } + offset += 3; + } else if (s.substr(offset, 7) === "[CDATA[") { + offset += 7; + index = s.indexOf("]]>", offset); + if (index !== offset) { + if (index === -1) { + index = end; + } + text = ""; + ii = offset; + while (ii < index) { + text += s.charAt(ii++); + } + text = text.replace(/\x01/gm,"<"); + if (text !== "") { + r += nextsep + "[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + text + "']]]]"; + nextsep = ","; + } + if (index === end) { + break; + } + offset = index; + } + offset += 3; + } + } else if (s.charAt(offset) === "?") { + offset++; + c = s.charAt(offset++); + nodename = ""; + while (seps_pi.indexOf(c) === -1) { + nodename += c; + c = s.charAt(offset++); + } + index = s.indexOf("?>", offset - 1); + if (index === -1) { + index = end; + } + if (nodename.toLowerCase() === "xml") { + throw Error("Invalid processing instruction"); + } else if (nodename !== "") { + text = ""; + ii = offset; + while (ii < index) { + text += s.charAt(ii++); + } + text = text.replace(/\x01/gm,"<"); + r0 = "[Fleur.XQueryX.computedPIConstructor,[[Fleur.XQueryX.piTarget,['" + nodename + "']],[Fleur.XQueryX.piValueExpr,[[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + text + "']]]]]]]]"; + if (r === "") { + return String(index + 2) + "." + r0; + } + r += nextsep + r0; + nextsep = ","; + } + if (index === end) { + break; + } + offset = index + 2; + } else if (s.charAt(offset) === "/") { + offset++; + c = s.charAt(offset++); + nodename = ""; + while (seps_close.indexOf(c) === -1 && offset <= end) { + nodename += c; + c = s.charAt(offset++); + } + if (nodename === currnodename) { + if (nextsep !== ",") { + r += "]]"; + } else { + r += "]]]]"; + } + nextsep = ","; + if (parents.length === 1) { + return offset + "." + r; + } + currnodename = parents.pop(); + } else { + throw Error("Malformed XML fragment"); + } + offset = s.indexOf(">", offset - 1) + 1; + if (offset === 0) { + break; + } + } else { + c = s.charAt(offset++); + nodename = ""; + while (seps_elt.indexOf(c) === -1 && offset <= end) { + nodename += c; + c = s.charAt(offset++); + } + index = s.indexOf(">", offset - 1); + if (nodename !== "") { + newnamespaces = {}; + for (prefix in namespaces) { + if (namespaces.hasOwnProperty(prefix)) { + newnamespaces[prefix] = namespaces[prefix]; + } + } + attrs = {}; + while (offset <= end) { + while (seps.indexOf(c) !== -1 && offset <= end) { + c = s.charAt(offset++); + } + if (c === "/" || c === ">" || offset === end) { + break; + } + attrname = ""; + while (seps_attr.indexOf(c) === -1 && offset <= end) { + attrname += c; + c = s.charAt(offset++); + } + if (attrname === "") { + throw new Error("Invalid character: " + c); + } + while (seps.indexOf(c) !== -1 && offset <= end) { + c = s.charAt(offset++); + } + if (c === "=") { + c = s.charAt(offset++); + while (seps.indexOf(c) !== -1 && offset <= end) { + c = s.charAt(offset++); + } + attrvalue = ""; + attrvalues = []; + if (c === "'" || c === "\"") { + c0 = c; + c1 = c; + c = s.charAt(offset++); + c2 = s.charAt(offset); + braces = 0; + attrvalue = ""; + ii = offset; + while ((c !== c0 || c2 === c0 || braces !== 0) && offset <= end) { + if (c === "{") { + if (braces === 0 && attrvalue !== "") { + attrvalues.push([0, attrvalue]); + attrvalue = ""; + } + if (c1 === c) { + braces--; + if (braces === 0) { + attrvalue = (attrvalues.length > 0 ? attrvalues.pop()[1] : "") + "{"; + } + } else { + braces++; + } + } else if (c === "}") { + if (braces === 1 && attrvalue !== "") { + attrvalues.push([1, attrvalue]); + attrvalue = ""; + } + if (c1 === c) { + braces++; + if (braces === 0) { + attrvalue += "}"; + } + } else { + braces--; + } + } else if (c === c2 && c === c0) { + attrvalue += c; + c1 = c; + c = s.charAt(++offset); + c2 = s.charAt(++offset); + continue; + } else { + attrvalue += c; + } + c1 = c; + c = c2; + c2 = s.charAt(++offset); + } + if (attrvalue !== "") { + attrvalues.push([0, attrvalue]); + } + c = c2; + offset++; + } else { + while (seps_elt.indexOf(c) === -1 && offset <= end) { + attrvalue += c; + c = s.charAt(offset++); + } + attrvalues = [[0, attrvalue]]; + } + } else { + attrvalues = [[0, attrname]]; + } + pindex = attrname.indexOf(":"); + prefix = pindex !== -1 ? attrname.substr(0, pindex) : " "; + localName = pindex !== -1 ? attrname.substr(pindex + 1) : attrname; + if (!attrs[prefix]) { + attrs[prefix] = {}; + } + attrs[prefix][localName] = attrvalues; + if (prefix === "xmlns") { + newnamespaces[localName] = attrvalues; + } else if (prefix === " " && localName === "xmlns") { + newnamespaces[" "] = attrvalues; + } + } + pindex = nodename.indexOf(":"); + if (pindex === -1) { + r0 = nextsep + "[Fleur.XQueryX.elementConstructor,[[Fleur.XQueryX.tagName,['" + nodename + "']]"; + } else { + r0 = nextsep + "[Fleur.XQueryX.elementConstructor,[[Fleur.XQueryX.tagName,['" + nodename.substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + nodename.substr(0, pindex) + "']]]]"; + } + if (Object.keys(attrs).length) { + nextsep = ",[Fleur.XQueryX.attributeList,["; + if (attrs[" "] && attrs[" "].xmlns) { + r0 += nextsep + "[Fleur.XQueryX.namespaceDeclaration,[[Fleur.XQueryX.uri,[" + (attrs[" "].xmlns.length !== 0 ? "'" + attrs[" "].xmlns[0][1] + "'" : "") + "]]]]"; + nextsep = ","; + delete attrs[" "].xmlns; + } + for (attrname in attrs.xmlns) { + if (attrs.xmlns.hasOwnProperty(attrname)) { + r0 += nextsep + "[Fleur.XQueryX.namespaceDeclaration,[[Fleur.XQueryX.prefixElt,['" + attrname + "']],[Fleur.XQueryX.uri,['" + attrs.xmlns[attrname][0][1] + "']]]]"; + nextsep = ","; + } + } + delete attrs.xmlns; + for (prefix in attrs) { + if (attrs.hasOwnProperty(prefix)) { + for (attrname in attrs[prefix]) { + if (attrs[prefix].hasOwnProperty(attrname)) { + r0 += nextsep + "[Fleur.XQueryX.attributeConstructor,[[Fleur.XQueryX.attributeName,['" + attrname + "'"; + if (prefix !== " ") { + r0 += ",[Fleur.XQueryX.prefix,['" + prefix + "']]"; + } + r0 += "]],"; + if (attrs[prefix][attrname].length === 0) { + r0 += "[Fleur.XQueryX.attributeValue,[]]"; + nextsep = ","; + } else if (attrs[prefix][attrname].length === 1 && attrs[prefix][attrname][0][0] === 0) { + r0 += "[Fleur.XQueryX.attributeValue,['" + Fleur.DocumentType.resolveEntities(null, attrs[prefix][attrname][0][1]).replace(/'/gm,"\\'").replace(/\x01/gm,"<") + "']]"; + nextsep = ","; + } else { + nextsep = "[Fleur.XQueryX.attributeValueExpr,["; + attrs[prefix][attrname].forEach(function(v) { + r0 += nextsep; + if (v[0] === 0) { + r0 += "[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + Fleur.DocumentType.resolveEntities(null, v[1]).replace(/'/gm,"\\'") + "']]]]"; + } else { + r0 += Fleur.XPathEvaluator._xp2js(v[1], "", ""); + } + nextsep = ","; + }); + r0 += "]]"; + } + r0 += "]]"; + } + } + } + } + r0 += "]]"; + } + if (s.charAt(offset - 1) !== "/") { + nextsep = ",[Fleur.XQueryX.elementContent,["; + parents.push(currnodename); + currnodename = nodename; + r += r0; + } else { + if (r === "") { + return String(offset + 1) + "." + r0 + "]]"; + } + r += r0 + "]]"; + nextsep = ","; + } + } else { + throw Error("Invalid element name"); + } + offset = index + 1; + if (offset === 0) { + break; + } + } + } + }; + Fleur.XPathEvaluator._getPredParam = function(c, s, l, arg, allowpredicates, predstart, predarr, ops) { + var t; + l = l || 0; + var p, plen, arg20, arg2; + var isret = false; + if (c === "?") { + var i = Fleur.XPathEvaluator._skipSpaces(s, 0); + var c2 = s.charAt(i); + var d = s.substr(i + 1); + var r, t1; + if (c2 !== "" && "0123456789".indexOf(c2) !== -1) { + t1 = Fleur.XPathEvaluator._getNumber(c2 + d); + r = "[Fleur.XQueryX.lookup,[[Fleur.XQueryX.integerConstantExpr,[[Fleur.XQueryX.value,['" + t1.replace(/e\+/, "e") + "']]]]]]"; + t = (t1.length + 1) + "." + r; + plen = t1.length + 1; + } else if (c2 !== "" && "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(c2) !== -1) { + t1 = Fleur.XPathEvaluator._getName(c2 + d); + r = "[Fleur.XQueryX.lookup,[[Fleur.XQueryX.NCName,['" + t1 + "']]]]"; + t = (t1.length + 1) + "." + r; + plen = t1.length + 1; + } else if (c2 === "*") { + t = "2.[Fleur.XQueryX.lookup,[[Fleur.XQueryX.star,[]]]]"; + plen = 2; + } else if (c2 === "(") { + t = Fleur.XPathEvaluator._xp2js(s.substr(i + 1), "", "5.999.("); + plen = s.length - parseInt(t.substr(0, t.indexOf(".")), 10) + 1 + i; + t = String(plen) + "." + "[Fleur.XQueryX.lookup,[[Fleur.XQueryX.expr,[" + t.substr(t.indexOf(".") + 1) + "]]]]"; + } + } else { + var func = ""; + if (arg.indexOf("[Fleur.XQueryX.nameTest,['") !== -1) { + var func0 = arg.substr(arg.indexOf("[Fleur.XQueryX.nameTest,['") + 25); + func = func0.substr(0, func0.length - 6); + } + if (func === "'function'") { + t = "function"; + plen = s.length; + } else { + t = Fleur.XPathEvaluator._xp2js(s, "", l === 0 ? "" : arg.substr(0, 57) === "[Fleur.XQueryX.quantifiedExpr,[[Fleur.XQueryX.quantifier," ? "5.999.q" : "5.999.("); + plen = s.length - parseInt(t.substr(0, t.indexOf(".")), 10) + 1; + } + } + if (t.indexOf("~~~~") !== -1) { + var t0 = t + "~#~#"; + t0 = t0.substr(0, t0.indexOf("~#~#")); + t0 = t0.replace('"', ""); + var msg = '"~~~~' + t0.substr(t0.indexOf("~~~~") + 4) + "in '" + s + "'~#~#" + '"'; + p = plen + "." + msg; + throw Error(t0.substr(t0.indexOf("~~~~") + 4) + "in '" + s + "'"); + } else if (t === "") { + var msg2 = '"' + "~~~~Unrecognized expression '" + s + "'~#~#" + '"'; + p = plen + "." + msg2; + throw Error("Unrecognized expression '" + s + "'"); + } else if (c === "{") { + var cargs = t.substr(t.indexOf(".") + 1); + if (cargs.substr(0, 25) === "[Fleur.XQueryX.arguments,") { + cargs = "[Fleur.XQueryX.sequenceExpr," + cargs.substr(25); + } + if (arg.substr(0, 40) === "[Fleur.XQueryX.computedEntryConstructor," || arg.substr(0, 42) === "[Fleur.XQueryX.computedElementConstructor," || arg.substr(0, 44) === "[Fleur.XQueryX.computedAttributeConstructor,") { + p = plen + "." + arg.substr(0, arg.length - 2) + ",[Fleur.XQueryX.valueExpr,[" + cargs + "]]]]"; + } else if (arg.substr(0, 37) === "[Fleur.XQueryX.computedPIConstructor,") { + p = plen + "." + arg.substr(0, arg.length - 2) + ",[Fleur.XQueryX.piValueExpr,[" + cargs + "]]]]"; + } else { + var cname0 = arg.substr(arg.indexOf("[Fleur.XQueryX.nameTest,['") + 25); + var cname = cname0.substr(0, cname0.length - 6); + switch (cname) { + case "'document'": + p = plen + "." + "[Fleur.XQueryX.computedDocumentConstructor,[[Fleur.XQueryX.argExpr,[" + cargs + "]]]]"; + break; + case "'comment'": + p = plen + "." + "[Fleur.XQueryX.computedCommentConstructor,[[Fleur.XQueryX.argExpr,[" + cargs + "]]]]"; + break; + case "'map'": + var cargs2 = cargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? cargs.substr(26, cargs.length - 28) : cargs; + p = plen + "." + "[Fleur.XQueryX.mapConstructor,[" + cargs2 + "]]"; + break; + case "'array'": + var cargs3 = cargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? cargs.substr(26, cargs.length - 28) : cargs; + p = plen + "." + "[Fleur.XQueryX.arrayConstructor,[" + cargs3 + "]]"; + break; + case "'entry'": + p = plen + "." + "[Fleur.XQueryX.computedEntryConstructor,[[Fleur.XQueryX.tagNameExpr,[" + cargs + "]]]]"; + break; + case "'element'": + p = plen + "." + "[Fleur.XQueryX.computedElementConstructor,[[Fleur.XQueryX.tagNameExpr,[" + cargs + "]]]]"; + break; + case "'attribute'": + p = plen + "." + "[Fleur.XQueryX.computedAttributeConstructor,[[Fleur.XQueryX.tagNameExpr,[" + cargs + "]]]]"; + break; + case "'processing-instruction'": + p = plen + "." + "[Fleur.XQueryX.computedPIConstructor,[[Fleur.XQueryX.piTargetExpr,[" + cargs + "]]]]"; + break; + case "'text'": + p = plen + "." + "[Fleur.XQueryX.computedTextConstructor,[[Fleur.XQueryX.argExpr,[" + cargs + "]]]]"; + break; + case "'try'": + p = plen + "." + "[Fleur.XQueryX.tryCatchExpr,[[Fleur.XQueryX.tryClause,[" + cargs + "]]]]"; + break; + default: + if (ops.startsWith("8.31.catch") || ops.startsWith("3.8.|8.31.catch")) { + arg20 = arg.substr(86); + arg2 = arg20.substr(0, arg20.length - 4); + p = plen + "." + "[Fleur.XQueryX.catchErrorList,[" + arg2 + "]],[Fleur.XQueryX.catchExpr,[" + cargs + "]]"; + } + break; + } + } + } else if (c === "(") { + if (arg.substr(0, 77) === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['") { + var fname0 = arg.substr(arg.indexOf("[Fleur.XQueryX.nameTest,['") + 25); + var fname = fname0.substr(0, fname0.length - 6); + var fargs = t.substr(t.indexOf(".") + 1); + var fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; + var parg0, parg; + switch (fname) { + case "'array'": + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['array']]]]")) + "[Fleur.XQueryX.arrayTest,[]]]]]]"; + break; + case "'attribute'": + parg = Fleur.XPathEvaluator._testFormat(fargs2, "Fleur.XQueryX.attributeName"); + p = plen + "." + "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['attribute']],[Fleur.XQueryX.attributeTest,[" + parg + "]]]]]]"; + break; + case "'comment'": + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['comment']]]]")) + "[Fleur.XQueryX.commentTest,[]]]]]]"; + break; + case "'document-node'": + if (fargs2 !== "") { + parg0 = fargs2.substr(fargs2.indexOf("[Fleur.XQueryX.elementTest,[")); + parg = parg0.substr(0, parg0.length - 4); + } else { + parg = ""; + } + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['document-node']]]]")) + "[Fleur.XQueryX.documentTest,[" + parg + "]]]]]]"; + break; + case "'element'": + parg = Fleur.XPathEvaluator._testFormat(fargs2, "Fleur.XQueryX.elementName"); + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['element']]]]")) + "[Fleur.XQueryX.elementTest,[" + parg + "]]]]]]"; + break; + case "'entry'": + parg = Fleur.XPathEvaluator._testFormat(fargs2, "Fleur.XQueryX.entryName"); + p = plen + "." + "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['entry']],[Fleur.XQueryX.entryTest,[" + parg + "]]]]]]"; + break; + case "'function'": + var j = -1; + var xq = s; + var pindex, np, nbpar = 0; + var fres = "[Fleur.XQueryX.paramList,["; + var end = xq.length; + do { + j = Fleur.XPathEvaluator._skipSpaces(xq, j + 1); + c = xq.charAt(j); + if (c !== ")") { + if (c !== "$") { + throw Error("Unexpected char at '" + xq.substr(j) + "'"); + } + j++; + c = xq.charAt(j); + d = xq.substr(j + 1); + if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) === -1) { + throw Error("Unexpected char at '" + xq.substr(j) + "'"); + } + var pname = Fleur.XPathEvaluator._getName(c + d); + j = Fleur.XPathEvaluator._skipSpaces(xq, j + pname.length); + c = xq.charAt(j); + var tdecl = ""; + if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) !== -1) { + d = xq.substr(j + 1); + r = Fleur.XPathEvaluator._getName(c + d); + if (r === "as") { + j = Fleur.XPathEvaluator._skipSpaces(xq, j + r.length); + c = xq.charAt(j); + if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) !== -1) { + d = xq.substr(j + 1); + var ptype = Fleur.XPathEvaluator._getName(c + d); + pindex = ptype.indexOf(":"); + np = pindex === -1 ? "'" + ptype + "'" : "'" + ptype.substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + ptype.substr(0, pindex) + "']]"; + c = xq.charAt(j + ptype.length); + tdecl = ",[Fleur.XQueryX.typeDeclaration,[[Fleur.XQueryX.atomicType,[" + np + "]]"; + if ("?+*".indexOf(c) !== -1) { + tdecl += ",[Fleur.XQueryX.occurrenceIndicator,['" + c + "']]"; + j++; + } + tdecl += "]]"; + j = Fleur.XPathEvaluator._skipSpaces(xq, j + ptype.length); + c = xq.charAt(j); + } + } + } + if (nbpar !== 0) { + fres += ","; + } + fres += "[Fleur.XQueryX.param,[[Fleur.XQueryX.varName,['" + pname + "']]" + tdecl + "]]"; + nbpar++; + } + } while (c === ","); + if (c !== ")") { + throw Error("Unexpected char at '" + xq.substr(j) + "'"); + } + fres += "]]"; + j = Fleur.XPathEvaluator._skipSpaces(xq, j + 1); + c = xq.charAt(j); + if (c === "a") { + d = xq.substr(j + 1); + r = Fleur.XPathEvaluator._getName(c + d); + if (r === "as") { + j = Fleur.XPathEvaluator._skipSpaces(xq, j + r.length); + c = xq.charAt(j); + if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) !== -1) { + d = xq.substr(j + 1); + ptype = Fleur.XPathEvaluator._getName(c + d); + pindex = ptype.indexOf(":"); + np = pindex === -1 ? "'" + ptype + "'" : "'" + ptype.substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + ptype.substr(0, pindex) + "']]"; + c = xq.charAt(j + ptype.length); + fres += ",[Fleur.XQueryX.typeDeclaration,[[Fleur.XQueryX.atomicType,[" + np + "]]"; + if ("?+*".indexOf(c) !== -1) { + fres += ",[Fleur.XQueryX.occurrenceIndicator,['" + c + "']]"; + j++; + } + fres += "]]"; + j = Fleur.XPathEvaluator._skipSpaces(xq, j + ptype.length); + c = xq.charAt(j); + } + } + } + if (c === "{") { + fres += ",[Fleur.XQueryX.functionBody,["; + var braces = 1; + var body = ""; + while ((c !== "}" || braces !== 0) && j !== end) { + c = xq.charAt(++j); + if (c === "{") { + braces++; + } else if (c === "}") { + braces--; + } + if (braces !== 0) { + body += c; + } + } + if (body !== "") { + fres += Fleur.XPathEvaluator._xp2js(body, "", ""); + } + fres += "]]"; + } else { + throw Error("Unexpected char at '" + xq.substr(j) + "'"); + } + plen = j + 2; + p = plen + ".[Fleur.XQueryX.inlineFunctionExpr,[" + fres + "]]"; + break; + case "'item'": + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['item']]]]")) + "[Fleur.XQueryX.anyItemType,[]]]]]]"; + break; + case "'map'": + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['map']]]]")) + "[Fleur.XQueryX.mapTest,[]]]]]]"; + break; + case "'namespace-node'": + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['namespace-node']]]]")) + "[Fleur.XQueryX.namespaceTest,[]]]]]]"; + break; + case "'node'": + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['node']]]]")) + "[Fleur.XQueryX.anyKindTest,[]]]]]]"; + break; + case "'processing-instruction'": + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['processing-instruction']]]]")) + "[Fleur.XQueryX.piTest,[" + (fargs2 ? "[Fleur.XQueryX.piTarget,[" + fargs2.substr(57) : "]]") + "]]]]"; + break; + case "'schema-attribute'": + parg0 = fargs.substr(fargs.indexOf("[Fleur.XQueryX.nameTest,['") + 25); + parg = parg0.substr(0, parg0.length - 6); + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['schema-attribute']]]]")) + "[Fleur.XQueryX.schemaAttributeTest,[" + parg + "]]]]]]"; + break; + case "'schema-element'": + parg0 = fargs.substr(fargs.indexOf("[Fleur.XQueryX.nameTest,['") + 25); + parg = parg0.substr(0, parg0.length - 6); + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['schema-element']]]]")) + "[Fleur.XQueryX.schemaElementTest,[" + parg + "]]]]]]"; + break; + case "'text'": + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['text']]]]")) + "[Fleur.XQueryX.textTest,[]]]]]]"; + break; + default: + p = plen + ".[Fleur.XQueryX.functionCallExpr,[[Fleur.XQueryX.functionName,[" + fname + "]],[Fleur.XQueryX.arguments,[" + fargs2 + "]]]]"; + } + } else if (arg.substr(0, 77) === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[") { + var arg1, lookup = false; + if (arg.indexOf(",[Fleur.XQueryX.predicates,[") !== -1) { + arg1 = arg.substr(0, arg.indexOf(",[Fleur.XQueryX.predicates,[")).substr(77); + arg20 = arg.substr(arg.indexOf(",[Fleur.XQueryX.predicates,[") + 28); + arg2 = arg20.substr(0, arg20.length - 6); + } else if (arg.indexOf(",[Fleur.XQueryX.lookup,[") !== -1) { + lookup = true; + arg1 = arg.substr(0, arg.indexOf(",[Fleur.XQueryX.lookup,[")).substr(77); + arg20 = arg.substr(arg.indexOf(",[Fleur.XQueryX.lookup,[") + 24); + arg2 = arg20.substr(0, arg20.length - 6); + } else { + arg1 = arg.substr(0, arg.length - 8).substr(77); + arg2 = ""; + } + fargs = t.substr(t.indexOf(".") + 1); + fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; + p = plen + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[[Fleur.XQueryX.dynamicFunctionInvocationExpr,[[Fleur.XQueryX.functionItem,[" + arg1 + (arg2 === "" ? "" : (lookup ? ",[Fleur.XQueryX.lookup,[" : ",[Fleur.XQueryX.predicates,[")+ arg2 + "]]") + (fargs2 === "" ? "" : ",[Fleur.XQueryX.arguments,[" + fargs2 + "]]") + "]]]]]]]]"; + } else if (arg.substr(0, 32) === "[Fleur.XQueryX.namedFunctionRef,") { + p = plen + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[[Fleur.XQueryX.dynamicFunctionInvocationExpr,[[Fleur.XQueryX.functionItem,[" + arg + "]]]]]]]]]]"; + } else if (arg === "[Fleur.XQueryX.flworExpr,[]]") { + fargs = t.substr(t.indexOf(".") + 1); + fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; + p = plen + ".[Fleur.XQueryX.flworExpr,[" + fargs2 + "]]"; + isret = true; + } else if (arg.substr(0, 57) === "[Fleur.XQueryX.quantifiedExpr,[[Fleur.XQueryX.quantifier,") { + fargs = t.substr(t.indexOf(".") + 1); + fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; + p = plen + "." + arg.substr(0, arg.length - 2) + "," + fargs2 + "]]"; + isret = true; + } else if (arg !== "") { + fargs = t.substr(t.indexOf(".") + 1); + fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; + p = plen + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[[Fleur.XQueryX.dynamicFunctionInvocationExpr,[[Fleur.XQueryX.functionItem,[" + arg + "]]" + (fargs2 === "" ? "" : ",[Fleur.XQueryX.arguments,[" + fargs2 + "]]") + "]]]]]]]]"; + } else { + p = plen + "." + t.substr(t.indexOf(".") + 1); + } + } else { + if (arg.substr(0, 25) !== "[Fleur.XQueryX.pathExpr,[") { + arg = "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[" + arg + "]]]]]]"; + } + if (c === "?") { + if (arg.indexOf(",[Fleur.XQueryX.predicates,[") === -1) { + p = plen + "." + arg.substr(0, arg.length - 4) + "," + t.substr(t.indexOf(".") + 1) + "]]]]"; + } else { + p = plen + "." + arg.substr(0, predstart) + predarr.reduce(function(s, pr) {return s + ",[Fleur.XQueryX.predicate,[" + pr + "]]";}, "") + "," + t.substr(t.indexOf(".") + 1) + "]]]]";; + } + allowpredicates = false; + } else if (arg.indexOf(",[Fleur.XQueryX.predicates,[") === -1) { + if (allowpredicates) { + predarr = []; + predarr.push(t.substr(t.indexOf(".") + 1)); + predstart = arg.length - 4; + } + p = plen + "." + arg.substr(0, arg.length - 4) + ",[" + (allowpredicates ? "Fleur.XQueryX.predicates" : "Fleur.XQueryX.predicate") + ",[" + t.substr(t.indexOf(".") + 1) + "]]]]]]"; + } else { + if (allowpredicates) { + predarr.push(t.substr(t.indexOf(".") + 1)); + } + p = plen + "." + arg.substr(0, arg.length - 6) + "," + t.substr(t.indexOf(".") + 1) + "]]]]]]"; + } + } + if (!isret) { + var inext = Fleur.XPathEvaluator._skipSpaces(s, plen - 1); + var cnext = s.charAt(inext); + if (cnext === "(" || cnext === "[" || cnext === "{" || cnext === "?") { + return Fleur.XPathEvaluator._getPredParam(cnext, s.substr(inext + 1), l + inext + 1, p.substr(p.indexOf(".") + 1), allowpredicates, predstart, predarr, ops); + } + } + return (l + plen) + "." + p.substr(p.indexOf(".") + 1); + }; + Fleur.XPathEvaluator._getPredParams = function(s, len, arg, ops) { + var i = Fleur.XPathEvaluator._skipSpaces(s, 0); + if (s.charAt(i) === "(" || s.charAt(i) === "[" || s.charAt(i) === "{" || (s.charAt(i) === "?" && ops.substr(0, 16) !== "13.6.instance of" && ops.substr(0, 16) !== "9.3.cast as" && ops.substr(0, 16) !== "13.4.castable as")) { + return Fleur.XPathEvaluator._getPredParam(s.charAt(i), s.substr(i + 1), len + i, arg, true, 0, [], ops); + } + return (len + i) + "." + arg; + }; + Fleur.XPathEvaluator._getStringLiteral = function(s) { + var i = Fleur.XPathEvaluator._skipSpaces(s, 0); + var d = s.substr(i + 1); + if (s.charAt(i) === "'") { + var sep2 = d.indexOf("'"); + var t2 = d.substr(0, d.indexOf("'")); + while (d.substr(sep2 + 1, 1) === "'") { + var d2 = d.substr(sep2 + 2); + t2 += "\\'" + d2.substr(0, d2.indexOf("'")); + sep2 += 2 + d2.indexOf("'"); + } + var t2b = "'" + Fleur.DocumentType.resolveEntities(null, t2) + "'"; + if (t2b === "''") { + t2b = ""; + } + return (sep2 + 2) + "." + t2b; + } else if (s.charAt(i) === '"') { + var sep3 = d.indexOf('"'); + var t3 = d.substr(0, d.indexOf('"')); + while (d.substr(sep3 + 1, 1) === '"') { + var d3 = d.substr(sep3 + 2); + t3 += '\\"' + d3.substr(0, d3.indexOf('"')); + sep3 += 2 + d3.indexOf('"'); + } + var t3b = '"' + Fleur.DocumentType.resolveEntities(null, t3) + '"'; + if (t3b === '""') { + t3b = ""; + } + return (sep3 + 2) + "." + t3b; + } + }; + Fleur.XPathEvaluator._getNumber = function(s, r) { + r = r || ""; + if (s === "") { + return r; + } + var c = s.charAt(0); + if (c === "E") { + c = "e"; + } + if ("0123456789".indexOf(c) !== -1 || ((c === "." || c === "e") && r.indexOf(c) === -1) || + ((c === "-" || c === "+") && r.endsWith("e"))) { + return Fleur.XPathEvaluator._getNumber(s.substr(1), r + c); + } + return r; + }; + Fleur.XPathEvaluator._xp2js = function(xp, args, ops) { + var i = Fleur.XPathEvaluator._skipSpaces(xp, 0); + var c = xp.charAt(i); + var d = xp.substr(i + 1); + var d2; + var r = ""; + if (c === "." && (d === "" || "0123456789".indexOf(d.charAt(0)) === -1)) { + if (d.charAt(0) === ".") { + r = "2.[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['parent']],[Fleur.XQueryX.anyKindTest,[]]]]]]"; + } else { + r = "1.[Fleur.XQueryX.contextItemExpr,[]]"; + } + } else if (c === ")" || c === "}") { + r = "0."; + } else if (c === "/") { + var ir = Fleur.XPathEvaluator._skipSpaces(d, 0); + r = (d.charAt(0) === "" || "/@*.(_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(d.charAt(ir)) === -1 ? "1" : "0") + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.rootExpr,[]]]]"; + } else if (c === "@") { + r = Fleur.XPathEvaluator._getNameStep(d, 1); + } else if (c === "'") { + var sep2 = d.indexOf("'"); + var t2 = Fleur.DocumentType.resolveEntities(null, d.substr(0, d.indexOf("'"))).replace(/[\\]/g, '\\\\').replace(/[\"]/g, '\\\"').replace(/[\/]/g, '\\/').replace(/[\b]/g, '\\b').replace(/[\f]/g, '\\f').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r').replace(/[\t]/g, '\\t'); + while (d.substr(sep2 + 1, 1) === "'") { + d2 = d.substr(sep2 + 2); + t2 += "\\'" + Fleur.DocumentType.resolveEntities(null, d2.substr(0, d2.indexOf("'"))).replace(/[\\]/g, '\\\\').replace(/[\"]/g, '\\\"').replace(/[\/]/g, '\\/').replace(/[\b]/g, '\\b').replace(/[\f]/g, '\\f').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r').replace(/[\t]/g, '\\t'); + sep2 += 2 + d2.indexOf("'"); + } + var t2b = "'" + t2 + "'"; + if (t2b === "''") { + t2b = ""; + } + r = (sep2 + 2) + ".[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,[" + t2b + "]]]]"; + } else if (c === '"') { + var sep3 = d.indexOf('"'); + var t3 = Fleur.DocumentType.resolveEntities(null, d.substr(0, d.indexOf('"'))).replace(/[\\]/g, '\\\\').replace(/[\']/g, "\\\'").replace(/[\/]/g, '\\/').replace(/[\b]/g, '\\b').replace(/[\f]/g, '\\f').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r').replace(/[\t]/g, '\\t'); + while (d.substr(sep3 + 1, 1) === '"') { + var d3 = d.substr(sep3 + 2); + t3 += '\\"' + Fleur.DocumentType.resolveEntities(null, d3.substr(0, d3.indexOf('"'))).replace(/[\\]/g, '\\\\').replace(/[\']/g, "\\\'").replace(/[\/]/g, '\\/').replace(/[\b]/g, '\\b').replace(/[\f]/g, '\\f').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r').replace(/[\t]/g, '\\t'); + sep3 += 2 + d3.indexOf('"'); + } + var t3b = '"' + t3 + '"'; + if (t3b === '""') { + t3b = ""; + } + r = (sep3 + 2) + ".[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,[" + t3b + "]]]]"; + } else if (c === "(") { + var endseq = Fleur.XPathEvaluator._skipSpaces(d, 0); + if (d.charAt(endseq) === ")") { + r = String(2 + endseq) + ".[Fleur.XQueryX.sequenceExpr,[]]"; + } else { + r = "0."; + } + } else if (c === "-" || c === "+") { + c = "~" + c; + r = "0."; + } else if (c !== "" && ".0123456789".indexOf(c) !== -1) { + var t5 = Fleur.XPathEvaluator._getNumber(c + d); + r = t5.length + ".[" + (t5.indexOf("e") !== -1 ? "Fleur.XQueryX.doubleConstantExpr" : t5.indexOf(".") !== -1 ? "Fleur.XQueryX.decimalConstantExpr" : "Fleur.XQueryX.integerConstantExpr") + ",[[Fleur.XQueryX.value,['" + t5.replace(/e\+/, "e") + "']]]]"; + } else if (c === "$") { + var t51 = Fleur.XPathEvaluator._getName(d); + var pt51 = (t51.indexOf(":") === -1 ? ":" : "") + t51; + var instr; + if (ops.startsWith("11.30.group by") || ops.startsWith("5.29.~,11.30.group by")) { + instr = "[Fleur.XQueryX.groupingSpec,[[Fleur.XQueryX.varName,["; + } else { + instr = "[Fleur.XQueryX.varRef,[[Fleur.XQueryX.name,["; + } + r = (t51.length + 1) + "." + instr + "'" + pt51.substr(pt51.indexOf(":") + 1) + "'" + (pt51.charAt(0) === ":" ? "" : ",[Fleur.XQueryX.prefix,['" + pt51.substr(0, pt51.indexOf(":")) + "']]") + "]]]]"; + } else if (c === "?") { + var c2 = d.charAt(0); + d = d.substr(1); + var t52; + if (c2 !== "" && "0123456789".indexOf(c2) !== -1) { + t52 = Fleur.XPathEvaluator._getNumber(c2 + d); + r = String(t52.length) + ".[Fleur.XQueryX.unaryLookup,[[Fleur.XQueryX.integerConstantExpr,[[Fleur.XQueryX.value,['" + t52.replace(/e\+/, "e") + "']]]]]]"; + } else if (c2 !== "" && "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(c2) !== -1) { + t52 = Fleur.XPathEvaluator._getName(c2 + d); + r = String(t52.length) + ".[Fleur.XQueryX.unaryLookup,[[Fleur.XQueryX.NCName,['" + t52 + "']]]]"; + } else if (c2 === "*") { + r = "1.[Fleur.XQueryX.unaryLookup,[[Fleur.XQueryX.star,[]]]]"; + } else if (c2 === "(") { + t52 = Fleur.XPathEvaluator._xp2js(d, "", "5.999.("); + var plen52 = d.length - parseInt(t52.substr(0, t52.indexOf(".")), 10) + 1; + r = String(plen52) + "." + "[Fleur.XQueryX.unaryLookup,[[Fleur.XQueryX.expr,[" + t52.substr(t52.indexOf(".") + 1) + "]]]]"; + } + } else if (c !== "" && "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz*".indexOf(c) !== -1) { + var t61 = Fleur.XPathEvaluator._getName(c+d); + if (["element","attribute","entry","processing-instruction"].indexOf(t61) !== -1) { + var i61 = Fleur.XPathEvaluator._skipSpaces(xp, i + t61.length); + var c61 = xp.charAt(i61); + if (c61 !== "" && "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(c61) !== -1) { + var d61 = xp.substr(i61 + 1); + var t62 = Fleur.XPathEvaluator._getName(c61 + d61); + switch(t61) { + case "element": + r = String(i61 - i + t62.length) + ".[Fleur.XQueryX.computedElementConstructor,[[Fleur.XQueryX.tagName,['" + t62 + "']]]]"; + break; + case "attribute": + r = String(i61 - i + t62.length) + ".[Fleur.XQueryX.computedAttributeConstructor,[[Fleur.XQueryX.tagName,['" + t62 + "']]]]"; + break; + case "processing-instruction": + r = String(i61 - i + t62.length) + ".[Fleur.XQueryX.computedPIConstructor,[[Fleur.XQueryX.piTarget,['" + t62 + "']]]]"; + break; + case "entry": + r = String(i61 - i + t62.length) + ".[Fleur.XQueryX.computedEntryConstructor,[[Fleur.XQueryX.tagName,['" + t62 + "']]]]"; + } + } else { + r = Fleur.XPathEvaluator._getNameStep(c + d, 0); + } + } else { + r = Fleur.XPathEvaluator._getNameStep(c + d, 0); + } + } else if (c === "<") { + r = Fleur.XPathEvaluator._getNodeConstructor(c + d); + } else { + r = "~~~~Unexpected char at '" + c + d + "'~#~#"; + throw Error("Unexpected char at '" + c + d + "'"); + } + if (r.indexOf("~~~~") !== -1) { + return r; + } + var rlen = parseInt(r.substr(0, r.indexOf(".")), 10); + var rval = r.substr(r.indexOf(".") + 1); + d2 = rlen === 0 ? c + d : d.substr(rlen - 1); + r = Fleur.XPathEvaluator._getPredParams(d2, rlen, rval, ops); + rlen = parseInt(r.substr(0, r.indexOf(".")), 10); + rval = r.substr(r.indexOf(".") + 1); + var args2 = rval.length + "." + rval + args; + var f = rlen === 0 ? c + d : d.substr(rlen - 1); + var i4 = Fleur.XPathEvaluator._skipSpaces(f, 0); + var o = f.charAt(i4); + var p = f.substr(f.indexOf(o)); + var op = "null"; + var op2 = "null"; + if ((p.substr(0, 9) === "ascending" || p.substr(0, 10) === "descending") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(o === "a" ? 9 : 10)) === -1) { + var postprec0 = Fleur.XPathEvaluator._precedence.substr(Fleur.XPathEvaluator._precedence.indexOf(".~~" + (o === "a" ? "ascending" : "descending") + ".") + (o === "a" ? 13 : 14)); + var postprec00 = postprec0.substr(postprec0.indexOf("&") + 1); + var postprec = postprec00.substr(0, postprec00.indexOf(".")); + var poststacks = Fleur.XPathEvaluator._calc(args2, ops, parseInt(postprec, 10)); + var postargslen = poststacks.substr(0, poststacks.indexOf(".")); + args2 = poststacks.substr(poststacks.indexOf(".") + 1).substr(0, parseInt(postargslen, 10)); + var postnextstack = poststacks.substr(postargslen.length + 1 + parseInt(postargslen, 10)); + var postopslen = postnextstack.substr(0, postnextstack.indexOf(".")); + ops = (postprec.length + 1 + (o === "a" ? 11 : 12)) + "." + postprec + ".~~" + (o === "a" ? "ascending" : "descending") + postnextstack.substr(postnextstack.indexOf(".") + 1).substr(0, parseInt(postopslen, 10)); + f = f.substr(i4 + (o === "a" ? 9 : 10)); + i4 = Fleur.XPathEvaluator._skipSpaces(f, 0); + o = f.charAt(i4); + p = f.substr(f.indexOf(o)); + } + if (ops.substr(0, 16) === "13.6.instance of") { + if (o === "+" || o === "?" || o === "*") { + ops = "14.6.instance of" + o + ops.substr(16); + i4 = Fleur.XPathEvaluator._skipSpaces(f, 1); + o = f.charAt(i4); + p = f.substr(f.indexOf(o)); + } + } else if (ops.substr(0, 13) === "10.5.treat as") { + if (o === "+" || o === "?" || o === "*") { + ops = "11.5.treat as" + o + ops.substr(13); + i4 = Fleur.XPathEvaluator._skipSpaces(f, 1); + o = f.charAt(i4); + p = f.substr(f.indexOf(o)); + } + } else if (ops.substr(0, 11) === "9.3.cast as") { + if (o === "?") { + ops = "10.3.cast as" + o + ops.substr(11); + i4 = Fleur.XPathEvaluator._skipSpaces(f, 1); + o = f.charAt(i4); + p = f.substr(f.indexOf(o)); + } + } else if (ops.substr(0, 16) === "13.4.castable as") { + if (o === "?") { + ops = "14.4.castable as" + o + ops.substr(16); + i4 = Fleur.XPathEvaluator._skipSpaces(f, 1); + o = f.charAt(i4); + p = f.substr(f.indexOf(o)); + } + } + if (o === "") { + var stacks = Fleur.XPathEvaluator._calc(args2, ops, 9999999); + var reslen0 = stacks.substr(stacks.indexOf(".") + 1); + var reslen = reslen0.substr(0, reslen0.indexOf(".")); + var ret0 = stacks.substr(stacks.indexOf(".") + 1); + return ret0.substr(ret0.indexOf(".") + 1).substr(0, parseInt(reslen, 10)); + } + if (o === "]" || o === ")" || o === "}" || (p.substr(0, 6) === "return" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(6)) === -1) || (p.substr(0, 9) === "satisfies" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(9)) === -1)) { + var stacks2 = Fleur.XPathEvaluator._calc(args2, ops, 998); + var reslen20 = stacks2.substr(stacks2.indexOf(".") + 1); + var reslen2 = reslen20.substr(0, reslen20.indexOf(".")); + var ret20 = stacks2.substr(stacks2.indexOf(".") + 1); + return (f.substr(f.indexOf(o) + 1).length - (o === "r" ? 5 : o === "s" ? 8 : 0)) + "." + ret20.substr(ret20.indexOf(".") + 1).substr(0, parseInt(reslen2, 10)); + } + if (o === "$") { + switch(rval) { + case "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['for']]]]]]": + rval = "[Fleur.XQueryX.flworExpr,[]]"; + op = "for"; + break; + case "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['let']]]]]]": + rval = "[Fleur.XQueryX.flworExpr,[]]"; + op = "let"; + break; + case "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['every']]]]]]": + rval = "[Fleur.XQueryX.quantifiedExpr,[[Fleur.XQueryX.quantifier,['every']]]]"; + op = "every"; + break; + case "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['some']]]]]]": + rval = "[Fleur.XQueryX.quantifiedExpr,[[Fleur.XQueryX.quantifier,['some']]]]"; + op = "some"; + break; + } + if (op !== "null") { + r = Fleur.XPathEvaluator._getPredParams("(" + f, rlen, rval); + rlen = parseInt(r.substr(0, r.indexOf(".")), 10); + rval = r.substr(r.indexOf(".") + 1); + args2 = rval.length + "." + rval + args; + op = op === "for" || op === "let" ? "return" : "satisfies"; + f = d.substr(rlen - 2 - op.length); + p = f.substr(1); + } + } else if (p.substr(0, 9) === "intersect" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(9)) === -1) { + op = p.substr(0, 9); + } else if (p.substr(0, 8) === "allowing" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(8)) === -1) { + op = p.substr(0, 8); + } else if (p.substr(0, 8) === "instance" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(8)) === -1) { + op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 8) + 2); + op2 = "instance of"; + } else if (p.substr(0, 8) === "castable" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(8)) === -1) { + op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 8) + 2); + op2 = "castable as"; + } else if ((p.substr(0, 6) === "except" || p.substr(0, 6) === "before") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(6)) === -1) { + op = p.substr(0, 6); + } else if (p.substr(0, 5) === "treat" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(5)) === -1) { + op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 5) + 2); + op2 = "treat as"; + } else if (p.substr(0, 5) === "group" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(5)) === -1) { + op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 5) + 2); + op2 = "group by"; + } else if (p.substr(0, 5) === "order" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(5)) === -1) { + op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 5) + 2); + op2 = "order by"; + } else if ((p.substr(0, 5) === "union" || p.substr(0, 5) === "every" || p.substr(0, 5) === "nodes" || p.substr(0, 5) === "after" || p.substr(0, 5) === "value" || p.substr(0, 5) === "count" || p.substr(0, 5) === "where" || p.substr(0, 5) === "empty" || p.substr(0, 5) === "catch") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(5)) === -1) { + op = p.substr(0, 5); + } else if (p.substr(0, 4) === "cast" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(4)) === -1) { + op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 4) + 2); + op2 = "cast as"; + } else if ((p.substr(0, 4) === "idiv" || p.substr(0, 4) === "some" || p.substr(0, 4) === "then" || p.substr(0, 4) === "else" || p.substr(0, 4) === "node" || p.substr(0, 4) === "with" || p.substr(0, 4) === "into") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(4)) === -1) { + op = p.substr(0, 4); + } else if ((p.substr(0, 3) === "div" || p.substr(0, 3) === "and" || p.substr(0, 3) === "mod" || p.substr(0, 3) === "let" || p.substr(0, 3) === "for") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(3)) === -1) { + op = p.substr(0, 3); + } else if ((p.substr(0, 2) === "or" || p.substr(0, 2) === "eq" || p.substr(0, 2) === "ne" || p.substr(0, 2) === "lt" || p.substr(0, 2) === "le" || p.substr(0, 2) === "gt" || p.substr(0, 2) === "ge" || p.substr(0, 2) === "is" || p.substr(0, 2) === "to" || p.substr(0, 2) === "in" || p.substr(0, 2) === "as" || p.substr(0, 2) === "at" || p.substr(0, 2) === "by") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(2)) === -1) { + op = p.substr(0, 2); + } else if (p.substr(0, 2) === "!=" || p.substr(0, 2) === "<=" || p.substr(0, 2) === ">=" || p.substr(0, 2) === "<<" || p.substr(0, 2) === ">>" || p.substr(0, 2) === "//" || p.substr(0, 2) === "~+" || p.substr(0, 2) === "~-" || p.substr(0, 2) === ":=" || p.substr(0, 2) === "||" || p.substr(0, 2) === "!!") { + op = p.substr(0, 2); + } else if ("+-*=|,;<>/!{:".indexOf(o) !== -1) { + op = o; + if (op === ",") { + if (ops.startsWith("5.18.:=") || ops.startsWith("11.30.group by") || ops.startsWith("5.29.~,11.30.group by")) { + op2 = "~,"; + } else { + var optrack = ops; + while (optrack !== "") { + if (optrack.startsWith("11.30.order by")) { + op2 = "~,"; + break; + } + var optracklen = parseInt(optrack.substr(0, optrack.indexOf(".")), 10); + var optrackprec0 = optrack.substring(optrack.indexOf(".") + 1, optracklen); + var optrackprec = parseInt(optrackprec0.substr(0, optrackprec0.indexOf(".")), 10); + if (optrackprec > 30) { + break; + } + optrack = optrack.substr(optrack.indexOf(".") + 1 + optracklen); + } + } + } + } + if (op !== "null") { + var opprec0 = Fleur.XPathEvaluator._precedence.substr(Fleur.XPathEvaluator._precedence.indexOf("." + (op2 !== "null" ? op2 : op) + ".") + (op2 !== "null" ? op2 : op).length + 2); + var opprec00 = opprec0.substr(opprec0.indexOf("&") + 1); + var opprec = opprec00.substr(0, opprec00.indexOf(".")); + var stacks3 = Fleur.XPathEvaluator._calc(args2, ops, parseInt(opprec, 10)); + var args3len = stacks3.substr(0, stacks3.indexOf(".")); + var args3 = stacks3.substr(stacks3.indexOf(".") + 1).substr(0, parseInt(args3len, 10)); + var nextstack = stacks3.substr(args3len.length + 1 + parseInt(args3len, 10)); + var ops3len = nextstack.substr(0, nextstack.indexOf(".")); + var ops3 = nextstack.substr(nextstack.indexOf(".") + 1).substr(0, parseInt(ops3len, 10)); + var xp3 = p.substr(op.length); + return Fleur.XPathEvaluator._xp2js(xp3, args3, (opprec.length + 1 + (op2 !== "null" ? op2 : op).length) + "." + opprec + "." + (op2 !== "null" ? op2 : op) + ops3); + } + throw Error("Unknown operator at '" + f + "'"); + }; + Fleur.XPathEvaluator._getVersion = function(xq) { + var i = Fleur.XPathEvaluator._skipSpaces(xq, 0); + var c = xq.charAt(i); + var d = xq.substr(i + 1); + var r = ""; + var v, e; + if (c === "" || "abcdefghijklmnopqrstuvwxyz".indexOf(c) === -1) { + return i + "."; + } + r = Fleur.XPathEvaluator._getName(c + d); + if (r === "xquery") { + var j = Fleur.XPathEvaluator._skipSpaces(xq, i + r.length); + c = xq.charAt(j); + d = xq.substr(j + 1); + if (c === "" || "abcdefghijklmnopqrstuvwxyz".indexOf(c) === -1) { + return i + "."; + } + r = Fleur.XPathEvaluator._getName(c + d); + if (r === "version") { + j = Fleur.XPathEvaluator._skipSpaces(xq, j + r.length); + c = xq.charAt(j); + d = xq.substr(j + 1); + if (c !== "'" && c !== '"') { + return i + "."; + } + r = Fleur.XPathEvaluator._getStringLiteral(c + d); + var vl = r.substr(0, r.indexOf(".")); + v = r.substr(vl.length + 1); + j = Fleur.XPathEvaluator._skipSpaces(xq, j + parseInt(vl, 10)); + c = xq.charAt(j); + if (c === ";") { + return (j + 1) + ".[Fleur.XQueryX.versionDecl,[[Fleur.XQueryX.version,[" + v + "]]]],"; + } + d = xq.substr(j + 1); + r = Fleur.XPathEvaluator._getName(c + d); + } + if (r === "encoding") { + j = Fleur.XPathEvaluator._skipSpaces(xq, j + r.length); + c = xq.charAt(j); + d = xq.substr(j + 1); + if (c !== "'" && c !== '"') { + return i + "."; + } + r = Fleur.XPathEvaluator._getStringLiteral(c + d); + var el = r.substr(0, r.indexOf(".")); + e = r.substr(el.length + 1); + j = Fleur.XPathEvaluator._skipSpaces(xq, j + parseInt(el, 10)); + c = xq.charAt(j); + if (c === ";") { + return (j + 1) + ".[Fleur.XQueryX.versionDecl,[" + (v ? "[Fleur.XQueryX.version,[" + v + "]]," : "") + "[Fleur.XQueryX.encoding,[" + e + "]]]],"; + } + } + } + return i + "."; + }; + })(typeof exports === 'undefined'? this.Fleur = {}: exports); } var XsltForms_xpathAxis = { - ANCESTOR_OR_SELF: 'ancestor-or-self', - ANCESTOR: 'ancestor', - ATTRIBUTE: 'attribute', - CHILD: 'child', - DESCENDANT_OR_SELF: 'descendant-or-self', - DESCENDANT: 'descendant', - ENTRY: 'entry', - FOLLOWING_SIBLING: 'following-sibling', - FOLLOWING: 'following', - NAMESPACE: 'namespace', - PARENT: 'parent', - PRECEDING_SIBLING: 'preceding-sibling', - PRECEDING: 'preceding', - SELF: 'self' -}; -console.info('XSLTForms 1.6 (663), XForms 1.1+ Engine, copyright (C) 2022 agenceXML - Alain Couthures, contact at xsltforms@agencexml.com\nYou can use fleur() Javascript function to evaluate an expression. Example: fleur(\"instance()\")'); + ANCESTOR_OR_SELF: 'ancestor-or-self', + ANCESTOR: 'ancestor', + ATTRIBUTE: 'attribute', + CHILD: 'child', + DESCENDANT_OR_SELF: 'descendant-or-self', + DESCENDANT: 'descendant', + ENTRY: 'entry', + FOLLOWING_SIBLING: 'following-sibling', + FOLLOWING: 'following', + NAMESPACE: 'namespace', + PARENT: 'parent', + PRECEDING_SIBLING: 'preceding-sibling', + PRECEDING: 'preceding', + SELF: 'self' +}; +console.info('XSLTForms 1.7 (664), XForms 1.1+ Engine, copyright (C) 2023 agenceXML - Alain Couthures, contact at xsltforms@agencexml.com\nYou can use fleur() Javascript function to evaluate an expression. Example: fleur(\"instance()\")'); var XsltForms_context; var XsltForms_globals = { - fileVersion: "1.6", - fileVersionNumber: 663, + fileVersion: "1.7", + fileVersionNumber: 664, language: "navigator", debugMode: false, debugButtons: [ @@ -2109,6 +2109,8 @@ var XsltForms_globals = { componentLoads: [], jslibraries: {}, htmlversion: "4", + hasusername: false, + haspassword: false, debugging : function() { if (document.documentElement.childNodes[0].nodeType === 8 || (XsltForms_browser.isIE && document.documentElement.childNodes[0].childNodes[1] && document.documentElement.childNodes[0].childNodes[1].nodeType === 8)) { var body = XsltForms_browser.isXhtml ? document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "body")[0] : document.getElementsByTagName("body")[0]; @@ -2492,7 +2494,7 @@ var XsltForms_globals = { this.refreshtime += d2 - d1; this.refreshcount++; }, - build : function(element, ctx, selected, varresolver) { + build : function(element, ctx, selected) { if (element.nodeType !== Fleur.Node.ELEMENT_NODE || element.id === "xsltforms-console" || element.hasXFElement === false) { return {ctx: ctx, hasXFElement: false}; } @@ -2504,10 +2506,10 @@ var XsltForms_globals = { if (xf) { if (xf instanceof Array) { for (var ixf = 0, lenxf = xf.length; ixf < lenxf; ixf++) { - xf[ixf].build(ctx, varresolver); + xf[ixf].build(ctx); } } else { - xf.build(ctx, varresolver); + xf.build(ctx); if (xf.isRepeat) { xf.refresh(selected); } @@ -2538,7 +2540,7 @@ var XsltForms_globals = { } if (!childs[i].getAttribute("cloned")) { var samechild = childs[i]; - var br = this.build(childs[i], curctx, selected, varresolver); + var br = this.build(childs[i], curctx, selected); if (childs[i] !== samechild) { i--; } else { @@ -2554,7 +2556,6 @@ var XsltForms_globals = { } } } - element.varScope = null; } if(this.building) { if (xf instanceof Array) { @@ -3629,17 +3630,19 @@ if (!Fleur.DOMParser && (XsltForms_browser.isIE || XsltForms_browser.isIE11)) { if (node.evaluate) { return node.evaluate(xpath, node, node.createNSResolver(node.documentElement), XPathResult.ANY_TYPE, null).iterateNext().textContent; } - return node.ownerDocument.evaluate(xpath, node, node.ownerDocument.createNSResolver(node), XPathResult.ANY_TYPE, null).iterateNext().textContent; - } catch (e) { - if (node.nodeName === "properties") { - for (var i = 0, l = node.childNodes.length; i < l; i++ ) { - if (node.childNodes[i].nodeName === xpath) { - return node.childNodes[i].textContent; - } + const ret = node.ownerDocument.evaluate(xpath, node, node.ownerDocument.createNSResolver(node), XPathResult.ANY_TYPE, null).iterateNext(); + if (ret) { + return ret.textContent; + } + } catch (e) {} + if (node.nodeName === "properties") { + for (var i = 0, l = node.childNodes.length; i < l; i++ ) { + if (node.childNodes[i].nodeName === xpath) { + return node.childNodes[i].textContent; } } - return defvalue || ""; } + return defvalue || ""; } if (node.nodeName === "properties") { for (var i = 0, l = node.childNodes.length; i < l; i++ ) { @@ -4646,21 +4649,6 @@ XsltForms_browser.dialog = { surround.style.display = "block"; surround.style.zIndex = (this.zindex + this.initzindex)*2; this.zindex++; - size = XsltForms_browser.getWindowSize(); - surround.style.height = size.height+"px"; - surround.style.width = size.width+"px"; - surround.style.top = size.scrollY+"px"; - surround.style.left = size.scrollX+"px"; - var surroundresize = function () { - var surround2 = document.getElementsByTagName("xforms-dialog-surround")[0]; - var size2 = XsltForms_browser.getWindowSize(); - surround2.style.height = size2.height+"px"; - surround2.style.width = size2.width+"px"; - surround2.style.top = size2.scrollY+"px"; - surround2.style.left = size2.scrollX+"px"; - }; - window.onscroll = surroundresize; - window.onresize = surroundresize; } div.style.display = "block"; div.style.zIndex = (this.zindex + this.initzindex)*2-1; @@ -5802,20 +5790,13 @@ XsltForms_browser.assert = function(condition, message) { XsltForms_globals.debugging(); } XsltForms_browser.debugConsole.write("Assertion failed: " + message); - if (XsltForms_browser.isIE) { // Internet Explorer - this.callstack = []; - for (var caller = arguments.caller; caller; caller = caller.caller) { - this.callstack.push(caller.name ? caller.name : ""); - } - } else { - try { - XsltForms_undefined(); - } catch (e) { - if (e.stack) { - this.callstack = e.stack.split("\n"); - this.callstack.shift(); - this.callstack.shift(); - } + try { + XsltForms_undefined(); + } catch (e) { + if (e.stack) { + this.callstack = e.stack.split("\n"); + this.callstack.shift(); + this.callstack.shift(); } } if (this.callstack) { @@ -5899,6 +5880,10 @@ XsltForms_browser.getValueItemsetCopy = function(node) { }; XsltForms_browser.setValue = function(node, value) { XsltForms_browser.assert(node); + const instance = document.getElementById(XsltForms_browser.getDocMeta(node.nodeType === Fleur.Node.DOCUMENT_NODE ? node : node.ownerDocument, "instance")); + if (instance && instance.xfElement) { + instance.xfElement.modified = true; + } if (node.nodeType === Fleur.Node.ATTRIBUTE_NODE || node.nodeType === Fleur.Node.TEXT_NODE) { node.nodeValue = value; } else if (XsltForms_browser.isIE && node.innerHTML && !(value instanceof Array)) { @@ -5985,12 +5970,12 @@ function fleur(expression) { let result; let compiled; const current = XsltForms_globals.defaultModel.getInstanceDocument().documentElement; - let ctx = new XsltForms_exprContext(XsltForms_subform.subforms["xsltforms-mainform"], current, null, null, null, Fleur.XPathNSResolver_default, current, null); + let ctx = new XsltForms_exprContext(XsltForms_subform.subforms["xsltforms-mainform"], current, null, null, null, new Fleur.XPathNSResolver(), current, null); let arr; if (Fleur.minimal) { try { compiled = Fleur.XPathEvaluator._xp2js(expression, "", ""); - eval("arr = " + compiled + ";"); + arr = eval(compiled); compiled = XsltForms_FleurConv[arr[0]](arr[1]); compiled = eval(compiled); let res = compiled.evaluate(ctx); @@ -6045,7 +6030,7 @@ const XsltForms_debugger = { XsltForms_debugger.xfbody.appendChild(document.body.firstChild); } XsltForms_debugger.xfboard.innerHTML = ''; - XsltForms_debugger.xfboard.innerHTML += "XForms Debugger (XSLTForms " + XsltForms_globals.fileVersion + (Fleur.version ? " + Fleur " + Fleur.version : "") + ")
"; + XsltForms_debugger.xfboard.innerHTML += "XForms Debugger (XSLTForms " + XsltForms_globals.fileVersion + (Fleur.version ? " + Fleur " + Fleur.version : "") + ")
> XPath expression
"; XsltForms_debugger.xfhistory = document.createElement("xforms-console-history"); XsltForms_debugger.xfboard.appendChild(XsltForms_debugger.xfhistory); const xfexprbody = document.createElement("xforms-body"); @@ -6077,10 +6062,10 @@ const XsltForms_debugger = { XsltForms_debugger.xfhistory.appendChild(expr); } else { const expr = document.createElement("xforms-expression"); - expr.textContent = "-> " + evt.target.value; + expr.textContent = "> " + evt.target.value; XsltForms_debugger.xfhistory.appendChild(expr); const value = document.createElement("xforms-result"); - value.textContent = "<- " + fleur(evt.target.value); + value.textContent = fleur(evt.target.value); XsltForms_debugger.xfhistory.appendChild(value); } XsltForms_debugger.textarea.value = ""; @@ -6102,679 +6087,684 @@ const XsltForms_debugger = { } }; function XsltForms_subform(subform, id, eltid) { - this.subform = subform; - this.id = id; - this.eltid = eltid; - if (eltid) { - document.getElementById(eltid).xfSubform = this; - } - this.models = []; - this.schemas = []; - this.instances = []; - this.binds = []; - this.xpaths = []; - this.expressions = {}; - this.subforms = []; - this.listeners = []; - this.ready = false; - if (subform) { - subform.subforms.push(this); - } - XsltForms_subform.subforms[id] = this; + this.subform = subform; + this.id = id; + this.eltid = eltid; + if (eltid) { + document.getElementById(eltid).xfSubform = this; + } + this.models = []; + this.schemas = []; + this.instances = []; + this.binds = []; + this.xpaths = []; + this.expressions = {}; + this.subforms = []; + this.listeners = []; + this.ready = false; + if (subform) { + subform.subforms.push(this); + } + XsltForms_subform.subforms[id] = this; } XsltForms_subform.subforms = {}; new XsltForms_subform(null, "xsltforms-mainform"); XsltForms_subform.prototype.construct = function() { - for (var i = 0, len = this.instances.length; i < len; i++) { - this.instances[i].construct(this); - } - XsltForms_browser.forEach(this.binds, "refresh"); - for (i = 0, len = this.instances.length; i < len; i++) { - this.instances[i].revalidate(); - } - window.setTimeout("XsltForms_xmlevents.dispatchList(XsltForms_subform.subforms[\""+ this.id + "\"].models, \"xforms-subform-ready\")", 1); - this.ready = true; + for (var i = 0, len = this.instances.length; i < len; i++) { + this.instances[i].construct(this); + } + XsltForms_browser.forEach(this.binds, "refresh"); + for (i = 0, len = this.instances.length; i < len; i++) { + this.instances[i].revalidate(); + } + window.setTimeout("XsltForms_xmlevents.dispatchList(XsltForms_subform.subforms[\""+ this.id + "\"].models, \"xforms-subform-ready\")", 1); + this.ready = true; }; XsltForms_subform.prototype.dispose = function() { - for (var h = 0, len0 = this.subforms.length; h < len0; h++) { - this.subforms[0].dispose(); - } - this.subforms = null; - XsltForms_globals.dispose(document.getElementById(this.eltid)); - for (var i0 = 0, len00 = this.schemas.length; i0 < len00; i0++) { - this.schemas[i0].dispose(this); - this.schemas[i0] = null; - } - this.schemas = null; - for (var j = 0, len2 = this.instances.length; j < len2; j++) { - this.instances[j].dispose(this); - this.instances[j] = null; - } - this.instances = null; - for (var i = 0, len = this.models.length; i < len; i++) { - this.models[i].dispose(this); - this.models[i] = null; - } - this.models = null; - for (var k = 0, len3 = this.xpaths.length; k < len3; k++) { - this.xpaths[k].dispose(this); - this.xpaths[k] = null; - } - this.xpaths = null; - this.expressions = null; - this.binds = null; - XsltForms_subform.subforms[this.id] = null; - var parentform = this.subform; - if (parentform) { - var parentsubforms = parentform.subforms; - for (var l = 0, len4 = parentsubforms.length; l < len4; l++) { - if (parentsubforms[l] === this) { - if (l < len4 - 1) { - parentsubforms[l] = parentsubforms[len4 - 1]; - } - parentsubforms.pop(); - break; - } - } - } - for (var m = 0, len5 = this.listeners.length; m < len5; m++) { - this.listeners[m].detach(); - this.listeners[m] = null; - } - this.listeners = null; + for (var h = 0, len0 = this.subforms.length; h < len0; h++) { + this.subforms[0].dispose(); + } + this.subforms = null; + XsltForms_globals.dispose(document.getElementById(this.eltid)); + for (var i0 = 0, len00 = this.schemas.length; i0 < len00; i0++) { + this.schemas[i0].dispose(this); + this.schemas[i0] = null; + } + this.schemas = null; + for (var j = 0, len2 = this.instances.length; j < len2; j++) { + this.instances[j].dispose(this); + this.instances[j] = null; + } + this.instances = null; + for (var i = 0, len = this.models.length; i < len; i++) { + this.models[i].dispose(this); + this.models[i] = null; + } + this.models = null; + for (var k = 0, len3 = this.xpaths.length; k < len3; k++) { + this.xpaths[k].dispose(this); + this.xpaths[k] = null; + } + this.xpaths = null; + this.expressions = null; + this.binds = null; + XsltForms_subform.subforms[this.id] = null; + var parentform = this.subform; + if (parentform) { + var parentsubforms = parentform.subforms; + for (var l = 0, len4 = parentsubforms.length; l < len4; l++) { + if (parentsubforms[l] === this) { + if (l < len4 - 1) { + parentsubforms[l] = parentsubforms[len4 - 1]; + } + parentsubforms.pop(); + break; + } + } + } + for (var m = 0, len5 = this.listeners.length; m < len5; m++) { + this.listeners[m].detach(); + this.listeners[m] = null; + } + this.listeners = null; }; function XsltForms_binding(subform, elt, mip, miptype, model) { - var xpath = mip ? mip.startsWith("xf-template-") ? XsltForms_binding.t2c(elt.getAttribute(mip)) : elt.getAttribute(mip) : elt.getAttribute("xf-ref") || elt.getAttribute("xf-value"); - var modelid = elt.getAttribute("xf-model"); - var bind = elt.getAttribute(mip === "xf-repeat-ref" ? "xf-repeat-bind" : mip === "data-xf-repeat-ref" ? "data-xf-repeat-bind" : "xf-bind"); - this.type = miptype || (elt.localName.toLowerCase() === "xforms-var" ? "#nodes or constant" : (elt.hasAttribute("xf-value") && !elt.hasAttribute("xf-ref") && mip !== "xf-repeat-ref" && mip !== "data-xf-repeat-ref" ? "xsd:string" : null)); - this.bind = bind ? bind : null; - this.xpath = xpath ? XsltForms_xpath.create(subform, xpath) : null; - var modelelt; - if( modelid ) { - modelelt = document.getElementById(modelid); - } - this.model = modelelt ? modelelt.xfElement : modelid || model; - this.result = null; + var xpath = mip ? mip.startsWith("xf-template-") ? XsltForms_binding.t2c(elt.getAttribute(mip)) : elt.getAttribute(mip) : elt.getAttribute("xf-ref") || elt.getAttribute("xf-value"); + var modelid = elt.getAttribute("xf-model"); + var bind = elt.getAttribute(mip === "xf-repeat-ref" ? "xf-repeat-bind" : mip === "data-xf-repeat-ref" ? "data-xf-repeat-bind" : "xf-bind"); + this.type = miptype || (elt.localName.toLowerCase() === "xforms-var" ? "#nodes or constant" : (elt.hasAttribute("xf-value") && !elt.hasAttribute("xf-ref") && mip !== "xf-repeat-ref" && mip !== "data-xf-repeat-ref" ? "xsd:string" : null)); + this.bind = bind ? bind : null; + this.xpath = xpath ? XsltForms_xpath.create(subform, xpath) : null; + var modelelt; + if( modelid ) { + modelelt = document.getElementById(modelid); + } + this.model = modelelt ? modelelt.xfElement : modelid || model; + this.result = null; } XsltForms_binding.t2c = function(s) { - var i = 0; - var l = s.length; - var c = s.charAt(i); - var instrpart = true; - var strpart = ""; - var exprpart = ""; - var parts = []; - while (i < l) { - if (instrpart) { - if (c === "{" && s.charAt(i + 1) !== "{") { - if (strpart !== "") { - parts.push('"' + strpart + '"'); - strpart = ""; - } - instrpart = false; - } else { - if (c === '"') { - strpart += '""'; - } else if (c === "{") { - strpart += "{"; - i++; - } else { - strpart += c; - } - } - } else { - if (c === "}") { - parts.push(exprpart); - exprpart = ""; - instrpart = true; - } else { - exprpart += c; - } - } - c = s.charAt(++i); - } - if (strpart !== "") { - parts.push('"' + strpart + '"'); - } - if (parts.length !== 1) { - return "concat(" + parts.join(",") + ")"; - } - return parts[0]; + var i = 0; + var l = s.length; + var c = s.charAt(i); + var instrpart = true; + var strpart = ""; + var exprpart = ""; + var parts = []; + while (i < l) { + if (instrpart) { + if (c === "{" && s.charAt(i + 1) !== "{") { + if (strpart !== "") { + parts.push('"' + strpart + '"'); + strpart = ""; + } + instrpart = false; + } else { + if (c === '"') { + strpart += '""'; + } else if (c === "{") { + strpart += "{"; + i++; + } else { + strpart += c; + } + } + } else { + if (c === "}") { + parts.push(exprpart); + exprpart = ""; + instrpart = true; + } else { + exprpart += c; + } + } + c = s.charAt(++i); + } + if (strpart !== "") { + parts.push('"' + strpart + '"'); + } + if (parts.length !== 1) { + return "concat(" + parts.join(",") + ")"; + } + return parts[0]; }; XsltForms_binding.prototype.evaluate = function() { - alert("Error"); -}; -XsltForms_binding.prototype.bind_evaluate = function(subform, ctx, varresolver, depsNodes, depsId, depsElements) { - var result = null; - if( typeof this.model === "string" ) { - return null; - } - if (this.bind) { - if (typeof this.bind === "string") { - var idel = document.getElementById(this.bind); - if (!idel) { - XsltForms_browser.debugConsole.write("Binding evaluation returned null for bind: " + this.bind); - return null; // A 'null' signifies bind-ID not found. - } - this.bind = idel.xfElement; - } - result = this.bind.nodes; - XsltForms_browser.copyArray(this.bind.depsNodes, depsNodes); - XsltForms_browser.copyArray(this.bind.depsElements, depsElements); - } else { - var exprCtx = new XsltForms_exprContext(subform, !ctx || (this.model && this.model !== document.getElementById(XsltForms_browser.getDocMeta(ctx.ownerDocument, "model")).xfElement) ? this.model ? this.model.getInstanceDocument().documentElement : XsltForms_globals.defaultModel.getInstanceDocument().documentElement : ctx, - null, null, null, null, ctx, varresolver, depsNodes, depsId, depsElements, this.model); - result = this.xpath.xpath_evaluate(exprCtx); - } - XsltForms_browser.assert(this.type || !result || typeof result === "object", "Binding evaluation didn't returned a nodeset but '"+(typeof result === "object" ? "" : result)+"' for " + (this.bind ? "bind: " + this.bind : "XPath expression: " + this.xpath.expression)); - switch (this.type) { - case "xsd:string": - result = XsltForms_globals.stringValue(result); - break; - case "xsd:boolean": - result = XsltForms_globals.booleanValue(result); - break; - case "xsd:anyAtomicType": - if (typeof result === "object") { - result = XsltForms_globals.stringValue(result); - } - break; - } - this.result = result; - return result; + alert("Error"); +}; +XsltForms_binding.prototype.bind_evaluate = function(subform, ctx, element, depsNodes, depsId, depsElements) { + var result = null; + if( typeof this.model === "string" ) { + return null; + } + if (this.bind) { + if (typeof this.bind === "string") { + var idel = document.getElementById(this.bind); + if (!idel) { + XsltForms_browser.debugConsole.write("Binding evaluation returned null for bind: " + this.bind); + return null; // A 'null' signifies bind-ID not found. + } + this.bind = idel.xfElement; + } + result = this.bind.nodes; + XsltForms_browser.copyArray(this.bind.depsNodes, depsNodes); + XsltForms_browser.copyArray(this.bind.depsElements, depsElements); + } else { + var exprCtx = new XsltForms_exprContext(subform, !ctx || (this.model && this.model !== document.getElementById(XsltForms_browser.getDocMeta(ctx.ownerDocument, "model")).xfElement) ? this.model ? this.model.getInstanceDocument().documentElement : XsltForms_globals.defaultModel.getInstanceDocument().documentElement : ctx, + null, null, null, null, ctx, element, depsNodes, depsId, depsElements, this.model); + result = this.xpath.xpath_evaluate(exprCtx); + } + XsltForms_browser.assert(this.type || result === null || typeof result === "object", "Binding evaluation didn't returned a nodeset but '"+(typeof result === "object" ? "" : result)+"' for " + (this.bind ? "bind: " + this.bind : "XPath expression: " + this.xpath.expression)); + switch (this.type) { + case "xsd:string": + result = XsltForms_globals.stringValue(result); + break; + case "xsd:boolean": + result = XsltForms_globals.booleanValue(result); + break; + case "xsd:anyAtomicType": + if (typeof result === "object") { + result = XsltForms_globals.stringValue(result); + } + break; + } + this.result = result; + return result; }; function XsltForms_mipbinding(subform, elt, mip, miptype, model) { - this.binding = new XsltForms_binding(subform, elt, mip, miptype, model); - this.nodes = []; - this.depsElements = []; - this.depsNodes = []; + this.binding = new XsltForms_binding(subform, elt, mip, miptype, model); + this.nodes = []; + this.depsElements = []; + this.depsNodes = []; } XsltForms_mipbinding.prototype.evaluate = function(ctx, node) { - var deps = null; - var depsN = null; - var curn = this.nodes.length; - for (var i0 = 0, len0 = this.nodes.length; i0 < len0; i0++ ) { - if (node === this.nodes[i0].node) { - deps = this.nodes[i0].deps; - depsN = this.nodes[i0].depsN; - curn = i0; - break; - } - } - if (!deps && !depsN) { - this.nodes.push({node: node, deps: [], depsN: []}); - deps = depsN = []; - } - var build = !XsltForms_globals.ready || (deps.length === 0); - var changes = XsltForms_globals.changes; - for (var i1 = 0, len1 = depsN.length; !build && i1 < len1; i1++) { - build = depsN[i1].nodeName === ""; - } - for (var i = 0, len = deps.length; !build && i < len; i++) { - var el = deps[i]; - for (var j = 0, len2 = changes.length; !build && j < len2; j++) { - if (el === changes[j]) { - if (el.instances) { //model - if (el.rebuilded || el.newRebuilded) { - build = true; - } else { - for (var k = 0, len3 = depsN.length; !build && k < len3; k++) { - build = XsltForms_browser.inArray(depsN[k], el.nodesChanged); - } - } - } else { - build = true; - } - } - } - } - if (build) { - depsN.length = 0; - deps.length = 0; - this.nodes[curn].result = this.binding.bind_evaluate(ctx.subform, ctx.node, null, this.nodes[curn].depsN, null, this.nodes[curn].deps); - return this.nodes[curn].result; - } - return this.nodes[curn].result; + var deps = null; + var depsN = null; + var curn = this.nodes.length; + for (var i0 = 0, len0 = this.nodes.length; i0 < len0; i0++ ) { + if (node === this.nodes[i0].node) { + deps = this.nodes[i0].deps; + depsN = this.nodes[i0].depsN; + curn = i0; + break; + } + } + if (!deps && !depsN) { + this.nodes.push({node: node, deps: [], depsN: []}); + deps = depsN = []; + } + var build = !XsltForms_globals.ready || (deps.length === 0); + var changes = XsltForms_globals.changes; + for (var i1 = 0, len1 = depsN.length; !build && i1 < len1; i1++) { + build = depsN[i1].nodeName === ""; + } + for (var i = 0, len = deps.length; !build && i < len; i++) { + var el = deps[i]; + for (var j = 0, len2 = changes.length; !build && j < len2; j++) { + if (el === changes[j]) { + if (el.instances) { //model + if (el.rebuilded || el.newRebuilded) { + build = true; + } else { + for (var k = 0, len3 = depsN.length; !build && k < len3; k++) { + build = XsltForms_browser.inArray(depsN[k], el.nodesChanged); + } + } + } else { + build = true; + } + } + } + } + if (build) { + depsN.length = 0; + deps.length = 0; + this.nodes[curn].result = this.binding.bind_evaluate(ctx.subform, ctx.node, null, this.nodes[curn].depsN, null, this.nodes[curn].deps); + return this.nodes[curn].result; + } + return this.nodes[curn].result; }; XsltForms_mipbinding.prototype.nodedispose_ = function(node) { - for (var i = 0, len = this.nodes.length; i < len; i++ ) { - if (node === this.nodes[i].node) { - this.nodes[i] = this.nodes[len-1]; - this.nodes.pop(); - break; - } - } + for (var i = 0, len = this.nodes.length; i < len; i++ ) { + if (node === this.nodes[i].node) { + this.nodes[i] = this.nodes[len-1]; + this.nodes.pop(); + break; + } + } }; XsltForms_mipbinding.nodedispose = function(node) { - var bindids = XsltForms_browser.getMeta(node, "bind"); - if (bindids) { - var binds = bindids.split(" "); - for (var j = 0, len2 = binds.length; j < len2; j++) { - var bind = XsltForms_collection[binds[j]].xfElement; - if (bind.required) { - bind.required.nodedispose_(node); - } - if (bind.relevant) { - bind.relevant.nodedispose_(node); - } - if (bind.readonly) { - bind.readonly.nodedispose_(node); - } - if (bind.constraint) { - bind.constraint.nodedispose_(node); - } - if (bind.calculate) { - bind.calculate.nodedispose_(node); - } - } - } - for (var n = node.firstChild; n; n = n.nextSibling) { - if (n.nodeType === Fleur.Node.ELEMENT_NODE) { - XsltForms_mipbinding.nodedispose(n); - } - } + var bindids = XsltForms_browser.getMeta(node, "bind"); + if (bindids) { + var binds = bindids.split(" "); + for (var j = 0, len2 = binds.length; j < len2; j++) { + var bind = XsltForms_collection[binds[j]].xfElement; + if (bind.required) { + bind.required.nodedispose_(node); + } + if (bind.relevant) { + bind.relevant.nodedispose_(node); + } + if (bind.readonly) { + bind.readonly.nodedispose_(node); + } + if (bind.constraint) { + bind.constraint.nodedispose_(node); + } + if (bind.calculate) { + bind.calculate.nodedispose_(node); + } + } + } + for (var n = node.firstChild; n; n = n.nextSibling) { + if (n.nodeType === Fleur.Node.ELEMENT_NODE) { + XsltForms_mipbinding.nodedispose(n); + } + } }; var XsltForms_idManager = { - cloneId : function(element) { - XsltForms_browser.assert(element && element.id); - var id = element.getAttribute("oldid") || element.id; - var list = this.data[id]; - if (!list) { - list = []; - this.data[id] = list; - } - var newId = "clonedId" + this.index++; - list.push(newId); - element.setAttribute("oldid", id); - element.id = newId; - }, + cloneId : function(element) { + XsltForms_browser.assert(element && element.id); + var id = element.getAttribute("oldid") || element.id; + var list = this.data[id]; + if (!list) { + list = []; + this.data[id] = list; + } + var newId = "clonedId" + this.index++; + list.push(newId); + element.setAttribute("oldid", id); + element.id = newId; + }, find : function(id) { - var ids = this.data[id]; - if (ids) { - for (var i = 0, len = ids.length; i < len; i++) { - var element = document.getElementById(ids[i]); - if (element) { - var parentElt = element.parentNode; - while (parentElt.nodeType === Fleur.Node.ELEMENT_NODE) { - if (parentElt.localName.toLowerCase() === "xforms-repeat-item" || parentElt.getAttribute("xforms-name" === "repeat-item")) { - if (parentElt.getAttribute("xf-selected") === "true") { - return element; - } - break; - } - parentElt = parentElt.parentNode; - } - } - } - } - var res = document.getElementById(id); - return res; - }, - clear : function() { - for (var i = 0, len = this.data.length; i < len; i++) { - this.data[i] = null; - } - this.data = []; - this.index = 0; - }, - data : [], - index : 0 + var ids = this.data[id]; + if (ids) { + for (var i = 0, len = ids.length; i < len; i++) { + var element = document.getElementById(ids[i]); + if (element) { + var parentElt = element.parentNode; + while (parentElt.nodeType === Fleur.Node.ELEMENT_NODE) { + if (parentElt.localName.toLowerCase() === "xforms-repeat-item" || parentElt.getAttribute("xforms-name" === "repeat-item")) { + if (parentElt.getAttribute("xf-selected") === "true") { + return element; + } + break; + } + parentElt = parentElt.parentNode; + } + } + } + } + var res = document.getElementById(id); + return res; + }, + clear : function() { + for (var i = 0, len = this.data.length; i < len; i++) { + this.data[i] = null; + } + this.data = []; + this.index = 0; + }, + data : [], + index : 0 }; var XsltForms_classes = {}; var XsltForms_collection = []; function XsltForms_class(className, parentName, customElementName, template) { - XsltForms_classes[customElementName] = this; - this.className = className; - this.parentName = parentName; - this.customElementName = customElementName; - this.template = document.createElement(this.customElementName); - this.template.innerHTML = template; - this.template = Array.prototype.slice.call(this.template.children); - this.classbinding = new Function("subform", "elt", "if (!elt.xfElement) { XsltForms_classes[elt.localName.toLowerCase()].applyTemplate(elt); elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); elt.xfElement = new " + this.className + "(subform, elt); }"); - if (typeof customElements !== "undefined") { - var instr; - this.upperClassName = this.customElementName.replace(/([-_]\w)/g, function(g) { return g[1].toUpperCase(); }); - instr = "class " + this.upperClassName + " extends " + this.parentName + " { constructor() { super(); } };"; - instr += " customElements.define('" + this.customElementName + "', " + this.upperClassName + ");"; - try { - eval(instr); - } catch(e) {} - } + XsltForms_classes[customElementName] = this; + this.className = className; + this.parentName = parentName; + this.customElementName = customElementName; + this.template = document.createElement(this.customElementName); + this.template.innerHTML = template; + this.template = Array.prototype.slice.call(this.template.children); + this.classbinding = new Function("subform", "elt", "if (!elt.xfElement) { XsltForms_classes[elt.localName.toLowerCase()].applyTemplate(elt); elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); elt.xfElement = new " + this.className + "(subform, elt); }"); + if (typeof customElements !== "undefined") { + var instr; + this.upperClassName = this.customElementName.replace(/([-_]\w)/g, function(g) { return g[1].toUpperCase(); }); + instr = "class " + this.upperClassName + " extends " + this.parentName + " { constructor() { super(); } };"; + instr += " customElements.define('" + this.customElementName + "', " + this.upperClassName + ");"; + try { + eval(instr); + } catch(e) {} + } } XsltForms_class.activateAll = function(subform, elt, callback) { - var scharr = []; - Array.prototype.slice.call(elt.querySelectorAll("xforms-model[xf-schema]")).forEach(function(m) { - scharr = scharr.concat(m.getAttribute("xf-schema").split(" ").map(function(sch) { - return [m, sch]; - })); - }); - var schback = function() { - for (var xcname in XsltForms_classes) { - if (XsltForms_classes.hasOwnProperty(xcname)) { - Array.prototype.slice.call(elt.getElementsByTagName(xcname)).forEach(function(elt2) { XsltForms_classes[elt2.localName].classbinding(subform, elt2); }); - } - } - Array.prototype.slice.call(elt.querySelectorAll('*[xf-repeat-ref]')).forEach(function(elt2) { if (!elt2.xfElement) { elt2.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt2); elt2.xfElement = new XsltForms_repeat(subform, elt2); } }); - Array.prototype.slice.call(elt.querySelectorAll('*[xf-repeat-bind]')).forEach(function(elt2) { if (!elt2.xfElement) { elt2.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt2); elt2.xfElement = new XsltForms_repeat(subform, elt2); } }); - Array.prototype.slice.call(elt.querySelectorAll('*[xforms-name="repeat"]')).forEach(function(elt2) { if (!elt2.xfElement) { elt2.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt2); elt2.xfElement = eval("new " + XsltForms_classes["xforms-" + elt.getAttribute("xforms-name")].classname + "(subform, elt2)"); } }); - Array.prototype.slice.call(elt.querySelectorAll('*[xf-avt]')).forEach(function(elt2) { - if (!elt2.xfElement) { - elt2.xfIndex = XsltForms_collection.length; - XsltForms_collection.push(elt2); - } - Array.prototype.slice.call(elt2.attributes).filter(function(a) { - return a.nodeName.startsWith('xf-template-'); - }).forEach(function(a) { - new XsltForms_avt(subform, elt2, a.nodeName.substr(12)); - }); - }); - callback(); - }; - var schloader = function(arr, callback) { - if (arr.length === 0) { - return callback(); - } - var sch = arr.pop(); - var m = sch[0]; - sch = sch[1]; - var req = XsltForms_browser.openRequest("GET", sch, true); - var func = function() { - if (req.readyState !== 4) { - return; - } - try { - if (req.status === 1223) { - req.status = 204; - req.statusText = "No Content"; - } - if (req.status !== 0 && (req.status < 200 || req.status >= 300)) { - XsltForms_globals.error(m.xfElement, "xforms-link-exception", "Schema not found"); - throw new Error("Error"); - } - var ndoc = XsltForms_browser.createXMLDocument(req.responseText); - new XsltForms_schema(subform, ndoc.documentElement.getAttribute("targetNamespace"), sch, {}, ndoc); - } catch (e) { - } - schloader(arr, callback); - }; - req.onreadystatechange = func; - if (req.overrideMimeType) { - req.overrideMimeType("application/xml"); - } - try { - req.send(null); - } catch(e) { - alert("File not found: " + sch); - } - }; - schloader(scharr.reverse(), schback); + var scharr = []; + Array.prototype.slice.call(elt.querySelectorAll("xforms-model[xf-schema]")).forEach(function(m) { + scharr = scharr.concat(m.getAttribute("xf-schema").split(" ").map(function(sch) { + return [m, sch]; + })); + }); + var schback = function() { + Array.prototype.slice.call(elt.getElementsByTagName("xforms-var")).forEach(function(elt2) { XsltForms_classes[elt2.localName].classbinding(subform, elt2); }); + for (var xcname in XsltForms_classes) { + if (XsltForms_classes.hasOwnProperty(xcname) && xcname !== "xforms-var") { + Array.prototype.slice.call(elt.getElementsByTagName(xcname)).forEach(function(elt2) { XsltForms_classes[elt2.localName].classbinding(subform, elt2); }); + } + } + Array.prototype.slice.call(elt.querySelectorAll('*[xf-repeat-ref]')).forEach(function(elt2) { if (!elt2.xfElement) { elt2.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt2); elt2.xfElement = new XsltForms_repeat(subform, elt2); } }); + Array.prototype.slice.call(elt.querySelectorAll('*[xf-repeat-bind]')).forEach(function(elt2) { if (!elt2.xfElement) { elt2.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt2); elt2.xfElement = new XsltForms_repeat(subform, elt2); } }); + Array.prototype.slice.call(elt.querySelectorAll('*[xforms-name="repeat"]')).forEach(function(elt2) { if (!elt2.xfElement) { elt2.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt2); elt2.xfElement = eval("new " + XsltForms_classes["xforms-" + elt.getAttribute("xforms-name")].classname + "(subform, elt2)"); } }); + Array.prototype.slice.call(elt.querySelectorAll('*[xf-avt]')).forEach(function(elt2) { + if (!elt2.xfElement) { + elt2.xfIndex = XsltForms_collection.length; + XsltForms_collection.push(elt2); + } + Array.prototype.slice.call(elt2.attributes).filter(function(a) { + return a.nodeName.startsWith('xf-template-'); + }).forEach(function(a) { + new XsltForms_avt(subform, elt2, a.nodeName.substr(12)); + }); + }); + callback(); + }; + var schloader = function(arr, callback) { + if (arr.length === 0) { + return callback(); + } + var sch = arr.pop(); + var m = sch[0]; + sch = sch[1]; + var req = XsltForms_browser.openRequest("GET", sch, true); + var func = function() { + if (req.readyState !== 4) { + return; + } + try { + if (req.status === 1223) { + req.status = 204; + req.statusText = "No Content"; + } + if (req.status !== 0 && (req.status < 200 || req.status >= 300)) { + XsltForms_globals.error(m.xfElement, "xforms-link-exception", "Schema not found"); + throw new Error("Error"); + } + var ndoc = XsltForms_browser.createXMLDocument(req.responseText); + new XsltForms_schema(subform, ndoc.documentElement.getAttribute("targetNamespace"), sch, {}, ndoc); + } catch (e) { + } + schloader(arr, callback); + }; + req.onreadystatechange = func; + if (req.overrideMimeType) { + req.overrideMimeType("application/xml"); + } + try { + req.send(null); + } catch(e) { + alert("File not found: " + sch); + } + }; + schloader(scharr.reverse(), schback); }; XsltForms_class._applyTemplate = function(elt, template) { - var children = elt.children || elt.childNodes; - var childarr = Array.prototype.slice.call(children).map(function(e) { return e.localName.toLowerCase(); }); - var pos = 0; - template.forEach(function(t) { - var inc = childarr.indexOf(t.localName); - var n = t.localName; - if (!n.startsWith("xforms-")) { - n = "xforms-" + t.getAttribute("xforms-name"); - } - if (inc !== -1) { - pos = inc + 1; - } else if (n === "xforms-body" || n === "xforms-alert" || n === "xforms-required" || t.childNodes.length !== 0) { - elt.insertBefore(t.cloneNode(true), children[pos]); - childarr = Array.prototype.slice.call(children).map(function(e) { return e.localName.toLowerCase(); }); - pos++; - } - }); - var label; - Array.prototype.slice.call(children).forEach(function(child) { - var n = child.localName.toLowerCase(); - if (((n === "xforms-hint" && child.getAttribute("xf-appearance") !== "minimal") || (n === "xforms-help" && child.getAttribute("xf-appearance") !== "minimal") || n === "xforms-alert") && (!child.previousSibling || !child.previousSibling.localName || child.previousSibling.localName.toLowerCase() !== n + "-mark")) { - elt.insertBefore(document.createElement(n + "-mark"), child); - } else if (n === "xforms-label") { - label = child; - } - }); - if (label) { - Array.prototype.slice.call(children).forEach(function(child) { - var n = child.localName.toLowerCase(); - if (n === "xforms-help" && child.getAttribute("xf-appearance") === "minimal") { - elt.insertBefore(child, label.nextSibling); - } - }); - } + var children = elt.children || elt.childNodes; + var childarr = Array.prototype.slice.call(children).map(function(e) { return e.localName.toLowerCase(); }); + var pos = 0; + template.forEach(function(t) { + var inc = childarr.indexOf(t.localName); + var n = t.localName; + if (!n.startsWith("xforms-")) { + n = "xforms-" + t.getAttribute("xforms-name"); + } + if (inc !== -1) { + pos = inc + 1; + } else if (n === "xforms-body" || n === "xforms-alert" || n === "xforms-required" || t.childNodes.length !== 0) { + elt.insertBefore(t.cloneNode(true), children[pos]); + childarr = Array.prototype.slice.call(children).map(function(e) { return e.localName.toLowerCase(); }); + pos++; + } + }); + var label; + Array.prototype.slice.call(children).forEach(function(child) { + var n = child.localName.toLowerCase(); + if (((n === "xforms-hint" && child.getAttribute("xf-appearance") !== "minimal") || (n === "xforms-help" && child.getAttribute("xf-appearance") !== "minimal") || n === "xforms-alert") && (!child.previousSibling || !child.previousSibling.localName || child.previousSibling.localName.toLowerCase() !== n + "-mark")) { + elt.insertBefore(document.createElement(n + "-mark"), child); + } else if (n === "xforms-label") { + label = child; + } + }); + if (label) { + Array.prototype.slice.call(children).forEach(function(child) { + var n = child.localName.toLowerCase(); + if (n === "xforms-help" && child.getAttribute("xf-appearance") === "minimal") { + elt.insertBefore(child, label.nextSibling); + } + }); + } }; XsltForms_class.prototype.applyTemplate = function(elt) { - XsltForms_class._applyTemplate(elt, this.template); + XsltForms_class._applyTemplate(elt, this.template); }; function XsltForms_listener(subform, observer, evtTarget, evtname, phase, handler, defaultaction) { - if (!observer) { - return; - } - phase = phase || "default"; - if (phase !== "default" && phase !== "capture") { - XsltForms_globals.error(XsltForms_globals.defaultModel, "xforms-compute-exception", - "Unknown event-phase(" + phase +") for event(" + evtname + ")"+(observer ? " on element(" + observer.id + ")":"") + "!"); - return; - } - this.subform = subform; - this.observer = observer; - this.evtTarget = evtTarget; - this.name = evtname; - this.evtName = document.addEventListener? evtname : "errorupdate"; - this.phase = phase; - this.handler = handler; - this.defaultaction = defaultaction; - if (observer.listeners) { - if (evtname === "xforms-subform-ready") { - for (var i = 0, l = observer.listeners.length; i < l; i++) { - if (observer.listeners[i].name === evtname) { - return; - } - } - } - } else { - observer.listeners = []; - } - observer.listeners.push(this); - this.callback = function(evt) { - if (!document.addEventListener) { - evt = evt || window.event; - evt.target = evt.srcElement; - evt.currentTarget = observer; - XsltForms_browser.debugConsole.write("observer:"+observer.id); - XsltForms_browser.debugConsole.write("name:"+evtname); - XsltForms_browser.debugConsole.write("target:"+evt.target.id); - XsltForms_browser.debugConsole.write("trueName:"+evt.trueName); - if (evt.trueName && evt.trueName !== evtname) { - return; - } - if (!evt.phase) { - if (phase === "capture") { - return; - } - } else if (evt.phase !== phase) { - return; - } - if (phase === "capture") { - evt.cancelBubble = true; - } - evt.preventDefault = function() { - this.returnValue = false; - }; - evt.stopPropagation = function() { - this.cancelBubble = true; - this.stopped = true; - }; - } - var effectiveTarget = true; - if (evt.target && evt.target.nodeType === 3) { - evt.target = evt.target.parentNode; - } - if (evt.currentTarget && (evt.target.nodeName.toUpperCase() === "BUTTON" || evt.target.nodeName.toUpperCase() === "A" || evt.target.nodeName.toUpperCase() === "INPUT" || evt.target.nodeName.toUpperCase() === "XFORMS-LABEL" || (XsltForms_browser.isChrome && (evt.eventPhase === 3 || evt instanceof UIEvent) && this.xfElement && this.xfElement.controlName === "trigger")) && !XsltForms_browser.isFF2) { - effectiveTarget = false; - } - if (evt.eventPhase === 3 && evt.target.xfElement && evt.target === evt.currentTarget && !XsltForms_browser.isFF2) { - effectiveTarget = false; - } - if (evtTarget && evt.target !== evtTarget) { - effectiveTarget = false; - } - XsltForms_browser.debugConsole.write("effectiveTarget:"+effectiveTarget); - if (effectiveTarget) { // && !(typeof UIEvent !== 'undefined' && evt instanceof UIEvent)) { - XsltForms_browser.debugConsole.write("Captured event " + evtname + " on <" + evt.target.nodeName + - (evt.target.className? " class=\"" + (typeof evt.target.className === "string" ? evt.target.className : evt.target.className.baseVal) + "\"" : "") + - (evt.target.id? " id=\"" + evt.target.id + "\"" : "") + "/>"); - handler.call(evt.target, evt); - } - if (!defaultaction) { - evt.preventDefault(); - } - if (!document.addEventListener) { - try { - evt.preventDefault = null; - evt.stopPropagation = null; - } catch (e) {} - } - }; - this.attach(); - if (subform) { - subform.listeners.push(this); - } + if (!observer) { + return; + } + phase = phase || "default"; + if (phase !== "default" && phase !== "capture") { + XsltForms_globals.error(XsltForms_globals.defaultModel, "xforms-compute-exception", + "Unknown event-phase(" + phase +") for event(" + evtname + ")"+(observer ? " on element(" + observer.id + ")":"") + "!"); + return; + } + this.subform = subform; + this.observer = observer; + this.evtTarget = evtTarget; + this.name = evtname; + this.evtName = document.addEventListener? evtname : "errorupdate"; + this.phase = phase; + this.handler = handler; + this.defaultaction = defaultaction; + if (observer.listeners) { + if (evtname === "xforms-subform-ready") { + for (var i = 0, l = observer.listeners.length; i < l; i++) { + if (observer.listeners[i].name === evtname) { + return; + } + } + } + } else { + observer.listeners = []; + } + observer.listeners.push(this); + this.callback = function(evt) { + if (!document.addEventListener) { + evt = evt || window.event; + evt.target = evt.srcElement; + evt.currentTarget = observer; + XsltForms_browser.debugConsole.write("observer:"+observer.id); + XsltForms_browser.debugConsole.write("name:"+evtname); + XsltForms_browser.debugConsole.write("target:"+evt.target.id); + XsltForms_browser.debugConsole.write("trueName:"+evt.trueName); + if (evt.trueName && evt.trueName !== evtname) { + return; + } + if (!evt.phase) { + if (phase === "capture") { + return; + } + } else if (evt.phase !== phase) { + return; + } + if (phase === "capture") { + evt.cancelBubble = true; + } + evt.preventDefault = function() { + this.returnValue = false; + }; + evt.stopPropagation = function() { + this.cancelBubble = true; + this.stopped = true; + }; + } + var effectiveTarget = true; + if (evt.target && evt.target.nodeType === 3) { + evt.target = evt.target.parentNode; + } + if (evt.currentTarget && (evt.target.nodeName.toUpperCase() === "BUTTON" || evt.target.nodeName.toUpperCase() === "A" || evt.target.nodeName.toUpperCase() === "INPUT" || evt.target.nodeName.toUpperCase() === "XFORMS-LABEL" || (XsltForms_browser.isChrome && (evt.eventPhase === 3 || evt instanceof UIEvent) && this.xfElement && this.xfElement.controlName === "trigger")) && !XsltForms_browser.isFF2) { + effectiveTarget = false; + } + if (evt.eventPhase === 3 && evt.target.xfElement && evt.target === evt.currentTarget && !XsltForms_browser.isFF2) { + effectiveTarget = false; + } + if (evtTarget && evt.target !== evtTarget) { + effectiveTarget = false; + } + XsltForms_browser.debugConsole.write("effectiveTarget:"+effectiveTarget); + if (effectiveTarget) { // && !(typeof UIEvent !== 'undefined' && evt instanceof UIEvent)) { + XsltForms_browser.debugConsole.write("Captured event " + evtname + " on <" + evt.target.nodeName + + (evt.target.className? " class=\"" + (typeof evt.target.className === "string" ? evt.target.className : evt.target.className.baseVal) + "\"" : "") + + (evt.target.id? " id=\"" + evt.target.id + "\"" : "") + "/>"); + handler.call(evt.target, evt); + } + if (!defaultaction) { + evt.preventDefault(); + } + if (!document.addEventListener) { + try { + evt.preventDefault = null; + evt.stopPropagation = null; + } catch (e) {} + } + }; + this.attach(); + if (subform) { + subform.listeners.push(this); + } } XsltForms_listener.destructs = []; XsltForms_listener.prototype.attach = function() { - XsltForms_browser.events.attach(this.observer, this.evtName, this.callback, this.phase === "capture"); - if (this.evtName === "xforms-model-destruct") { - XsltForms_listener.destructs.push({observer: this.observer, callback: this.callback}); - } + XsltForms_browser.events.attach(this.observer, this.evtName, this.callback, this.phase === "capture"); + if (this.evtName === "xforms-model-destruct") { + XsltForms_listener.destructs.push({observer: this.observer, callback: this.callback}); + } }; XsltForms_listener.prototype.detach = function() { - if( this.observer.listeners ) { - for (var i = 0, l = this.observer.listeners.length; i < l; i++) { - if (this.observer.listeners[i] === this) { - this.observer.listeners.splice(i, 1); - break; - } - } - } - XsltForms_browser.events.detach(this.observer, this.evtName, this.callback, this.phase === "capture"); + if( this.observer.listeners ) { + for (var i = 0, l = this.observer.listeners.length; i < l; i++) { + if (this.observer.listeners[i] === this) { + this.observer.listeners.splice(i, 1); + break; + } + } + } + XsltForms_browser.events.detach(this.observer, this.evtName, this.callback, this.phase === "capture"); }; XsltForms_listener.prototype.clone = function(element) { - return new XsltForms_listener(this.subform, element, this.evtTarget, this.name, this.phase, this.handler); + return new XsltForms_listener(this.subform, element, this.evtTarget, this.name, this.phase, this.handler); }; var XsltForms_xmlevents = { - REGISTRY : [], - EventContexts : [], - define : function(evtname, bubbles, cancelable, defaultAction) { - XsltForms_xmlevents.REGISTRY[evtname] = { - bubbles: bubbles, - cancelable: cancelable, - defaultAction: defaultAction? defaultAction : function() { } - }; - }, - makeEventContext : function(evcontext, type, targetid, bubbles, cancelable) { - if (!evcontext) { - evcontext = {}; - } - if (!evcontext.type) { - evcontext.type = type; - } - try { - evcontext.targetid = targetid; - evcontext.bubbles = bubbles; - evcontext.cancelable = cancelable; - } catch (e) { - } - return evcontext; - } + REGISTRY : [], + EventContexts : [], + define : function(evtname, bubbles, cancelable, defaultAction) { + XsltForms_xmlevents.REGISTRY[evtname] = { + bubbles: bubbles, + cancelable: cancelable, + defaultAction: defaultAction? defaultAction : function() { } + }; + }, + makeEventContext : function(evcontext, type, targetid, bubbles, cancelable) { + if (!evcontext) { + evcontext = {}; + } + if (!evcontext.type) { + evcontext.type = type; + } + try { + evcontext.targetid = targetid; + if (!evcontext.bubbles || Object.getOwnPropertyDescriptor(evcontext, "bubbles")) { + evcontext.bubbles = bubbles; + } + if (!evcontext.cancelable || Object.getOwnPropertyDescriptor(evcontext, "cancelable")) { + evcontext.cancelable = cancelable; + } + } catch (e) { + } + return evcontext; + } }; XsltForms_xmlevents.dispatchList = function(list, evtname) { - for (var id = 0, len = list.length; id < len; id++) { - XsltForms_xmlevents.dispatch(list[id], evtname); - } + for (var id = 0, len = list.length; id < len; id++) { + XsltForms_xmlevents.dispatch(list[id], evtname); + } }; XsltForms_xmlevents.dispatch = function(target, evtname, type, bubbles, cancelable, defaultAction, evcontext) { - if (!target) { - XsltForms_browser.debugConsole.write("ERROR: Cannot dispatch event " + name + " as the target is null"); - return; - } - target = target.element || target; - XsltForms_browser.assert(target && typeof(target.nodeName) !== "undefined"); - XsltForms_browser.debugConsole.write("Dispatching event " + evtname + " on <" + target.nodeName.toLowerCase() + - (target.className? " class=\"" + (typeof target.className === "string" ? target.className : target.className.baseVal) + "\"" : "") + - (target.id? " id=\"" + target.id + "\"" : "") + "/>"); - var reg = XsltForms_xmlevents.REGISTRY[evtname]; - if (reg) { - bubbles = reg.bubbles; - cancelable = reg.cancelable; - defaultAction = reg.defaultAction; - } - if (!defaultAction) { - defaultAction = function() { }; - } - evcontext = XsltForms_xmlevents.makeEventContext(evcontext, evtname, target.id, bubbles, cancelable); - XsltForms_xmlevents.EventContexts.push(evcontext); - try { - var evt, res; - if (target.dispatchEvent) { - evt = document.createEvent("Event"); - evt.initEvent(evtname, bubbles, cancelable); - res = target.dispatchEvent(evt); - if ((res && !evt.stopped) || !cancelable) { - defaultAction.call(target.xfElement, evt); - } - } else { - var canceler = null; - var ancestors = []; - for (var a = target.parentNode; a; a = a.parentNode) { - ancestors.unshift(a); - } - for (var i = 0, len = ancestors.length; i < len; i++) { - evt = document.createEventObject(); - evt.trueName = evtname; - evt.phase = "capture"; - ancestors[i].fireEvent("onerrorupdate", evt); - if (evt.stopped) { - return; - } - } - evt = document.createEventObject(); - evt.trueName = evtname; - evt.phase = "capture"; - evt.target = target; - target.fireEvent("onerrorupdate" , evt); - if (!bubbles) { - canceler = new XsltForms_listener(null, target, null, evtname, "default", function(evt) { evt.cancelBubble = true; }); - } - evt = document.createEventObject(); - evt.trueName = evtname; - evt.phase = "default"; - evt.target = target; - res = target.fireEvent("onerrorupdate", evt); - try { - if ((res && !evt.stopped) || !cancelable) { - defaultAction.call(target.xfElement, evt); - } - if (!bubbles) { - canceler.detach(); - } - } catch (e2) { - } - } - } catch (e) { - alert("XSLTForms Exception\n--------------------------\n\nError dispatching event '"+evtname+"' :\n\n"+(typeof(e.stack)==="undefined"?"":e.stack)+"\n\n"+(e.name?e.name+(e.message?"\n\n"+e.message:""):e)); - } finally { - if (XsltForms_xmlevents.EventContexts[XsltForms_xmlevents.EventContexts.length - 1].rheadsdoc) { - XsltForms_xmlevents.EventContexts[XsltForms_xmlevents.EventContexts.length - 1].rheadsdoc = null; - } - if (XsltForms_xmlevents.EventContexts[XsltForms_xmlevents.EventContexts.length - 1]["response-body"]) { - XsltForms_xmlevents.EventContexts[XsltForms_xmlevents.EventContexts.length - 1]["response-body"] = null; - } - XsltForms_xmlevents.EventContexts.pop(); - } + if (!target) { + XsltForms_browser.debugConsole.write("ERROR: Cannot dispatch event " + name + " as the target is null"); + return; + } + target = target.element || target; + XsltForms_browser.assert(target && typeof(target.nodeName) !== "undefined"); + XsltForms_browser.debugConsole.write("Dispatching event " + evtname + " on <" + target.nodeName.toLowerCase() + + (target.className? " class=\"" + (typeof target.className === "string" ? target.className : target.className.baseVal) + "\"" : "") + + (target.id? " id=\"" + target.id + "\"" : "") + "/>"); + var reg = XsltForms_xmlevents.REGISTRY[evtname]; + if (reg) { + bubbles = reg.bubbles; + cancelable = reg.cancelable; + defaultAction = reg.defaultAction; + } + if (!defaultAction) { + defaultAction = function() { }; + } + evcontext = XsltForms_xmlevents.makeEventContext(evcontext, evtname, target.id, bubbles, cancelable); + XsltForms_xmlevents.EventContexts.push(evcontext); + try { + var evt, res; + if (target.dispatchEvent) { + evt = document.createEvent("Event"); + evt.initEvent(evtname, bubbles, cancelable); + res = target.dispatchEvent(evt); + if ((res && !evt.stopped) || !cancelable) { + defaultAction.call(target.xfElement, evt); + } + } else { + var canceler = null; + var ancestors = []; + for (var a = target.parentNode; a; a = a.parentNode) { + ancestors.unshift(a); + } + for (var i = 0, len = ancestors.length; i < len; i++) { + evt = document.createEventObject(); + evt.trueName = evtname; + evt.phase = "capture"; + ancestors[i].fireEvent("onerrorupdate", evt); + if (evt.stopped) { + return; + } + } + evt = document.createEventObject(); + evt.trueName = evtname; + evt.phase = "capture"; + evt.target = target; + target.fireEvent("onerrorupdate" , evt); + if (!bubbles) { + canceler = new XsltForms_listener(null, target, null, evtname, "default", function(evt) { evt.cancelBubble = true; }); + } + evt = document.createEventObject(); + evt.trueName = evtname; + evt.phase = "default"; + evt.target = target; + res = target.fireEvent("onerrorupdate", evt); + try { + if ((res && !evt.stopped) || !cancelable) { + defaultAction.call(target.xfElement, evt); + } + if (!bubbles) { + canceler.detach(); + } + } catch (e2) { + } + } + } catch (e) { + alert("XSLTForms Exception\n--------------------------\n\nError dispatching event '"+evtname+"' :\n\n"+(typeof(e.stack)==="undefined"?"":e.stack)+"\n\n"+(e.name?e.name+(e.message?"\n\n"+e.message:""):e)); + } finally { + if (XsltForms_xmlevents.EventContexts[XsltForms_xmlevents.EventContexts.length - 1].rheadsdoc) { + XsltForms_xmlevents.EventContexts[XsltForms_xmlevents.EventContexts.length - 1].rheadsdoc = null; + } + if (XsltForms_xmlevents.EventContexts[XsltForms_xmlevents.EventContexts.length - 1]["response-body"]) { + XsltForms_xmlevents.EventContexts[XsltForms_xmlevents.EventContexts.length - 1]["response-body"] = null; + } + XsltForms_xmlevents.EventContexts.pop(); + } }; XsltForms_xmlevents.define("xforms-model-construct", true, false, function() { this.construct(); }); XsltForms_xmlevents.define("xforms-model-construct-done", true, false); @@ -6821,794 +6811,802 @@ XsltForms_xmlevents.define("xforms-unload-done", true, false); XsltForms_xmlevents.define("xforms-upload-done", true, false); XsltForms_xmlevents.define("xforms-upload-error", true, false); function XsltForms_binaryExpr(expr1, op, expr2) { - this.expr1 = expr1; - this.expr2 = expr2; - this.op = op.replace(">", ">").replace("<", "<"); + this.expr1 = expr1; + this.expr2 = expr2; + this.op = op.replace(">", ">").replace("<", "<"); } XsltForms_binaryExpr.prototype.evaluate = function(ctx) { - var v1 = this.expr1.evaluate(ctx); - var v2 = this.expr2.evaluate(ctx); - var n1; - var n2; - if (v1 && v2 && (((typeof v1) === "object" && v1.length > 1) || ((typeof v2) === "object" && v2.length > 1)) && - (this.op === "=" || this.op === "!=" || this.op === "<" || this.op === "<=" || this.op === ">" || this.op === ">=")) { - if (typeof v1 !== "object") { - v1 = [v1]; - } - if (typeof v2 !== "object") { - v2 = [v2]; - } - for (var i = 0, len = v1.length; i < len; i++) { - n1 = XsltForms_globals.numberValue([v1[i]]); - if (isNaN(n1)) { - n1 = XsltForms_globals.stringValue([v1[i]]); - } - for (var j = 0, len1 = v2.length; j < len1; j++) { - n2 = XsltForms_globals.numberValue([v2[j]]); - if (isNaN(n2)) { - n2 = XsltForms_globals.stringValue([v2[j]]); - } - switch (this.op) { - case '=': - if (n1 == n2) { - return true; - } - break; - case '!=': - if (n1 != n2) { - return true; - } - break; - case '<': - if (n1 < n2) { - return true; - } - break; - case '<=': - if (n1 <= n2) { - return true; - } - break; - case '>': - if (n1 > n2) { - return true; - } - break; - case '>=': - if (n1 >= n2) { - return true; - } - break; - } - } - } - return false; - } - n1 = XsltForms_globals.numberValue(v1); - n2 = XsltForms_globals.numberValue(v2); - if (isNaN(n1) || isNaN(n2)) { - n1 = XsltForms_globals.stringValue(v1); - n2 = XsltForms_globals.stringValue(v2); - } - var res = 0; - switch (this.op) { - case 'or' : res = XsltForms_globals.booleanValue(v1) || XsltForms_globals.booleanValue(v2); break; - case 'and' : res = XsltForms_globals.booleanValue(v1) && XsltForms_globals.booleanValue(v2); break; - case '+' : res = n1 + n2; break; - case '-' : res = n1 - n2; break; - case '*' : res = n1 * n2; break; - case 'mod' : res = n1 % n2; break; - case 'div' : res = n1 / n2; break; - case '=' : res = n1 === n2; break; - case '!=' : res = n1 !== n2; break; - case '<' : res = n1 < n2; break; - case '<=' : res = n1 <= n2; break; - case '>' : res = n1 > n2; break; - case '>=' : res = n1 >= n2; break; - } - return typeof res === "number" ? Math.round(res*1000000)/1000000 : res; -}; -function XsltForms_exprContext(subform, node, position, nodelist, parentNode, nsresolver, current, varresolver, depsNodes, depsId, depsElements) { - this.subform = subform; - this.node = node; - this.current = current || node; - if(!position) { - var repeat = node && node.nodeType ? XsltForms_browser.getMeta(node, "repeat") : null; - if(repeat) { - var eltrepeat = XsltForms_collection[repeat]; - if (eltrepeat) { - var xrepeat = eltrepeat.xfElement; - var len; - for(position = 1, len = xrepeat.nodes.length; position <= len; position++) { - if(node === xrepeat.nodes[position-1]) { - break; - } - } - } - } - } - this.position = position || 1; - this.nodelist = nodelist || [ node ]; - this.parent = parentNode; - this.root = parentNode ? parentNode.root : node ? node.ownerDocument : null; - this.nsresolver = nsresolver; - this.varresolver = varresolver; - this.depsId = depsId; - this.initDeps(depsNodes, depsElements); + var v1 = this.expr1.evaluate(ctx); + var v2 = this.expr2.evaluate(ctx); + var n1; + var n2; + if (v1 && v2 && (((typeof v1) === "object" && v1.length > 1) || ((typeof v2) === "object" && v2.length > 1)) && + (this.op === "=" || this.op === "!=" || this.op === "<" || this.op === "<=" || this.op === ">" || this.op === ">=")) { + if (typeof v1 !== "object") { + v1 = [v1]; + } + if (typeof v2 !== "object") { + v2 = [v2]; + } + for (var i = 0, len = v1.length; i < len; i++) { + n1 = XsltForms_globals.numberValue([v1[i]]); + if (isNaN(n1)) { + n1 = XsltForms_globals.stringValue([v1[i]]); + } + for (var j = 0, len1 = v2.length; j < len1; j++) { + n2 = XsltForms_globals.numberValue([v2[j]]); + if (isNaN(n2)) { + n2 = XsltForms_globals.stringValue([v2[j]]); + } + switch (this.op) { + case '=': + if (n1 == n2) { + return true; + } + break; + case '!=': + if (n1 != n2) { + return true; + } + break; + case '<': + if (n1 < n2) { + return true; + } + break; + case '<=': + if (n1 <= n2) { + return true; + } + break; + case '>': + if (n1 > n2) { + return true; + } + break; + case '>=': + if (n1 >= n2) { + return true; + } + break; + } + } + } + return false; + } + n1 = XsltForms_globals.numberValue(v1); + n2 = XsltForms_globals.numberValue(v2); + if (isNaN(n1) || isNaN(n2)) { + n1 = XsltForms_globals.stringValue(v1); + n2 = XsltForms_globals.stringValue(v2); + } + var res = 0; + switch (this.op) { + case 'or' : res = XsltForms_globals.booleanValue(v1) || XsltForms_globals.booleanValue(v2); break; + case 'and' : res = XsltForms_globals.booleanValue(v1) && XsltForms_globals.booleanValue(v2); break; + case '+' : res = n1 + n2; break; + case '-' : res = n1 - n2; break; + case '*' : res = n1 * n2; break; + case 'mod' : res = n1 % n2; break; + case 'div' : res = n1 / n2; break; + case '=' : res = n1 === n2; break; + case '!=' : res = n1 !== n2; break; + case '<' : res = n1 < n2; break; + case '<=' : res = n1 <= n2; break; + case '>' : res = n1 > n2; break; + case '>=' : res = n1 >= n2; break; + } + return typeof res === "number" ? Math.round(res*1000000)/1000000 : res; +}; +function XsltForms_exprContext(subform, node, position, nodelist, parentNode, nsresolver, current, elt, depsNodes, depsId, depsElements) { + this.subform = subform; + this.node = node; + this.current = current || node; + if (!position) { + var repeat = node && node.nodeType ? XsltForms_browser.getMeta(node, "repeat") : null; + if (repeat) { + var eltrepeat = XsltForms_collection[repeat]; + if (eltrepeat) { + var xrepeat = eltrepeat.xfElement; + var len; + for (position = 1, len = xrepeat.nodes.length; position <= len; position++) { + if (node === xrepeat.nodes[position - 1]) { + break; + } + } + } + } + } + this.position = position || 1; + this.nodelist = nodelist || [node]; + this.parent = parentNode; + this.root = parentNode ? parentNode.root : node ? node.ownerDocument : null; + this.nsresolver = nsresolver; + this.element = elt; + this.depsId = depsId; + this.initDeps(depsNodes, depsElements); } XsltForms_exprContext.prototype.clone = function(node, position, nodelist) { - return new XsltForms_exprContext(this.subform, node || this.node, - typeof position === "undefined" ? this.position : position, - nodelist || this.nodelist, this, this.nsresolver, this.current, this.varresolver, - this.depsNodes, this.depsId, this.depsElements); + return new XsltForms_exprContext(this.subform, node || this.node, + typeof position === "undefined" ? this.position : position, + nodelist || this.nodelist, this, this.nsresolver, this.current, this.element, + this.depsNodes, this.depsId, this.depsElements); }; XsltForms_exprContext.prototype.setNode = function(node, position) { - this.node = node; - this.position = position; + this.node = node; + this.position = position; }; XsltForms_exprContext.prototype.initDeps = function(depsNodes, depsElements) { - this.depsNodes = depsNodes || []; - this.depsElements = depsElements || []; + this.depsNodes = depsNodes || []; + this.depsElements = depsElements || []; }; XsltForms_exprContext.prototype.addDepNode = function(node) { - var deps = this.depsNodes; - if (deps && node.nodeType && node.nodeType !== Fleur.Node.DOCUMENT_NODE && (!this.depsId || !XsltForms_browser.inValueMeta(node, "depfor", this.depsId))) { // !inArray(node, deps)) { - if (this.depsId) { - XsltForms_browser.addValueMeta(node, "depfor", this.depsId); - } - deps.push(node); - } + var deps = this.depsNodes; + if (deps && node.nodeType && node.nodeType !== Fleur.Node.DOCUMENT_NODE && (!this.depsId || !XsltForms_browser.inValueMeta(node, "depfor", this.depsId))) { // !inArray(node, deps)) { + if (this.depsId) { + XsltForms_browser.addValueMeta(node, "depfor", this.depsId); + } + deps.push(node); + } }; XsltForms_exprContext.prototype.addDepElement = function(element) { - var deps = this.depsElements; - if (deps && !XsltForms_browser.inArray(element, deps)) { - deps.push(element); - } + var deps = this.depsElements; + if (deps && !XsltForms_browser.inArray(element, deps)) { + deps.push(element); + } }; function XsltForms_tokenExpr(m) { - this.value = m; + this.value = m; } XsltForms_tokenExpr.prototype.evaluate = function() { - return XsltForms_globals.stringValue(this.value); + return XsltForms_globals.stringValue(this.value); }; function XsltForms_unaryMinusExpr(expr) { - this.expr = expr; + this.expr = expr; } XsltForms_unaryMinusExpr.prototype.evaluate = function(ctx) { - return -XsltForms_globals.numberValue(this.expr.evaluate(ctx)); + return -XsltForms_globals.numberValue(this.expr.evaluate(ctx)); }; function XsltForms_cteExpr(value) { - this.value = XsltForms_browser.isEscaped ? typeof value === "string" ? XsltForms_browser.unescape(value) : value : value; + this.value = XsltForms_browser.isEscaped ? typeof value === "string" ? XsltForms_browser.unescape(value) : value : value; } XsltForms_cteExpr.prototype.evaluate = function() { - return this.value; + return this.value; }; function XsltForms_filterExpr(expr, predicate) { - this.expr = expr; - this.predicate = predicate; + this.expr = expr; + this.predicate = predicate; } XsltForms_filterExpr.prototype.evaluate = function(ctx) { - var nodes = XsltForms_globals.nodeSetValue(this.expr.evaluate(ctx)); - for (var i = 0, len = this.predicate.length; i < len; ++i) { - var nodes0 = nodes; - nodes = []; - for (var j = 0, len1 = nodes0.length; j < len1; ++j) { - var n = nodes0[j]; - var newCtx = ctx.clone(n, j, nodes0); - if (XsltForms_globals.booleanValue(this.predicate[i].evaluate(newCtx))) { - nodes.push(n); - } - } - } - return nodes; + var nodes = XsltForms_globals.nodeSetValue(this.expr.evaluate(ctx)); + for (var i = 0, len = this.predicate.length; i < len; ++i) { + var nodes0 = nodes; + nodes = []; + for (var j = 0, len1 = nodes0.length; j < len1; ++j) { + var n = nodes0[j]; + var newCtx = ctx.clone(n, j, nodes0); + if (XsltForms_globals.booleanValue(this.predicate[i].evaluate(newCtx))) { + nodes.push(n); + } + } + } + return nodes; }; var XsltForms_FleurConv = []; var XsltForms_FleurConv_unsupported = function() { - return "~~~~Unsupported syntax~#~#"; + return "~~~~Unsupported syntax~#~#"; }; for (var XsltForms_i = 0; XsltForms_i < Fleur.Xlength; XsltForms_i++) { - XsltForms_FleurConv[XsltForms_i] = XsltForms_FleurConv_unsupported; + XsltForms_FleurConv[XsltForms_i] = XsltForms_FleurConv_unsupported; } XsltForms_FleurConv[Fleur.XQueryX.anyKindTest] = function() { - return "new XsltForms_nodeTestAny()"; + return "new XsltForms_nodeTestAny()"; }; XsltForms_FleurConv[Fleur.XQueryX.arrayTest] = function() { - return "new XsltForms_nodeTestType(131)"; + return "new XsltForms_nodeTestType(131)"; }; XsltForms_FleurConv[Fleur.XQueryX.commentTest] = function() { - return "new XsltForms_nodeTestType(8)"; + return "new XsltForms_nodeTestType(8)"; }; XsltForms_FleurConv[Fleur.XQueryX.contextItemExpr] = function() { - return "new XsltForms_locationExpr(false,new XsltForms_stepExpr('self',new XsltForms_nodeTestAny()))"; + return "new XsltForms_locationExpr(false,new XsltForms_stepExpr('self',new XsltForms_nodeTestAny()))"; }; XsltForms_FleurConv[Fleur.XQueryX.decimalConstantExpr] = function(children) { - return "new XsltForms_cteExpr(" + children[0][1][0] + ")"; + return "new XsltForms_cteExpr(" + children[0][1][0] + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.doubleConstantExpr] = function(children) { - return "new XsltForms_cteExpr(" + children[0][1][0] + ")"; + return "new XsltForms_cteExpr(" + children[0][1][0] + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.entryTest] = function() { - return "new XsltForms_nodeTestType(133)"; + return "new XsltForms_nodeTestType(133)"; }; XsltForms_FleurConv[Fleur.XQueryX.filterExpr] = function() { - return "new XsltForms_stepExpr('self',new XsltForms_nodeTestAny())"; + return "new XsltForms_stepExpr('self',new XsltForms_nodeTestAny())"; }; XsltForms_FleurConv[Fleur.XQueryX.functionCallExpr] = function(children) { - var fname = children[0][1][0]; - var uri = "http://www.w3.org/2005/xpath-functions"; - var args = children[1][1]; - if (children[0][1][1] && children[0][1][1][0] === Fleur.XQueryX.prefix) { - var pf = children[0][1][1][1][0]; - if (pf === "xf" || pf === "xform" || pf === "xforms") { - uri = "http://www.w3.org/2002/xforms"; - } else if (pf === "math") { - uri = "http://exslt.org/math"; - } else { - uri = Fleur.XPathNSResolver_default.uri[Fleur.XPathNSResolver_default.pf.indexOf(pf)]; - } - } else if (" boolean-from-string is-card-number count-non-empty index power random if choose property digest hmac local-date local-dateTime now days-from-date days-to-date seconds-from-dateTime seconds-to-dateTime adjust-dateTime-to-timezone seconds months instance current context event nodeindex is-valid serialize transform ".indexOf(" " + fname + " ") !== -1) { - uri = "http://www.w3.org/2002/xforms"; - } - var ret = "new XsltForms_functionCallExpr('" + uri + " " + fname + "'"; - for (var i = 0, l = args.length; i < l; i++) { - ret += "," + XsltForms_FleurConv[args[i][0]](args[i][1]); - } - ret += ")"; - return ret; + var fname = children[0][1][0]; + var uri = "http://www.w3.org/2005/xpath-functions"; + var args = children[1][1]; + if (children[0][1][1] && children[0][1][1][0] === Fleur.XQueryX.prefix) { + var pf = children[0][1][1][1][0]; + if (pf === "xf" || pf === "xform" || pf === "xforms") { + uri = "http://www.w3.org/2002/xforms"; + } else if (pf === "math") { + uri = "http://exslt.org/math"; + } else { + uri = Fleur.XPathNSResolver_default.uri[Fleur.XPathNSResolver_default.pf.indexOf(pf)]; + } + } else if (" boolean-from-string is-card-number count-non-empty index power random if choose property digest hmac local-date local-dateTime now days-from-date days-to-date seconds-from-dateTime seconds-to-dateTime adjust-dateTime-to-timezone seconds months instance current context event nodeindex is-valid serialize transform ".indexOf(" " + fname + " ") !== -1) { + uri = "http://www.w3.org/2002/xforms"; + } + var ret = "new XsltForms_functionCallExpr('" + uri + " " + fname + "'"; + for (var i = 0, l = args.length; i < l; i++) { + ret += "," + XsltForms_FleurConv[args[i][0]](args[i][1]); + } + ret += ")"; + return ret; }; XsltForms_FleurConv[Fleur.XQueryX.integerConstantExpr] = function(children) { - return "new XsltForms_cteExpr(" + children[0][1][0] + ")"; + return "new XsltForms_cteExpr(" + children[0][1][0] + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.mapTest] = function() { - return "new XsltForms_nodeTestType(132)"; + return "new XsltForms_nodeTestType(132)"; }; XsltForms_FleurConv[Fleur.XQueryX.nameTest] = function(children, axis) { - var ret = "new XsltForms_nodeTestName("; - if (children.length !== 1 && children[1][0] === Fleur.XQueryX.prefix) { - ret += "'" + children[1][1][0] + "'"; - } else if (axis === "attribute") { - ret += "null"; - } else { - ret += "''"; - } - ret += ",'"; - ret += children[0]; - ret += "')"; - return ret; + var ret = "new XsltForms_nodeTestName("; + if (children.length !== 1 && children[1][0] === Fleur.XQueryX.prefix) { + ret += "'" + children[1][1][0] + "'"; + } else if (axis === "attribute") { + ret += "null"; + } else { + ret += "''"; + } + ret += ",'"; + ret += children[0]; + ret += "')"; + return ret; }; XsltForms_FleurConv[Fleur.XQueryX.pathExpr] = function(children) { - var ret = ""; - var i = 0; - var pathexpr = false; - if (children[0][0] === Fleur.XQueryX.stepExpr && children[0][1][0][0] === Fleur.XQueryX.filterExpr && children[0][1][0][1][0][0] !== Fleur.XQueryX.contextItemExpr) { - pathexpr = true; - ret = "new XsltForms_pathExpr("; - ret += XsltForms_FleurConv[children[0][1][0][1][0][0]](children[0][1][0][1][0][1]); - ret += ","; - i++; - } - ret += "new XsltForms_locationExpr("; - if (children[0][0] !== Fleur.XQueryX.rootExpr) { - ret += "false"; - if (!pathexpr) { - ret += ","; - } - } - for (var l = children.length; i < l; i++) { - ret += (i !== 0 ? "," : "") + XsltForms_FleurConv[children[i][0]](children[i][1]); - } - ret += ")"; - if (pathexpr) { - ret += ")"; - } - return ret; + var ret = ""; + var i = 0; + var pathexpr = false; + if (children[0][0] === Fleur.XQueryX.stepExpr && children[0][1][0][0] === Fleur.XQueryX.filterExpr && children[0][1][0][1][0][0] !== Fleur.XQueryX.contextItemExpr) { + pathexpr = true; + ret = "new XsltForms_pathExpr("; + ret += XsltForms_FleurConv[children[0][1][0][1][0][0]](children[0][1][0][1][0][1]); + ret += ","; + i++; + } + ret += "new XsltForms_locationExpr("; + if (children[0][0] !== Fleur.XQueryX.rootExpr) { + ret += "false"; + if (!pathexpr) { + ret += ","; + } + } + for (var l = children.length; i < l; i++) { + ret += (i !== 0 ? "," : "") + XsltForms_FleurConv[children[i][0]](children[i][1]); + } + ret += ")"; + if (pathexpr) { + ret += ")"; + } + return ret; }; XsltForms_FleurConv[Fleur.XQueryX.piTest] = function(children) { - return "new XsltForms_nodeTestPi(" + (children.length !== 0 ? "'" + children[0][1][0] + "'" : "") + ")"; + return "new XsltForms_nodeTestPi(" + (children.length !== 0 ? "'" + children[0][1][0] + "'" : "") + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.predicates] = function(children) { - var ret = ""; - for (var i = 0, l = children.length; i < l; i++) { - ret += ",new XsltForms_predicateExpr(" + XsltForms_FleurConv[children[i][0]](children[i][1]) + ")"; - } - return ret; + var ret = ""; + for (var i = 0, l = children.length; i < l; i++) { + ret += ",new XsltForms_predicateExpr(" + XsltForms_FleurConv[children[i][0]](children[i][1]) + ")"; + } + return ret; }; XsltForms_FleurConv[Fleur.XQueryX.rootExpr] = function() { - return "true"; + return "true"; }; XsltForms_FleurConv[Fleur.XQueryX.stepExpr] = function(children) { - if (children.length === 1) { - return XsltForms_FleurConv[children[0][0]](children[0][1]); - } - var lpred; - var ret = "new XsltForms_stepExpr('"; - if (children[0][0] === Fleur.XQueryX.xpathAxis) { - ret += children[0][1][0]; - ret += "',"; - ret += XsltForms_FleurConv[children[1][0]](children[1][1], children[0][1][0]); - lpred = 3; - } else { - ret += "self',new XsltForms_nodeTestAny()"; - lpred = 2; - } - if (children.length === lpred) { - ret += XsltForms_FleurConv[children[lpred - 1][0]](children[lpred - 1][1]); - } - ret += ")"; - return ret; + if (children.length === 1) { + return XsltForms_FleurConv[children[0][0]](children[0][1]); + } + var lpred; + var ret = "new XsltForms_stepExpr('"; + if (children[0][0] === Fleur.XQueryX.xpathAxis) { + ret += children[0][1][0]; + ret += "',"; + ret += XsltForms_FleurConv[children[1][0]](children[1][1], children[0][1][0]); + lpred = 3; + } else { + ret += "self',new XsltForms_nodeTestAny()"; + lpred = 2; + } + if (children.length === lpred) { + ret += XsltForms_FleurConv[children[lpred - 1][0]](children[lpred - 1][1]); + } + ret += ")"; + return ret; }; XsltForms_FleurConv[Fleur.XQueryX.stringConstantExpr] = function(children) { - return "new XsltForms_cteExpr('" + (children[0][1][0] || "").replace(/\'/g, "\\'") + "')"; + return "new XsltForms_cteExpr('" + (children[0][1][0] || "").replace(/\'/g, "\\'") + "')"; }; XsltForms_FleurConv[Fleur.XQueryX.textTest] = function() { - return "new XsltForms_nodeTestType(3)"; + return "new XsltForms_nodeTestType(3)"; }; XsltForms_FleurConv[Fleur.XQueryX.varRef] = function(children) { - var nsURI; - if (children[0][1].length === 1) { - nsURI = ""; - } else { - nsURI = children[0][1][1][1][0] + ":"; - } - return "new XsltForms_varRef(\"" + nsURI + children[0][1][0] + "\")"; + var nsURI; + if (children[0][1].length === 1) { + nsURI = ""; + } else { + nsURI = children[0][1][1][1][0] + ":"; + } + return "new XsltForms_varRef(\"" + nsURI + children[0][1][0] + "\")"; }; XsltForms_FleurConv[Fleur.XQueryX.Wildcard] = function(children, axis) { - if (axis !== 'attribute') { - if (children.length === 0) { - return "new XsltForms_nodeTestType(1)"; - } - if (children[0][0] === Fleur.XQueryX.NCName) { - return "new XsltForms_nodeTestName('" + children[0][1][0] + "','')),new XsltForms_stepExpr('" + axis + "',new XsltForms_nodeTestType(1)"; - } - return "new XsltForms_nodeTestName('*','" + children[1][1][0] + "')"; - } - if (children.length === 0) { - return "new XsltForms_nodeTestAny()"; - } - if (children[0][0] === Fleur.XQueryX.NCName) { - return "new XsltForms_nodeTestName('" + children[0][1][0] + "','*')"; - } - return "new XsltForms_nodeTestName('*','" + children[1][1][0] + "')"; + if (axis !== 'attribute') { + if (children.length === 0) { + return "new XsltForms_nodeTestType(1)"; + } + if (children[0][0] === Fleur.XQueryX.NCName) { + return "new XsltForms_nodeTestName('" + children[0][1][0] + "','')),new XsltForms_stepExpr('" + axis + "',new XsltForms_nodeTestType(1)"; + } + return "new XsltForms_nodeTestName('*','" + children[1][1][0] + "')"; + } + if (children.length === 0) { + return "new XsltForms_nodeTestAny()"; + } + if (children[0][0] === Fleur.XQueryX.NCName) { + return "new XsltForms_nodeTestName('" + children[0][1][0] + "','*')"; + } + return "new XsltForms_nodeTestName('*','" + children[1][1][0] + "')"; }; XsltForms_FleurConv[Fleur.XQueryX.addOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'+'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'+'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.andOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'and'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'and'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.divOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'div'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'div'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.equalOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'='," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'='," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.greaterThanOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'>'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'>'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.greaterThanOrEqualOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'>='," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'>='," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.lessThanOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'<'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'<'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.lessThanOrEqualOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'<='," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'<='," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.modOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'mod'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'mod'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.multiplyOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'*'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'*'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.notEqualOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'!='," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'!='," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.orOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'or'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'or'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.subtractOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'-'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'-'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.unaryMinusOp] = function(children) { - var operand = children[0][1][0][0]; - if (operand === Fleur.XQueryX.integerConstantExpr || operand === Fleur.XQueryX.decimalConstantExpr || operand === Fleur.XQueryX.doubleConstantExpr) { - return "new XsltForms_cteExpr(-" + children[0][1][0][1][0][1] + ")"; - } + var operand = children[0][1][0][0]; + if (operand === Fleur.XQueryX.integerConstantExpr || operand === Fleur.XQueryX.decimalConstantExpr || operand === Fleur.XQueryX.doubleConstantExpr) { + return "new XsltForms_cteExpr(-" + children[0][1][0][1][0][1] + ")"; + } }; XsltForms_FleurConv[Fleur.XQueryX.unionOp] = function(children) { - return "new XsltForms_unionExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + "," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_unionExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + "," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; function XsltForms_locationExpr(absolute) { - this.absolute = absolute; - this.steps = []; - for (var i = 1, len = arguments.length; i < len; i++) { - this.steps.push(arguments[i]); - } + this.absolute = absolute; + this.steps = []; + for (var i = 1, len = arguments.length; i < len; i++) { + this.steps.push(arguments[i]); + } } XsltForms_locationExpr.prototype.evaluate = function(ctx) { - var start = (this.absolute && ctx.root )|| !ctx.node ? ctx.root : ctx.node; - var m = XsltForms_browser.getDocMeta((start.nodeType === Fleur.Node.DOCUMENT_NODE ? start : start.ownerDocument), "model"); - if (m) { - ctx.addDepElement(document.getElementById(m).xfElement); - } - var nodes = []; - if (this.steps[0]) { - this.xPathStep(nodes, this.steps, 0, start, ctx); - } else { - nodes[0] = start; - } - return nodes; + var start = (this.absolute && ctx.root )|| !ctx.node ? ctx.root : ctx.node; + var m = XsltForms_browser.getDocMeta((start.nodeType === Fleur.Node.DOCUMENT_NODE ? start : start.ownerDocument), "model"); + if (m) { + ctx.addDepElement(document.getElementById(m).xfElement); + } + var nodes = []; + if (this.steps[0]) { + this.xPathStep(nodes, this.steps, 0, start, ctx); + } else { + nodes[0] = start; + } + return nodes; }; XsltForms_locationExpr.prototype.xPathStep = function(nodes, steps, step, input, ctx) { - var s = steps[step]; - var nodelist = s.evaluate(ctx.clone(input)); - for (var i = 0, len = nodelist.length; i < len; ++i) { - var node = nodelist[i]; - if (step === steps.length - 1) { - if (!XsltForms_browser.inArray(node, nodes)) { - nodes.push(node); - } - ctx.addDepNode(node); - } else { - this.xPathStep(nodes, steps, step + 1, node, ctx); - } - } + var s = steps[step]; + var nodelist = s.evaluate(ctx.clone(input)); + for (var i = 0, len = nodelist.length; i < len; ++i) { + var node = nodelist[i]; + if (step === steps.length - 1) { + if (!XsltForms_browser.inArray(node, nodes)) { + nodes.push(node); + } + ctx.addDepNode(node); + } else { + this.xPathStep(nodes, steps, step + 1, node, ctx); + } + } }; function XsltForms_nodeTestAny() { } XsltForms_nodeTestAny.prototype.evaluate = function(node) { - var n = node.localName || node.baseName; - return !n || (n.substr(0, 10) !== "xsltforms_" && node.namespaceURI !== "http://www.w3.org/2000/xmlns/"); + var n = node.localName || node.baseName; + return !n || (n.substr(0, 10) !== "xsltforms_" && node.namespaceURI !== "http://www.w3.org/2000/xmlns/"); }; function XsltForms_nodeTestName(prefix, tname) { - this.prefix = prefix; - this.name = tname; - this.uppercase = tname.toUpperCase(); - this.wildcard = tname === "*"; - this.notwildcard = tname !== "*"; - this.notwildcardprefix = prefix !== "*"; - this.hasprefix = prefix && this.notwildcardprefix; + this.prefix = prefix; + this.name = tname; + this.uppercase = tname.toUpperCase(); + this.wildcard = tname === "*"; + this.notwildcard = tname !== "*"; + this.notwildcardprefix = prefix !== "*"; + this.hasprefix = prefix && this.notwildcardprefix; } XsltForms_nodeTestName.prototype.evaluate = function(node, nsresolver, csensitive) { - var nodename = node.localName || node.baseName; - if (this.notwildcard && (nodename !== this.name || (csensitive && nodename.toUpperCase() !== this.uppercase))) { - return false; - } - if (this.wildcard) { - return this.hasprefix ? node.namespaceURI === nsresolver.lookupNamespaceURI(this.prefix) : true; - } - var ns = node.namespaceURI; - return this.hasprefix ? ns === nsresolver.lookupNamespaceURI(this.prefix) : - (this.notwildcardprefix ? !ns || ns === "" || ns === nsresolver.lookupNamespaceURI("") : true); + var nodename = node.localName || node.baseName; + if (this.notwildcard && (nodename !== this.name || (csensitive && nodename.toUpperCase() !== this.uppercase))) { + return false; + } + if (this.wildcard) { + return this.hasprefix ? node.namespaceURI === nsresolver.lookupNamespaceURI(this.prefix) : true; + } + var ns = node.namespaceURI; + return this.hasprefix ? ns === nsresolver.lookupNamespaceURI(this.prefix) : + (this.notwildcardprefix ? !ns || ns === "" || ns === nsresolver.lookupNamespaceURI("") : true); }; function XsltForms_nodeTestPI(target) { - this.target = target; + this.target = target; } XsltForms_nodeTestPI.prototype.evaluate = function(node) { - return node.nodeType === Fleur.Node.PROCESSING_INSTRUCTION_NODE && - (!this.target || node.nodeName === this.target); + return node.nodeType === Fleur.Node.PROCESSING_INSTRUCTION_NODE && + (!this.target || node.nodeName === this.target); }; function XsltForms_nodeTestType(type) { - this.type = type; + this.type = type; } XsltForms_nodeTestType.prototype.evaluate = function(node) { - return node.nodeType === this.type; + return node.nodeType === this.type; }; function XsltForms_pathExpr(filter, rel) { - this.filter = filter; - this.rel = rel; + this.filter = filter; + this.rel = rel; } XsltForms_pathExpr.prototype.evaluate = function(ctx) { - var nodes = XsltForms_globals.nodeSetValue(this.filter.evaluate(ctx)); - var nodes1 = []; - for (var i = 0, len = nodes.length; i < len; i++) { - var newCtx = ctx.clone(nodes[i], i, nodes); - var nodes0 = XsltForms_globals.nodeSetValue(this.rel.evaluate(newCtx)); - for (var j = 0, len1 = nodes0.length; j < len1; j++) { - nodes1.push(nodes0[j]); - } - } - return nodes1; + var nodes = XsltForms_globals.nodeSetValue(this.filter.evaluate(ctx)); + var nodes1 = []; + for (var i = 0, len = nodes.length; i < len; i++) { + var newCtx = ctx.clone(nodes[i], i, nodes); + var nodes0 = XsltForms_globals.nodeSetValue(this.rel.evaluate(newCtx)); + for (var j = 0, len1 = nodes0.length; j < len1; j++) { + nodes1.push(nodes0[j]); + } + } + return nodes1; }; function XsltForms_predicateExpr(expr) { - this.expr = expr; + this.expr = expr; } XsltForms_predicateExpr.prototype.evaluate = function(ctx) { - var v = this.expr.evaluate(ctx); - return typeof v === "number" ? ctx.position === v : XsltForms_globals.booleanValue(v); + var v = this.expr.evaluate(ctx); + return typeof v === "number" ? ctx.position === v : XsltForms_globals.booleanValue(v); }; function XsltForms_stepExpr(axis, nodetest) { - this.axis = axis; - this.nodetest = nodetest; - this.predicates = []; - for (var i = 2, len = arguments.length; i < len; i++) { - this.predicates.push(arguments[i]); - } + this.axis = axis; + this.nodetest = nodetest; + this.predicates = []; + for (var i = 2, len = arguments.length; i < len; i++) { + this.predicates.push(arguments[i]); + } } XsltForms_stepExpr.prototype.evaluate = function(ctx) { - var input = ctx.node; - var list = []; - switch(this.axis) { - case XsltForms_xpathAxis.ANCESTOR_OR_SELF : - XsltForms_stepExpr.push(ctx, list, input, this.nodetest); - if (input.nodeType === Fleur.Node.ATTRIBUTE_NODE) { - input = input.ownerElement ? input.ownerElement : input.selectSingleNode(".."); - XsltForms_stepExpr.push(ctx, list, input, this.nodetest); - } else if (input.nodeType === Fleur.Node.ENTRY_NODE) { - input = input.ownerMap; - XsltForms_stepExpr.push(ctx, list, input, this.nodetest); - } - for (var pn = input.parentNode; pn.parentNode; pn = pn.parentNode) { - XsltForms_stepExpr.push(ctx, list, pn, this.nodetest); - } - break; - case XsltForms_xpathAxis.ANCESTOR : - if (input.nodeType === Fleur.Node.ATTRIBUTE_NODE) { - input = input.ownerElement ? input.ownerElement : input.selectSingleNode(".."); - XsltForms_stepExpr.push(ctx, list, input, this.nodetest); - } else if (input.nodeType === Fleur.Node.ENTRY_NODE) { - input = input.ownerMap; - XsltForms_stepExpr.push(ctx, list, input, this.nodetest); - } - for (var pn2 = input.parentNode; pn2.parentNode; pn2 = pn2.parentNode) { - XsltForms_stepExpr.push(ctx, list, pn2, this.nodetest); - } - break; - case XsltForms_xpathAxis.ATTRIBUTE : - XsltForms_stepExpr.pushList(ctx, list, input.attributes, this.nodetest, !input.namespaceURI || input.namespaceURI === "http://www.w3.org/1999/xhtml"); - break; - case XsltForms_xpathAxis.CHILD : - XsltForms_stepExpr.pushList(ctx, list, input.childNodes, this.nodetest); - break; - case XsltForms_xpathAxis.DESCENDANT_OR_SELF : - XsltForms_stepExpr.push(ctx, list, input, this.nodetest); - XsltForms_stepExpr.pushDescendants(ctx, list, input, this.nodetest); - break; - case XsltForms_xpathAxis.DESCENDANT : - XsltForms_stepExpr.pushDescendants(ctx, list, input, this.nodetest); - break; - case XsltForms_xpathAxis.ENTRY : - XsltForms_stepExpr.pushList(ctx, list, input.entries, this.nodetest); - break; - case XsltForms_xpathAxis.FOLLOWING : - var n = input.nodeType === Fleur.Node.ATTRIBUTE_NODE ? (input.ownerElement ? input.ownerElement : input.selectSingleNode("..")) : (input.nodeType === Fleur.Node.ENTRY_NODE ? input.ownerMap : input); - while (n.nodeType !== Fleur.Node.DOCUMENT_NODE) { - for (var nn = n.nextSibling; nn; nn = nn.nextSibling) { - XsltForms_stepExpr.push(ctx, list, nn, this.nodetest); - XsltForms_stepExpr.pushDescendants(ctx, list, nn, this.nodetest); - } - n = n.parentNode; - } - break; - case XsltForms_xpathAxis.FOLLOWING_SIBLING : - for (var ns = input.nextSibling; ns; ns = ns.nextSibling) { - XsltForms_stepExpr.push(ctx, list, ns, this.nodetest); - } - break; - case XsltForms_xpathAxis.NAMESPACE : - alert('not implemented: axis namespace'); - break; - case XsltForms_xpathAxis.PARENT : - if (input.parentNode) { - XsltForms_stepExpr.push(ctx, list, input.parentNode, this.nodetest); - } else { - if (input.nodeType === Fleur.Node.ATTRIBUTE_NODE) { - XsltForms_stepExpr.push(ctx, list, input.ownerElement ? input.ownerElement : input.selectSingleNode(".."), this.nodetest); - } else if (input.nodeType === Fleur.Node.ENTRY_NODE) { - XsltForms_stepExpr.push(ctx, list, input.ownerMap, this.nodetest); - } - } - break; - case XsltForms_xpathAxis.PRECEDING : - var p = input.nodeType === Fleur.Node.ATTRIBUTE_NODE ? (input.ownerElement ? input.ownerElement : input.selectSingleNode("..")) : (input.nodeType === Fleur.Node.ENTRY_NODE ? input.ownerMap : input); - while (p.nodeType !== Fleur.Node.DOCUMENT_NODE) { - for (var ps = p.previousSibling; ps; ps = ps.previousSibling) { - XsltForms_stepExpr.pushDescendantsRev(ctx, list, ps, this.nodetest); - XsltForms_stepExpr.push(ctx, list, ps, this.nodetest); - } - p = p.parentNode; - } - break; - case XsltForms_xpathAxis.PRECEDING_SIBLING : - for (var ps2 = input.previousSibling; ps2; ps2 = ps2.previousSibling) { - XsltForms_stepExpr.push(ctx, list, ps2, this.nodetest); - } - break; - case XsltForms_xpathAxis.SELF : - XsltForms_stepExpr.push(ctx, list, input, this.nodetest); - break; - default : - throw new Error({name:'ERROR -- NO SUCH AXIS: ' + this.axis}); - } - for (var i = 0, len = this.predicates.length; i < len; i++) { - var pred = this.predicates[i]; - var newList = []; - for (var j = 0, len1 = list.length; j < len1; j++) { - var x = list[j]; - var newCtx = ctx.clone(x, j + 1, list); - if (XsltForms_globals.booleanValue(pred.evaluate(newCtx))) { - newList.push(x); - } - } - list = newList; - } - return list; + var input = ctx.node; + var list = []; + switch(this.axis) { + case XsltForms_xpathAxis.ANCESTOR_OR_SELF : + XsltForms_stepExpr.push(ctx, list, input, this.nodetest); + if (input.nodeType === Fleur.Node.ATTRIBUTE_NODE) { + input = input.ownerElement ? input.ownerElement : input.selectSingleNode(".."); + XsltForms_stepExpr.push(ctx, list, input, this.nodetest); + } else if (input.nodeType === Fleur.Node.ENTRY_NODE) { + input = input.ownerMap; + XsltForms_stepExpr.push(ctx, list, input, this.nodetest); + } + for (var pn = input.parentNode; pn.parentNode; pn = pn.parentNode) { + XsltForms_stepExpr.push(ctx, list, pn, this.nodetest); + } + break; + case XsltForms_xpathAxis.ANCESTOR : + if (input.nodeType === Fleur.Node.ATTRIBUTE_NODE) { + input = input.ownerElement ? input.ownerElement : input.selectSingleNode(".."); + XsltForms_stepExpr.push(ctx, list, input, this.nodetest); + } else if (input.nodeType === Fleur.Node.ENTRY_NODE) { + input = input.ownerMap; + XsltForms_stepExpr.push(ctx, list, input, this.nodetest); + } + for (var pn2 = input.parentNode; pn2.parentNode; pn2 = pn2.parentNode) { + XsltForms_stepExpr.push(ctx, list, pn2, this.nodetest); + } + break; + case XsltForms_xpathAxis.ATTRIBUTE : + XsltForms_stepExpr.pushList(ctx, list, input.attributes, this.nodetest, !input.namespaceURI || input.namespaceURI === "http://www.w3.org/1999/xhtml"); + break; + case XsltForms_xpathAxis.CHILD : + XsltForms_stepExpr.pushList(ctx, list, input.childNodes, this.nodetest); + break; + case XsltForms_xpathAxis.DESCENDANT_OR_SELF : + XsltForms_stepExpr.push(ctx, list, input, this.nodetest); + XsltForms_stepExpr.pushDescendants(ctx, list, input, this.nodetest); + break; + case XsltForms_xpathAxis.DESCENDANT : + XsltForms_stepExpr.pushDescendants(ctx, list, input, this.nodetest); + break; + case XsltForms_xpathAxis.ENTRY : + XsltForms_stepExpr.pushList(ctx, list, input.entries, this.nodetest); + break; + case XsltForms_xpathAxis.FOLLOWING : + var n = input.nodeType === Fleur.Node.ATTRIBUTE_NODE ? (input.ownerElement ? input.ownerElement : input.selectSingleNode("..")) : (input.nodeType === Fleur.Node.ENTRY_NODE ? input.ownerMap : input); + while (n.nodeType !== Fleur.Node.DOCUMENT_NODE) { + for (var nn = n.nextSibling; nn; nn = nn.nextSibling) { + XsltForms_stepExpr.push(ctx, list, nn, this.nodetest); + XsltForms_stepExpr.pushDescendants(ctx, list, nn, this.nodetest); + } + n = n.parentNode; + } + break; + case XsltForms_xpathAxis.FOLLOWING_SIBLING : + for (var ns = input.nextSibling; ns; ns = ns.nextSibling) { + XsltForms_stepExpr.push(ctx, list, ns, this.nodetest); + } + break; + case XsltForms_xpathAxis.NAMESPACE : + alert('not implemented: axis namespace'); + break; + case XsltForms_xpathAxis.PARENT : + if (input.parentNode) { + XsltForms_stepExpr.push(ctx, list, input.parentNode, this.nodetest); + } else { + if (input.nodeType === Fleur.Node.ATTRIBUTE_NODE) { + XsltForms_stepExpr.push(ctx, list, input.ownerElement ? input.ownerElement : input.selectSingleNode(".."), this.nodetest); + } else if (input.nodeType === Fleur.Node.ENTRY_NODE) { + XsltForms_stepExpr.push(ctx, list, input.ownerMap, this.nodetest); + } + } + break; + case XsltForms_xpathAxis.PRECEDING : + var p = input.nodeType === Fleur.Node.ATTRIBUTE_NODE ? (input.ownerElement ? input.ownerElement : input.selectSingleNode("..")) : (input.nodeType === Fleur.Node.ENTRY_NODE ? input.ownerMap : input); + while (p.nodeType !== Fleur.Node.DOCUMENT_NODE) { + for (var ps = p.previousSibling; ps; ps = ps.previousSibling) { + XsltForms_stepExpr.pushDescendantsRev(ctx, list, ps, this.nodetest); + XsltForms_stepExpr.push(ctx, list, ps, this.nodetest); + } + p = p.parentNode; + } + break; + case XsltForms_xpathAxis.PRECEDING_SIBLING : + for (var ps2 = input.previousSibling; ps2; ps2 = ps2.previousSibling) { + XsltForms_stepExpr.push(ctx, list, ps2, this.nodetest); + } + break; + case XsltForms_xpathAxis.SELF : + XsltForms_stepExpr.push(ctx, list, input, this.nodetest); + break; + default : + throw new Error({name:'ERROR -- NO SUCH AXIS: ' + this.axis}); + } + for (var i = 0, len = this.predicates.length; i < len; i++) { + var pred = this.predicates[i]; + var newList = []; + for (var j = 0, len1 = list.length; j < len1; j++) { + var x = list[j]; + var newCtx = ctx.clone(x, j + 1, list); + if (XsltForms_globals.booleanValue(pred.evaluate(newCtx))) { + newList.push(x); + } + } + list = newList; + } + return list; }; XsltForms_stepExpr.push = function(ctx, list, node, test, csensitive) { - if (test.evaluate(node, ctx.nsresolver, csensitive) && !XsltForms_browser.inArray(node, list)) { - list[list.length] = node; - } + if (test.evaluate(node, ctx.nsresolver, csensitive) && !XsltForms_browser.inArray(node, list)) { + list[list.length] = node; + } }; XsltForms_stepExpr.pushList = function(ctx, list, l, test, csensitive) { - for (var i = 0, len = l ? l.length : 0; i < len; i++) { - XsltForms_stepExpr.push(ctx, list, l[i], test, csensitive); - } + for (var i = 0, len = l ? l.length : 0; i < len; i++) { + XsltForms_stepExpr.push(ctx, list, l[i], test, csensitive); + } }; XsltForms_stepExpr.pushDescendants = function(ctx, list, node, test) { - for (var n = node.firstChild; n; n = n.nextSibling) { - XsltForms_stepExpr.push(ctx, list, n, test); - XsltForms_stepExpr.pushDescendants(ctx, list, n, test); - } + for (var n = node.firstChild; n; n = n.nextSibling) { + XsltForms_stepExpr.push(ctx, list, n, test); + XsltForms_stepExpr.pushDescendants(ctx, list, n, test); + } }; XsltForms_stepExpr.pushDescendantsRev = function(ctx, list, node, test) { - for (var n = node.lastChild; n; n = n.previousSibling) { - XsltForms_stepExpr.push(ctx, list, n, test); - XsltForms_stepExpr.pushDescendantsRev(ctx, list, n, test); - } + for (var n = node.lastChild; n; n = n.previousSibling) { + XsltForms_stepExpr.push(ctx, list, n, test); + XsltForms_stepExpr.pushDescendantsRev(ctx, list, n, test); + } }; function XsltForms_unionExpr(expr1, expr2) { - this.expr1 = expr1; - this.expr2 = expr2; + this.expr1 = expr1; + this.expr2 = expr2; } XsltForms_unionExpr.prototype.evaluate = function(ctx) { - var nodes1 = XsltForms_globals.nodeSetValue(this.expr1.evaluate(ctx)); - var nodes2 = XsltForms_globals.nodeSetValue(this.expr2.evaluate(ctx)); - var len1 = nodes1.length; - for (var i2 = 0, len = nodes2.length; i2 < len; i2++) { - var found = false; - for (var i1 = 0; i1 < len1; i1++) { - found = nodes1[i1] === nodes2[i2]; - if (found) { - break; - } - } - if (!found) { - nodes1.push(nodes2[i2]); - } - } - var posres = []; - for (var i3 = 0, len3 = nodes1.length; i3 < len3; i3++) { - posres.push({count: XsltForms_browser.selectNodesLength("preceding::* | ancestor::*", nodes1[i3]), node: nodes1[i3]}); - } - posres.sort(function(a,b){return a.count - b.count;}); - for (var i4 = 0, len4 = posres.length; i4 < len4; i4++) { - nodes1[i4] = posres[i4].node; - } - return nodes1; + var nodes1 = XsltForms_globals.nodeSetValue(this.expr1.evaluate(ctx)); + var nodes2 = XsltForms_globals.nodeSetValue(this.expr2.evaluate(ctx)); + var len1 = nodes1.length; + for (var i2 = 0, len = nodes2.length; i2 < len; i2++) { + var found = false; + for (var i1 = 0; i1 < len1; i1++) { + found = nodes1[i1] === nodes2[i2]; + if (found) { + break; + } + } + if (!found) { + nodes1.push(nodes2[i2]); + } + } + var posres = []; + for (var i3 = 0, len3 = nodes1.length; i3 < len3; i3++) { + posres.push({count: XsltForms_browser.selectNodesLength("preceding::* | ancestor::*", nodes1[i3]), node: nodes1[i3]}); + } + posres.sort(function(a,b){return a.count - b.count;}); + for (var i4 = 0, len4 = posres.length; i4 < len4; i4++) { + nodes1[i4] = posres[i4].node; + } + return nodes1; }; function XsltForms_varRef(vname) { - this.name = vname; + this.name = vname; } XsltForms_varRef.prototype.evaluate = function(ctx) { - if (!ctx.varresolver || !ctx.varresolver[this.name]) { - return ""; - } - if (ctx.varresolver[this.name] instanceof XsltForms_var) { - var varxf = ctx.varresolver[this.name]; - for (var i = 0, l = varxf.depsNodesRefresh.length; i < l ; i++) { - ctx.addDepNode(varxf.depsNodesRefresh[i]); - } - for (i = 0, l = varxf.depsNodesBuild.length; i < l ; i++) { - ctx.addDepNode(varxf.depsNodesBuild[i]); - } - for (var j = 0, l2 = varxf.depsElements.length; j < l2 ; j++) { - ctx.addDepElement(varxf.depsElements[j]); - } - return varxf.boundnodes; - } - return ctx.varresolver[this.name][0]; + let varxf = XsltForms_varResolver(ctx.element, this.name); + for (var i = 0, l = varxf.depsNodesRefresh.length; i < l ; i++) { + ctx.addDepNode(varxf.depsNodesRefresh[i]); + } + for (i = 0, l = varxf.depsNodesBuild.length; i < l ; i++) { + ctx.addDepNode(varxf.depsNodesBuild[i]); + } + for (var j = 0, l2 = varxf.depsElements.length; j < l2 ; j++) { + ctx.addDepElement(varxf.depsElements[j]); + } + return varxf.boundnodes; }; +function XsltForms_varResolver(elt, name) { + let p = elt; + while (p) { + if (p.previousSibling) { + p = p.previousSibling; + if (p.localName === "xforms-var" && p.xfElement.name === name) { + return p.xfElement; + } + } else { + p = p.parentNode; + } + } + XsltForms_globals.error(null, "xforms-compute-exception", "Variable $" + name + " not found"); +} XsltForms_globals.stringValue = function(value) { - if (Fleur.minimal) { - return typeof value !== "object"? "" + value : (!value || value.length === 0 ? "" : XsltForms_globals.xmlValue(value.head())); - } - return XsltForms_globals.xmlValue(value.head ? value.head() : value); + if (Fleur.minimal) { + return typeof value !== "object"? "" + value : (!value || value.length === 0 ? "" : XsltForms_globals.xmlValue(value.head())); + } + return XsltForms_globals.xmlValue(value.head ? value.head() : value); }; XsltForms_globals.booleanValue = function(value) { - if (Fleur.minimal) { - return typeof value === "undefined" || !value ? false : (typeof value.length !== "undefined"? value.length > 0 : !!value); - } - return value.data === "true"; + if (Fleur.minimal) { + return typeof value === "undefined" || !value ? false : (typeof value.length !== "undefined"? value.length > 0 : !!value); + } + return value.data === "true"; }; XsltForms_globals.numberValue = function(value) { - if (Fleur.minimal) { - if (typeof value === "boolean") { - return 'A' - 0; - } else { - var v = typeof value === "object"? XsltForms_globals.stringValue(value) : value; - return v === '' ? NaN : v - 0; - } - } - return Number(XsltForms_globals.stringValue(value)); + if (Fleur.minimal) { + if (typeof value === "boolean") { + return 'A' - 0; + } else { + var v = typeof value === "object"? XsltForms_globals.stringValue(value) : value; + return v === '' ? NaN : v - 0; + } + } + return Number(XsltForms_globals.stringValue(value)); }; XsltForms_globals.nodeSetValue = function(value) { - return value; + return value; }; if (XsltForms_browser.isIE) { - XsltForms_globals.xmlValue = function(node) { - if (typeof node !== "object") { - return node; - } - var ret = node.text; - var schtyp = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string"); - if (schtyp["eval"]) { - try { - ret = ret === "" ? 0 : eval(ret); - } catch (e) {} - } - return ret; - }; + XsltForms_globals.xmlValue = function(node) { + if (typeof node !== "object") { + return node; + } + var ret = node.text; + var schtyp = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string"); + if (schtyp["eval"]) { + try { + ret = ret === "" ? 0 : eval(ret); + } catch (e) {} + } + return ret; + }; } else { - XsltForms_globals.xmlValue = function(node) { - if (typeof node !== "object") { - return node; - } - var ret = typeof node.text !== "undefined" ? node.text : typeof node.textContent !== "undefined" ? node.textContent : typeof node.documentElement.text !== "undefined" ? node.documentElement.text : node.documentElement.textContent; - var schtyp = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string"); - if (schtyp["eval"]) { - try { - ret = ret === "" ? 0 : eval(ret); - } catch (e) {} - } - return ret; - }; + XsltForms_globals.xmlValue = function(node) { + if (typeof node !== "object") { + return node; + } + var ret = typeof node.text !== "undefined" ? node.text : typeof node.textContent !== "undefined" ? node.textContent : typeof node.documentElement.text !== "undefined" ? node.documentElement.text : node.documentElement.textContent; + var schtyp = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string"); + if (schtyp["eval"]) { + try { + ret = ret === "" ? 0 : eval(ret); + } catch (e) {} + } + return ret; + }; } XsltForms_globals.xmlResolveEntities = function(s) { - var parts = XsltForms_globals.stringSplit(s, '&'); - var ret = parts[0]; - for (var i = 1, len = parts.length; i < len; ++i) { - var p = parts[i]; - var index = p.indexOf(";"); - if (index === -1) { - ret += parts[i]; - continue; - } - var rp = p.substring(0, index); - var ch; - switch (rp) { - case 'lt': ch = '<'; break; - case 'gt': ch = '>'; break; - case 'amp': ch = '&'; break; - case 'quot': ch = '"'; break; - case 'apos': ch = '\''; break; - case 'nbsp': ch = String.fromCharCode(160); break; - default: - var span = XsltForms_browser.isXhtml ? document.createElementNS("http://www.w3.org/1999/xhtml", 'span') : document.createElement('span'); - span.innerHTML = '&' + rp + '; '; - ch = span.childNodes[0].nodeValue.charAt(0); - } - ret += ch + p.substring(index + 1); - } - return ret; + var parts = XsltForms_globals.stringSplit(s, '&'); + var ret = parts[0]; + for (var i = 1, len = parts.length; i < len; ++i) { + var p = parts[i]; + var index = p.indexOf(";"); + if (index === -1) { + ret += parts[i]; + continue; + } + var rp = p.substring(0, index); + var ch; + switch (rp) { + case 'lt': ch = '<'; break; + case 'gt': ch = '>'; break; + case 'amp': ch = '&'; break; + case 'quot': ch = '"'; break; + case 'apos': ch = '\''; break; + case 'nbsp': ch = String.fromCharCode(160); break; + default: + var span = XsltForms_browser.isXhtml ? document.createElementNS("http://www.w3.org/1999/xhtml", 'span') : document.createElement('span'); + span.innerHTML = '&' + rp + '; '; + ch = span.childNodes[0].nodeValue.charAt(0); + } + ret += ch + p.substring(index + 1); + } + return ret; }; XsltForms_globals.stringSplit = function(s, c) { - var a = s.indexOf(c); - if (a === -1) { - return [s]; - } - var cl = c.length; - var parts = []; - parts.push(s.substr(0,a)); - while (a !== -1) { - var a1 = s.indexOf(c, a + cl); - if (a1 !== -1) { - parts.push(s.substr(a + cl, a1 - a - cl)); - } else { - parts.push(s.substr(a + cl)); - } - a = a1; - } - return parts; + var a = s.indexOf(c); + if (a === -1) { + return [s]; + } + var cl = c.length; + var parts = []; + parts.push(s.substr(0,a)); + while (a !== -1) { + var a1 = s.indexOf(c, a + cl); + if (a1 !== -1) { + parts.push(s.substr(a + cl, a1 - a - cl)); + } else { + parts.push(s.substr(a + cl)); + } + a = a1; + } + return parts; }; function XsltForms_xpath(subform, expression) { this.subform = subform; @@ -7618,8 +7616,7 @@ function XsltForms_xpath(subform, expression) { try { if (Fleur.minimal) { compiled = Fleur.XPathEvaluator._xp2js(expression, "", ""); - var arr; - eval("arr = " + compiled + ";"); + var arr = eval(compiled); compiled = Fleur.minimal ? XsltForms_FleurConv[arr[0]](arr[1]) : (new Fleur.Transpiler("ctx", " ")).funcdef(arr); compiled = eval(compiled); } else { @@ -7639,11 +7636,11 @@ function XsltForms_xpath(subform, expression) { XsltForms_xpath.prototype.evaluate = function() { alert("XPath error"); }; -XsltForms_xpath.prototype.xpath_evaluate = function(ctx, current, subform, varresolver) { +XsltForms_xpath.prototype.xpath_evaluate = function(ctx, current, subform, element) { var d1 = new Date(); XsltForms_browser.assert(ctx); if (!ctx.node) { - ctx = new XsltForms_exprContext(subform, ctx, null, null, null, this.nsresolver, current, varresolver); + ctx = new XsltForms_exprContext(subform, ctx, null, null, null, this.nsresolver, current, element); } else if (!ctx.nsresolver) { ctx.nsresolver = this.nsresolver; } @@ -7692,37 +7689,37 @@ XsltForms_xpath.registerNS = function(prefix, uri) { } }; function XsltForms_xpathFunction(acceptContext, defaultTo, returnNodes, body) { - this.evaluate = body; - this.defaultTo = defaultTo; - this.acceptContext = acceptContext; - this.returnNodes = returnNodes; + this.evaluate = body; + this.defaultTo = defaultTo; + this.acceptContext = acceptContext; + this.returnNodes = returnNodes; } XsltForms_xpathFunction.DEFAULT_NONE = null; XsltForms_xpathFunction.DEFAULT_NODE = 0; XsltForms_xpathFunction.DEFAULT_NODESET = 1; XsltForms_xpathFunction.DEFAULT_STRING = 2; XsltForms_xpathFunction.prototype.call = function(context, arguments_) { - if (arguments_.length === 0) { - switch (this.defaultTo) { - case XsltForms_xpathFunction.DEFAULT_NODE: - if (context.node) { - arguments_ = [context.node]; - } - break; - case XsltForms_xpathFunction.DEFAULT_NODESET: - if (context.node) { - arguments_ = [[context.node]]; - } - break; - case XsltForms_xpathFunction.DEFAULT_STRING: - arguments_ = [XsltForms_xpathCoreFunctions.string.evaluate([context.node])]; - break; - } - } - if (this.acceptContext) { - arguments_.unshift(context); - } - return this.evaluate.apply(null, arguments_); + if (arguments_.length === 0) { + switch (this.defaultTo) { + case XsltForms_xpathFunction.DEFAULT_NODE: + if (context.node) { + arguments_ = [context.node]; + } + break; + case XsltForms_xpathFunction.DEFAULT_NODESET: + if (context.node) { + arguments_ = [[context.node]]; + } + break; + case XsltForms_xpathFunction.DEFAULT_STRING: + arguments_ = [XsltForms_xpathCoreFunctions.string.evaluate([context.node])]; + break; + } + } + if (this.acceptContext) { + arguments_.unshift(context); + } + return this.evaluate.apply(null, arguments_); }; var XsltForms_mathConstants = { "PI": "3.14159265358979323846264338327950288419716939937510582", @@ -9777,1566 +9774,1627 @@ XsltForms_globals.validate_ = function(node) { return true; }; Fleur.XPathNSResolver_default = { - pf: [ - "xml", - "xmlns", - "xs", - "xsd", - "xsd_", - "xsi", - "xf", - "xforms", - "xsltforms", - " function", - "fn", - "local", - "math", - "map", - "array", - "err", - "b", - "bin", - "file", - "http", - "request", - "prof", - "proc", - "js", - "fleur", - "dgram", - "base64", - "internal", - "unit", - "ietf", - "excel", - "zip", - "matrix", - "xpath", - "xquery" - ], - uri: [ - "http://www.w3.org/XML/1998/namespace", - "http://www.w3.org/2000/xmlns/", - "http://www.w3.org/2001/XMLSchema", - "http://www.w3.org/2001/XMLSchema", - "http://www.w3.org/2001/XMLSchema", - "http://www.w3.org/2001/XMLSchema-instance", - "http://www.w3.org/2002/xforms", - "http://www.w3.org/2002/xforms", - "http://www.agencexml.com/xsltforms", - "http://www.w3.org/2005/xpath-functions", - "http://www.w3.org/2005/xpath-functions", - "http://www.w3.org/2005/xpath", - "http://www.w3.org/2005/xpath-functions/math", - "http://www.w3.org/2005/xpath-functions/map", - "http://www.w3.org/2005/xpath-functions/array", - "http://www.w3.org/2005/xqt-errors", - "http://xqib.org", - "http://expath.org/ns/binary", - "http://expath.org/ns/file", - "http://expath.org/ns/http-client", - "http://exquery.org/ns/request", - "http://basex.org/modules/prof", - "http://basex.org/modules/proc", - "http://www.w3.org/standards/webdesign/script", - "http://www.agencexml.com/fleur", - "http://www.agencexml.com/fleur/dgram", - "http://www.agencexml.com/fleur/base64", - "http://www.agencexml.com/fleur/internal", - "http://www.agencexml.com/fleur/unit", - "https://tools.ietf.org/rfc/index", - "http://schemas.openxmlformats.org/spreadsheetml/2006/main", - "http://expath.org/ns/zip", - "http://www.mathunion.org/matrix", - "http://www.w3.org/2005/xpath", - "http://www.w3.org/2005/xquery" - ] + pf: [ + "xml", + "xmlns", + "xs", + "xsd", + "xsd_", + "xsi", + "xf", + "xforms", + "xsltforms", + " function", + "fn", + "local", + "math", + "map", + "array", + "err", + "b", + "bin", + "file", + "http", + "request", + "prof", + "proc", + "js", + "fleur", + "dgram", + "base64", + "internal", + "unit", + "ietf", + "excel", + "zip", + "matrix", + "xpath", + "xquery" + ], + uri: [ + "http://www.w3.org/XML/1998/namespace", + "http://www.w3.org/2000/xmlns/", + "http://www.w3.org/2001/XMLSchema", + "http://www.w3.org/2001/XMLSchema", + "http://www.w3.org/2001/XMLSchema", + "http://www.w3.org/2001/XMLSchema-instance", + "http://www.w3.org/2002/xforms", + "http://www.w3.org/2002/xforms", + "http://www.agencexml.com/xsltforms", + "http://www.w3.org/2005/xpath-functions", + "http://www.w3.org/2005/xpath-functions", + "http://www.w3.org/2005/xpath", + "http://www.w3.org/2005/xpath-functions/math", + "http://www.w3.org/2005/xpath-functions/map", + "http://www.w3.org/2005/xpath-functions/array", + "http://www.w3.org/2005/xqt-errors", + "http://xqib.org", + "http://expath.org/ns/binary", + "http://expath.org/ns/file", + "http://expath.org/ns/http-client", + "http://exquery.org/ns/request", + "http://basex.org/modules/prof", + "http://basex.org/modules/proc", + "http://www.w3.org/standards/webdesign/script", + "http://www.agencexml.com/fleur", + "http://www.agencexml.com/fleur/dgram", + "http://www.agencexml.com/fleur/base64", + "http://www.agencexml.com/fleur/internal", + "http://www.agencexml.com/fleur/unit", + "https://tools.ietf.org/rfc/index", + "http://schemas.openxmlformats.org/spreadsheetml/2006/main", + "http://expath.org/ns/zip", + "http://www.mathunion.org/matrix", + "http://www.w3.org/2005/xpath", + "http://www.w3.org/2005/xquery" + ] }; if (Fleur.minimal) { - Fleur.XPathNSResolver = function(node) { - this.pf = Fleur.XPathNSResolver_default.pf.slice(); - this.uri = Fleur.XPathNSResolver_default.uri.slice(); - this.node = node; -}; -Fleur.XPathNSResolver.prototype.lookupNamespaceURI = function(prefix) { - var uri; - var index = this.pf.lastIndexOf(prefix); - if (index !== -1) { - return this.uri[index]; - } - if (this.node) { - uri = this.node.lookupNamespaceURI(prefix); - if (uri) { - this.pf.push(prefix); - this.uri.push(uri); - } - } - return uri; -}; -Fleur.XPathNSResolver.prototype.lookupPrefix = function(namespaceURI) { - var pf; - var index = this.uri.lastIndexOf(namespaceURI); - if (index !== -1) { - return this.pf[index]; - } - if (this.node) { - pf = this.node.lookupPrefix(namespaceURI); - if (pf) { - this.pf.push(pf); - this.uri.push(namespaceURI); - } - } - return pf; -}; -Fleur.XPathNSResolver.prototype.declareNamespace = function(prefix, uri) { - this.pf.push(prefix); - this.uri.push(uri); -}; + Fleur.XPathNSResolver = function(node) { + this.pf = Fleur.XPathNSResolver_default.pf.slice(); + this.uri = Fleur.XPathNSResolver_default.uri.slice(); + this.node = node; + }; + Fleur.XPathNSResolver.prototype.lookupNamespaceURI = function(prefix) { + var uri; + var index = this.pf.lastIndexOf(prefix); + if (index !== -1) { + return this.uri[index]; + } + if (this.node) { + uri = this.node.lookupNamespaceURI(prefix); + if (uri) { + this.pf.push(prefix); + this.uri.push(uri); + } + } + return uri; + }; + Fleur.XPathNSResolver.prototype.lookupPrefix = function(namespaceURI) { + var pf; + var index = this.uri.lastIndexOf(namespaceURI); + if (index !== -1) { + return this.pf[index]; + } + if (this.node) { + pf = this.node.lookupPrefix(namespaceURI); + if (pf) { + this.pf.push(pf); + this.uri.push(namespaceURI); + } + } + return pf; + }; + Fleur.XPathNSResolver.prototype.declareNamespace = function(prefix, uri) { + this.pf.push(prefix); + this.uri.push(uri); + }; } function XsltForms_functionCallExpr(fname) { - this.name = fname; - this.func = XsltForms_xpathCoreFunctions[fname]; - this.xpathfunc = !!this.func; - this.args = []; - if (!this.xpathfunc) { - try { - this.func = eval(fname.split(" ")[1]); - } catch (e) { - alert(e); - } - } - if (!this.func && !XsltForms_debugger.active) { - XsltForms_globals.error(this, "xforms-compute-exception", "Function " + this.name + "() not found"); - } - for (var i = 1, len = arguments.length; i < len; i++) { - this.args.push(arguments[i]); - } + this.name = fname; + this.func = XsltForms_xpathCoreFunctions[fname]; + this.xpathfunc = !!this.func; + this.args = []; + if (!this.xpathfunc) { + try { + this.func = eval(fname.split(" ")[1]); + } catch (e) { + alert(e); + } + } + if (!this.func && !XsltForms_debugger.active) { + XsltForms_globals.error(this, "xforms-compute-exception", "Function " + this.name + "() not found"); + } + for (var i = 1, len = arguments.length; i < len; i++) { + this.args.push(arguments[i]); + } } XsltForms_functionCallExpr.prototype.evaluate = function(ctx) { - var arguments_ = []; - if (this.xpathfunc) { - for (var i = 0, len = this.args.length; i < len; i++) { - arguments_[i] = this.args[i].evaluate(ctx); - } - return this.func.call(ctx, arguments_); - } else { - for (var i2 = 0, len2 = this.args.length; i2 < len2; i2++) { - arguments_[i2] = XsltForms_globals.stringValue(this.args[i2].evaluate(ctx)); - } - XsltForms_context = {ctx: ctx}; - return this.func.apply(null,arguments_); - } + var arguments_ = []; + if (this.xpathfunc) { + for (var i = 0, len = this.args.length; i < len; i++) { + arguments_[i] = this.args[i].evaluate(ctx); + } + return this.func.call(ctx, arguments_); + } else { + for (var i2 = 0, len2 = this.args.length; i2 < len2; i2++) { + arguments_[i2] = XsltForms_globals.stringValue(this.args[i2].evaluate(ctx)); + } + XsltForms_context = {ctx: ctx}; + return this.func.apply(null,arguments_); + } }; function XsltForms_coreElement() { } XsltForms_coreElement.prototype.init = function(subform, elt) { - this.subforms = []; - this.subforms[subform] = true; - this.nbsubforms = 1; - this.subform = subform; - this.element = elt; + this.subforms = []; + this.subforms[subform] = true; + this.nbsubforms = 1; + this.subform = subform; + this.element = elt; }; XsltForms_coreElement.prototype.build = function() {}; XsltForms_coreElement.prototype.dispose = function() { - if (this.element) { - this.element.xfElement = null; - this.element.parentNode.removeChild(this.element); - } - this.element = null; - this.model = null; + if (this.element) { + this.element.xfElement = null; + this.element.parentNode.removeChild(this.element); + } + this.element = null; + this.model = null; }; new XsltForms_class("XsltForms_options", "HTMLElement", "xforms-options"); function XsltForms_options(subform, elt) { - this.init(subform, elt); - var debug = elt.getAttribute("xf-debug"); - if (debug && debug.toLowerCase() === "yes") { - XsltForms_globals.debugMode = true; - XsltForms_globals.debugging(); - } - var lang = elt.getAttribute("xf-lang"); - if (lang) { - XsltForms_globals.language = lang; - } + this.init(subform, elt); + var debug = elt.getAttribute("xf-debug"); + if (debug && debug.toLowerCase() === "yes") { + XsltForms_globals.debugMode = true; + XsltForms_globals.debugging(); + } + var lang = elt.getAttribute("xf-lang"); + if (lang) { + XsltForms_globals.language = lang; + } } XsltForms_options.prototype = new XsltForms_coreElement(); +new XsltForms_class("XsltForms_form", "HTMLElement", "xforms-form"); +function XsltForms_form(subform, elt) { + Array.prototype.slice.call(elt.attributes).forEach(function(n) { + if (n.nodeName.substr(0, 6) === "xmlns:" || n.nodeName.substr(0, 6) === "xmlns-") { + Fleur.XPathNSResolver_default.pf.push(n.nodeName.substr(6)); + Fleur.XPathNSResolver_default.uri.push(n.nodeValue); + } else if (n.localName === "xmlns" && n.prefix) { + Fleur.XPathNSResolver_default.pf.push(n.prefix.toLowerCase()); + Fleur.XPathNSResolver_default.uri.push(n.namespaceURI); + } else if (n.prefix && n.prefix !== "") { + Fleur.XPathNSResolver_default.pf.push(n.prefix.toLowerCase()); + Fleur.XPathNSResolver_default.uri.push(n.namespaceURI); + } + }); + this.init(subform, elt); + let xmodelconfig, xdialog, xbody; + const contents = []; + Array.prototype.slice.call(elt.children).forEach(function(n) { + switch(n.localName.toLowerCase()) { + case "xforms-model": + xmodelconfig = n; + break; + case "xforms-dialog": + xdialog = n; + break; + case "xforms-body": + xbody = n; + break; + default: + contents.push(n); + } + }); + if (!xdialog) { + const xcons = document.createElement("xforms-dialog"); + xcons.setAttribute("id", "xsltforms-console"); + elt.appendChild(xcons); + const stap = document.createElement("xforms-dialog"); + stap.setAttribute("id", "xsltforms-status-panel"); + elt.appendChild(stap); + } + if (!xbody) { + const frm = document.createElement("form"); + contents.forEach(n => frm.appendChild(n)); + const xbo = document.createElement("xforms-body"); + xbo.appendChild(frm); + elt.appendChild(xbo); + } + XsltForms_globals.formelt = elt.querySelector("form"); +} +XsltForms_form.prototype = new XsltForms_coreElement(); Array.prototype.slice.call(document.documentElement.attributes).forEach(function(n) { - if (n.nodeName.substr(0, 6) === "xmlns:" || n.nodeName.substr(0, 6) === "xmlns-") { - Fleur.XPathNSResolver_default.pf.push(n.nodeName.substr(6)); - Fleur.XPathNSResolver_default.uri.push(n.nodeValue); - } else if (n.localName === "xmlns" && n.prefix) { - Fleur.XPathNSResolver_default.pf.push(n.prefix.toLowerCase()); - Fleur.XPathNSResolver_default.uri.push(n.namespaceURI); - } else if (n.prefix && n.prefix !== "") { - Fleur.XPathNSResolver_default.pf.push(n.prefix.toLowerCase()); - Fleur.XPathNSResolver_default.uri.push(n.namespaceURI); - } + if (n.nodeName.substr(0, 6) === "xmlns:" || n.nodeName.substr(0, 6) === "xmlns-") { + Fleur.XPathNSResolver_default.pf.push(n.nodeName.substr(6)); + Fleur.XPathNSResolver_default.uri.push(n.nodeValue); + } else if (n.localName === "xmlns" && n.prefix) { + Fleur.XPathNSResolver_default.pf.push(n.prefix.toLowerCase()); + Fleur.XPathNSResolver_default.uri.push(n.namespaceURI); + } else if (n.prefix && n.prefix !== "") { + Fleur.XPathNSResolver_default.pf.push(n.prefix.toLowerCase()); + Fleur.XPathNSResolver_default.uri.push(n.namespaceURI); + } }); Array.prototype.slice.call(document.querySelectorAll("script[data-uri]")).forEach(function(n) { - XsltForms_globals.jslibraries[n.getAttribute("data-uri")] = n.getAttribute("data-version"); + XsltForms_globals.jslibraries[n.getAttribute("data-uri")] = n.getAttribute("data-version"); }); new XsltForms_class("XsltForms_model", "HTMLElement", "xforms-model"); function XsltForms_model(subform, elt) { - if (!elt.id && !document.getElementById(subform.id + "-model-default")) { - elt.id = subform.id + "-model-default"; - } - var children = elt.children; - for (var i = 0, l = children.length; i < l; i++) { - if (children[i].localName.toLowerCase() === "xforms-instance") { - break; - } - } - if (i === l) { - var definst = document.createElement("xforms-instance"); - definst.innerHTML = ' + - - - - - - -

Type your first name in the input box.
If you are running XForms, the output should be displayed in the output area.

- - Please enter your first name: - -
- - Output: - -
- - Enter a date: - - - Save this form - + + + + + + + + + + Please enter your first name: + +
+ + Output: + +
+ + Enter a date: + + + Save this form + +
\ No newline at end of file diff --git a/public/direct/hello-standalone.xhtml b/public/direct/hello-standalone.xhtml new file mode 100644 index 0000000..17e71f5 --- /dev/null +++ b/public/direct/hello-standalone.xhtml @@ -0,0 +1,1137 @@ + + + + + + + + Hello World in XForms + + + +

Type your first name in the input box.
+ If you are running XForms, the output should be displayed in the output area.

+ + + + + + + + + + Please enter your first name: + +
+ + Output: + +
+ + Enter a date: + + + Save this form + +
+ + \ No newline at end of file diff --git a/public/direct/hello.htm b/public/direct/hello.htm index 292ded2..27808f9 100644 --- a/public/direct/hello.htm +++ b/public/direct/hello.htm @@ -1,7 +1,7 @@ - + Hello World in XForms diff --git a/public/direct/xsltforms.css b/public/direct/xsltforms.css index 637304f..4cebb04 100644 --- a/public/direct/xsltforms.css +++ b/public/direct/xsltforms.css @@ -1,8 +1,8 @@ /* -XSLTForms 1.6 (663) +XSLTForms 1.7 (664) XForms 1.1+ Engine -Copyright (C) 2022 agenceXML - Alain Couthures +Copyright (C) 2023 agenceXML - Alain Couthures Contact at : xsltforms@agencexml.com This library is free software; you can redistribute it and/or @@ -194,10 +194,10 @@ xforms-label:hover + xforms-help[xf-appearance="minimal"]:not([href]) { cursor: pointer; } #xsltforms-console { - font-size: 0.8em; - color: #888888; - border-top: thin solid #888888; - display: none; + font-size: 0.8em; + color: #888888; + border-top: thin solid #888888; + display: none; } xforms-debugger { display: flex; @@ -247,32 +247,41 @@ xforms-expression { display: block; } xforms-dialog { - display: none; - position: absolute; - width: 400px; - height: 300px; - background-color: white; - border-top: 1px solid black; - border-left: 1px solid black; - border-bottom: 3px solid black; - border-right: 3px solid black; - padding: 10px; - z-index: 10; - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; - box-sizing: border-box; + display: none; + position: absolute; + width: 400px; + height: 300px; + background-color: white; + border-top: 1px solid black; + border-left: 1px solid black; + border-bottom: 3px solid black; + border-right: 3px solid black; + padding: 10px; + z-index: 10; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; } xforms-dialog-surround { - display: none; - position: absolute; - left: 0; - top: 0; - width: 100%; - height: 100%; - background-color: green; - filter:alpha(opacity=40); - opacity:0.4; - -moz-opacity:0.4; + display: none; + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 100%; + background-color: green; + filter:alpha(opacity=40); + opacity:0.4; + -moz-opacity:0.4; +} +xforms-form > xforms-body > form { + display: inline; +} +xforms-status-panel { + display: none; + z-index: 99; + top: 294.5px; + left: 490px; } xforms-action, xforms-alert-mark, @@ -342,7 +351,7 @@ xforms-select1:not([xf-appearance="full"]) > xforms-body > xforms-item, xforms-select1:not([xf-appearance="full"]) > xforms-body > xforms-itemset, xforms-select1:not([xf-appearance="full"]) > xforms-body > xforms-choices, xforms-itemset > xforms-label { - display: none; + display: none; } xforms-group:not([xf-ref]):not([xf-bind]), xforms-group[xf-bound]:not([xf-notrelevant]), @@ -358,26 +367,10 @@ xforms-select1[xf-appearance="full"] > xforms-body > xforms-itemset > xforms-ite xforms-select1[xf-appearance="full"] > xforms-body > xforms-choices > xforms-label, xforms-select1[xf-appearance="full"] > xforms-body > xforms-choices > xforms-item, xforms-select1[xf-appearance="full"] > xforms-body > xforms-choices > xforms-itemset > xforms-item { - display: block; + display: block; } xforms-repeat[xf-bound]:not([xf-notrelevant]) > xforms-repeat-item { - display: table-row; -} -xforms-repeat-item > xforms-output[xf-value], -xforms-repeat-item > xforms-output[xf-bound]:not([xf-notrelevant]), -xforms-repeat-item > xforms-input[xf-bound]:not([xf-notrelevant]), -xforms-repeat-item > xforms-textarea[xf-bound]:not([xf-notrelevant]), -xforms-repeat-item > xforms-secret[xf-bound]:not([xf-notrelevant]), -xforms-repeat-item > xforms-upload[xf-bound]:not([xf-notrelevant]), -xforms-repeat-item > xforms-range[xf-bound]:not([xf-notrelevant]), -xforms-repeat-item > xforms-trigger:not([xf-ref]):not([xf-bind]), -xforms-repeat-item > xforms-trigger[xf-bound]:not([xf-notrelevant]), -xforms-repeat-item > xforms-submit, -xforms-repeat-item > xforms-select[xf-bound]:not([xf-notrelevant])[xf-appearance="full"], -xforms-repeat-item > xforms-select1[xf-bound]:not([xf-notrelevant])[xf-appearance="full"], -xforms-repeat-item > xforms-select[xf-bound]:not([xf-notrelevant]):not([xf-appearance="full"]), -xforms-repeat-item > xforms-select1[xf-bound]:not([xf-notrelevant]):not([xf-appearance="full"]) { - display: inline-table; + display: inherit; } xforms-output[xf-value], xforms-output[xf-bound]:not([xf-notrelevant]), @@ -401,7 +394,7 @@ xforms-select1[xf-appearance="full"] > xforms-body > xforms-item > xforms-label, xforms-select1[xf-appearance="full"] > xforms-body > xforms-itemset > xforms-item > xforms-label, xforms-select1[xf-appearance="full"] > xforms-body > xforms-choices > xforms-item > xforms-label, xforms-select1[xf-appearance="full"] > xforms-body > xforms-choices > xforms-itemset > xforms-item > xforms-label { - display: inline-block; + display: inline-block; } xforms-select[xf-appearance="full"] > xforms-body > xforms-choices > xforms-label, xforms-select1[xf-appearance="full"] > xforms-body > xforms-choices > xforms-label { diff --git a/public/direct/xsltforms.js b/public/direct/xsltforms.js index e86941d..06e1147 100644 --- a/public/direct/xsltforms.js +++ b/public/direct/xsltforms.js @@ -1,8 +1,8 @@ /* -XSLTForms 1.6 (663) +XSLTForms 1.7 (664) XForms 1.1+ Engine -Copyright (C) 2022 agenceXML - Alain Couthures +Copyright (C) 2023 agenceXML - Alain Couthures Contact at xsltforms@agencexml.com This library is free software; you can redistribute it and/or @@ -22,2053 +22,2053 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA "use strict"; if (typeof Fleur === "undefined") { - console.info('Fleur 1.0 (15), XPath 1.0 Parser, copyright (C) 2022 agenceXML - Alain Couthures, contact at fleur@agencexml.com'); - (function(Fleur) { - Fleur.Node = function() {}; - Fleur.Node.ELEMENT_NODE = 1; - Fleur.Node.ATTRIBUTE_NODE = 2; - Fleur.Node.TEXT_NODE = 3; - Fleur.Node.CDATA_NODE = 4; - Fleur.Node.ENTITY_REFERENCE_NODE = 5; - Fleur.Node.ENTITY_NODE = 6; - Fleur.Node.PROCESSING_INSTRUCTION_NODE = 7; - Fleur.Node.COMMENT_NODE = 8; - Fleur.Node.DOCUMENT_NODE = 9; - Fleur.Node.DOCUMENT_TYPE_NODE = 10; - Fleur.Node.DOCUMENT_FRAGMENT_NODE = 11; - Fleur.Node.NOTATION_NODE = 12; - Fleur.Node.NAMESPACE_NODE = 129; - Fleur.Node.ATOMIC_NODE = Fleur.Node.TEXT_NODE; - Fleur.Node.SEQUENCE_NODE = 130; - Fleur.Node.ARRAY_NODE = 131; - Fleur.Node.MAP_NODE = 132; - Fleur.Node.ENTRY_NODE = 133; - Fleur.minimal = true; - Fleur.DocumentType = function() {}; - Fleur.DocumentType.resolveEntities = function(doctype, s) { - var offset = 0, index, entityname, entityvalue = null; - while ((index = s.indexOf("&", offset)) !== -1) { - entityname = s.substring(index + 1, s.indexOf(";", index + 1)); - switch (entityname) { - case "amp": - entityvalue = "&"; - break; - case "lt": - entityvalue = "<"; - break; - case "gt": - entityvalue = ">"; - break; - case "apos": - entityvalue = "'"; - break; - case "quot": - entityvalue = '"'; - break; - default: - if (entityname.charAt(0) === "#") { - entityvalue = String.fromCharCode(parseInt(entityname.charAt(1).toLowerCase() === 'x' ? "0" + entityname.substr(1).toLowerCase() : entityname.substr(1), entityname.charAt(1).toLowerCase() === 'x' ? 16 : 10)); - } else if (doctype) { - entityvalue = doctype.getEntity(entityname); - } - } - if (entityvalue) { - s = s.substr(0, index) + entityvalue + s.substr(index + entityname.length + 2); - offset = index + entityvalue.length; - entityvalue = null; - } else { - break; - } - } - return s.split("\r\n").join("\n"); - }; - Fleur.Serializer = function() {}; - Fleur.Serializer.escapeXML = function(s) { - return s.replace(/&/g, "&").replace(//g, ">"); - }; - Fleur.Serializer.prototype._serializeXMLToString = function(node, indent, offset, cdataSectionElements) { - var s, i, l; - switch (node.nodeType) { - case Fleur.Node.ELEMENT_NODE: - s = (indent ? offset + "\x3C" : "\x3C") + node.nodeName; - if (indent) { - var names = []; - for (i = 0, l = node.attributes.length; i < l; i++) { - names.push(node.attributes[i].nodeName); - } - names.sort(); - for (i = 0, l = names.length; i < l; i++) { - s += " " + names[i] + "=\"" + Fleur.Serializer.escapeXML(node.getAttribute(names[i])).replace('"', """) + "\""; - } - } else { - for (i = 0, l = node.attributes.length; i < l; i++) { - s += " " + node.attributes[i].nodeName + "=\"" + Fleur.Serializer.escapeXML(node.attributes[i].nodeValue).replace('"', """) + "\""; - } - } - if (node.childNodes.length === 0) { - return s + (indent ? "/\x3E\n" : "/\x3E"); - } - s += indent && (node.childNodes[0].nodeType !== Fleur.Node.TEXT_NODE || node.childNodes[0].data.match(/^[ \t\n\r]*$/)) ? "\x3E\n" : "\x3E"; - if (cdataSectionElements.indexOf(" " + node.nodeName + " ") !== -1) { - for (i = 0, l = node.childNodes.length; i < l; i++) { - if (node.childNodes[i].nodeType === Fleur.Node.TEXT_NODE) { - s += "\x3C![CDATA["; - s += node.childNodes[i].data; - s += "]]\x3E"; - } else { - s += this._serializeXMLToString(node.childNodes[i], indent, offset + " ", cdataSectionElements); - } - } - } else { - for (i = 0, l = node.childNodes.length; i < l; i++) { - s += this._serializeXMLToString(node.childNodes[i], indent, offset + " ", cdataSectionElements); - } - } - return s + (indent && (node.childNodes[0].nodeType !== Fleur.Node.TEXT_NODE || node.childNodes[0].data.match(/^[ \t\n\r]*$/)) ? offset + "\x3C/" : "\x3C/") + node.nodeName + (indent ? "\x3E\n" : "\x3E"); - case Fleur.Node.TEXT_NODE: - if (indent && node.data.match(/^[ \t\n\r]*$/) && node.parentNode.childNodes.length !== 1) { - return ""; - } - return Fleur.Serializer.escapeXML(node.data); - case Fleur.Node.CDATA_NODE: - return (indent ? offset + "\x3C![CDATA[" : "\x3C![CDATA[") + node.data + (indent ? "]]\x3E\n" : "]]\x3E"); - case Fleur.Node.PROCESSING_INSTRUCTION_NODE: - return (indent ? offset + "\x3C?" : "\x3C?") + node.nodeName + " " + node.nodeValue + (indent ? "?\x3E\n" : "?\x3E"); - case Fleur.Node.COMMENT_NODE: - return (indent ? offset + "\x3C!--" : "\x3C!--") + node.data + (indent ? "--\x3E\n" : "--\x3E"); - case Fleur.Node.DOCUMENT_NODE: - s = '\x3C?xml version="1.0" encoding="UTF-8"?\x3E\r\n'; - for (i = 0, l = node.childNodes.length; i < l; i++) { - s += this._serializeXMLToString(node.childNodes[i], indent, offset, cdataSectionElements); - } - return s; - } - }; - Fleur.Serializer.prototype.serializeToString = function(node, mediatype, indent, cdataSectionElements) { - var media = mediatype.split(";"), config = {}, param, paramreg = /^\s*(\S*)\s*=\s*(\S*)\s*$/, i = 1, l = media.length, ser; - while (i < l) { - param = paramreg.exec(media[i]); - config[param[1]] = param[2]; - i++; - } - switch (media[0].replace(/^\s+|\s+$/gm,'')) { - case "text/xml": - case "application/xml": - ser = this._serializeXMLToString(node, indent, "", " " + cdataSectionElements + " "); - if (indent && ser.charAt(ser.length - 1) === "\n") { - ser = ser.substr(0, ser.length - 1); - } - return ser; - } - }; - Fleur.XMLSerializer = function() {}; - Fleur.XMLSerializer.prototype = new Fleur.Serializer(); - Fleur.XMLSerializer.prototype.serializeToString = function(node, indent, cdataSectionElements) { - return Fleur.Serializer.prototype.serializeToString.call(this, node, "application/xml", indent, cdataSectionElements); - }; - Fleur.Xlength = 0; - Fleur.XQueryXNames = [["http://www.w3.org/2005/XQueryX", "http://www.w3.org/2000/xmlns/", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/2007/xquery-update-10"], []]; - Fleur.XQueryX = {}; - Fleur.XQueryXNames[1][Fleur.XQueryX.NCName = Fleur.Xlength++] = [1, 0, "xqx:NCName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.QName = Fleur.Xlength++] = [1, 0, "xqx:QName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.URIExpr = Fleur.Xlength++] = [1, 0, "xqx:URIExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.Wildcard = Fleur.Xlength++] = [1, 0, "xqx:Wildcard"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.addOp = Fleur.Xlength++] = [1, 0, "xqx:addOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.allowingEmpty = Fleur.Xlength++] = [1, 0, "xqx:allowingEmpty"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.andOp = Fleur.Xlength++] = [1, 0, "xqx:andOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.annotation = Fleur.Xlength++] = [1, 0, "xqx:annotation"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.annotationName = Fleur.Xlength++] = [1, 0, "xqx:annotationName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.anyElementTest = Fleur.Xlength++] = [1, 0, "xqx:anyElementTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.anyFunctionTest = Fleur.Xlength++] = [1, 0, "xqx:anyFunctionTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.anyItemType = Fleur.Xlength++] = [1, 0, "xqx:anyItemType"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.anyKindTest = Fleur.Xlength++] = [1, 0, "xqx:anyKindTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.arrayConstructor = Fleur.Xlength++] = [1, 0, "xqx:arrayConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.argExpr = Fleur.Xlength++] = [1, 0, "xqx:argExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.argumentPlaceholder = Fleur.Xlength++] = [1, 0, "xqx:argumentPlaceholder"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.arguments = Fleur.Xlength++] = [1, 0, "xqx:arguments"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.arithmeticOp = Fleur.Xlength++] = [1, 0, "xqx:arithmeticOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.arrayTest = Fleur.Xlength++] = [1, 0, "xqx:arrayTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.atomicType = Fleur.Xlength++] = [1, 0, "xqx:atomicType"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.attributeConstructor = Fleur.Xlength++] = [1, 0, "xqx:attributeConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.attributeList = Fleur.Xlength++] = [1, 0, "xqx:attributeList"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.attributeName = Fleur.Xlength++] = [1, 0, "xqx:attributeName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.attributeTest = Fleur.Xlength++] = [1, 0, "xqx:attributeTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.attributeValue = Fleur.Xlength++] = [1, 0, "xqx:attributeValue"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.attributeValueExpr = Fleur.Xlength++] = [1, 0, "xqx:attributeValueExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.baseUriDecl = Fleur.Xlength++] = [1, 0, "xqx:baseUriDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.bindingSequence = Fleur.Xlength++] = [1, 0, "xqx:bindingSequence"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.boundarySpaceDecl = Fleur.Xlength++] = [1, 0, "xqx:boundarySpaceDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.castExpr = Fleur.Xlength++] = [1, 0, "xqx:castExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.castableExpr = Fleur.Xlength++] = [1, 0, "xqx:castableExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.catchClause = Fleur.Xlength++] = [1, 0, "xqx:catchClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.catchErrorList = Fleur.Xlength++] = [1, 0, "xqx:catchErrorList"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.catchExpr = Fleur.Xlength++] = [1, 0, "xqx:catchExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.collation = Fleur.Xlength++] = [1, 0, "xqx:collation"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.commentTest = Fleur.Xlength++] = [1, 0, "xqx:commentTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.comparisonOp = Fleur.Xlength++] = [1, 0, "xqx:comparisonOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.computedAttributeConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedAttributeConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.computedCommentConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedCommentConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.computedDocumentConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedDocumentConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.computedElementConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedElementConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.computedEntryConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedEntryConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.computedNamespaceConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedNamespaceConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.computedPIConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedPIConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.computedTextConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedTextConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.constantExpr = Fleur.Xlength++] = [1, 0, "xqx:constantExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.constructionDecl = Fleur.Xlength++] = [1, 0, "xqx:constructionDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.constructorFunctionExpr = Fleur.Xlength++] = [1, 0, "xqx:constructorFunctionExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.contentExpr = Fleur.Xlength++] = [1, 0, "xqx:contentExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.contextItemDecl = Fleur.Xlength++] = [1, 0, "xqx:contextItemDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.contextItemExpr = Fleur.Xlength++] = [1, 0, "xqx:contextItemExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.copyNamespacesDecl = Fleur.Xlength++] = [1, 0, "xqx:copyNamespacesDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.countClause = Fleur.Xlength++] = [1, 0, "xqx:countClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.currentItem = Fleur.Xlength++] = [1, 0, "xqx:currentItem"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.decimalConstantExpr = Fleur.Xlength++] = [1, 0, "xqx:decimalConstantExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatDecl = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatName = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatParam = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatParam"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatParamName = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatParamName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatParamValue = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatParamValue"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.defaultCollationDecl = Fleur.Xlength++] = [1, 0, "xqx:defaultCollationDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.defaultElementNamespace = Fleur.Xlength++] = [1, 0, "xqx:defaultElementNamespace"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.defaultNamespaceCategory = Fleur.Xlength++] = [1, 0, "xqx:defaultNamespaceCategory"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.defaultNamespaceDecl = Fleur.Xlength++] = [1, 0, "xqx:defaultNamespaceDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.divOp = Fleur.Xlength++] = [1, 0, "xqx:divOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.documentTest = Fleur.Xlength++] = [1, 0, "xqx:documentTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.doubleConstantExpr = Fleur.Xlength++] = [1, 0, "xqx:doubleConstantExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.doubleMapExpr = Fleur.Xlength++] = [1, 0, "xqx:doubleMapExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.dynamicFunctionInvocationExpr = Fleur.Xlength++] = [1, 0, "xqx:dynamicFunctionInvocationExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.elementConstructor = Fleur.Xlength++] = [1, 0, "xqx:elementConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.elementContent = Fleur.Xlength++] = [1, 0, "xqx:elementContent"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.elementName = Fleur.Xlength++] = [1, 0, "xqx:elementName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.elementTest = Fleur.Xlength++] = [1, 0, "xqx:elementTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.elseClause = Fleur.Xlength++] = [1, 0, "xqx:elseClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.emptyOrderingDecl = Fleur.Xlength++] = [1, 0, "xqx:emptyOrderingDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.emptyOrderingMode = Fleur.Xlength++] = [1, 0, "xqx:emptyOrderingMode"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.encoding = Fleur.Xlength++] = [1, 0, "xqx:encoding"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.endExpr = Fleur.Xlength++] = [1, 0, "xqx:endExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.entryTest = Fleur.Xlength++] = [1, 0, "xqx:entryTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.eqOp = Fleur.Xlength++] = [1, 0, "xqx:eqOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.equalOp = Fleur.Xlength++] = [1, 0, "xqx:equalOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.exceptOp = Fleur.Xlength++] = [1, 0, "xqx:exceptOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.expr = Fleur.Xlength++] = [1, 0, "xqx:expr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.extensionExpr = Fleur.Xlength++] = [1, 0, "xqx:extensionExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.external = Fleur.Xlength++] = [1, 0, "xqx:external"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.externalDefinition = Fleur.Xlength++] = [1, 0, "xqx:externalDefinition"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.filterExpr = Fleur.Xlength++] = [1, 0, "xqx:filterExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.firstOperand = Fleur.Xlength++] = [1, 0, "xqx:firstOperand"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.flworExpr = Fleur.Xlength++] = [1, 0, "xqx:flworExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.forClause = Fleur.Xlength++] = [1, 0, "xqx:forClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.forClauseItem = Fleur.Xlength++] = [1, 0, "xqx:forClauseItem"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.forExpr = Fleur.Xlength++] = [1, 0, "xqx:forExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.forLetClauseItemExtensions = Fleur.Xlength++] = [1, 0, "xqx:forLetClauseItemExtensions"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.functionBody = Fleur.Xlength++] = [1, 0, "xqx:functionBody"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.functionCallExpr = Fleur.Xlength++] = [1, 0, "xqx:functionCallExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.functionDecl = Fleur.Xlength++] = [1, 0, "xqx:functionDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.functionItem = Fleur.Xlength++] = [1, 0, "xqx:functionItem"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.functionName = Fleur.Xlength++] = [1, 0, "xqx:functionName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.geOp = Fleur.Xlength++] = [1, 0, "xqx:geOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.generalComparisonOp = Fleur.Xlength++] = [1, 0, "xqx:generalComparisonOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.greaterThanOp = Fleur.Xlength++] = [1, 0, "xqx:greaterThanOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.greaterThanOrEqualOp = Fleur.Xlength++] = [1, 0, "xqx:greaterThanOrEqualOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.groupByClause = Fleur.Xlength++] = [1, 0, "xqx:groupByClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.groupVarInitialize = Fleur.Xlength++] = [1, 0, "xqx:groupVarInitialize"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.groupingSpec = Fleur.Xlength++] = [1, 0, "xqx:groupingSpec"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.gtOp = Fleur.Xlength++] = [1, 0, "xqx:gtOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.idivOp = Fleur.Xlength++] = [1, 0, "xqx:idivOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.ifClause = Fleur.Xlength++] = [1, 0, "xqx:ifClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.ifThenElseExpr = Fleur.Xlength++] = [1, 0, "xqx:ifThenElseExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.inheritMode = Fleur.Xlength++] = [1, 0, "xqx:inheritMode"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.inlineFunctionExpr = Fleur.Xlength++] = [1, 0, "xqx:inlineFunctionExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.instanceOfExpr = Fleur.Xlength++] = [1, 0, "xqx:instanceOfExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.integerConstantExpr = Fleur.Xlength++] = [1, 0, "xqx:integerConstantExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.intersectOp = Fleur.Xlength++] = [1, 0, "xqx:intersectOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.isOp = Fleur.Xlength++] = [1, 0, "xqx:isOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.itemType = Fleur.Xlength++] = [1, 0, "xqx:itemType"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.javascriptImport = Fleur.Xlength++] = [1, 0, "xqx:javascriptImport"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.kindTest = Fleur.Xlength++] = [1, 0, "xqx:kindTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.leOp = Fleur.Xlength++] = [1, 0, "xqx:leOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.lessThanOp = Fleur.Xlength++] = [1, 0, "xqx:lessThanOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.lessThanOrEqualOp = Fleur.Xlength++] = [1, 0, "xqx:lessThanOrEqualOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.letClause = Fleur.Xlength++] = [1, 0, "xqx:letClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.letClauseItem = Fleur.Xlength++] = [1, 0, "xqx:letClauseItem"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.letExpr = Fleur.Xlength++] = [1, 0, "xqx:letExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.libraryModule = Fleur.Xlength++] = [1, 0, "xqx:libraryModule"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.logicalOp = Fleur.Xlength++] = [1, 0, "xqx:logicalOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.lookup = Fleur.Xlength++] = [1, 0, "xqx:lookup"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.ltOp = Fleur.Xlength++] = [1, 0, "xqx:ltOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.mainModule = Fleur.Xlength++] = [1, 0, "xqx:mainModule"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.mapConstructor = Fleur.Xlength++] = [1, 0, "xqx:mapConstructor"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.mapConstructorEntry = Fleur.Xlength++] = [1, 0, "xqx:mapConstructorEntry"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.mapKeyExpr = Fleur.Xlength++] = [1, 0, "xqx:mapKeyExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.mapTest = Fleur.Xlength++] = [1, 0, "xqx:mapTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.mapValueExpr = Fleur.Xlength++] = [1, 0, "xqx:mapValueExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.modOp = Fleur.Xlength++] = [1, 0, "xqx:modOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.module = Fleur.Xlength++] = [1, 0, "xqx:module"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.moduleDecl = Fleur.Xlength++] = [1, 0, "xqx:moduleDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.moduleImport = Fleur.Xlength++] = [1, 0, "xqx:moduleImport"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.multidimExpr = Fleur.Xlength++] = [1, 0, "xqx:multidimExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.multiplyOp = Fleur.Xlength++] = [1, 0, "xqx:multiplyOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.name = Fleur.Xlength++] = [1, 0, "xqx:name"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.nameTest = Fleur.Xlength++] = [1, 0, "xqx:nameTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.namedFunctionRef = Fleur.Xlength++] = [1, 0, "xqx:namedFunctionRef"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.namespaceDecl = Fleur.Xlength++] = [1, 0, "xqx:namespaceDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.namespaceDeclaration = Fleur.Xlength++] = [1, 0, "xqx:namespaceDeclaration"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.namespacePrefix = Fleur.Xlength++] = [1, 0, "xqx:namespacePrefix"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.namespaceTest = Fleur.Xlength++] = [1, 0, "xqx:namespaceTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.neOp = Fleur.Xlength++] = [1, 0, "xqx:neOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.nextItem = Fleur.Xlength++] = [1, 0, "xqx:nextItem"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.nillable = Fleur.Xlength++] = [1, 0, "xqx:nillable"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.nodeAfterOp = Fleur.Xlength++] = [1, 0, "xqx:nodeAfterOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.nodeBeforeOp = Fleur.Xlength++] = [1, 0, "xqx:nodeBeforeOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.nodeComparisonOp = Fleur.Xlength++] = [1, 0, "xqx:nodeComparisonOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.notEqualOp = Fleur.Xlength++] = [1, 0, "xqx:notEqualOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.occurrenceIndicator = Fleur.Xlength++] = [1, 0, "xqx:occurrenceIndicator"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.operand = Fleur.Xlength++] = [1, 0, "xqx:operand"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.operatorExpr = Fleur.Xlength++] = [1, 0, "xqx:operatorExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.optionContents = Fleur.Xlength++] = [1, 0, "xqx:optionContents"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.optionDecl = Fleur.Xlength++] = [1, 0, "xqx:optionDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.optionName = Fleur.Xlength++] = [1, 0, "xqx:optionName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.optional = Fleur.Xlength++] = [1, 0, "xqx:optional"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.orOp = Fleur.Xlength++] = [1, 0, "xqx:orOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.orderByClause = Fleur.Xlength++] = [1, 0, "xqx:orderByClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.orderByExpr = Fleur.Xlength++] = [1, 0, "xqx:orderByExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.orderBySpec = Fleur.Xlength++] = [1, 0, "xqx:orderBySpec"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.orderComparisonOp = Fleur.Xlength++] = [1, 0, "xqx:orderComparisonOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.orderModifier = Fleur.Xlength++] = [1, 0, "xqx:orderModifier"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.orderedExpr = Fleur.Xlength++] = [1, 0, "xqx:orderedExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.orderingKind = Fleur.Xlength++] = [1, 0, "xqx:orderingKind"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.orderingModeDecl = Fleur.Xlength++] = [1, 0, "xqx:orderingModeDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.param = Fleur.Xlength++] = [1, 0, "xqx:param"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.paramList = Fleur.Xlength++] = [1, 0, "xqx:paramList"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.paramTypeList = Fleur.Xlength++] = [1, 0, "xqx:paramTypeList"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.parenthesizedItemType = Fleur.Xlength++] = [1, 0, "xqx:parenthesizedItemType"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.pathExpr = Fleur.Xlength++] = [1, 0, "xqx:pathExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.piTarget = Fleur.Xlength++] = [1, 0, "xqx:piTarget"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.piTargetExpr = Fleur.Xlength++] = [1, 0, "xqx:piTargetExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.piTest = Fleur.Xlength++] = [1, 0, "xqx:piTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.piValueExpr = Fleur.Xlength++] = [1, 0, "xqx:piValueExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.positionalVariableBinding = Fleur.Xlength++] = [1, 0, "xqx:positionalVariableBinding"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.pragma = Fleur.Xlength++] = [1, 0, "xqx:pragma"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.pragmaContents = Fleur.Xlength++] = [1, 0, "xqx:pragmaContents"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.pragmaName = Fleur.Xlength++] = [1, 0, "xqx:pragmaName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.predicate = Fleur.Xlength++] = [1, 0, "xqx:predicate"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.predicateExpr = Fleur.Xlength++] = [1, 0, "xqx:predicateExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.predicates = Fleur.Xlength++] = [1, 0, "xqx:predicates"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.prefixElt = Fleur.Xlength++] = [1, 0, "xqx:prefix"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.prefixExpr = Fleur.Xlength++] = [1, 0, "xqx:prefixExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.preserveMode = Fleur.Xlength++] = [1, 0, "xqx:preserveMode"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.previousItem = Fleur.Xlength++] = [1, 0, "xqx:previousItem"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.prolog = Fleur.Xlength++] = [1, 0, "xqx:prolog"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.prologPartOneItem = Fleur.Xlength++] = [1, 0, "xqx:prologPartOneItem"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.prologPartTwoItem = Fleur.Xlength++] = [1, 0, "xqx:prologPartTwoItem"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.quantifiedExpr = Fleur.Xlength++] = [1, 0, "xqx:quantifiedExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.quantifiedExprInClause = Fleur.Xlength++] = [1, 0, "xqx:quantifiedExprInClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.quantifier = Fleur.Xlength++] = [1, 0, "xqx:quantifier"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.queryBody = Fleur.Xlength++] = [1, 0, "xqx:queryBody"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.rangeSequenceExpr = Fleur.Xlength++] = [1, 0, "xqx:rangeSequenceExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.resultExpr = Fleur.Xlength++] = [1, 0, "xqx:resultExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.returnClause = Fleur.Xlength++] = [1, 0, "xqx:returnClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.rootExpr = Fleur.Xlength++] = [1, 0, "xqx:rootExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.schemaAttributeTest = Fleur.Xlength++] = [1, 0, "xqx:schemaAttributeTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.schemaElementTest = Fleur.Xlength++] = [1, 0, "xqx:schemaElementTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.schemaImport = Fleur.Xlength++] = [1, 0, "xqx:schemaImport"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.secondOperand = Fleur.Xlength++] = [1, 0, "xqx:secondOperand"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.sequenceExpr = Fleur.Xlength++] = [1, 0, "xqx:sequenceExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.sequenceType = Fleur.Xlength++] = [1, 0, "xqx:sequenceType"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.sequenceTypeUnion = Fleur.Xlength++] = [1, 0, "xqx:sequenceTypeUnion"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.setOp = Fleur.Xlength++] = [1, 0, "xqx:setOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.simpleMapExpr = Fleur.Xlength++] = [1, 0, "xqx:simpleMapExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.singleType = Fleur.Xlength++] = [1, 0, "xqx:singleType"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.slidingWindowClause = Fleur.Xlength++] = [1, 0, "xqx:slidingWindowClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.sourceExpr = Fleur.Xlength++] = [1, 0, "xqx:sourceExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.stable = Fleur.Xlength++] = [1, 0, "xqx:stable"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.star = Fleur.Xlength++] = [1, 0, "xqx:star"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.startExpr = Fleur.Xlength++] = [1, 0, "xqx:startExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.stepExpr = Fleur.Xlength++] = [1, 0, "xqx:stepExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.stringConcatenateOp = Fleur.Xlength++] = [1, 0, "xqx:stringConcatenateOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.stringConstantExpr = Fleur.Xlength++] = [1, 0, "xqx:stringConstantExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.stringOp = Fleur.Xlength++] = [1, 0, "xqx:stringOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.subtractOp = Fleur.Xlength++] = [1, 0, "xqx:subtractOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.switchCaseExpr = Fleur.Xlength++] = [1, 0, "xqx:switchCaseExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.switchExpr = Fleur.Xlength++] = [1, 0, "xqx:switchExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.switchExprCaseClause = Fleur.Xlength++] = [1, 0, "xqx:switchExprCaseClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.switchExprDefaultClause = Fleur.Xlength++] = [1, 0, "xqx:switchExprDefaultClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.tagName = Fleur.Xlength++] = [1, 0, "xqx:tagName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.tagNameExpr = Fleur.Xlength++] = [1, 0, "xqx:tagNameExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.targetLocation = Fleur.Xlength++] = [1, 0, "xqx:targetLocation"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.targetLocationExpr = Fleur.Xlength++] = [1, 0, "xqx:targetLocationExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.targetNamespace = Fleur.Xlength++] = [1, 0, "xqx:targetNamespace"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.textTest = Fleur.Xlength++] = [1, 0, "xqx:textTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.thenClause = Fleur.Xlength++] = [1, 0, "xqx:thenClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.treatExpr = Fleur.Xlength++] = [1, 0, "xqx:treatExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.tryCatchExpr = Fleur.Xlength++] = [1, 0, "xqx:tryCatchExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.tryClause = Fleur.Xlength++] = [1, 0, "xqx:tryClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.tumblingWindowClause = Fleur.Xlength++] = [1, 0, "xqx:tumblingWindowClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.typeDeclaration = Fleur.Xlength++] = [1, 0, "xqx:typeDeclaration"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.typeName = Fleur.Xlength++] = [1, 0, "xqx:typeName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.typedFunctionTest = Fleur.Xlength++] = [1, 0, "xqx:typedFunctionTest"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.typedVariableBinding = Fleur.Xlength++] = [1, 0, "xqx:typedVariableBinding"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.typeswitchExpr = Fleur.Xlength++] = [1, 0, "xqx:typeswitchExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.typeswitchExprCaseClause = Fleur.Xlength++] = [1, 0, "xqx:typeswitchExprCaseClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.typeswitchExprDefaultClause = Fleur.Xlength++] = [1, 0, "xqx:typeswitchExprDefaultClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.unaryMinusOp = Fleur.Xlength++] = [1, 0, "xqx:unaryMinusOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.unaryPlusOp = Fleur.Xlength++] = [1, 0, "xqx:unaryPlusOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.unionOp = Fleur.Xlength++] = [1, 0, "xqx:unionOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.unorderedExpr = Fleur.Xlength++] = [1, 0, "xqx:unorderedExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.unaryLookup = Fleur.Xlength++] = [1, 0, "xqx:unaryLookup"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.uri = Fleur.Xlength++] = [1, 0, "xqx:uri"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.validateExpr = Fleur.Xlength++] = [1, 0, "xqx:validateExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.validationMode = Fleur.Xlength++] = [1, 0, "xqx:validationMode"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.value = Fleur.Xlength++] = [1, 0, "xqx:value"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.valueComparisonOp = Fleur.Xlength++] = [1, 0, "xqx:valueComparisonOp"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.valueExpr = Fleur.Xlength++] = [1, 0, "xqx:valueExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.varDecl = Fleur.Xlength++] = [1, 0, "xqx:varDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.varName = Fleur.Xlength++] = [1, 0, "xqx:varName"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.varRef = Fleur.Xlength++] = [1, 0, "xqx:varRef"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.varValue = Fleur.Xlength++] = [1, 0, "xqx:varValue"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.variableBinding = Fleur.Xlength++] = [1, 0, "xqx:variableBinding"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.version = Fleur.Xlength++] = [1, 0, "xqx:version"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.versionDecl = Fleur.Xlength++] = [1, 0, "xqx:versionDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.voidSequenceType = Fleur.Xlength++] = [1, 0, "xqx:voidSequenceType"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.whereClause = Fleur.Xlength++] = [1, 0, "xqx:whereClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.winEndExpr = Fleur.Xlength++] = [1, 0, "xqx:winEndExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.winStartExpr = Fleur.Xlength++] = [1, 0, "xqx:winStartExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.windowClause = Fleur.Xlength++] = [1, 0, "xqx:windowClause"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.windowEndCondition = Fleur.Xlength++] = [1, 0, "xqx:windowEndCondition"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.windowStartCondition = Fleur.Xlength++] = [1, 0, "xqx:windowStartCondition"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.windowVars = Fleur.Xlength++] = [1, 0, "xqx:windowVars"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.xpathAxis = Fleur.Xlength++] = [1, 0, "xqx:xpathAxis"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.URI = Fleur.Xlength++] = [2, 0, "xqx:URI"]; - Fleur.XQueryXNames[1][Fleur.XQueryX["default"] = Fleur.Xlength++] = [2, 0, "xqx:default"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.nondeterministic = Fleur.Xlength++] = [2, 0, "xqx:nondeterministic"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.onlyEnd = Fleur.Xlength++] = [2, 0, "xqx:onlyEnd"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.prefix = Fleur.Xlength++] = [2, 0, "xqx:prefix"]; - Fleur.XQueryXNames[1][Fleur.XQueryX["private"] = Fleur.Xlength++] = [2, 0, "xqx:private"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.sequentialFunction = Fleur.Xlength++] = [2, 0, "xqx:sequentialFunction"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.updatingFunction = Fleur.Xlength++] = [2, 0, "xqx:updatingFunction"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.xqx = Fleur.Xlength++] = [2, 1, "xmlns:xqx"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.xsi = Fleur.Xlength++] = [2, 1, "xmlns:xsi"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.schemaLocation = Fleur.Xlength++] = [2, 2, "xsi:schemaLocation"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.xqxuf = Fleur.Xlength++] = [2, 1, "xmlns:xqxuf"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.copyModifyExpr = Fleur.Xlength++] = [1, 3, "xqxuf:copyModifyExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.copySource = Fleur.Xlength++] = [1, 3, "xqxuf:copySource"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.deleteExpr = Fleur.Xlength++] = [1, 3, "xqxuf:deleteExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.insertAfter = Fleur.Xlength++] = [1, 3, "xqxuf:insertAfter"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.insertAsFirst = Fleur.Xlength++] = [1, 3, "xqxuf:insertAsFirst"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.insertAsLast = Fleur.Xlength++] = [1, 3, "xqxuf:insertAsLast"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.insertBefore = Fleur.Xlength++] = [1, 3, "xqxuf:insertBefore"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.insertExpr = Fleur.Xlength++] = [1, 3, "xqxuf:insertExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.insertInto = Fleur.Xlength++] = [1, 3, "xqxuf:insertInto"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.modifyExpr = Fleur.Xlength++] = [1, 3, "xqxuf:modifyExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.newNameExpr = Fleur.Xlength++] = [1, 3, "xqxuf:newNameExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.renameExpr = Fleur.Xlength++] = [1, 3, "xqxuf:renameExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.replaceExpr = Fleur.Xlength++] = [1, 3, "xqxuf:replaceExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.replaceValue = Fleur.Xlength++] = [1, 3, "xqxuf:replaceValue"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.replacementExpr = Fleur.Xlength++] = [1, 3, "xqxuf:replacementExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.returnExpr = Fleur.Xlength++] = [1, 3, "xqxuf:returnExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.revalidationDecl = Fleur.Xlength++] = [1, 3, "xqxuf:revalidationDecl"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.sourceExprUf = Fleur.Xlength++] = [1, 3, "xqxuf:sourceExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.targetExpr = Fleur.Xlength++] = [1, 3, "xqxuf:targetExpr"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.transformCopies = Fleur.Xlength++] = [1, 3, "xqxuf:transformCopies"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.transformCopy = Fleur.Xlength++] = [1, 3, "xqxuf:transformCopy"]; - Fleur.XQueryXNames[1][Fleur.XQueryX.transformExpr = Fleur.Xlength++] = [1, 3, "xqxuf:transformExpr"]; - Fleur.XPathEvaluator = function() {}; - Fleur.XPathEvaluator._precedence = "././/.:.as.&0.!.!!.&1.~+.~-.&2.cast as.&3.castable as.&4.treat as.&5.instance of.&6.intersect.except.&7.|.union.&8.div.mod.*.idiv.&9.+.-.&10.to.&11.||.&12.eq.ne.lt.le.gt.ge.<.>.<=.>=.is.<<.>>.=.!=.&13.and.&14.or.&15.allowing.&16.at.&17.:=.in.&18.after.before.into.with.value.&19.node.nodes.&20.~~ascending.~~descending.empty.&28.~,.&29.for.let.group by.order by.stable order by.count.where.some.every.&30.then.catch.&31.else.return.satisfies.&32.,.&50.;.&51."; - Fleur.XPathEvaluator._rightgrouping1 = Fleur.XPathEvaluator._precedence.substr(Fleur.XPathEvaluator._precedence.indexOf(".then.") + 6); - Fleur.XPathEvaluator._rightgrouping1 = Fleur.XPathEvaluator._rightgrouping1.substr(Fleur.XPathEvaluator._rightgrouping1.indexOf("&") + 1); - Fleur.XPathEvaluator._rightgrouping1 = parseInt(Fleur.XPathEvaluator._rightgrouping1.substr(0, Fleur.XPathEvaluator._rightgrouping1.indexOf(".")), 10); - Fleur.XPathEvaluator._rightgrouping2 = Fleur.XPathEvaluator._precedence.substr(Fleur.XPathEvaluator._precedence.indexOf(".return.") + 6); - Fleur.XPathEvaluator._rightgrouping2 = Fleur.XPathEvaluator._rightgrouping2.substr(Fleur.XPathEvaluator._rightgrouping2.indexOf("&") + 1); - Fleur.XPathEvaluator._rightgrouping2 = parseInt(Fleur.XPathEvaluator._rightgrouping2.substr(0, Fleur.XPathEvaluator._rightgrouping2.indexOf(".")), 10); - Fleur.XPathEvaluator._opcodes = "./;stepExpr.|;unionOp.union;unionOp.div;divOp.mod;modOp.*;multiplyOp.idiv;idivOp.+;addOp.-;subtractOp.to;toOp.||;stringConcatenateOp.eq;eqOp.ne;neOp.lt;ltOp.le;leOp.gt;gtOp.ge;geOp.<;lessThanOp.>;greaterThanOp.<=;lessThanOrEqualOp.>=;greaterThanOrEqualOp.is;isOp.<<;nodeBeforeOp.>>;nodeAfterOp.=;equalOp.!=;notEqualOp.and;andOp.or;orOp.,;argExpr."; - Fleur.XPathEvaluator._skipComment = function(s, offset) { - var i = offset; - var c = s.charAt(i); - var d = s.charAt(i + 1); - var l = s.length; - do { - if (c === "(" && d === ":") { - i = Fleur.XPathEvaluator._skipComment(s, i + 2); - } else if (c === ":" && d === ")") { - return i + 1; - } - c = s.charAt(++i); - d = s.charAt(i + 1); - } while (i < l); - }; - Fleur.XPathEvaluator._skipSpaces = function(s, offset) { - var i = offset; - var c = s.charAt(i); - var l = s.length; - do { - if (c === "(" && s.charAt(i + 1) === ":") { - i = Fleur.XPathEvaluator._skipComment(s, i + 2); - } else if (c !== "\n" && c !== "\r" && c !== "\t" && c !== " ") { - return i; - } - c = s.charAt(++i); - } while (i < l); - return i; - }; - Fleur.XPathEvaluator._getName = function(s) { - var i = 0; - var o = s.charAt(0); - var prev = ""; - while (o !== "" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:*{".indexOf(o) !== -1) { - if (o === "*") { - if (i > 0 && (s.charAt(i - 1) === ":" || s.charAt(i - 1) === "}")) { - i++; - break; - } else if (s.charAt(i + 1) !== ":") { - if (i === 0) { - i++; - } - break; - } - } - if (o === "{") { - if (prev !== "Q") { - return s.substr(0, i); - } - while (o !== "" && o !== "}") { - o = s.charAt(++i); - } - } - prev = o; - o = s.charAt(++i); - } - if (o === "#") { - o = s.charAt(++i); - while (o !== "" && "0123456789".indexOf(o) !== -1) { - o = s.charAt(++i); - } - } - return s.substr(0, i); - }; - Fleur.XPathEvaluator._getNameStep = function(s, attr) { - var n = Fleur.XPathEvaluator._getName(s); - var fctind = n.indexOf("#"); - if (fctind !== -1) { - var pindex = n.indexOf(":"); - if (pindex === -1) { - return n.length + ".[Fleur.XQueryX.namedFunctionRef,[[Fleur.XQueryX.functionName,['" + n.substr(0, fctind) + "']],[Fleur.XQueryX.integerConstantExpr,[[Fleur.XQueryX.value,['" + n.substr(fctind + 1) + "']]]]]]"; - } - return n.length + ".[Fleur.XQueryX.namedFunctionRef,[[Fleur.XQueryX.functionName,['" + n.substr(0, fctind).substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + n.substr(0, pindex) + "']]]],[Fleur.XQueryX.integerConstantExpr,[[Fleur.XQueryX.value,['" + n.substr(fctind + 1) + "']]]]]]"; - } - var aind = n.indexOf("::"); - var axis = aind !== -1 ? n.substr(0, aind) : attr ? "attribute" : "child"; - var n2 = aind !== -1 ? n.substr(aind + 2) : n; - var eq = n2.substr(0, 2) === "Q{"; - var sind = eq ? n2.indexOf("}") : n2.indexOf(":"); - var n3 = sind !== -1 ? n2.substr(sind + 1) : n2; - var nsp = eq ? n2.substr(2, sind - 2) : sind !== -1 ? n2.substr(0, sind) : ""; - var ntest = n3 === "*" || nsp === "*" ? "[Fleur.XQueryX.Wildcard,[" + (n3 !== "*" ? "[Fleur.XQueryX.star,[]],[Fleur.XQueryX.NCName,['" + n3 + "']]" : "") + "]]" : "[Fleur.XQueryX.nameTest,['" + n3 + "'" + (eq || sind !== -1 ? ",[" + (eq ? "Fleur.XQueryX.URI" : "Fleur.XQueryX.prefix") + ",['" + nsp + "']]" : "") + "]]"; - return (n.length + attr) + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['" + axis + "']]," + ntest + "]]]]"; - }; - Fleur.XPathEvaluator._pathExprFormat = function(s, p) { - if (s.substr(0, 25) === "[Fleur.XQueryX.pathExpr,[") { - return s.substr(25, s.length - 29) + p + "]]"; - } - return "[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[" + s + "]]" + p + "]]"; - }; - Fleur.XPathEvaluator._calc = function(args, ops, opprec) { - var curop = parseInt(ops.split(".")[1], 10); - if ((ops === "" || curop > opprec || opprec === 31) || (curop >= opprec && (curop === Fleur.XPathEvaluator._rightgrouping1 || curop === Fleur.XPathEvaluator._rightgrouping2))) { - return args.length + "." + args + ops.length + "." + ops; - } - var op0 = ops.substr(ops.indexOf(".") + 1, parseInt(ops.split(".")[0], 10)); - var op = op0.substr(op0.indexOf(".") + 1); - var arg2len = args.substr(0, args.indexOf(".")); - var arg2val = args.substr(args.indexOf(".") + 1).substr(0, parseInt(arg2len, 10)); - var arg2val2, arg2val3; - var args3, arg1len, arg1val, arg1val2, arg1val3; - if (op.startsWith("~~")) { - args3 = args; - arg1len = arg2len; - arg1val = arg2val; - } else { - args3 = args.substr(arg2len.length + 1 + parseInt(arg2len, 10)); - arg1len = args3.substr(0, args3.indexOf(".")); - arg1val = args3.substr(args3.indexOf(".") + 1).substr(0, parseInt(arg1len, 10)); - } - var arg; - var occ; - switch (op) { - case ";": - if (arg1val.substr(0, 58) === "[Fleur.XQueryX.sequenceExpr,[[Fleur.XQueryX.multidimExpr,[") { - arg = "[Fleur.XQueryX.sequenceExpr,[[Fleur.XQueryX.multidimExpr,[" + arg1val.substr(58, arg1val.length - 62) + "," + arg2val + "]]]]"; - } else { - arg = "[Fleur.XQueryX.sequenceExpr,[[Fleur.XQueryX.multidimExpr,[" + arg1val + "," + arg2val + "]]]]"; - } - break; - case ",": - if (ops.substr(0, 13) === "4.50.,5.999.(") { - if (arg1val.substr(0, 26) === "[Fleur.XQueryX.arguments,[") { - arg = arg1val.substr(0, arg1val.length - 2) + "," + arg2val + "]]"; - } else { - arg = "[Fleur.XQueryX.arguments,[" + arg1val + "," + arg2val + "]]"; - } - } else if (ops.substr(0, 13) === "4.50.,5.999.q") { - arg = arg1val + "," + arg2val; - } else if (ops.startsWith("4.50.,")) { - if (arg1val.substr(0, 36) === "[Fleur.XQueryX.mapConstructorEntry,[") { - arg = arg1val + "," + arg2val; - } else if (arg1val.substr(0, 29) === "[Fleur.XQueryX.sequenceExpr,[" && arg1val !== "[Fleur.XQueryX.sequenceExpr,[]]") { - arg = arg1val.substr(0, arg1val.length - 2) + "," + arg2val + "]]"; - } else { - arg = "[Fleur.XQueryX.sequenceExpr,[" + arg1val + "," + arg2val + "]]"; - } - } else { - arg = arg1val + "," + arg2val; - } - break; - case "~,": - if (arg1val.substr(0, 29) === "[Fleur.XQueryX.letClauseItem," || arg1val.substr(0, 27) === "[Fleur.XQueryX.groupBySpec,") { - arg = arg1val + "," + arg2val; - } else if (arg1val.substr(0, 25) === "[Fleur.XQueryX.letClause,") { - if (arg2val.substr(0, 25) === "Fleur.XQueryX.letClause,") { - arg = arg1val.substr(0, arg1val.length - 2) + "," + arg2val.substr(25); - } else { - arg = arg1val.substr(0, arg1val.length - 2) + "," + arg2val + "]]"; - } - } else { - if (arg1val.substr(0, 27) !== "[Fleur.XQueryX.orderBySpec,") { - arg = "[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg1val + "]]]]"; - } else { - arg = arg1val; - } - arg += ","; - if (arg2val.substr(0, 27) !== "[Fleur.XQueryX.orderBySpec,") { - arg += "[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg2val + "]]]]"; - } else { - arg += arg2val; - } - } - break; - case "//": - arg = "[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg1val, "") + ",[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['descendant-or-self']],[Fleur.XQueryX.anyKindTest,[]]]]," + Fleur.XPathEvaluator._pathExprFormat(arg2val, "") + "]]"; - break; - case "/": - arg = "[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg1val, "") + (arg2val !== "" ? "," + Fleur.XPathEvaluator._pathExprFormat(arg2val, "") : "") + "]]"; - break; - case "!!": - arg = "[Fleur.XQueryX.doubleMapExpr,[[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg1val, "") + "]],[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg2val, "") + "]]]]"; - break; - case "!": - arg = "[Fleur.XQueryX.simpleMapExpr,[[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg1val, "") + "]],[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg2val, "") + "]]]]"; - break; - case "|": - if (ops.startsWith("3.8.|8.31.catch")) { - if (arg1val.substr(0, 24) === "[Fleur.XQueryX.pathExpr,") { - arg1val2 = arg1val.substr(86); - arg1val = arg1val2.substr(0, arg1val2.length - 4); - } - if (arg2val.substr(0, 24) === "[Fleur.XQueryX.pathExpr,") { - arg2val2 = arg2val.substr(86); - arg2val = arg2val2.substr(0, arg2val2.length - 4); - arg = arg1val + "," + arg2val; - } else { - arg = "[Fleur.XQueryX.catchErrorList,[" + arg1val + "," + arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.catchErrorList,[") + 31); - } - } else { - arg = "[Fleur.XQueryX.unionOp,[[Fleur.XQueryX.firstOperand,[" + arg1val + "]],[Fleur.XQueryX.secondOperand,[" + arg2val + "]]]]"; - } - break; - case ":": - arg = "[Fleur.XQueryX.mapConstructorEntry,[[Fleur.XQueryX.mapKeyExpr,[" + arg1val + "]],[Fleur.XQueryX.mapValueExpr,[" + arg2val + "]]]]"; - break; - case "?": - break; - case "to": - arg = "[Fleur.XQueryX.rangeSequenceExpr,[[Fleur.XQueryX.startExpr,[" + arg1val + "]],[Fleur.XQueryX.endExpr,[" + arg2val + "]]]]"; - break; - case "~-": - arg = "[Fleur.XQueryX.unaryMinusOp,[[Fleur.XQueryX.operand,[" + arg2val + "]]]]"; - break; - case "~+": - arg = "[Fleur.XQueryX.unaryPlusOp,[[Fleur.XQueryX.operand,[" + arg2val + "]]]]"; - break; - case "allowing": - arg = "[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.allowingEmpty,[]]"; - break; - case "at": - if (arg1val.substr(0, 36) === "[Fleur.XQueryX.typedVariableBinding,") { - arg = arg1val + ",[Fleur.XQueryX.positionalVariableBinding,[" + arg2val.substr(0, arg2val.length - 4).substr(44) + "]]"; - } else { - arg = "[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.positionalVariableBinding,[" + arg2val.substr(0, arg2val.length - 4).substr(44) + "]]"; - } - break; - case "in": - if (ops.substr(ops.length - 7) === "5.999.q") { - arg = "[Fleur.XQueryX.quantifiedExprInClause,[[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.sourceExpr,[" + arg2val + "]]]]"; - } else if (arg1val.substr(0, 36) === "[Fleur.XQueryX.typedVariableBinding,") { - arg = "[Fleur.XQueryX.forClause,[[Fleur.XQueryX.forClauseItem,[" + arg1val + ",[Fleur.XQueryX.forExpr,[" + arg2val + "]]]]]]"; - } else { - arg = "[Fleur.XQueryX.forClause,[[Fleur.XQueryX.forClauseItem,[[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.forExpr,[" + arg2val + "]]]]]]"; - } - break; - case "as": - if (arg2val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['last']]]]]]") { - arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertInto,[[Fleur.XQueryX.insertAsLast,[]]]]"; - } else if (arg2val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['first']]]]]]") { - arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertInto,[[Fleur.XQueryX.insertAsFirst,[]]]]"; - } else { - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); - arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); - arg = "[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]],[Fleur.XQueryX.typeDeclaration,[" + arg2val3 + "]]"; - } - break; - case ":=": - if (ops.startsWith("5.18.:=11.30.group by") || ops.startsWith("5.18.:=5.29.~,11.30.group by")) { - if (arg1val.substr(0, 28) === "[Fleur.XQueryX.groupingSpec,") { - arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.groupVarInitialize,[[Fleur.XQueryX.varValue,[" + arg2val + "]]]]]]"; - } else { - arg = "[Fleur.XQueryX.groupingSpec,[[Fleur.XQueryX.varName,[" + arg1val.substr(44, arg1val.length - 48) + "]],[Fleur.XQueryX.groupVarInitialize,[[Fleur.XQueryX.varValue,[" + arg2val + "]]]]]]"; - } - } else if (arg1val.substr(0, 23) === "[Fleur.XQueryX.varName,") { - arg = "[Fleur.XQueryX.letClause,[[Fleur.XQueryX.letClauseItem,[[Fleur.XQueryX.typedVariableBinding,[" + arg1val + "]],[Fleur.XQueryX.letExpr,[" + arg2val + "]]]]]]"; - } else { - arg = "[Fleur.XQueryX.letClause,[[Fleur.XQueryX.letClauseItem,[[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.letExpr,[" + arg2val + "]]]]]]"; - } - break; - case "return": - arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.returnClause,[" + arg2val + "]]]]"; - break; - case "satisfies": - arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.predicateExpr,[" + arg2val + "]]]]"; - break; - case "cast as": - case "cast as?": - occ = op.charAt(7); - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); - arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); - arg = "[Fleur.XQueryX.castExpr,[[Fleur.XQueryX.argExpr,[" + arg1val + "]],[Fleur.XQueryX.singleType,[" + arg2val3 + (occ === "?" ? ",[Fleur.XQueryX.optional,[]]" : "") + "]]]]"; - break; - case "castable as": - case "castable as?": - occ = op.charAt(11); - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); - arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); - arg = "[Fleur.XQueryX.castableExpr,[[Fleur.XQueryX.argExpr,[" + arg1val + "]],[Fleur.XQueryX.singleType,[" + arg2val3 + (occ === "?" ? ",[Fleur.XQueryX.optional,[]]" : "") + "]]]]"; - break; - case "treat as": - case "treat as+": - case "treat as?": - case "treat as*": - occ = op.charAt(8); - if (arg2val.indexOf("[Fleur.XQueryX.nameTest,") !== -1) { - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); - arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); - } else if (arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") !== -1) { - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") + 86); - arg2val3 = arg2val2.substr(0, arg2val2.length - 4); - } else { - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['attribute']],") + 90); - arg2val3 = arg2val2.substr(0, arg2val2.length - 4); - } - arg = "[Fleur.XQueryX.treatExpr,[[Fleur.XQueryX.argExpr,[" + arg1val + "]],[Fleur.XQueryX.sequenceType,[" + arg2val3 + (occ !== "" ? ",[Fleur.XQueryX.occurrenceIndicator,['" + occ + "']]" : "") + "]]]]"; - break; - case "instance of": - case "instance of+": - case "instance of?": - case "instance of*": - occ = op.charAt(11); - if (arg2val.indexOf("[Fleur.XQueryX.nameTest,") !== -1) { - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); - arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); - } else if (arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") !== -1) { - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") + 86); - arg2val3 = arg2val2.substr(0, arg2val2.length - 4); - } else { - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['attribute']],") + 90); - arg2val3 = arg2val2.substr(0, arg2val2.length - 4); - } - arg = "[Fleur.XQueryX.instanceOfExpr,[[Fleur.XQueryX.argExpr,[" + arg1val + "]],[Fleur.XQueryX.sequenceType,[" + arg2val3 + (occ !== "" ? ",[Fleur.XQueryX.occurrenceIndicator,['" + occ + "']]" : "") + "]]]]"; - break; - case "then": - if (arg1val.substr(0, 95) === "[Fleur.XQueryX.functionCallExpr,[[Fleur.XQueryX.functionName,['if']],[Fleur.XQueryX.arguments,[") { - arg = "[Fleur.XQueryX.ifThenElseExpr,[[Fleur.XQueryX.ifClause,[" + arg1val.substr(0, arg1val.length - 4).substr(arg1val.indexOf(",[Fleur.XQueryX.arguments,[") + 27) + "]],[Fleur.XQueryX.thenClause,[" + arg2val + "]]]]"; - } - opprec = -1; - break; - case "else": - if (arg1val.substr(0, 30) === "[Fleur.XQueryX.ifThenElseExpr,") { - arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.elseClause,[" + arg2val + "]]]]"; - } - break; - case "catch": - if (arg1val.substr(0, 28) === "[Fleur.XQueryX.tryCatchExpr,") { - arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.catchClause,[" + arg2val + "]]]]"; - } - break; - case "let": - arg = arg1val + "," + arg2val; - break; - case "for": - arg = arg1val + "," + arg2val; - break; - case "group by": - arg = arg1val + ",[Fleur.XQueryX.groupByClause,[" + arg2val + "]]"; - break; - case "order by": - if (arg2val.substr(0, 27) === "[Fleur.XQueryX.orderBySpec,") { - arg = arg1val + ",[Fleur.XQueryX.orderByClause,[" + arg2val + "]]"; - } else { - arg = arg1val + ",[Fleur.XQueryX.orderByClause,[[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg2val + "]]]]]]"; - } - break; - case "~~ascending": - case "~~descending": - arg = "[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg1val + "]],[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.orderingKind,['" + op.substr(2) + "']]]]]]"; - break; - case "empty": - if (arg1val.substr(0,27) === "[Fleur.XQueryX.orderBySpec,") { - if (arg1val.endsWith(",[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.orderingKind,['ascending']]]]]]") || arg1val.endsWith(",[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.orderingKind,['descending']]]]]]")) { - arg = arg1val.substr(0, arg1val.length - 4) + ",[Fleur.XQueryX.emptyOrderingMode,['empty " + arg2val.substr(112, arg2val.length - 119) + "']]]]]]"; - } else { - arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.emptyOrderingMode,['empty " + arg2val.substr(112, arg2val.length - 119) + "']]]]]]"; - } - } else { - arg = "[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg1val + "]],[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.emptyOrderingMode,['empty " + arg2val.substr(112, arg2val.length - 119) + "']]]]]]"; - } - break; - case "where": - arg = arg1val + ",[Fleur.XQueryX.whereClause,[" + arg2val + "]]"; - break; - case "count": - arg = arg1val + ",[Fleur.XQueryX.countClause,[" + arg2val + "]]"; - break; - case "nodes": - if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['delete']]]]]]") { - arg = "[Fleur.XQueryX.deleteExpr,[[Fleur.XQueryX.targetExpr,[" + arg2val + "]]]]"; - } else if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['insert']]]]]]") { - arg = "[Fleur.XQueryX.insertExpr,[" + arg2val + "]]"; - } - break; - case "node": - if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['delete']]]]]]") { - arg = "[Fleur.XQueryX.deleteExpr,[[Fleur.XQueryX.targetExpr,[" + arg2val + "]]]]"; - } else if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['insert']]]]]]") { - arg = "[Fleur.XQueryX.insertExpr,[" + arg2val + "]]"; - } else if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['replace']]]]]]") { - arg = "[Fleur.XQueryX.replaceExpr,[" + arg2val + "]]"; - } else if (arg1val === "[Fleur.XQueryX.replaceValue,[]]") { - arg = "[Fleur.XQueryX.replaceExpr,[[Fleur.XQueryX.replaceValue,[]]," + arg2val + "]]"; - } - break; - case "into": - if (arg1val.substr(0, 28) === "[Fleur.XQueryX.sourceExprUf,") { - arg = arg1val + ",[Fleur.XQueryX.targetExpr,[" + arg2val + "]]"; - } else { - arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertInto,[]],[Fleur.XQueryX.targetExpr,[" + arg2val + "]]"; - } - break; - case "after": - arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertAfter,[]],[Fleur.XQueryX.targetExpr,[" + arg2val + "]]"; - break; - case "before": - arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertBefore,[]],[Fleur.XQueryX.targetExpr,[" + arg2val + "]]"; - break; - case "value": - if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['replace']]]]]]" && arg2val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['of']]]]]]") { - arg = "[Fleur.XQueryX.replaceValue,[]]"; - } - break; - case "with": - arg = "[Fleur.XQueryX.targetExpr,[" + arg1val + "]],[Fleur.XQueryX.replacementExpr,[" + arg2val + "]]"; - break; - default: - var opcode0 = Fleur.XPathEvaluator._opcodes.substr(Fleur.XPathEvaluator._opcodes.indexOf("." + op + ";") + op.length + 2); - var opcode = opcode0.substr(0, opcode0.indexOf(".")); - arg = "[Fleur.XQueryX." + opcode + ",[[Fleur.XQueryX.firstOperand,[" + arg1val + "]],[Fleur.XQueryX.secondOperand,[" + arg2val + "]]]]"; - } - var args2 = arg.length + "." + arg + args3.substr(arg1len.length + 1 + parseInt(arg1len, 10)); - return Fleur.XPathEvaluator._calc(args2, ops.substr(ops.indexOf(".") + 1).substr(parseInt(ops.substr(0, ops.indexOf(".")), 10)), opprec); - }; - Fleur.XPathEvaluator._testFormat = function(s, namecode) { - var arg1, arg2, arg20, arg200; - if (s === "") { - return ""; - } - if (s.indexOf(",[Fleur.XQueryX.pathExpr,[") !== -1) { - arg1 = s.substr(0, s.indexOf(",[Fleur.XQueryX.pathExpr,[")); - arg20 = s.substr(s.indexOf(",[Fleur.XQueryX.pathExpr,[") + 1); - arg200 = arg20.substr(arg20.indexOf("[Fleur.XQueryX.nameTest,['") + 25); - arg2 = "," + "[Fleur.XQueryX.typeName,[" + arg200.substr(0, arg200.length - 6) + "]]"; - } else { - arg1 = s; - arg2 = ""; - } - var arg120 = arg1.indexOf("[Fleur.XQueryX.nameTest,['") !== -1 ? arg1.substr(arg1.indexOf("[Fleur.XQueryX.nameTest,['") + 25) : "[Fleur.XQueryX.star,[]]"; - var arg12 = "[" + namecode + ",[" + (arg120 === "[Fleur.XQueryX.star,[]]" ? arg120 : "[Fleur.XQueryX.QName,[" + arg120.substr(0, arg120.length - 6) + "]]") + "]]"; - return arg12 + arg2; - }; - Fleur.XPathEvaluator._getNodeConstructor = function(s) { - var ii, text, texts, entityname, index, offset = 0, end = s.length, nodename, attrname, attrvalue, attrvalues, attrs, parents = [], currnodename = "", c, c0, c1, c2, braces, - seps_pi = " \t\n\r?", seps_close = " \t\n\r>", seps_elt = " \t\n\r/>", seps_attr = " \t\n\r=/<>", seps = " \t\n\r", rseps = /^\s*$/gm, - namespaces = {}, newnamespaces = {}, pindex, prefix, localName, r0, r = "", nextsep = ""; - while (offset !== end) { - text = ""; - texts = []; - c1 = " "; - c = s.charAt(offset); - braces = 0; - while ((c !== "<" || braces !== 0) && offset !== end) { - if (c === "{") { - if (braces === 0 && text !== "") { - if (/\S/.test(text.replace("\\n", "\n").replace("\\r", "\r"))) { - texts.push([0, text]); - } - text = ""; - } - if (braces !== 0) { - text += "{"; - } - if (c1 === c) { - braces--; - if (braces === 0) { - text = (texts.length > 0 ? texts.pop()[1] : "") + "{"; - } - } else { - braces++; - } - } else if (c === "}") { - if (braces === 1 && text !== "") { - texts.push([1, text]); - text = ""; - } - if (braces !== 1 && braces !== -1) { - text += "}"; - } - if (c1 === c) { - braces++; - } else { - braces--; - } - } else if (c === "&") { - c = s.charAt(++offset); - entityname = ""; - while (c !== ";" && offset !== end) { - entityname += c; - c = s.charAt(++offset); - } - if (offset === end) { - break; - } - if (entityname.charAt(0) === "#") { - text += String.fromCharCode(parseInt(entityname.charAt(1).toLowerCase() === 'x' ? "0" + entityname.substr(1).toLowerCase() : entityname.substr(1), entityname.charAt(1).toLowerCase() === 'x' ? 16 : 10)); - } else { - text += Fleur.encchars[entityname]; - } - } else if (braces === 0 && c === "\n") { - text += "\\n"; - } else if (braces === 0 && c === "\r") { - text += "\\r"; - } else { - text += c; - } - c1 = c; - c = s.charAt(++offset); - } - if (/\S/.test(text.replace("\\n", "\n").replace("\\r", "\r")) && texts.length === 0) { - r += nextsep + "[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + text.replace(/'/gm,"\\'") + "']]]]"; - nextsep = ","; - } else if (texts.length > 0) { - if (/\S/.test(text.replace("\\n", "\n").replace("\\r", "\r"))) { - texts.push([0, text]); - } - texts.forEach(function(t) { - r += nextsep; - if (t[0] === 0) { - r += "[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + t[1].replace(/'/gm,"\\'") + "']]]]"; - } else { - r += Fleur.XPathEvaluator._xp2js(t[1], "", ""); - } - nextsep = ","; - }); - } - if (offset === end) { - break; - } - offset++; - if (s.charAt(offset) === "!") { - offset++; - if (s.substr(offset, 2) === "--") { - offset += 2; - index = s.indexOf("-->", offset); - if (index !== offset) { - if (index === -1) { - index = end; - } - text = ""; - ii = offset; - while (ii < index) { - text += s.charAt(ii++); - } - text = text.replace(/\x01/gm,"<"); - r0 = "[Fleur.XQueryX.computedCommentConstructor,[[Fleur.XQueryX.argExpr,[[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + text + "']]]]]]]]"; - if (r === "") { - return offset + "." + r0; - } - r += nextsep + r0; - nextsep = ","; - if (index === end) { - break; - } - offset = index; - } - offset += 3; - } else if (s.substr(offset, 7) === "[CDATA[") { - offset += 7; - index = s.indexOf("]]>", offset); - if (index !== offset) { - if (index === -1) { - index = end; - } - text = ""; - ii = offset; - while (ii < index) { - text += s.charAt(ii++); - } - text = text.replace(/\x01/gm,"<"); - if (text !== "") { - r += nextsep + "[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + text + "']]]]"; - nextsep = ","; - } - if (index === end) { - break; - } - offset = index; - } - offset += 3; - } - } else if (s.charAt(offset) === "?") { - offset++; - c = s.charAt(offset++); - nodename = ""; - while (seps_pi.indexOf(c) === -1) { - nodename += c; - c = s.charAt(offset++); - } - index = s.indexOf("?>", offset - 1); - if (index === -1) { - index = end; - } - if (nodename.toLowerCase() === "xml") { - throw Error("Invalid processing instruction"); - } else if (nodename !== "") { - text = ""; - ii = offset; - while (ii < index) { - text += s.charAt(ii++); - } - text = text.replace(/\x01/gm,"<"); - r0 = "[Fleur.XQueryX.computedPIConstructor,[[Fleur.XQueryX.piTarget,['" + nodename + "']],[Fleur.XQueryX.piValueExpr,[[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + text + "']]]]]]]]"; - if (r === "") { - return String(index + 2) + "." + r0; - } - r += nextsep + r0; - nextsep = ","; - } - if (index === end) { - break; - } - offset = index + 2; - } else if (s.charAt(offset) === "/") { - offset++; - c = s.charAt(offset++); - nodename = ""; - while (seps_close.indexOf(c) === -1 && offset <= end) { - nodename += c; - c = s.charAt(offset++); - } - if (nodename === currnodename) { - if (nextsep !== ",") { - r += "]]"; - } else { - r += "]]]]"; - } - nextsep = ","; - if (parents.length === 1) { - return offset + "." + r; - } - currnodename = parents.pop(); - } else { - throw Error("Malformed XML fragment"); - } - offset = s.indexOf(">", offset - 1) + 1; - if (offset === 0) { - break; - } - } else { - c = s.charAt(offset++); - nodename = ""; - while (seps_elt.indexOf(c) === -1 && offset <= end) { - nodename += c; - c = s.charAt(offset++); - } - index = s.indexOf(">", offset - 1); - if (nodename !== "") { - newnamespaces = {}; - for (prefix in namespaces) { - if (namespaces.hasOwnProperty(prefix)) { - newnamespaces[prefix] = namespaces[prefix]; - } - } - attrs = {}; - while (offset <= end) { - while (seps.indexOf(c) !== -1 && offset <= end) { - c = s.charAt(offset++); - } - if (c === "/" || c === ">" || offset === end) { - break; - } - attrname = ""; - while (seps_attr.indexOf(c) === -1 && offset <= end) { - attrname += c; - c = s.charAt(offset++); - } - if (attrname === "") { - throw new Error("Invalid character: " + c); - } - while (seps.indexOf(c) !== -1 && offset <= end) { - c = s.charAt(offset++); - } - if (c === "=") { - c = s.charAt(offset++); - while (seps.indexOf(c) !== -1 && offset <= end) { - c = s.charAt(offset++); - } - attrvalue = ""; - attrvalues = []; - if (c === "'" || c === "\"") { - c0 = c; - c1 = c; - c = s.charAt(offset++); - c2 = s.charAt(offset); - braces = 0; - attrvalue = ""; - ii = offset; - while ((c !== c0 || c2 === c0 || braces !== 0) && offset <= end) { - if (c === "{") { - if (braces === 0 && attrvalue !== "") { - attrvalues.push([0, attrvalue]); - attrvalue = ""; - } - if (c1 === c) { - braces--; - if (braces === 0) { - attrvalue = (attrvalues.length > 0 ? attrvalues.pop()[1] : "") + "{"; - } - } else { - braces++; - } - } else if (c === "}") { - if (braces === 1 && attrvalue !== "") { - attrvalues.push([1, attrvalue]); - attrvalue = ""; - } - if (c1 === c) { - braces++; - if (braces === 0) { - attrvalue += "}"; - } - } else { - braces--; - } - } else if (c === c2 && c === c0) { - attrvalue += c; - c1 = c; - c = s.charAt(++offset); - c2 = s.charAt(++offset); - continue; - } else { - attrvalue += c; - } - c1 = c; - c = c2; - c2 = s.charAt(++offset); - } - if (attrvalue !== "") { - attrvalues.push([0, attrvalue]); - } - c = c2; - offset++; - } else { - while (seps_elt.indexOf(c) === -1 && offset <= end) { - attrvalue += c; - c = s.charAt(offset++); - } - attrvalues = [[0, attrvalue]]; - } - } else { - attrvalues = [[0, attrname]]; - } - pindex = attrname.indexOf(":"); - prefix = pindex !== -1 ? attrname.substr(0, pindex) : " "; - localName = pindex !== -1 ? attrname.substr(pindex + 1) : attrname; - if (!attrs[prefix]) { - attrs[prefix] = {}; - } - attrs[prefix][localName] = attrvalues; - if (prefix === "xmlns") { - newnamespaces[localName] = attrvalues; - } else if (prefix === " " && localName === "xmlns") { - newnamespaces[" "] = attrvalues; - } - } - pindex = nodename.indexOf(":"); - if (pindex === -1) { - r0 = nextsep + "[Fleur.XQueryX.elementConstructor,[[Fleur.XQueryX.tagName,['" + nodename + "']]"; - } else { - r0 = nextsep + "[Fleur.XQueryX.elementConstructor,[[Fleur.XQueryX.tagName,['" + nodename.substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + nodename.substr(0, pindex) + "']]]]"; - } - if (Object.keys(attrs).length) { - nextsep = ",[Fleur.XQueryX.attributeList,["; - if (attrs[" "] && attrs[" "].xmlns) { - r0 += nextsep + "[Fleur.XQueryX.namespaceDeclaration,[[Fleur.XQueryX.uri,[" + (attrs[" "].xmlns.length !== 0 ? "'" + attrs[" "].xmlns[0][1] + "'" : "") + "]]]]"; - nextsep = ","; - delete attrs[" "].xmlns; - } - for (attrname in attrs.xmlns) { - if (attrs.xmlns.hasOwnProperty(attrname)) { - r0 += nextsep + "[Fleur.XQueryX.namespaceDeclaration,[[Fleur.XQueryX.prefixElt,['" + attrname + "']],[Fleur.XQueryX.uri,['" + attrs.xmlns[attrname][0][1] + "']]]]"; - nextsep = ","; - } - } - delete attrs.xmlns; - for (prefix in attrs) { - if (attrs.hasOwnProperty(prefix)) { - for (attrname in attrs[prefix]) { - if (attrs[prefix].hasOwnProperty(attrname)) { - r0 += nextsep + "[Fleur.XQueryX.attributeConstructor,[[Fleur.XQueryX.attributeName,['" + attrname + "'"; - if (prefix !== " ") { - r0 += ",[Fleur.XQueryX.prefix,['" + prefix + "']]"; - } - r0 += "]],"; - if (attrs[prefix][attrname].length === 0) { - r0 += "[Fleur.XQueryX.attributeValue,[]]"; - nextsep = ","; - } else if (attrs[prefix][attrname].length === 1 && attrs[prefix][attrname][0][0] === 0) { - r0 += "[Fleur.XQueryX.attributeValue,['" + Fleur.DocumentType.resolveEntities(null, attrs[prefix][attrname][0][1]).replace(/'/gm,"\\'").replace(/\x01/gm,"<") + "']]"; - nextsep = ","; - } else { - nextsep = "[Fleur.XQueryX.attributeValueExpr,["; - attrs[prefix][attrname].forEach(function(v) { - r0 += nextsep; - if (v[0] === 0) { - r0 += "[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + Fleur.DocumentType.resolveEntities(null, v[1]).replace(/'/gm,"\\'") + "']]]]"; - } else { - r0 += Fleur.XPathEvaluator._xp2js(v[1], "", ""); - } - nextsep = ","; - }); - r0 += "]]"; - } - r0 += "]]"; - } - } - } - } - r0 += "]]"; - } - if (s.charAt(offset - 1) !== "/") { - nextsep = ",[Fleur.XQueryX.elementContent,["; - parents.push(currnodename); - currnodename = nodename; - r += r0; - } else { - if (r === "") { - return String(offset + 1) + "." + r0 + "]]"; - } - r += r0 + "]]"; - nextsep = ","; - } - } else { - throw Error("Invalid element name"); - } - offset = index + 1; - if (offset === 0) { - break; - } - } - } - }; - Fleur.XPathEvaluator._getPredParam = function(c, s, l, arg, allowpredicates, predstart, predarr, ops) { - var t; - l = l || 0; - var p, plen, arg20, arg2; - var isret = false; - if (c === "?") { - var i = Fleur.XPathEvaluator._skipSpaces(s, 0); - var c2 = s.charAt(i); - var d = s.substr(i + 1); - var r, t1; - if (c2 !== "" && "0123456789".indexOf(c2) !== -1) { - t1 = Fleur.XPathEvaluator._getNumber(c2 + d); - r = "[Fleur.XQueryX.lookup,[[Fleur.XQueryX.integerConstantExpr,[[Fleur.XQueryX.value,['" + t1.replace(/e\+/, "e") + "']]]]]]"; - t = (t1.length + 1) + "." + r; - plen = t1.length + 1; - } else if (c2 !== "" && "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(c2) !== -1) { - t1 = Fleur.XPathEvaluator._getName(c2 + d); - r = "[Fleur.XQueryX.lookup,[[Fleur.XQueryX.NCName,['" + t1 + "']]]]"; - t = (t1.length + 1) + "." + r; - plen = t1.length + 1; - } else if (c2 === "*") { - t = "2.[Fleur.XQueryX.lookup,[[Fleur.XQueryX.star,[]]]]"; - plen = 2; - } else if (c2 === "(") { - t = Fleur.XPathEvaluator._xp2js(s.substr(i + 1), "", "5.999.("); - plen = s.length - parseInt(t.substr(0, t.indexOf(".")), 10) + 1 + i; - t = String(plen) + "." + "[Fleur.XQueryX.lookup,[[Fleur.XQueryX.expr,[" + t.substr(t.indexOf(".") + 1) + "]]]]"; - } - } else { - var func = ""; - if (arg.indexOf("[Fleur.XQueryX.nameTest,['") !== -1) { - var func0 = arg.substr(arg.indexOf("[Fleur.XQueryX.nameTest,['") + 25); - func = func0.substr(0, func0.length - 6); - } - if (func === "'function'") { - t = "function"; - plen = s.length; - } else { - t = Fleur.XPathEvaluator._xp2js(s, "", l === 0 ? "" : arg.substr(0, 57) === "[Fleur.XQueryX.quantifiedExpr,[[Fleur.XQueryX.quantifier," ? "5.999.q" : "5.999.("); - plen = s.length - parseInt(t.substr(0, t.indexOf(".")), 10) + 1; - } - } - if (t.indexOf("~~~~") !== -1) { - var t0 = t + "~#~#"; - t0 = t0.substr(0, t0.indexOf("~#~#")); - t0 = t0.replace('"', ""); - var msg = '"~~~~' + t0.substr(t0.indexOf("~~~~") + 4) + "in '" + s + "'~#~#" + '"'; - p = plen + "." + msg; - throw Error(t0.substr(t0.indexOf("~~~~") + 4) + "in '" + s + "'"); - } else if (t === "") { - var msg2 = '"' + "~~~~Unrecognized expression '" + s + "'~#~#" + '"'; - p = plen + "." + msg2; - throw Error("Unrecognized expression '" + s + "'"); - } else if (c === "{") { - var cargs = t.substr(t.indexOf(".") + 1); - if (cargs.substr(0, 25) === "[Fleur.XQueryX.arguments,") { - cargs = "[Fleur.XQueryX.sequenceExpr," + cargs.substr(25); - } - if (arg.substr(0, 40) === "[Fleur.XQueryX.computedEntryConstructor," || arg.substr(0, 42) === "[Fleur.XQueryX.computedElementConstructor," || arg.substr(0, 44) === "[Fleur.XQueryX.computedAttributeConstructor,") { - p = plen + "." + arg.substr(0, arg.length - 2) + ",[Fleur.XQueryX.valueExpr,[" + cargs + "]]]]"; - } else if (arg.substr(0, 37) === "[Fleur.XQueryX.computedPIConstructor,") { - p = plen + "." + arg.substr(0, arg.length - 2) + ",[Fleur.XQueryX.piValueExpr,[" + cargs + "]]]]"; - } else { - var cname0 = arg.substr(arg.indexOf("[Fleur.XQueryX.nameTest,['") + 25); - var cname = cname0.substr(0, cname0.length - 6); - switch (cname) { - case "'document'": - p = plen + "." + "[Fleur.XQueryX.computedDocumentConstructor,[[Fleur.XQueryX.argExpr,[" + cargs + "]]]]"; - break; - case "'comment'": - p = plen + "." + "[Fleur.XQueryX.computedCommentConstructor,[[Fleur.XQueryX.argExpr,[" + cargs + "]]]]"; - break; - case "'map'": - var cargs2 = cargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? cargs.substr(26, cargs.length - 28) : cargs; - p = plen + "." + "[Fleur.XQueryX.mapConstructor,[" + cargs2 + "]]"; - break; - case "'array'": - var cargs3 = cargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? cargs.substr(26, cargs.length - 28) : cargs; - p = plen + "." + "[Fleur.XQueryX.arrayConstructor,[" + cargs3 + "]]"; - break; - case "'entry'": - p = plen + "." + "[Fleur.XQueryX.computedEntryConstructor,[[Fleur.XQueryX.tagNameExpr,[" + cargs + "]]]]"; - break; - case "'element'": - p = plen + "." + "[Fleur.XQueryX.computedElementConstructor,[[Fleur.XQueryX.tagNameExpr,[" + cargs + "]]]]"; - break; - case "'attribute'": - p = plen + "." + "[Fleur.XQueryX.computedAttributeConstructor,[[Fleur.XQueryX.tagNameExpr,[" + cargs + "]]]]"; - break; - case "'processing-instruction'": - p = plen + "." + "[Fleur.XQueryX.computedPIConstructor,[[Fleur.XQueryX.piTargetExpr,[" + cargs + "]]]]"; - break; - case "'text'": - p = plen + "." + "[Fleur.XQueryX.computedTextConstructor,[[Fleur.XQueryX.argExpr,[" + cargs + "]]]]"; - break; - case "'try'": - p = plen + "." + "[Fleur.XQueryX.tryCatchExpr,[[Fleur.XQueryX.tryClause,[" + cargs + "]]]]"; - break; - default: - if (ops.startsWith("8.31.catch") || ops.startsWith("3.8.|8.31.catch")) { - arg20 = arg.substr(86); - arg2 = arg20.substr(0, arg20.length - 4); - p = plen + "." + "[Fleur.XQueryX.catchErrorList,[" + arg2 + "]],[Fleur.XQueryX.catchExpr,[" + cargs + "]]"; - } - break; - } - } - } else if (c === "(") { - if (arg.substr(0, 77) === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['") { - var fname0 = arg.substr(arg.indexOf("[Fleur.XQueryX.nameTest,['") + 25); - var fname = fname0.substr(0, fname0.length - 6); - var fargs = t.substr(t.indexOf(".") + 1); - var fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; - var parg0, parg; - switch (fname) { - case "'array'": - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['array']]]]")) + "[Fleur.XQueryX.arrayTest,[]]]]]]"; - break; - case "'attribute'": - parg = Fleur.XPathEvaluator._testFormat(fargs2, "Fleur.XQueryX.attributeName"); - p = plen + "." + "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['attribute']],[Fleur.XQueryX.attributeTest,[" + parg + "]]]]]]"; - break; - case "'comment'": - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['comment']]]]")) + "[Fleur.XQueryX.commentTest,[]]]]]]"; - break; - case "'document-node'": - if (fargs2 !== "") { - parg0 = fargs2.substr(fargs2.indexOf("[Fleur.XQueryX.elementTest,[")); - parg = parg0.substr(0, parg0.length - 4); - } else { - parg = ""; - } - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['document-node']]]]")) + "[Fleur.XQueryX.documentTest,[" + parg + "]]]]]]"; - break; - case "'element'": - parg = Fleur.XPathEvaluator._testFormat(fargs2, "Fleur.XQueryX.elementName"); - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['element']]]]")) + "[Fleur.XQueryX.elementTest,[" + parg + "]]]]]]"; - break; - case "'entry'": - parg = Fleur.XPathEvaluator._testFormat(fargs2, "Fleur.XQueryX.entryName"); - p = plen + "." + "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['entry']],[Fleur.XQueryX.entryTest,[" + parg + "]]]]]]"; - break; - case "'function'": - var j = -1; - var xq = s; - var pindex, np, nbpar = 0; - var fres = "[Fleur.XQueryX.paramList,["; - var end = xq.length; - do { - j = Fleur.XPathEvaluator._skipSpaces(xq, j + 1); - c = xq.charAt(j); - if (c !== ")") { - if (c !== "$") { - throw Error("Unexpected char at '" + xq.substr(j) + "'"); - } - j++; - c = xq.charAt(j); - d = xq.substr(j + 1); - if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) === -1) { - throw Error("Unexpected char at '" + xq.substr(j) + "'"); - } - var pname = Fleur.XPathEvaluator._getName(c + d); - j = Fleur.XPathEvaluator._skipSpaces(xq, j + pname.length); - c = xq.charAt(j); - var tdecl = ""; - if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) !== -1) { - d = xq.substr(j + 1); - r = Fleur.XPathEvaluator._getName(c + d); - if (r === "as") { - j = Fleur.XPathEvaluator._skipSpaces(xq, j + r.length); - c = xq.charAt(j); - if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) !== -1) { - d = xq.substr(j + 1); - var ptype = Fleur.XPathEvaluator._getName(c + d); - pindex = ptype.indexOf(":"); - np = pindex === -1 ? "'" + ptype + "'" : "'" + ptype.substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + ptype.substr(0, pindex) + "']]"; - c = xq.charAt(j + ptype.length); - tdecl = ",[Fleur.XQueryX.typeDeclaration,[[Fleur.XQueryX.atomicType,[" + np + "]]"; - if ("?+*".indexOf(c) !== -1) { - tdecl += ",[Fleur.XQueryX.occurrenceIndicator,['" + c + "']]"; - j++; - } - tdecl += "]]"; - j = Fleur.XPathEvaluator._skipSpaces(xq, j + ptype.length); - c = xq.charAt(j); - } - } - } - if (nbpar !== 0) { - fres += ","; - } - fres += "[Fleur.XQueryX.param,[[Fleur.XQueryX.varName,['" + pname + "']]" + tdecl + "]]"; - nbpar++; - } - } while (c === ","); - if (c !== ")") { - throw Error("Unexpected char at '" + xq.substr(j) + "'"); - } - fres += "]]"; - j = Fleur.XPathEvaluator._skipSpaces(xq, j + 1); - c = xq.charAt(j); - if (c === "a") { - d = xq.substr(j + 1); - r = Fleur.XPathEvaluator._getName(c + d); - if (r === "as") { - j = Fleur.XPathEvaluator._skipSpaces(xq, j + r.length); - c = xq.charAt(j); - if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) !== -1) { - d = xq.substr(j + 1); - ptype = Fleur.XPathEvaluator._getName(c + d); - pindex = ptype.indexOf(":"); - np = pindex === -1 ? "'" + ptype + "'" : "'" + ptype.substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + ptype.substr(0, pindex) + "']]"; - c = xq.charAt(j + ptype.length); - fres += ",[Fleur.XQueryX.typeDeclaration,[[Fleur.XQueryX.atomicType,[" + np + "]]"; - if ("?+*".indexOf(c) !== -1) { - fres += ",[Fleur.XQueryX.occurrenceIndicator,['" + c + "']]"; - j++; - } - fres += "]]"; - j = Fleur.XPathEvaluator._skipSpaces(xq, j + ptype.length); - c = xq.charAt(j); - } - } - } - if (c === "{") { - fres += ",[Fleur.XQueryX.functionBody,["; - var braces = 1; - var body = ""; - while ((c !== "}" || braces !== 0) && j !== end) { - c = xq.charAt(++j); - if (c === "{") { - braces++; - } else if (c === "}") { - braces--; - } - if (braces !== 0) { - body += c; - } - } - if (body !== "") { - fres += Fleur.XPathEvaluator._xp2js(body, "", ""); - } - fres += "]]"; - } else { - throw Error("Unexpected char at '" + xq.substr(j) + "'"); - } - plen = j + 2; - p = plen + ".[Fleur.XQueryX.inlineFunctionExpr,[" + fres + "]]"; - break; - case "'item'": - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['item']]]]")) + "[Fleur.XQueryX.anyItemType,[]]]]]]"; - break; - case "'map'": - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['map']]]]")) + "[Fleur.XQueryX.mapTest,[]]]]]]"; - break; - case "'namespace-node'": - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['namespace-node']]]]")) + "[Fleur.XQueryX.namespaceTest,[]]]]]]"; - break; - case "'node'": - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['node']]]]")) + "[Fleur.XQueryX.anyKindTest,[]]]]]]"; - break; - case "'processing-instruction'": - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['processing-instruction']]]]")) + "[Fleur.XQueryX.piTest,[" + (fargs2 ? "[Fleur.XQueryX.piTarget,[" + fargs2.substr(57) : "]]") + "]]]]"; - break; - case "'schema-attribute'": - parg0 = fargs.substr(fargs.indexOf("[Fleur.XQueryX.nameTest,['") + 25); - parg = parg0.substr(0, parg0.length - 6); - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['schema-attribute']]]]")) + "[Fleur.XQueryX.schemaAttributeTest,[" + parg + "]]]]]]"; - break; - case "'schema-element'": - parg0 = fargs.substr(fargs.indexOf("[Fleur.XQueryX.nameTest,['") + 25); - parg = parg0.substr(0, parg0.length - 6); - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['schema-element']]]]")) + "[Fleur.XQueryX.schemaElementTest,[" + parg + "]]]]]]"; - break; - case "'text'": - p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['text']]]]")) + "[Fleur.XQueryX.textTest,[]]]]]]"; - break; - default: - p = plen + ".[Fleur.XQueryX.functionCallExpr,[[Fleur.XQueryX.functionName,[" + fname + "]],[Fleur.XQueryX.arguments,[" + fargs2 + "]]]]"; - } - } else if (arg.substr(0, 77) === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[") { - var arg1, lookup = false; - if (arg.indexOf(",[Fleur.XQueryX.predicates,[") !== -1) { - arg1 = arg.substr(0, arg.indexOf(",[Fleur.XQueryX.predicates,[")).substr(77); - arg20 = arg.substr(arg.indexOf(",[Fleur.XQueryX.predicates,[") + 28); - arg2 = arg20.substr(0, arg20.length - 6); - } else if (arg.indexOf(",[Fleur.XQueryX.lookup,[") !== -1) { - lookup = true; - arg1 = arg.substr(0, arg.indexOf(",[Fleur.XQueryX.lookup,[")).substr(77); - arg20 = arg.substr(arg.indexOf(",[Fleur.XQueryX.lookup,[") + 24); - arg2 = arg20.substr(0, arg20.length - 6); - } else { - arg1 = arg.substr(0, arg.length - 8).substr(77); - arg2 = ""; - } - fargs = t.substr(t.indexOf(".") + 1); - fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; - p = plen + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[[Fleur.XQueryX.dynamicFunctionInvocationExpr,[[Fleur.XQueryX.functionItem,[" + arg1 + (arg2 === "" ? "" : (lookup ? ",[Fleur.XQueryX.lookup,[" : ",[Fleur.XQueryX.predicates,[")+ arg2 + "]]") + (fargs2 === "" ? "" : ",[Fleur.XQueryX.arguments,[" + fargs2 + "]]") + "]]]]]]]]"; - } else if (arg.substr(0, 32) === "[Fleur.XQueryX.namedFunctionRef,") { - p = plen + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[[Fleur.XQueryX.dynamicFunctionInvocationExpr,[[Fleur.XQueryX.functionItem,[" + arg + "]]]]]]]]]]"; - } else if (arg === "[Fleur.XQueryX.flworExpr,[]]") { - fargs = t.substr(t.indexOf(".") + 1); - fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; - p = plen + ".[Fleur.XQueryX.flworExpr,[" + fargs2 + "]]"; - isret = true; - } else if (arg.substr(0, 57) === "[Fleur.XQueryX.quantifiedExpr,[[Fleur.XQueryX.quantifier,") { - fargs = t.substr(t.indexOf(".") + 1); - fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; - p = plen + "." + arg.substr(0, arg.length - 2) + "," + fargs2 + "]]"; - isret = true; - } else if (arg !== "") { - fargs = t.substr(t.indexOf(".") + 1); - fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; - p = plen + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[[Fleur.XQueryX.dynamicFunctionInvocationExpr,[[Fleur.XQueryX.functionItem,[" + arg + "]]" + (fargs2 === "" ? "" : ",[Fleur.XQueryX.arguments,[" + fargs2 + "]]") + "]]]]]]]]"; - } else { - p = plen + "." + t.substr(t.indexOf(".") + 1); - } - } else { - if (arg.substr(0, 25) !== "[Fleur.XQueryX.pathExpr,[") { - arg = "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[" + arg + "]]]]]]"; - } - if (c === "?") { - if (arg.indexOf(",[Fleur.XQueryX.predicates,[") === -1) { - p = plen + "." + arg.substr(0, arg.length - 4) + "," + t.substr(t.indexOf(".") + 1) + "]]]]"; - } else { - p = plen + "." + arg.substr(0, predstart) + predarr.reduce(function(s, pr) {return s + ",[Fleur.XQueryX.predicate,[" + pr + "]]";}, "") + "," + t.substr(t.indexOf(".") + 1) + "]]]]";; - } - allowpredicates = false; - } else if (arg.indexOf(",[Fleur.XQueryX.predicates,[") === -1) { - if (allowpredicates) { - predarr = []; - predarr.push(t.substr(t.indexOf(".") + 1)); - predstart = arg.length - 4; - } - p = plen + "." + arg.substr(0, arg.length - 4) + ",[" + (allowpredicates ? "Fleur.XQueryX.predicates" : "Fleur.XQueryX.predicate") + ",[" + t.substr(t.indexOf(".") + 1) + "]]]]]]"; - } else { - if (allowpredicates) { - predarr.push(t.substr(t.indexOf(".") + 1)); - } - p = plen + "." + arg.substr(0, arg.length - 6) + "," + t.substr(t.indexOf(".") + 1) + "]]]]]]"; - } - } - if (!isret) { - var inext = Fleur.XPathEvaluator._skipSpaces(s, plen - 1); - var cnext = s.charAt(inext); - if (cnext === "(" || cnext === "[" || cnext === "{" || cnext === "?") { - return Fleur.XPathEvaluator._getPredParam(cnext, s.substr(inext + 1), l + inext + 1, p.substr(p.indexOf(".") + 1), allowpredicates, predstart, predarr, ops); - } - } - return (l + plen) + "." + p.substr(p.indexOf(".") + 1); - }; - Fleur.XPathEvaluator._getPredParams = function(s, len, arg, ops) { - var i = Fleur.XPathEvaluator._skipSpaces(s, 0); - if (s.charAt(i) === "(" || s.charAt(i) === "[" || s.charAt(i) === "{" || (s.charAt(i) === "?" && ops.substr(0, 16) !== "13.6.instance of" && ops.substr(0, 16) !== "9.3.cast as" && ops.substr(0, 16) !== "13.4.castable as")) { - return Fleur.XPathEvaluator._getPredParam(s.charAt(i), s.substr(i + 1), len + i, arg, true, 0, [], ops); - } - return (len + i) + "." + arg; - }; - Fleur.XPathEvaluator._getStringLiteral = function(s) { - var i = Fleur.XPathEvaluator._skipSpaces(s, 0); - var d = s.substr(i + 1); - if (s.charAt(i) === "'") { - var sep2 = d.indexOf("'"); - var t2 = d.substr(0, d.indexOf("'")); - while (d.substr(sep2 + 1, 1) === "'") { - var d2 = d.substr(sep2 + 2); - t2 += "\\'" + d2.substr(0, d2.indexOf("'")); - sep2 += 2 + d2.indexOf("'"); - } - var t2b = "'" + Fleur.DocumentType.resolveEntities(null, t2) + "'"; - if (t2b === "''") { - t2b = ""; - } - return (sep2 + 2) + "." + t2b; - } else if (s.charAt(i) === '"') { - var sep3 = d.indexOf('"'); - var t3 = d.substr(0, d.indexOf('"')); - while (d.substr(sep3 + 1, 1) === '"') { - var d3 = d.substr(sep3 + 2); - t3 += '\\"' + d3.substr(0, d3.indexOf('"')); - sep3 += 2 + d3.indexOf('"'); - } - var t3b = '"' + Fleur.DocumentType.resolveEntities(null, t3) + '"'; - if (t3b === '""') { - t3b = ""; - } - return (sep3 + 2) + "." + t3b; - } - }; - Fleur.XPathEvaluator._getNumber = function(s, r) { - r = r || ""; - if (s === "") { - return r; - } - var c = s.charAt(0); - if (c === "E") { - c = "e"; - } - if ("0123456789".indexOf(c) !== -1 || ((c === "." || c === "e") && r.indexOf(c) === -1) || - ((c === "-" || c === "+") && r.endsWith("e"))) { - return Fleur.XPathEvaluator._getNumber(s.substr(1), r + c); - } - return r; - }; - Fleur.XPathEvaluator._xp2js = function(xp, args, ops) { - var i = Fleur.XPathEvaluator._skipSpaces(xp, 0); - var c = xp.charAt(i); - var d = xp.substr(i + 1); - var d2; - var r = ""; - if (c === "." && (d === "" || "0123456789".indexOf(d.charAt(0)) === -1)) { - if (d.charAt(0) === ".") { - r = "2.[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['parent']],[Fleur.XQueryX.anyKindTest,[]]]]]]"; - } else { - r = "1.[Fleur.XQueryX.contextItemExpr,[]]"; - } - } else if (c === ")" || c === "}") { - r = "0."; - } else if (c === "/") { - var ir = Fleur.XPathEvaluator._skipSpaces(d, 0); - r = (d.charAt(0) === "" || "/@*.(_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(d.charAt(ir)) === -1 ? "1" : "0") + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.rootExpr,[]]]]"; - } else if (c === "@") { - r = Fleur.XPathEvaluator._getNameStep(d, 1); - } else if (c === "'") { - var sep2 = d.indexOf("'"); - var t2 = Fleur.DocumentType.resolveEntities(null, d.substr(0, d.indexOf("'"))).replace(/[\\]/g, '\\\\').replace(/[\"]/g, '\\\"').replace(/[\/]/g, '\\/').replace(/[\b]/g, '\\b').replace(/[\f]/g, '\\f').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r').replace(/[\t]/g, '\\t'); - while (d.substr(sep2 + 1, 1) === "'") { - d2 = d.substr(sep2 + 2); - t2 += "\\'" + Fleur.DocumentType.resolveEntities(null, d2.substr(0, d2.indexOf("'"))).replace(/[\\]/g, '\\\\').replace(/[\"]/g, '\\\"').replace(/[\/]/g, '\\/').replace(/[\b]/g, '\\b').replace(/[\f]/g, '\\f').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r').replace(/[\t]/g, '\\t'); - sep2 += 2 + d2.indexOf("'"); - } - var t2b = "'" + t2 + "'"; - if (t2b === "''") { - t2b = ""; - } - r = (sep2 + 2) + ".[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,[" + t2b + "]]]]"; - } else if (c === '"') { - var sep3 = d.indexOf('"'); - var t3 = Fleur.DocumentType.resolveEntities(null, d.substr(0, d.indexOf('"'))).replace(/[\\]/g, '\\\\').replace(/[\']/g, "\\\'").replace(/[\/]/g, '\\/').replace(/[\b]/g, '\\b').replace(/[\f]/g, '\\f').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r').replace(/[\t]/g, '\\t'); - while (d.substr(sep3 + 1, 1) === '"') { - var d3 = d.substr(sep3 + 2); - t3 += '\\"' + Fleur.DocumentType.resolveEntities(null, d3.substr(0, d3.indexOf('"'))).replace(/[\\]/g, '\\\\').replace(/[\']/g, "\\\'").replace(/[\/]/g, '\\/').replace(/[\b]/g, '\\b').replace(/[\f]/g, '\\f').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r').replace(/[\t]/g, '\\t'); - sep3 += 2 + d3.indexOf('"'); - } - var t3b = '"' + t3 + '"'; - if (t3b === '""') { - t3b = ""; - } - r = (sep3 + 2) + ".[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,[" + t3b + "]]]]"; - } else if (c === "(") { - var endseq = Fleur.XPathEvaluator._skipSpaces(d, 0); - if (d.charAt(endseq) === ")") { - r = String(2 + endseq) + ".[Fleur.XQueryX.sequenceExpr,[]]"; - } else { - r = "0."; - } - } else if (c === "-" || c === "+") { - c = "~" + c; - r = "0."; - } else if (c !== "" && ".0123456789".indexOf(c) !== -1) { - var t5 = Fleur.XPathEvaluator._getNumber(c + d); - r = t5.length + ".[" + (t5.indexOf("e") !== -1 ? "Fleur.XQueryX.doubleConstantExpr" : t5.indexOf(".") !== -1 ? "Fleur.XQueryX.decimalConstantExpr" : "Fleur.XQueryX.integerConstantExpr") + ",[[Fleur.XQueryX.value,['" + t5.replace(/e\+/, "e") + "']]]]"; - } else if (c === "$") { - var t51 = Fleur.XPathEvaluator._getName(d); - var pt51 = (t51.indexOf(":") === -1 ? ":" : "") + t51; - var instr; - if (ops.startsWith("11.30.group by") || ops.startsWith("5.29.~,11.30.group by")) { - instr = "[Fleur.XQueryX.groupingSpec,[[Fleur.XQueryX.varName,["; - } else { - instr = "[Fleur.XQueryX.varRef,[[Fleur.XQueryX.name,["; - } - r = (t51.length + 1) + "." + instr + "'" + pt51.substr(pt51.indexOf(":") + 1) + "'" + (pt51.charAt(0) === ":" ? "" : ",[Fleur.XQueryX.prefix,['" + pt51.substr(0, pt51.indexOf(":")) + "']]") + "]]]]"; - } else if (c === "?") { - var c2 = d.charAt(0); - d = d.substr(1); - var t52; - if (c2 !== "" && "0123456789".indexOf(c2) !== -1) { - t52 = Fleur.XPathEvaluator._getNumber(c2 + d); - r = String(t52.length) + ".[Fleur.XQueryX.unaryLookup,[[Fleur.XQueryX.integerConstantExpr,[[Fleur.XQueryX.value,['" + t52.replace(/e\+/, "e") + "']]]]]]"; - } else if (c2 !== "" && "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(c2) !== -1) { - t52 = Fleur.XPathEvaluator._getName(c2 + d); - r = String(t52.length) + ".[Fleur.XQueryX.unaryLookup,[[Fleur.XQueryX.NCName,['" + t52 + "']]]]"; - } else if (c2 === "*") { - r = "1.[Fleur.XQueryX.unaryLookup,[[Fleur.XQueryX.star,[]]]]"; - } else if (c2 === "(") { - t52 = Fleur.XPathEvaluator._xp2js(d, "", "5.999.("); - var plen52 = d.length - parseInt(t52.substr(0, t52.indexOf(".")), 10) + 1; - r = String(plen52) + "." + "[Fleur.XQueryX.unaryLookup,[[Fleur.XQueryX.expr,[" + t52.substr(t52.indexOf(".") + 1) + "]]]]"; - } - } else if (c !== "" && "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz*".indexOf(c) !== -1) { - var t61 = Fleur.XPathEvaluator._getName(c+d); - if (["element","attribute","entry","processing-instruction"].indexOf(t61) !== -1) { - var i61 = Fleur.XPathEvaluator._skipSpaces(xp, i + t61.length); - var c61 = xp.charAt(i61); - if (c61 !== "" && "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(c61) !== -1) { - var d61 = xp.substr(i61 + 1); - var t62 = Fleur.XPathEvaluator._getName(c61 + d61); - switch(t61) { - case "element": - r = String(i61 - i + t62.length) + ".[Fleur.XQueryX.computedElementConstructor,[[Fleur.XQueryX.tagName,['" + t62 + "']]]]"; - break; - case "attribute": - r = String(i61 - i + t62.length) + ".[Fleur.XQueryX.computedAttributeConstructor,[[Fleur.XQueryX.tagName,['" + t62 + "']]]]"; - break; - case "processing-instruction": - r = String(i61 - i + t62.length) + ".[Fleur.XQueryX.computedPIConstructor,[[Fleur.XQueryX.piTarget,['" + t62 + "']]]]"; - break; - case "entry": - r = String(i61 - i + t62.length) + ".[Fleur.XQueryX.computedEntryConstructor,[[Fleur.XQueryX.tagName,['" + t62 + "']]]]"; - } - } else { - r = Fleur.XPathEvaluator._getNameStep(c + d, 0); - } - } else { - r = Fleur.XPathEvaluator._getNameStep(c + d, 0); - } - } else if (c === "<") { - r = Fleur.XPathEvaluator._getNodeConstructor(c + d); - } else { - r = "~~~~Unexpected char at '" + c + d + "'~#~#"; - throw Error("Unexpected char at '" + c + d + "'"); - } - if (r.indexOf("~~~~") !== -1) { - return r; - } - var rlen = parseInt(r.substr(0, r.indexOf(".")), 10); - var rval = r.substr(r.indexOf(".") + 1); - d2 = rlen === 0 ? c + d : d.substr(rlen - 1); - r = Fleur.XPathEvaluator._getPredParams(d2, rlen, rval, ops); - rlen = parseInt(r.substr(0, r.indexOf(".")), 10); - rval = r.substr(r.indexOf(".") + 1); - var args2 = rval.length + "." + rval + args; - var f = rlen === 0 ? c + d : d.substr(rlen - 1); - var i4 = Fleur.XPathEvaluator._skipSpaces(f, 0); - var o = f.charAt(i4); - var p = f.substr(f.indexOf(o)); - var op = "null"; - var op2 = "null"; - if ((p.substr(0, 9) === "ascending" || p.substr(0, 10) === "descending") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(o === "a" ? 9 : 10)) === -1) { - var postprec0 = Fleur.XPathEvaluator._precedence.substr(Fleur.XPathEvaluator._precedence.indexOf(".~~" + (o === "a" ? "ascending" : "descending") + ".") + (o === "a" ? 13 : 14)); - var postprec00 = postprec0.substr(postprec0.indexOf("&") + 1); - var postprec = postprec00.substr(0, postprec00.indexOf(".")); - var poststacks = Fleur.XPathEvaluator._calc(args2, ops, parseInt(postprec, 10)); - var postargslen = poststacks.substr(0, poststacks.indexOf(".")); - args2 = poststacks.substr(poststacks.indexOf(".") + 1).substr(0, parseInt(postargslen, 10)); - var postnextstack = poststacks.substr(postargslen.length + 1 + parseInt(postargslen, 10)); - var postopslen = postnextstack.substr(0, postnextstack.indexOf(".")); - ops = (postprec.length + 1 + (o === "a" ? 11 : 12)) + "." + postprec + ".~~" + (o === "a" ? "ascending" : "descending") + postnextstack.substr(postnextstack.indexOf(".") + 1).substr(0, parseInt(postopslen, 10)); - f = f.substr(i4 + (o === "a" ? 9 : 10)); - i4 = Fleur.XPathEvaluator._skipSpaces(f, 0); - o = f.charAt(i4); - p = f.substr(f.indexOf(o)); - } - if (ops.substr(0, 16) === "13.6.instance of") { - if (o === "+" || o === "?" || o === "*") { - ops = "14.6.instance of" + o + ops.substr(16); - i4 = Fleur.XPathEvaluator._skipSpaces(f, 1); - o = f.charAt(i4); - p = f.substr(f.indexOf(o)); - } - } else if (ops.substr(0, 13) === "10.5.treat as") { - if (o === "+" || o === "?" || o === "*") { - ops = "11.5.treat as" + o + ops.substr(13); - i4 = Fleur.XPathEvaluator._skipSpaces(f, 1); - o = f.charAt(i4); - p = f.substr(f.indexOf(o)); - } - } else if (ops.substr(0, 11) === "9.3.cast as") { - if (o === "?") { - ops = "10.3.cast as" + o + ops.substr(11); - i4 = Fleur.XPathEvaluator._skipSpaces(f, 1); - o = f.charAt(i4); - p = f.substr(f.indexOf(o)); - } - } else if (ops.substr(0, 16) === "13.4.castable as") { - if (o === "?") { - ops = "14.4.castable as" + o + ops.substr(16); - i4 = Fleur.XPathEvaluator._skipSpaces(f, 1); - o = f.charAt(i4); - p = f.substr(f.indexOf(o)); - } - } - if (o === "") { - var stacks = Fleur.XPathEvaluator._calc(args2, ops, 9999999); - var reslen0 = stacks.substr(stacks.indexOf(".") + 1); - var reslen = reslen0.substr(0, reslen0.indexOf(".")); - var ret0 = stacks.substr(stacks.indexOf(".") + 1); - return ret0.substr(ret0.indexOf(".") + 1).substr(0, parseInt(reslen, 10)); - } - if (o === "]" || o === ")" || o === "}" || (p.substr(0, 6) === "return" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(6)) === -1) || (p.substr(0, 9) === "satisfies" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(9)) === -1)) { - var stacks2 = Fleur.XPathEvaluator._calc(args2, ops, 998); - var reslen20 = stacks2.substr(stacks2.indexOf(".") + 1); - var reslen2 = reslen20.substr(0, reslen20.indexOf(".")); - var ret20 = stacks2.substr(stacks2.indexOf(".") + 1); - return (f.substr(f.indexOf(o) + 1).length - (o === "r" ? 5 : o === "s" ? 8 : 0)) + "." + ret20.substr(ret20.indexOf(".") + 1).substr(0, parseInt(reslen2, 10)); - } - if (o === "$") { - switch(rval) { - case "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['for']]]]]]": - rval = "[Fleur.XQueryX.flworExpr,[]]"; - op = "for"; - break; - case "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['let']]]]]]": - rval = "[Fleur.XQueryX.flworExpr,[]]"; - op = "let"; - break; - case "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['every']]]]]]": - rval = "[Fleur.XQueryX.quantifiedExpr,[[Fleur.XQueryX.quantifier,['every']]]]"; - op = "every"; - break; - case "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['some']]]]]]": - rval = "[Fleur.XQueryX.quantifiedExpr,[[Fleur.XQueryX.quantifier,['some']]]]"; - op = "some"; - break; - } - if (op !== "null") { - r = Fleur.XPathEvaluator._getPredParams("(" + f, rlen, rval); - rlen = parseInt(r.substr(0, r.indexOf(".")), 10); - rval = r.substr(r.indexOf(".") + 1); - args2 = rval.length + "." + rval + args; - op = op === "for" || op === "let" ? "return" : "satisfies"; - f = d.substr(rlen - 2 - op.length); - p = f.substr(1); - } - } else if (p.substr(0, 9) === "intersect" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(9)) === -1) { - op = p.substr(0, 9); - } else if (p.substr(0, 8) === "allowing" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(8)) === -1) { - op = p.substr(0, 8); - } else if (p.substr(0, 8) === "instance" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(8)) === -1) { - op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 8) + 2); - op2 = "instance of"; - } else if (p.substr(0, 8) === "castable" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(8)) === -1) { - op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 8) + 2); - op2 = "castable as"; - } else if ((p.substr(0, 6) === "except" || p.substr(0, 6) === "before") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(6)) === -1) { - op = p.substr(0, 6); - } else if (p.substr(0, 5) === "treat" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(5)) === -1) { - op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 5) + 2); - op2 = "treat as"; - } else if (p.substr(0, 5) === "group" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(5)) === -1) { - op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 5) + 2); - op2 = "group by"; - } else if (p.substr(0, 5) === "order" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(5)) === -1) { - op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 5) + 2); - op2 = "order by"; - } else if ((p.substr(0, 5) === "union" || p.substr(0, 5) === "every" || p.substr(0, 5) === "nodes" || p.substr(0, 5) === "after" || p.substr(0, 5) === "value" || p.substr(0, 5) === "count" || p.substr(0, 5) === "where" || p.substr(0, 5) === "empty" || p.substr(0, 5) === "catch") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(5)) === -1) { - op = p.substr(0, 5); - } else if (p.substr(0, 4) === "cast" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(4)) === -1) { - op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 4) + 2); - op2 = "cast as"; - } else if ((p.substr(0, 4) === "idiv" || p.substr(0, 4) === "some" || p.substr(0, 4) === "then" || p.substr(0, 4) === "else" || p.substr(0, 4) === "node" || p.substr(0, 4) === "with" || p.substr(0, 4) === "into") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(4)) === -1) { - op = p.substr(0, 4); - } else if ((p.substr(0, 3) === "div" || p.substr(0, 3) === "and" || p.substr(0, 3) === "mod" || p.substr(0, 3) === "let" || p.substr(0, 3) === "for") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(3)) === -1) { - op = p.substr(0, 3); - } else if ((p.substr(0, 2) === "or" || p.substr(0, 2) === "eq" || p.substr(0, 2) === "ne" || p.substr(0, 2) === "lt" || p.substr(0, 2) === "le" || p.substr(0, 2) === "gt" || p.substr(0, 2) === "ge" || p.substr(0, 2) === "is" || p.substr(0, 2) === "to" || p.substr(0, 2) === "in" || p.substr(0, 2) === "as" || p.substr(0, 2) === "at" || p.substr(0, 2) === "by") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(2)) === -1) { - op = p.substr(0, 2); - } else if (p.substr(0, 2) === "!=" || p.substr(0, 2) === "<=" || p.substr(0, 2) === ">=" || p.substr(0, 2) === "<<" || p.substr(0, 2) === ">>" || p.substr(0, 2) === "//" || p.substr(0, 2) === "~+" || p.substr(0, 2) === "~-" || p.substr(0, 2) === ":=" || p.substr(0, 2) === "||" || p.substr(0, 2) === "!!") { - op = p.substr(0, 2); - } else if ("+-*=|,;<>/!{:".indexOf(o) !== -1) { - op = o; - if (op === ",") { - if (ops.startsWith("5.18.:=") || ops.startsWith("11.30.group by") || ops.startsWith("5.29.~,11.30.group by")) { - op2 = "~,"; - } else { - var optrack = ops; - while (optrack !== "") { - if (optrack.startsWith("11.30.order by")) { - op2 = "~,"; - break; - } - var optracklen = parseInt(optrack.substr(0, optrack.indexOf(".")), 10); - var optrackprec0 = optrack.substring(optrack.indexOf(".") + 1, optracklen); - var optrackprec = parseInt(optrackprec0.substr(0, optrackprec0.indexOf(".")), 10); - if (optrackprec > 30) { - break; - } - optrack = optrack.substr(optrack.indexOf(".") + 1 + optracklen); - } - } - } - } - if (op !== "null") { - var opprec0 = Fleur.XPathEvaluator._precedence.substr(Fleur.XPathEvaluator._precedence.indexOf("." + (op2 !== "null" ? op2 : op) + ".") + (op2 !== "null" ? op2 : op).length + 2); - var opprec00 = opprec0.substr(opprec0.indexOf("&") + 1); - var opprec = opprec00.substr(0, opprec00.indexOf(".")); - var stacks3 = Fleur.XPathEvaluator._calc(args2, ops, parseInt(opprec, 10)); - var args3len = stacks3.substr(0, stacks3.indexOf(".")); - var args3 = stacks3.substr(stacks3.indexOf(".") + 1).substr(0, parseInt(args3len, 10)); - var nextstack = stacks3.substr(args3len.length + 1 + parseInt(args3len, 10)); - var ops3len = nextstack.substr(0, nextstack.indexOf(".")); - var ops3 = nextstack.substr(nextstack.indexOf(".") + 1).substr(0, parseInt(ops3len, 10)); - var xp3 = p.substr(op.length); - return Fleur.XPathEvaluator._xp2js(xp3, args3, (opprec.length + 1 + (op2 !== "null" ? op2 : op).length) + "." + opprec + "." + (op2 !== "null" ? op2 : op) + ops3); - } - throw Error("Unknown operator at '" + f + "'"); - }; - Fleur.XPathEvaluator._getVersion = function(xq) { - var i = Fleur.XPathEvaluator._skipSpaces(xq, 0); - var c = xq.charAt(i); - var d = xq.substr(i + 1); - var r = ""; - var v, e; - if (c === "" || "abcdefghijklmnopqrstuvwxyz".indexOf(c) === -1) { - return i + "."; - } - r = Fleur.XPathEvaluator._getName(c + d); - if (r === "xquery") { - var j = Fleur.XPathEvaluator._skipSpaces(xq, i + r.length); - c = xq.charAt(j); - d = xq.substr(j + 1); - if (c === "" || "abcdefghijklmnopqrstuvwxyz".indexOf(c) === -1) { - return i + "."; - } - r = Fleur.XPathEvaluator._getName(c + d); - if (r === "version") { - j = Fleur.XPathEvaluator._skipSpaces(xq, j + r.length); - c = xq.charAt(j); - d = xq.substr(j + 1); - if (c !== "'" && c !== '"') { - return i + "."; - } - r = Fleur.XPathEvaluator._getStringLiteral(c + d); - var vl = r.substr(0, r.indexOf(".")); - v = r.substr(vl.length + 1); - j = Fleur.XPathEvaluator._skipSpaces(xq, j + parseInt(vl, 10)); - c = xq.charAt(j); - if (c === ";") { - return (j + 1) + ".[Fleur.XQueryX.versionDecl,[[Fleur.XQueryX.version,[" + v + "]]]],"; - } - d = xq.substr(j + 1); - r = Fleur.XPathEvaluator._getName(c + d); - } - if (r === "encoding") { - j = Fleur.XPathEvaluator._skipSpaces(xq, j + r.length); - c = xq.charAt(j); - d = xq.substr(j + 1); - if (c !== "'" && c !== '"') { - return i + "."; - } - r = Fleur.XPathEvaluator._getStringLiteral(c + d); - var el = r.substr(0, r.indexOf(".")); - e = r.substr(el.length + 1); - j = Fleur.XPathEvaluator._skipSpaces(xq, j + parseInt(el, 10)); - c = xq.charAt(j); - if (c === ";") { - return (j + 1) + ".[Fleur.XQueryX.versionDecl,[" + (v ? "[Fleur.XQueryX.version,[" + v + "]]," : "") + "[Fleur.XQueryX.encoding,[" + e + "]]]],"; - } - } - } - return i + "."; - }; - })(typeof exports === 'undefined'? this.Fleur = {}: exports); + console.info('Fleur 1.0 (15), XPath 1.0 Parser, copyright (C) 2023 agenceXML - Alain Couthures, contact at fleur@agencexml.com'); + (function(Fleur) { + Fleur.Node = function() {}; + Fleur.Node.ELEMENT_NODE = 1; + Fleur.Node.ATTRIBUTE_NODE = 2; + Fleur.Node.TEXT_NODE = 3; + Fleur.Node.CDATA_NODE = 4; + Fleur.Node.ENTITY_REFERENCE_NODE = 5; + Fleur.Node.ENTITY_NODE = 6; + Fleur.Node.PROCESSING_INSTRUCTION_NODE = 7; + Fleur.Node.COMMENT_NODE = 8; + Fleur.Node.DOCUMENT_NODE = 9; + Fleur.Node.DOCUMENT_TYPE_NODE = 10; + Fleur.Node.DOCUMENT_FRAGMENT_NODE = 11; + Fleur.Node.NOTATION_NODE = 12; + Fleur.Node.NAMESPACE_NODE = 129; + Fleur.Node.ATOMIC_NODE = Fleur.Node.TEXT_NODE; + Fleur.Node.SEQUENCE_NODE = 130; + Fleur.Node.ARRAY_NODE = 131; + Fleur.Node.MAP_NODE = 132; + Fleur.Node.ENTRY_NODE = 133; + Fleur.minimal = true; + Fleur.DocumentType = function() {}; + Fleur.DocumentType.resolveEntities = function(doctype, s) { + var offset = 0, index, entityname, entityvalue = null; + while ((index = s.indexOf("&", offset)) !== -1) { + entityname = s.substring(index + 1, s.indexOf(";", index + 1)); + switch (entityname) { + case "amp": + entityvalue = "&"; + break; + case "lt": + entityvalue = "<"; + break; + case "gt": + entityvalue = ">"; + break; + case "apos": + entityvalue = "'"; + break; + case "quot": + entityvalue = '"'; + break; + default: + if (entityname.charAt(0) === "#") { + entityvalue = String.fromCharCode(parseInt(entityname.charAt(1).toLowerCase() === 'x' ? "0" + entityname.substr(1).toLowerCase() : entityname.substr(1), entityname.charAt(1).toLowerCase() === 'x' ? 16 : 10)); + } else if (doctype) { + entityvalue = doctype.getEntity(entityname); + } + } + if (entityvalue) { + s = s.substr(0, index) + entityvalue + s.substr(index + entityname.length + 2); + offset = index + entityvalue.length; + entityvalue = null; + } else { + break; + } + } + return s.split("\r\n").join("\n"); + }; + Fleur.Serializer = function() {}; + Fleur.Serializer.escapeXML = function(s) { + return s.replace(/&/g, "&").replace(//g, ">"); + }; + Fleur.Serializer.prototype._serializeXMLToString = function(node, indent, offset, cdataSectionElements) { + var s, i, l; + switch (node.nodeType) { + case Fleur.Node.ELEMENT_NODE: + s = (indent ? offset + "\x3C" : "\x3C") + node.nodeName; + if (indent) { + var names = []; + for (i = 0, l = node.attributes.length; i < l; i++) { + names.push(node.attributes[i].nodeName); + } + names.sort(); + for (i = 0, l = names.length; i < l; i++) { + s += " " + names[i] + "=\"" + Fleur.Serializer.escapeXML(node.getAttribute(names[i])).replace('"', """) + "\""; + } + } else { + for (i = 0, l = node.attributes.length; i < l; i++) { + s += " " + node.attributes[i].nodeName + "=\"" + Fleur.Serializer.escapeXML(node.attributes[i].nodeValue).replace('"', """) + "\""; + } + } + if (node.childNodes.length === 0) { + return s + (indent ? "/\x3E\n" : "/\x3E"); + } + s += indent && (node.childNodes[0].nodeType !== Fleur.Node.TEXT_NODE || node.childNodes[0].data.match(/^[ \t\n\r]*$/)) ? "\x3E\n" : "\x3E"; + if (cdataSectionElements.indexOf(" " + node.nodeName + " ") !== -1) { + for (i = 0, l = node.childNodes.length; i < l; i++) { + if (node.childNodes[i].nodeType === Fleur.Node.TEXT_NODE) { + s += "\x3C![CDATA["; + s += node.childNodes[i].data; + s += "]]\x3E"; + } else { + s += this._serializeXMLToString(node.childNodes[i], indent, offset + " ", cdataSectionElements); + } + } + } else { + for (i = 0, l = node.childNodes.length; i < l; i++) { + s += this._serializeXMLToString(node.childNodes[i], indent, offset + " ", cdataSectionElements); + } + } + return s + (indent && (node.childNodes[0].nodeType !== Fleur.Node.TEXT_NODE || node.childNodes[0].data.match(/^[ \t\n\r]*$/)) ? offset + "\x3C/" : "\x3C/") + node.nodeName + (indent ? "\x3E\n" : "\x3E"); + case Fleur.Node.TEXT_NODE: + if (indent && node.data.match(/^[ \t\n\r]*$/) && node.parentNode.childNodes.length !== 1) { + return ""; + } + return Fleur.Serializer.escapeXML(node.data); + case Fleur.Node.CDATA_NODE: + return (indent ? offset + "\x3C![CDATA[" : "\x3C![CDATA[") + node.data + (indent ? "]]\x3E\n" : "]]\x3E"); + case Fleur.Node.PROCESSING_INSTRUCTION_NODE: + return (indent ? offset + "\x3C?" : "\x3C?") + node.nodeName + " " + node.nodeValue + (indent ? "?\x3E\n" : "?\x3E"); + case Fleur.Node.COMMENT_NODE: + return (indent ? offset + "\x3C!--" : "\x3C!--") + node.data + (indent ? "--\x3E\n" : "--\x3E"); + case Fleur.Node.DOCUMENT_NODE: + s = '\x3C?xml version="1.0" encoding="UTF-8"?\x3E\r\n'; + for (i = 0, l = node.childNodes.length; i < l; i++) { + s += this._serializeXMLToString(node.childNodes[i], indent, offset, cdataSectionElements); + } + return s; + } + }; + Fleur.Serializer.prototype.serializeToString = function(node, mediatype, indent, cdataSectionElements) { + var media = mediatype.split(";"), config = {}, param, paramreg = /^\s*(\S*)\s*=\s*(\S*)\s*$/, i = 1, l = media.length, ser; + while (i < l) { + param = paramreg.exec(media[i]); + config[param[1]] = param[2]; + i++; + } + switch (media[0].replace(/^\s+|\s+$/gm,'')) { + case "text/xml": + case "application/xml": + ser = this._serializeXMLToString(node, indent, "", " " + cdataSectionElements + " "); + if (indent && ser.charAt(ser.length - 1) === "\n") { + ser = ser.substr(0, ser.length - 1); + } + return ser; + } + }; + Fleur.XMLSerializer = function() {}; + Fleur.XMLSerializer.prototype = new Fleur.Serializer(); + Fleur.XMLSerializer.prototype.serializeToString = function(node, indent, cdataSectionElements) { + return Fleur.Serializer.prototype.serializeToString.call(this, node, "application/xml", indent, cdataSectionElements); + }; + Fleur.Xlength = 0; + Fleur.XQueryXNames = [["http://www.w3.org/2005/XQueryX", "http://www.w3.org/2000/xmlns/", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/2007/xquery-update-10"], []]; + Fleur.XQueryX = {}; + Fleur.XQueryXNames[1][Fleur.XQueryX.NCName = Fleur.Xlength++] = [1, 0, "xqx:NCName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.QName = Fleur.Xlength++] = [1, 0, "xqx:QName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.URIExpr = Fleur.Xlength++] = [1, 0, "xqx:URIExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.Wildcard = Fleur.Xlength++] = [1, 0, "xqx:Wildcard"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.addOp = Fleur.Xlength++] = [1, 0, "xqx:addOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.allowingEmpty = Fleur.Xlength++] = [1, 0, "xqx:allowingEmpty"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.andOp = Fleur.Xlength++] = [1, 0, "xqx:andOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.annotation = Fleur.Xlength++] = [1, 0, "xqx:annotation"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.annotationName = Fleur.Xlength++] = [1, 0, "xqx:annotationName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.anyElementTest = Fleur.Xlength++] = [1, 0, "xqx:anyElementTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.anyFunctionTest = Fleur.Xlength++] = [1, 0, "xqx:anyFunctionTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.anyItemType = Fleur.Xlength++] = [1, 0, "xqx:anyItemType"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.anyKindTest = Fleur.Xlength++] = [1, 0, "xqx:anyKindTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.arrayConstructor = Fleur.Xlength++] = [1, 0, "xqx:arrayConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.argExpr = Fleur.Xlength++] = [1, 0, "xqx:argExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.argumentPlaceholder = Fleur.Xlength++] = [1, 0, "xqx:argumentPlaceholder"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.arguments = Fleur.Xlength++] = [1, 0, "xqx:arguments"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.arithmeticOp = Fleur.Xlength++] = [1, 0, "xqx:arithmeticOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.arrayTest = Fleur.Xlength++] = [1, 0, "xqx:arrayTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.atomicType = Fleur.Xlength++] = [1, 0, "xqx:atomicType"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.attributeConstructor = Fleur.Xlength++] = [1, 0, "xqx:attributeConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.attributeList = Fleur.Xlength++] = [1, 0, "xqx:attributeList"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.attributeName = Fleur.Xlength++] = [1, 0, "xqx:attributeName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.attributeTest = Fleur.Xlength++] = [1, 0, "xqx:attributeTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.attributeValue = Fleur.Xlength++] = [1, 0, "xqx:attributeValue"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.attributeValueExpr = Fleur.Xlength++] = [1, 0, "xqx:attributeValueExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.baseUriDecl = Fleur.Xlength++] = [1, 0, "xqx:baseUriDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.bindingSequence = Fleur.Xlength++] = [1, 0, "xqx:bindingSequence"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.boundarySpaceDecl = Fleur.Xlength++] = [1, 0, "xqx:boundarySpaceDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.castExpr = Fleur.Xlength++] = [1, 0, "xqx:castExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.castableExpr = Fleur.Xlength++] = [1, 0, "xqx:castableExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.catchClause = Fleur.Xlength++] = [1, 0, "xqx:catchClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.catchErrorList = Fleur.Xlength++] = [1, 0, "xqx:catchErrorList"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.catchExpr = Fleur.Xlength++] = [1, 0, "xqx:catchExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.collation = Fleur.Xlength++] = [1, 0, "xqx:collation"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.commentTest = Fleur.Xlength++] = [1, 0, "xqx:commentTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.comparisonOp = Fleur.Xlength++] = [1, 0, "xqx:comparisonOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.computedAttributeConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedAttributeConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.computedCommentConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedCommentConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.computedDocumentConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedDocumentConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.computedElementConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedElementConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.computedEntryConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedEntryConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.computedNamespaceConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedNamespaceConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.computedPIConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedPIConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.computedTextConstructor = Fleur.Xlength++] = [1, 0, "xqx:computedTextConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.constantExpr = Fleur.Xlength++] = [1, 0, "xqx:constantExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.constructionDecl = Fleur.Xlength++] = [1, 0, "xqx:constructionDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.constructorFunctionExpr = Fleur.Xlength++] = [1, 0, "xqx:constructorFunctionExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.contentExpr = Fleur.Xlength++] = [1, 0, "xqx:contentExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.contextItemDecl = Fleur.Xlength++] = [1, 0, "xqx:contextItemDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.contextItemExpr = Fleur.Xlength++] = [1, 0, "xqx:contextItemExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.copyNamespacesDecl = Fleur.Xlength++] = [1, 0, "xqx:copyNamespacesDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.countClause = Fleur.Xlength++] = [1, 0, "xqx:countClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.currentItem = Fleur.Xlength++] = [1, 0, "xqx:currentItem"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.decimalConstantExpr = Fleur.Xlength++] = [1, 0, "xqx:decimalConstantExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatDecl = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatName = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatParam = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatParam"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatParamName = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatParamName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.decimalFormatParamValue = Fleur.Xlength++] = [1, 0, "xqx:decimalFormatParamValue"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.defaultCollationDecl = Fleur.Xlength++] = [1, 0, "xqx:defaultCollationDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.defaultElementNamespace = Fleur.Xlength++] = [1, 0, "xqx:defaultElementNamespace"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.defaultNamespaceCategory = Fleur.Xlength++] = [1, 0, "xqx:defaultNamespaceCategory"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.defaultNamespaceDecl = Fleur.Xlength++] = [1, 0, "xqx:defaultNamespaceDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.divOp = Fleur.Xlength++] = [1, 0, "xqx:divOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.documentTest = Fleur.Xlength++] = [1, 0, "xqx:documentTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.doubleConstantExpr = Fleur.Xlength++] = [1, 0, "xqx:doubleConstantExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.doubleMapExpr = Fleur.Xlength++] = [1, 0, "xqx:doubleMapExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.dynamicFunctionInvocationExpr = Fleur.Xlength++] = [1, 0, "xqx:dynamicFunctionInvocationExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.elementConstructor = Fleur.Xlength++] = [1, 0, "xqx:elementConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.elementContent = Fleur.Xlength++] = [1, 0, "xqx:elementContent"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.elementName = Fleur.Xlength++] = [1, 0, "xqx:elementName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.elementTest = Fleur.Xlength++] = [1, 0, "xqx:elementTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.elseClause = Fleur.Xlength++] = [1, 0, "xqx:elseClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.emptyOrderingDecl = Fleur.Xlength++] = [1, 0, "xqx:emptyOrderingDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.emptyOrderingMode = Fleur.Xlength++] = [1, 0, "xqx:emptyOrderingMode"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.encoding = Fleur.Xlength++] = [1, 0, "xqx:encoding"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.endExpr = Fleur.Xlength++] = [1, 0, "xqx:endExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.entryTest = Fleur.Xlength++] = [1, 0, "xqx:entryTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.eqOp = Fleur.Xlength++] = [1, 0, "xqx:eqOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.equalOp = Fleur.Xlength++] = [1, 0, "xqx:equalOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.exceptOp = Fleur.Xlength++] = [1, 0, "xqx:exceptOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.expr = Fleur.Xlength++] = [1, 0, "xqx:expr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.extensionExpr = Fleur.Xlength++] = [1, 0, "xqx:extensionExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.external = Fleur.Xlength++] = [1, 0, "xqx:external"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.externalDefinition = Fleur.Xlength++] = [1, 0, "xqx:externalDefinition"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.filterExpr = Fleur.Xlength++] = [1, 0, "xqx:filterExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.firstOperand = Fleur.Xlength++] = [1, 0, "xqx:firstOperand"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.flworExpr = Fleur.Xlength++] = [1, 0, "xqx:flworExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.forClause = Fleur.Xlength++] = [1, 0, "xqx:forClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.forClauseItem = Fleur.Xlength++] = [1, 0, "xqx:forClauseItem"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.forExpr = Fleur.Xlength++] = [1, 0, "xqx:forExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.forLetClauseItemExtensions = Fleur.Xlength++] = [1, 0, "xqx:forLetClauseItemExtensions"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.functionBody = Fleur.Xlength++] = [1, 0, "xqx:functionBody"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.functionCallExpr = Fleur.Xlength++] = [1, 0, "xqx:functionCallExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.functionDecl = Fleur.Xlength++] = [1, 0, "xqx:functionDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.functionItem = Fleur.Xlength++] = [1, 0, "xqx:functionItem"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.functionName = Fleur.Xlength++] = [1, 0, "xqx:functionName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.geOp = Fleur.Xlength++] = [1, 0, "xqx:geOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.generalComparisonOp = Fleur.Xlength++] = [1, 0, "xqx:generalComparisonOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.greaterThanOp = Fleur.Xlength++] = [1, 0, "xqx:greaterThanOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.greaterThanOrEqualOp = Fleur.Xlength++] = [1, 0, "xqx:greaterThanOrEqualOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.groupByClause = Fleur.Xlength++] = [1, 0, "xqx:groupByClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.groupVarInitialize = Fleur.Xlength++] = [1, 0, "xqx:groupVarInitialize"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.groupingSpec = Fleur.Xlength++] = [1, 0, "xqx:groupingSpec"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.gtOp = Fleur.Xlength++] = [1, 0, "xqx:gtOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.idivOp = Fleur.Xlength++] = [1, 0, "xqx:idivOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.ifClause = Fleur.Xlength++] = [1, 0, "xqx:ifClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.ifThenElseExpr = Fleur.Xlength++] = [1, 0, "xqx:ifThenElseExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.inheritMode = Fleur.Xlength++] = [1, 0, "xqx:inheritMode"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.inlineFunctionExpr = Fleur.Xlength++] = [1, 0, "xqx:inlineFunctionExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.instanceOfExpr = Fleur.Xlength++] = [1, 0, "xqx:instanceOfExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.integerConstantExpr = Fleur.Xlength++] = [1, 0, "xqx:integerConstantExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.intersectOp = Fleur.Xlength++] = [1, 0, "xqx:intersectOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.isOp = Fleur.Xlength++] = [1, 0, "xqx:isOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.itemType = Fleur.Xlength++] = [1, 0, "xqx:itemType"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.javascriptImport = Fleur.Xlength++] = [1, 0, "xqx:javascriptImport"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.kindTest = Fleur.Xlength++] = [1, 0, "xqx:kindTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.leOp = Fleur.Xlength++] = [1, 0, "xqx:leOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.lessThanOp = Fleur.Xlength++] = [1, 0, "xqx:lessThanOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.lessThanOrEqualOp = Fleur.Xlength++] = [1, 0, "xqx:lessThanOrEqualOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.letClause = Fleur.Xlength++] = [1, 0, "xqx:letClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.letClauseItem = Fleur.Xlength++] = [1, 0, "xqx:letClauseItem"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.letExpr = Fleur.Xlength++] = [1, 0, "xqx:letExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.libraryModule = Fleur.Xlength++] = [1, 0, "xqx:libraryModule"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.logicalOp = Fleur.Xlength++] = [1, 0, "xqx:logicalOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.lookup = Fleur.Xlength++] = [1, 0, "xqx:lookup"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.ltOp = Fleur.Xlength++] = [1, 0, "xqx:ltOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.mainModule = Fleur.Xlength++] = [1, 0, "xqx:mainModule"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.mapConstructor = Fleur.Xlength++] = [1, 0, "xqx:mapConstructor"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.mapConstructorEntry = Fleur.Xlength++] = [1, 0, "xqx:mapConstructorEntry"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.mapKeyExpr = Fleur.Xlength++] = [1, 0, "xqx:mapKeyExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.mapTest = Fleur.Xlength++] = [1, 0, "xqx:mapTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.mapValueExpr = Fleur.Xlength++] = [1, 0, "xqx:mapValueExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.modOp = Fleur.Xlength++] = [1, 0, "xqx:modOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.module = Fleur.Xlength++] = [1, 0, "xqx:module"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.moduleDecl = Fleur.Xlength++] = [1, 0, "xqx:moduleDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.moduleImport = Fleur.Xlength++] = [1, 0, "xqx:moduleImport"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.multidimExpr = Fleur.Xlength++] = [1, 0, "xqx:multidimExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.multiplyOp = Fleur.Xlength++] = [1, 0, "xqx:multiplyOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.name = Fleur.Xlength++] = [1, 0, "xqx:name"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.nameTest = Fleur.Xlength++] = [1, 0, "xqx:nameTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.namedFunctionRef = Fleur.Xlength++] = [1, 0, "xqx:namedFunctionRef"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.namespaceDecl = Fleur.Xlength++] = [1, 0, "xqx:namespaceDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.namespaceDeclaration = Fleur.Xlength++] = [1, 0, "xqx:namespaceDeclaration"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.namespacePrefix = Fleur.Xlength++] = [1, 0, "xqx:namespacePrefix"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.namespaceTest = Fleur.Xlength++] = [1, 0, "xqx:namespaceTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.neOp = Fleur.Xlength++] = [1, 0, "xqx:neOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.nextItem = Fleur.Xlength++] = [1, 0, "xqx:nextItem"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.nillable = Fleur.Xlength++] = [1, 0, "xqx:nillable"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.nodeAfterOp = Fleur.Xlength++] = [1, 0, "xqx:nodeAfterOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.nodeBeforeOp = Fleur.Xlength++] = [1, 0, "xqx:nodeBeforeOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.nodeComparisonOp = Fleur.Xlength++] = [1, 0, "xqx:nodeComparisonOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.notEqualOp = Fleur.Xlength++] = [1, 0, "xqx:notEqualOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.occurrenceIndicator = Fleur.Xlength++] = [1, 0, "xqx:occurrenceIndicator"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.operand = Fleur.Xlength++] = [1, 0, "xqx:operand"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.operatorExpr = Fleur.Xlength++] = [1, 0, "xqx:operatorExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.optionContents = Fleur.Xlength++] = [1, 0, "xqx:optionContents"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.optionDecl = Fleur.Xlength++] = [1, 0, "xqx:optionDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.optionName = Fleur.Xlength++] = [1, 0, "xqx:optionName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.optional = Fleur.Xlength++] = [1, 0, "xqx:optional"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.orOp = Fleur.Xlength++] = [1, 0, "xqx:orOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.orderByClause = Fleur.Xlength++] = [1, 0, "xqx:orderByClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.orderByExpr = Fleur.Xlength++] = [1, 0, "xqx:orderByExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.orderBySpec = Fleur.Xlength++] = [1, 0, "xqx:orderBySpec"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.orderComparisonOp = Fleur.Xlength++] = [1, 0, "xqx:orderComparisonOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.orderModifier = Fleur.Xlength++] = [1, 0, "xqx:orderModifier"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.orderedExpr = Fleur.Xlength++] = [1, 0, "xqx:orderedExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.orderingKind = Fleur.Xlength++] = [1, 0, "xqx:orderingKind"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.orderingModeDecl = Fleur.Xlength++] = [1, 0, "xqx:orderingModeDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.param = Fleur.Xlength++] = [1, 0, "xqx:param"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.paramList = Fleur.Xlength++] = [1, 0, "xqx:paramList"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.paramTypeList = Fleur.Xlength++] = [1, 0, "xqx:paramTypeList"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.parenthesizedItemType = Fleur.Xlength++] = [1, 0, "xqx:parenthesizedItemType"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.pathExpr = Fleur.Xlength++] = [1, 0, "xqx:pathExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.piTarget = Fleur.Xlength++] = [1, 0, "xqx:piTarget"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.piTargetExpr = Fleur.Xlength++] = [1, 0, "xqx:piTargetExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.piTest = Fleur.Xlength++] = [1, 0, "xqx:piTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.piValueExpr = Fleur.Xlength++] = [1, 0, "xqx:piValueExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.positionalVariableBinding = Fleur.Xlength++] = [1, 0, "xqx:positionalVariableBinding"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.pragma = Fleur.Xlength++] = [1, 0, "xqx:pragma"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.pragmaContents = Fleur.Xlength++] = [1, 0, "xqx:pragmaContents"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.pragmaName = Fleur.Xlength++] = [1, 0, "xqx:pragmaName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.predicate = Fleur.Xlength++] = [1, 0, "xqx:predicate"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.predicateExpr = Fleur.Xlength++] = [1, 0, "xqx:predicateExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.predicates = Fleur.Xlength++] = [1, 0, "xqx:predicates"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.prefixElt = Fleur.Xlength++] = [1, 0, "xqx:prefix"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.prefixExpr = Fleur.Xlength++] = [1, 0, "xqx:prefixExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.preserveMode = Fleur.Xlength++] = [1, 0, "xqx:preserveMode"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.previousItem = Fleur.Xlength++] = [1, 0, "xqx:previousItem"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.prolog = Fleur.Xlength++] = [1, 0, "xqx:prolog"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.prologPartOneItem = Fleur.Xlength++] = [1, 0, "xqx:prologPartOneItem"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.prologPartTwoItem = Fleur.Xlength++] = [1, 0, "xqx:prologPartTwoItem"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.quantifiedExpr = Fleur.Xlength++] = [1, 0, "xqx:quantifiedExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.quantifiedExprInClause = Fleur.Xlength++] = [1, 0, "xqx:quantifiedExprInClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.quantifier = Fleur.Xlength++] = [1, 0, "xqx:quantifier"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.queryBody = Fleur.Xlength++] = [1, 0, "xqx:queryBody"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.rangeSequenceExpr = Fleur.Xlength++] = [1, 0, "xqx:rangeSequenceExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.resultExpr = Fleur.Xlength++] = [1, 0, "xqx:resultExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.returnClause = Fleur.Xlength++] = [1, 0, "xqx:returnClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.rootExpr = Fleur.Xlength++] = [1, 0, "xqx:rootExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.schemaAttributeTest = Fleur.Xlength++] = [1, 0, "xqx:schemaAttributeTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.schemaElementTest = Fleur.Xlength++] = [1, 0, "xqx:schemaElementTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.schemaImport = Fleur.Xlength++] = [1, 0, "xqx:schemaImport"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.secondOperand = Fleur.Xlength++] = [1, 0, "xqx:secondOperand"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.sequenceExpr = Fleur.Xlength++] = [1, 0, "xqx:sequenceExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.sequenceType = Fleur.Xlength++] = [1, 0, "xqx:sequenceType"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.sequenceTypeUnion = Fleur.Xlength++] = [1, 0, "xqx:sequenceTypeUnion"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.setOp = Fleur.Xlength++] = [1, 0, "xqx:setOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.simpleMapExpr = Fleur.Xlength++] = [1, 0, "xqx:simpleMapExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.singleType = Fleur.Xlength++] = [1, 0, "xqx:singleType"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.slidingWindowClause = Fleur.Xlength++] = [1, 0, "xqx:slidingWindowClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.sourceExpr = Fleur.Xlength++] = [1, 0, "xqx:sourceExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.stable = Fleur.Xlength++] = [1, 0, "xqx:stable"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.star = Fleur.Xlength++] = [1, 0, "xqx:star"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.startExpr = Fleur.Xlength++] = [1, 0, "xqx:startExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.stepExpr = Fleur.Xlength++] = [1, 0, "xqx:stepExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.stringConcatenateOp = Fleur.Xlength++] = [1, 0, "xqx:stringConcatenateOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.stringConstantExpr = Fleur.Xlength++] = [1, 0, "xqx:stringConstantExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.stringOp = Fleur.Xlength++] = [1, 0, "xqx:stringOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.subtractOp = Fleur.Xlength++] = [1, 0, "xqx:subtractOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.switchCaseExpr = Fleur.Xlength++] = [1, 0, "xqx:switchCaseExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.switchExpr = Fleur.Xlength++] = [1, 0, "xqx:switchExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.switchExprCaseClause = Fleur.Xlength++] = [1, 0, "xqx:switchExprCaseClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.switchExprDefaultClause = Fleur.Xlength++] = [1, 0, "xqx:switchExprDefaultClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.tagName = Fleur.Xlength++] = [1, 0, "xqx:tagName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.tagNameExpr = Fleur.Xlength++] = [1, 0, "xqx:tagNameExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.targetLocation = Fleur.Xlength++] = [1, 0, "xqx:targetLocation"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.targetLocationExpr = Fleur.Xlength++] = [1, 0, "xqx:targetLocationExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.targetNamespace = Fleur.Xlength++] = [1, 0, "xqx:targetNamespace"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.textTest = Fleur.Xlength++] = [1, 0, "xqx:textTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.thenClause = Fleur.Xlength++] = [1, 0, "xqx:thenClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.treatExpr = Fleur.Xlength++] = [1, 0, "xqx:treatExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.tryCatchExpr = Fleur.Xlength++] = [1, 0, "xqx:tryCatchExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.tryClause = Fleur.Xlength++] = [1, 0, "xqx:tryClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.tumblingWindowClause = Fleur.Xlength++] = [1, 0, "xqx:tumblingWindowClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.typeDeclaration = Fleur.Xlength++] = [1, 0, "xqx:typeDeclaration"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.typeName = Fleur.Xlength++] = [1, 0, "xqx:typeName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.typedFunctionTest = Fleur.Xlength++] = [1, 0, "xqx:typedFunctionTest"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.typedVariableBinding = Fleur.Xlength++] = [1, 0, "xqx:typedVariableBinding"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.typeswitchExpr = Fleur.Xlength++] = [1, 0, "xqx:typeswitchExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.typeswitchExprCaseClause = Fleur.Xlength++] = [1, 0, "xqx:typeswitchExprCaseClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.typeswitchExprDefaultClause = Fleur.Xlength++] = [1, 0, "xqx:typeswitchExprDefaultClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.unaryMinusOp = Fleur.Xlength++] = [1, 0, "xqx:unaryMinusOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.unaryPlusOp = Fleur.Xlength++] = [1, 0, "xqx:unaryPlusOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.unionOp = Fleur.Xlength++] = [1, 0, "xqx:unionOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.unorderedExpr = Fleur.Xlength++] = [1, 0, "xqx:unorderedExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.unaryLookup = Fleur.Xlength++] = [1, 0, "xqx:unaryLookup"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.uri = Fleur.Xlength++] = [1, 0, "xqx:uri"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.validateExpr = Fleur.Xlength++] = [1, 0, "xqx:validateExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.validationMode = Fleur.Xlength++] = [1, 0, "xqx:validationMode"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.value = Fleur.Xlength++] = [1, 0, "xqx:value"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.valueComparisonOp = Fleur.Xlength++] = [1, 0, "xqx:valueComparisonOp"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.valueExpr = Fleur.Xlength++] = [1, 0, "xqx:valueExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.varDecl = Fleur.Xlength++] = [1, 0, "xqx:varDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.varName = Fleur.Xlength++] = [1, 0, "xqx:varName"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.varRef = Fleur.Xlength++] = [1, 0, "xqx:varRef"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.varValue = Fleur.Xlength++] = [1, 0, "xqx:varValue"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.variableBinding = Fleur.Xlength++] = [1, 0, "xqx:variableBinding"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.version = Fleur.Xlength++] = [1, 0, "xqx:version"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.versionDecl = Fleur.Xlength++] = [1, 0, "xqx:versionDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.voidSequenceType = Fleur.Xlength++] = [1, 0, "xqx:voidSequenceType"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.whereClause = Fleur.Xlength++] = [1, 0, "xqx:whereClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.winEndExpr = Fleur.Xlength++] = [1, 0, "xqx:winEndExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.winStartExpr = Fleur.Xlength++] = [1, 0, "xqx:winStartExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.windowClause = Fleur.Xlength++] = [1, 0, "xqx:windowClause"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.windowEndCondition = Fleur.Xlength++] = [1, 0, "xqx:windowEndCondition"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.windowStartCondition = Fleur.Xlength++] = [1, 0, "xqx:windowStartCondition"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.windowVars = Fleur.Xlength++] = [1, 0, "xqx:windowVars"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.xpathAxis = Fleur.Xlength++] = [1, 0, "xqx:xpathAxis"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.URI = Fleur.Xlength++] = [2, 0, "xqx:URI"]; + Fleur.XQueryXNames[1][Fleur.XQueryX["default"] = Fleur.Xlength++] = [2, 0, "xqx:default"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.nondeterministic = Fleur.Xlength++] = [2, 0, "xqx:nondeterministic"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.onlyEnd = Fleur.Xlength++] = [2, 0, "xqx:onlyEnd"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.prefix = Fleur.Xlength++] = [2, 0, "xqx:prefix"]; + Fleur.XQueryXNames[1][Fleur.XQueryX["private"] = Fleur.Xlength++] = [2, 0, "xqx:private"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.sequentialFunction = Fleur.Xlength++] = [2, 0, "xqx:sequentialFunction"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.updatingFunction = Fleur.Xlength++] = [2, 0, "xqx:updatingFunction"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.xqx = Fleur.Xlength++] = [2, 1, "xmlns:xqx"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.xsi = Fleur.Xlength++] = [2, 1, "xmlns:xsi"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.schemaLocation = Fleur.Xlength++] = [2, 2, "xsi:schemaLocation"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.xqxuf = Fleur.Xlength++] = [2, 1, "xmlns:xqxuf"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.copyModifyExpr = Fleur.Xlength++] = [1, 3, "xqxuf:copyModifyExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.copySource = Fleur.Xlength++] = [1, 3, "xqxuf:copySource"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.deleteExpr = Fleur.Xlength++] = [1, 3, "xqxuf:deleteExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.insertAfter = Fleur.Xlength++] = [1, 3, "xqxuf:insertAfter"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.insertAsFirst = Fleur.Xlength++] = [1, 3, "xqxuf:insertAsFirst"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.insertAsLast = Fleur.Xlength++] = [1, 3, "xqxuf:insertAsLast"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.insertBefore = Fleur.Xlength++] = [1, 3, "xqxuf:insertBefore"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.insertExpr = Fleur.Xlength++] = [1, 3, "xqxuf:insertExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.insertInto = Fleur.Xlength++] = [1, 3, "xqxuf:insertInto"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.modifyExpr = Fleur.Xlength++] = [1, 3, "xqxuf:modifyExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.newNameExpr = Fleur.Xlength++] = [1, 3, "xqxuf:newNameExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.renameExpr = Fleur.Xlength++] = [1, 3, "xqxuf:renameExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.replaceExpr = Fleur.Xlength++] = [1, 3, "xqxuf:replaceExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.replaceValue = Fleur.Xlength++] = [1, 3, "xqxuf:replaceValue"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.replacementExpr = Fleur.Xlength++] = [1, 3, "xqxuf:replacementExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.returnExpr = Fleur.Xlength++] = [1, 3, "xqxuf:returnExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.revalidationDecl = Fleur.Xlength++] = [1, 3, "xqxuf:revalidationDecl"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.sourceExprUf = Fleur.Xlength++] = [1, 3, "xqxuf:sourceExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.targetExpr = Fleur.Xlength++] = [1, 3, "xqxuf:targetExpr"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.transformCopies = Fleur.Xlength++] = [1, 3, "xqxuf:transformCopies"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.transformCopy = Fleur.Xlength++] = [1, 3, "xqxuf:transformCopy"]; + Fleur.XQueryXNames[1][Fleur.XQueryX.transformExpr = Fleur.Xlength++] = [1, 3, "xqxuf:transformExpr"]; + Fleur.XPathEvaluator = function() {}; + Fleur.XPathEvaluator._precedence = "././/.:.as.&0.!.!!.&1.~+.~-.&2.cast as.&3.castable as.&4.treat as.&5.instance of.&6.intersect.except.&7.|.union.&8.div.mod.*.idiv.&9.+.-.&10.to.&11.||.&12.eq.ne.lt.le.gt.ge.<.>.<=.>=.is.<<.>>.=.!=.&13.and.&14.or.&15.allowing.&16.at.&17.:=.in.&18.after.before.into.with.value.&19.node.nodes.&20.~~ascending.~~descending.empty.&28.~,.&29.for.let.group by.order by.stable order by.count.where.some.every.&30.then.catch.&31.else.return.satisfies.&32.,.&50.;.&51."; + Fleur.XPathEvaluator._rightgrouping1 = Fleur.XPathEvaluator._precedence.substr(Fleur.XPathEvaluator._precedence.indexOf(".then.") + 6); + Fleur.XPathEvaluator._rightgrouping1 = Fleur.XPathEvaluator._rightgrouping1.substr(Fleur.XPathEvaluator._rightgrouping1.indexOf("&") + 1); + Fleur.XPathEvaluator._rightgrouping1 = parseInt(Fleur.XPathEvaluator._rightgrouping1.substr(0, Fleur.XPathEvaluator._rightgrouping1.indexOf(".")), 10); + Fleur.XPathEvaluator._rightgrouping2 = Fleur.XPathEvaluator._precedence.substr(Fleur.XPathEvaluator._precedence.indexOf(".return.") + 6); + Fleur.XPathEvaluator._rightgrouping2 = Fleur.XPathEvaluator._rightgrouping2.substr(Fleur.XPathEvaluator._rightgrouping2.indexOf("&") + 1); + Fleur.XPathEvaluator._rightgrouping2 = parseInt(Fleur.XPathEvaluator._rightgrouping2.substr(0, Fleur.XPathEvaluator._rightgrouping2.indexOf(".")), 10); + Fleur.XPathEvaluator._opcodes = "./;stepExpr.|;unionOp.union;unionOp.div;divOp.mod;modOp.*;multiplyOp.idiv;idivOp.+;addOp.-;subtractOp.to;toOp.||;stringConcatenateOp.eq;eqOp.ne;neOp.lt;ltOp.le;leOp.gt;gtOp.ge;geOp.<;lessThanOp.>;greaterThanOp.<=;lessThanOrEqualOp.>=;greaterThanOrEqualOp.is;isOp.<<;nodeBeforeOp.>>;nodeAfterOp.=;equalOp.!=;notEqualOp.and;andOp.or;orOp.,;argExpr."; + Fleur.XPathEvaluator._skipComment = function(s, offset) { + var i = offset; + var c = s.charAt(i); + var d = s.charAt(i + 1); + var l = s.length; + do { + if (c === "(" && d === ":") { + i = Fleur.XPathEvaluator._skipComment(s, i + 2); + } else if (c === ":" && d === ")") { + return i + 1; + } + c = s.charAt(++i); + d = s.charAt(i + 1); + } while (i < l); + }; + Fleur.XPathEvaluator._skipSpaces = function(s, offset) { + var i = offset; + var c = s.charAt(i); + var l = s.length; + do { + if (c === "(" && s.charAt(i + 1) === ":") { + i = Fleur.XPathEvaluator._skipComment(s, i + 2); + } else if (c !== "\n" && c !== "\r" && c !== "\t" && c !== " ") { + return i; + } + c = s.charAt(++i); + } while (i < l); + return i; + }; + Fleur.XPathEvaluator._getName = function(s) { + var i = 0; + var o = s.charAt(0); + var prev = ""; + while (o !== "" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:*{".indexOf(o) !== -1) { + if (o === "*") { + if (i > 0 && (s.charAt(i - 1) === ":" || s.charAt(i - 1) === "}")) { + i++; + break; + } else if (s.charAt(i + 1) !== ":") { + if (i === 0) { + i++; + } + break; + } + } + if (o === "{") { + if (prev !== "Q") { + return s.substr(0, i); + } + while (o !== "" && o !== "}") { + o = s.charAt(++i); + } + } + prev = o; + o = s.charAt(++i); + } + if (o === "#") { + o = s.charAt(++i); + while (o !== "" && "0123456789".indexOf(o) !== -1) { + o = s.charAt(++i); + } + } + return s.substr(0, i); + }; + Fleur.XPathEvaluator._getNameStep = function(s, attr) { + var n = Fleur.XPathEvaluator._getName(s); + var fctind = n.indexOf("#"); + if (fctind !== -1) { + var pindex = n.indexOf(":"); + if (pindex === -1) { + return n.length + ".[Fleur.XQueryX.namedFunctionRef,[[Fleur.XQueryX.functionName,['" + n.substr(0, fctind) + "']],[Fleur.XQueryX.integerConstantExpr,[[Fleur.XQueryX.value,['" + n.substr(fctind + 1) + "']]]]]]"; + } + return n.length + ".[Fleur.XQueryX.namedFunctionRef,[[Fleur.XQueryX.functionName,['" + n.substr(0, fctind).substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + n.substr(0, pindex) + "']]]],[Fleur.XQueryX.integerConstantExpr,[[Fleur.XQueryX.value,['" + n.substr(fctind + 1) + "']]]]]]"; + } + var aind = n.indexOf("::"); + var axis = aind !== -1 ? n.substr(0, aind) : attr ? "attribute" : "child"; + var n2 = aind !== -1 ? n.substr(aind + 2) : n; + var eq = n2.substr(0, 2) === "Q{"; + var sind = eq ? n2.indexOf("}") : n2.indexOf(":"); + var n3 = sind !== -1 ? n2.substr(sind + 1) : n2; + var nsp = eq ? n2.substr(2, sind - 2) : sind !== -1 ? n2.substr(0, sind) : ""; + var ntest = n3 === "*" || nsp === "*" ? "[Fleur.XQueryX.Wildcard,[" + (n3 !== "*" ? "[Fleur.XQueryX.star,[]],[Fleur.XQueryX.NCName,['" + n3 + "']]" : "") + "]]" : "[Fleur.XQueryX.nameTest,['" + n3 + "'" + (eq || sind !== -1 ? ",[" + (eq ? "Fleur.XQueryX.URI" : "Fleur.XQueryX.prefix") + ",['" + nsp + "']]" : "") + "]]"; + return (n.length + attr) + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['" + axis + "']]," + ntest + "]]]]"; + }; + Fleur.XPathEvaluator._pathExprFormat = function(s, p) { + if (s.substr(0, 25) === "[Fleur.XQueryX.pathExpr,[") { + return s.substr(25, s.length - 29) + p + "]]"; + } + return "[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[" + s + "]]" + p + "]]"; + }; + Fleur.XPathEvaluator._calc = function(args, ops, opprec) { + var curop = parseInt(ops.split(".")[1], 10); + if ((ops === "" || curop > opprec || opprec === 31) || (curop >= opprec && (curop === Fleur.XPathEvaluator._rightgrouping1 || curop === Fleur.XPathEvaluator._rightgrouping2))) { + return args.length + "." + args + ops.length + "." + ops; + } + var op0 = ops.substr(ops.indexOf(".") + 1, parseInt(ops.split(".")[0], 10)); + var op = op0.substr(op0.indexOf(".") + 1); + var arg2len = args.substr(0, args.indexOf(".")); + var arg2val = args.substr(args.indexOf(".") + 1).substr(0, parseInt(arg2len, 10)); + var arg2val2, arg2val3; + var args3, arg1len, arg1val, arg1val2, arg1val3; + if (op.startsWith("~~")) { + args3 = args; + arg1len = arg2len; + arg1val = arg2val; + } else { + args3 = args.substr(arg2len.length + 1 + parseInt(arg2len, 10)); + arg1len = args3.substr(0, args3.indexOf(".")); + arg1val = args3.substr(args3.indexOf(".") + 1).substr(0, parseInt(arg1len, 10)); + } + var arg; + var occ; + switch (op) { + case ";": + if (arg1val.substr(0, 58) === "[Fleur.XQueryX.sequenceExpr,[[Fleur.XQueryX.multidimExpr,[") { + arg = "[Fleur.XQueryX.sequenceExpr,[[Fleur.XQueryX.multidimExpr,[" + arg1val.substr(58, arg1val.length - 62) + "," + arg2val + "]]]]"; + } else { + arg = "[Fleur.XQueryX.sequenceExpr,[[Fleur.XQueryX.multidimExpr,[" + arg1val + "," + arg2val + "]]]]"; + } + break; + case ",": + if (ops.substr(0, 13) === "4.50.,5.999.(") { + if (arg1val.substr(0, 26) === "[Fleur.XQueryX.arguments,[") { + arg = arg1val.substr(0, arg1val.length - 2) + "," + arg2val + "]]"; + } else { + arg = "[Fleur.XQueryX.arguments,[" + arg1val + "," + arg2val + "]]"; + } + } else if (ops.substr(0, 13) === "4.50.,5.999.q") { + arg = arg1val + "," + arg2val; + } else if (ops.startsWith("4.50.,")) { + if (arg1val.substr(0, 36) === "[Fleur.XQueryX.mapConstructorEntry,[") { + arg = arg1val + "," + arg2val; + } else if (arg1val.substr(0, 29) === "[Fleur.XQueryX.sequenceExpr,[" && arg1val !== "[Fleur.XQueryX.sequenceExpr,[]]") { + arg = arg1val.substr(0, arg1val.length - 2) + "," + arg2val + "]]"; + } else { + arg = "[Fleur.XQueryX.sequenceExpr,[" + arg1val + "," + arg2val + "]]"; + } + } else { + arg = arg1val + "," + arg2val; + } + break; + case "~,": + if (arg1val.substr(0, 29) === "[Fleur.XQueryX.letClauseItem," || arg1val.substr(0, 27) === "[Fleur.XQueryX.groupBySpec,") { + arg = arg1val + "," + arg2val; + } else if (arg1val.substr(0, 25) === "[Fleur.XQueryX.letClause,") { + if (arg2val.substr(0, 25) === "Fleur.XQueryX.letClause,") { + arg = arg1val.substr(0, arg1val.length - 2) + "," + arg2val.substr(25); + } else { + arg = arg1val.substr(0, arg1val.length - 2) + "," + arg2val + "]]"; + } + } else { + if (arg1val.substr(0, 27) !== "[Fleur.XQueryX.orderBySpec,") { + arg = "[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg1val + "]]]]"; + } else { + arg = arg1val; + } + arg += ","; + if (arg2val.substr(0, 27) !== "[Fleur.XQueryX.orderBySpec,") { + arg += "[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg2val + "]]]]"; + } else { + arg += arg2val; + } + } + break; + case "//": + arg = "[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg1val, "") + ",[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['descendant-or-self']],[Fleur.XQueryX.anyKindTest,[]]]]," + Fleur.XPathEvaluator._pathExprFormat(arg2val, "") + "]]"; + break; + case "/": + arg = "[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg1val, "") + (arg2val !== "" ? "," + Fleur.XPathEvaluator._pathExprFormat(arg2val, "") : "") + "]]"; + break; + case "!!": + arg = "[Fleur.XQueryX.doubleMapExpr,[[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg1val, "") + "]],[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg2val, "") + "]]]]"; + break; + case "!": + arg = "[Fleur.XQueryX.simpleMapExpr,[[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg1val, "") + "]],[Fleur.XQueryX.pathExpr,[" + Fleur.XPathEvaluator._pathExprFormat(arg2val, "") + "]]]]"; + break; + case "|": + if (ops.startsWith("3.8.|8.31.catch")) { + if (arg1val.substr(0, 24) === "[Fleur.XQueryX.pathExpr,") { + arg1val2 = arg1val.substr(86); + arg1val = arg1val2.substr(0, arg1val2.length - 4); + } + if (arg2val.substr(0, 24) === "[Fleur.XQueryX.pathExpr,") { + arg2val2 = arg2val.substr(86); + arg2val = arg2val2.substr(0, arg2val2.length - 4); + arg = arg1val + "," + arg2val; + } else { + arg = "[Fleur.XQueryX.catchErrorList,[" + arg1val + "," + arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.catchErrorList,[") + 31); + } + } else { + arg = "[Fleur.XQueryX.unionOp,[[Fleur.XQueryX.firstOperand,[" + arg1val + "]],[Fleur.XQueryX.secondOperand,[" + arg2val + "]]]]"; + } + break; + case ":": + arg = "[Fleur.XQueryX.mapConstructorEntry,[[Fleur.XQueryX.mapKeyExpr,[" + arg1val + "]],[Fleur.XQueryX.mapValueExpr,[" + arg2val + "]]]]"; + break; + case "?": + break; + case "to": + arg = "[Fleur.XQueryX.rangeSequenceExpr,[[Fleur.XQueryX.startExpr,[" + arg1val + "]],[Fleur.XQueryX.endExpr,[" + arg2val + "]]]]"; + break; + case "~-": + arg = "[Fleur.XQueryX.unaryMinusOp,[[Fleur.XQueryX.operand,[" + arg2val + "]]]]"; + break; + case "~+": + arg = "[Fleur.XQueryX.unaryPlusOp,[[Fleur.XQueryX.operand,[" + arg2val + "]]]]"; + break; + case "allowing": + arg = "[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.allowingEmpty,[]]"; + break; + case "at": + if (arg1val.substr(0, 36) === "[Fleur.XQueryX.typedVariableBinding,") { + arg = arg1val + ",[Fleur.XQueryX.positionalVariableBinding,[" + arg2val.substr(0, arg2val.length - 4).substr(44) + "]]"; + } else { + arg = "[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.positionalVariableBinding,[" + arg2val.substr(0, arg2val.length - 4).substr(44) + "]]"; + } + break; + case "in": + if (ops.substr(ops.length - 7) === "5.999.q") { + arg = "[Fleur.XQueryX.quantifiedExprInClause,[[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.sourceExpr,[" + arg2val + "]]]]"; + } else if (arg1val.substr(0, 36) === "[Fleur.XQueryX.typedVariableBinding,") { + arg = "[Fleur.XQueryX.forClause,[[Fleur.XQueryX.forClauseItem,[" + arg1val + ",[Fleur.XQueryX.forExpr,[" + arg2val + "]]]]]]"; + } else { + arg = "[Fleur.XQueryX.forClause,[[Fleur.XQueryX.forClauseItem,[[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.forExpr,[" + arg2val + "]]]]]]"; + } + break; + case "as": + if (arg2val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['last']]]]]]") { + arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertInto,[[Fleur.XQueryX.insertAsLast,[]]]]"; + } else if (arg2val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['first']]]]]]") { + arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertInto,[[Fleur.XQueryX.insertAsFirst,[]]]]"; + } else { + arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); + arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); + arg = "[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]],[Fleur.XQueryX.typeDeclaration,[" + arg2val3 + "]]"; + } + break; + case ":=": + if (ops.startsWith("5.18.:=11.30.group by") || ops.startsWith("5.18.:=5.29.~,11.30.group by")) { + if (arg1val.substr(0, 28) === "[Fleur.XQueryX.groupingSpec,") { + arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.groupVarInitialize,[[Fleur.XQueryX.varValue,[" + arg2val + "]]]]]]"; + } else { + arg = "[Fleur.XQueryX.groupingSpec,[[Fleur.XQueryX.varName,[" + arg1val.substr(44, arg1val.length - 48) + "]],[Fleur.XQueryX.groupVarInitialize,[[Fleur.XQueryX.varValue,[" + arg2val + "]]]]]]"; + } + } else if (arg1val.substr(0, 23) === "[Fleur.XQueryX.varName,") { + arg = "[Fleur.XQueryX.letClause,[[Fleur.XQueryX.letClauseItem,[[Fleur.XQueryX.typedVariableBinding,[" + arg1val + "]],[Fleur.XQueryX.letExpr,[" + arg2val + "]]]]]]"; + } else { + arg = "[Fleur.XQueryX.letClause,[[Fleur.XQueryX.letClauseItem,[[Fleur.XQueryX.typedVariableBinding,[[Fleur.XQueryX.varName,[" + arg1val.substr(0, arg1val.length - 4).substr(44) + "]]]],[Fleur.XQueryX.letExpr,[" + arg2val + "]]]]]]"; + } + break; + case "return": + arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.returnClause,[" + arg2val + "]]]]"; + break; + case "satisfies": + arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.predicateExpr,[" + arg2val + "]]]]"; + break; + case "cast as": + case "cast as?": + occ = op.charAt(7); + arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); + arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); + arg = "[Fleur.XQueryX.castExpr,[[Fleur.XQueryX.argExpr,[" + arg1val + "]],[Fleur.XQueryX.singleType,[" + arg2val3 + (occ === "?" ? ",[Fleur.XQueryX.optional,[]]" : "") + "]]]]"; + break; + case "castable as": + case "castable as?": + occ = op.charAt(11); + arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); + arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); + arg = "[Fleur.XQueryX.castableExpr,[[Fleur.XQueryX.argExpr,[" + arg1val + "]],[Fleur.XQueryX.singleType,[" + arg2val3 + (occ === "?" ? ",[Fleur.XQueryX.optional,[]]" : "") + "]]]]"; + break; + case "treat as": + case "treat as+": + case "treat as?": + case "treat as*": + occ = op.charAt(8); + if (arg2val.indexOf("[Fleur.XQueryX.nameTest,") !== -1) { + arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); + arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); + } else if (arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") !== -1) { + arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") + 86); + arg2val3 = arg2val2.substr(0, arg2val2.length - 4); + } else { + arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['attribute']],") + 90); + arg2val3 = arg2val2.substr(0, arg2val2.length - 4); + } + arg = "[Fleur.XQueryX.treatExpr,[[Fleur.XQueryX.argExpr,[" + arg1val + "]],[Fleur.XQueryX.sequenceType,[" + arg2val3 + (occ !== "" ? ",[Fleur.XQueryX.occurrenceIndicator,['" + occ + "']]" : "") + "]]]]"; + break; + case "instance of": + case "instance of+": + case "instance of?": + case "instance of*": + occ = op.charAt(11); + if (arg2val.indexOf("[Fleur.XQueryX.nameTest,") !== -1) { + arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); + arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); + } else if (arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") !== -1) { + arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") + 86); + arg2val3 = arg2val2.substr(0, arg2val2.length - 4); + } else { + arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['attribute']],") + 90); + arg2val3 = arg2val2.substr(0, arg2val2.length - 4); + } + arg = "[Fleur.XQueryX.instanceOfExpr,[[Fleur.XQueryX.argExpr,[" + arg1val + "]],[Fleur.XQueryX.sequenceType,[" + arg2val3 + (occ !== "" ? ",[Fleur.XQueryX.occurrenceIndicator,['" + occ + "']]" : "") + "]]]]"; + break; + case "then": + if (arg1val.substr(0, 95) === "[Fleur.XQueryX.functionCallExpr,[[Fleur.XQueryX.functionName,['if']],[Fleur.XQueryX.arguments,[") { + arg = "[Fleur.XQueryX.ifThenElseExpr,[[Fleur.XQueryX.ifClause,[" + arg1val.substr(0, arg1val.length - 4).substr(arg1val.indexOf(",[Fleur.XQueryX.arguments,[") + 27) + "]],[Fleur.XQueryX.thenClause,[" + arg2val + "]]]]"; + } + opprec = -1; + break; + case "else": + if (arg1val.substr(0, 30) === "[Fleur.XQueryX.ifThenElseExpr,") { + arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.elseClause,[" + arg2val + "]]]]"; + } + break; + case "catch": + if (arg1val.substr(0, 28) === "[Fleur.XQueryX.tryCatchExpr,") { + arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.catchClause,[" + arg2val + "]]]]"; + } + break; + case "let": + arg = arg1val + "," + arg2val; + break; + case "for": + arg = arg1val + "," + arg2val; + break; + case "group by": + arg = arg1val + ",[Fleur.XQueryX.groupByClause,[" + arg2val + "]]"; + break; + case "order by": + if (arg2val.substr(0, 27) === "[Fleur.XQueryX.orderBySpec,") { + arg = arg1val + ",[Fleur.XQueryX.orderByClause,[" + arg2val + "]]"; + } else { + arg = arg1val + ",[Fleur.XQueryX.orderByClause,[[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg2val + "]]]]]]"; + } + break; + case "~~ascending": + case "~~descending": + arg = "[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg1val + "]],[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.orderingKind,['" + op.substr(2) + "']]]]]]"; + break; + case "empty": + if (arg1val.substr(0,27) === "[Fleur.XQueryX.orderBySpec,") { + if (arg1val.endsWith(",[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.orderingKind,['ascending']]]]]]") || arg1val.endsWith(",[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.orderingKind,['descending']]]]]]")) { + arg = arg1val.substr(0, arg1val.length - 4) + ",[Fleur.XQueryX.emptyOrderingMode,['empty " + arg2val.substr(112, arg2val.length - 119) + "']]]]]]"; + } else { + arg = arg1val.substr(0, arg1val.length - 2) + ",[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.emptyOrderingMode,['empty " + arg2val.substr(112, arg2val.length - 119) + "']]]]]]"; + } + } else { + arg = "[Fleur.XQueryX.orderBySpec,[[Fleur.XQueryX.orderByExpr,[" + arg1val + "]],[Fleur.XQueryX.orderModifier,[[Fleur.XQueryX.emptyOrderingMode,['empty " + arg2val.substr(112, arg2val.length - 119) + "']]]]]]"; + } + break; + case "where": + arg = arg1val + ",[Fleur.XQueryX.whereClause,[" + arg2val + "]]"; + break; + case "count": + arg = arg1val + ",[Fleur.XQueryX.countClause,[" + arg2val + "]]"; + break; + case "nodes": + if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['delete']]]]]]") { + arg = "[Fleur.XQueryX.deleteExpr,[[Fleur.XQueryX.targetExpr,[" + arg2val + "]]]]"; + } else if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['insert']]]]]]") { + arg = "[Fleur.XQueryX.insertExpr,[" + arg2val + "]]"; + } + break; + case "node": + if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['delete']]]]]]") { + arg = "[Fleur.XQueryX.deleteExpr,[[Fleur.XQueryX.targetExpr,[" + arg2val + "]]]]"; + } else if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['insert']]]]]]") { + arg = "[Fleur.XQueryX.insertExpr,[" + arg2val + "]]"; + } else if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['replace']]]]]]") { + arg = "[Fleur.XQueryX.replaceExpr,[" + arg2val + "]]"; + } else if (arg1val === "[Fleur.XQueryX.replaceValue,[]]") { + arg = "[Fleur.XQueryX.replaceExpr,[[Fleur.XQueryX.replaceValue,[]]," + arg2val + "]]"; + } + break; + case "into": + if (arg1val.substr(0, 28) === "[Fleur.XQueryX.sourceExprUf,") { + arg = arg1val + ",[Fleur.XQueryX.targetExpr,[" + arg2val + "]]"; + } else { + arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertInto,[]],[Fleur.XQueryX.targetExpr,[" + arg2val + "]]"; + } + break; + case "after": + arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertAfter,[]],[Fleur.XQueryX.targetExpr,[" + arg2val + "]]"; + break; + case "before": + arg = "[Fleur.XQueryX.sourceExprUf,[" + arg1val + "]],[Fleur.XQueryX.insertBefore,[]],[Fleur.XQueryX.targetExpr,[" + arg2val + "]]"; + break; + case "value": + if (arg1val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['replace']]]]]]" && arg2val === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['of']]]]]]") { + arg = "[Fleur.XQueryX.replaceValue,[]]"; + } + break; + case "with": + arg = "[Fleur.XQueryX.targetExpr,[" + arg1val + "]],[Fleur.XQueryX.replacementExpr,[" + arg2val + "]]"; + break; + default: + var opcode0 = Fleur.XPathEvaluator._opcodes.substr(Fleur.XPathEvaluator._opcodes.indexOf("." + op + ";") + op.length + 2); + var opcode = opcode0.substr(0, opcode0.indexOf(".")); + arg = "[Fleur.XQueryX." + opcode + ",[[Fleur.XQueryX.firstOperand,[" + arg1val + "]],[Fleur.XQueryX.secondOperand,[" + arg2val + "]]]]"; + } + var args2 = arg.length + "." + arg + args3.substr(arg1len.length + 1 + parseInt(arg1len, 10)); + return Fleur.XPathEvaluator._calc(args2, ops.substr(ops.indexOf(".") + 1).substr(parseInt(ops.substr(0, ops.indexOf(".")), 10)), opprec); + }; + Fleur.XPathEvaluator._testFormat = function(s, namecode) { + var arg1, arg2, arg20, arg200; + if (s === "") { + return ""; + } + if (s.indexOf(",[Fleur.XQueryX.pathExpr,[") !== -1) { + arg1 = s.substr(0, s.indexOf(",[Fleur.XQueryX.pathExpr,[")); + arg20 = s.substr(s.indexOf(",[Fleur.XQueryX.pathExpr,[") + 1); + arg200 = arg20.substr(arg20.indexOf("[Fleur.XQueryX.nameTest,['") + 25); + arg2 = "," + "[Fleur.XQueryX.typeName,[" + arg200.substr(0, arg200.length - 6) + "]]"; + } else { + arg1 = s; + arg2 = ""; + } + var arg120 = arg1.indexOf("[Fleur.XQueryX.nameTest,['") !== -1 ? arg1.substr(arg1.indexOf("[Fleur.XQueryX.nameTest,['") + 25) : "[Fleur.XQueryX.star,[]]"; + var arg12 = "[" + namecode + ",[" + (arg120 === "[Fleur.XQueryX.star,[]]" ? arg120 : "[Fleur.XQueryX.QName,[" + arg120.substr(0, arg120.length - 6) + "]]") + "]]"; + return arg12 + arg2; + }; + Fleur.XPathEvaluator._getNodeConstructor = function(s) { + var ii, text, texts, entityname, index, offset = 0, end = s.length, nodename, attrname, attrvalue, attrvalues, attrs, parents = [], currnodename = "", c, c0, c1, c2, braces, + seps_pi = " \t\n\r?", seps_close = " \t\n\r>", seps_elt = " \t\n\r/>", seps_attr = " \t\n\r=/<>", seps = " \t\n\r", rseps = /^\s*$/gm, + namespaces = {}, newnamespaces = {}, pindex, prefix, localName, r0, r = "", nextsep = ""; + while (offset !== end) { + text = ""; + texts = []; + c1 = " "; + c = s.charAt(offset); + braces = 0; + while ((c !== "<" || braces !== 0) && offset !== end) { + if (c === "{") { + if (braces === 0 && text !== "") { + if (/\S/.test(text.replace("\\n", "\n").replace("\\r", "\r"))) { + texts.push([0, text]); + } + text = ""; + } + if (braces !== 0) { + text += "{"; + } + if (c1 === c) { + braces--; + if (braces === 0) { + text = (texts.length > 0 ? texts.pop()[1] : "") + "{"; + } + } else { + braces++; + } + } else if (c === "}") { + if (braces === 1 && text !== "") { + texts.push([1, text]); + text = ""; + } + if (braces !== 1 && braces !== -1) { + text += "}"; + } + if (c1 === c) { + braces++; + } else { + braces--; + } + } else if (c === "&") { + c = s.charAt(++offset); + entityname = ""; + while (c !== ";" && offset !== end) { + entityname += c; + c = s.charAt(++offset); + } + if (offset === end) { + break; + } + if (entityname.charAt(0) === "#") { + text += String.fromCharCode(parseInt(entityname.charAt(1).toLowerCase() === 'x' ? "0" + entityname.substr(1).toLowerCase() : entityname.substr(1), entityname.charAt(1).toLowerCase() === 'x' ? 16 : 10)); + } else { + text += Fleur.encchars[entityname]; + } + } else if (braces === 0 && c === "\n") { + text += "\\n"; + } else if (braces === 0 && c === "\r") { + text += "\\r"; + } else { + text += c; + } + c1 = c; + c = s.charAt(++offset); + } + if (/\S/.test(text.replace("\\n", "\n").replace("\\r", "\r")) && texts.length === 0) { + r += nextsep + "[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + text.replace(/'/gm,"\\'") + "']]]]"; + nextsep = ","; + } else if (texts.length > 0) { + if (/\S/.test(text.replace("\\n", "\n").replace("\\r", "\r"))) { + texts.push([0, text]); + } + texts.forEach(function(t) { + r += nextsep; + if (t[0] === 0) { + r += "[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + t[1].replace(/'/gm,"\\'") + "']]]]"; + } else { + r += Fleur.XPathEvaluator._xp2js(t[1], "", ""); + } + nextsep = ","; + }); + } + if (offset === end) { + break; + } + offset++; + if (s.charAt(offset) === "!") { + offset++; + if (s.substr(offset, 2) === "--") { + offset += 2; + index = s.indexOf("-->", offset); + if (index !== offset) { + if (index === -1) { + index = end; + } + text = ""; + ii = offset; + while (ii < index) { + text += s.charAt(ii++); + } + text = text.replace(/\x01/gm,"<"); + r0 = "[Fleur.XQueryX.computedCommentConstructor,[[Fleur.XQueryX.argExpr,[[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + text + "']]]]]]]]"; + if (r === "") { + return offset + "." + r0; + } + r += nextsep + r0; + nextsep = ","; + if (index === end) { + break; + } + offset = index; + } + offset += 3; + } else if (s.substr(offset, 7) === "[CDATA[") { + offset += 7; + index = s.indexOf("]]>", offset); + if (index !== offset) { + if (index === -1) { + index = end; + } + text = ""; + ii = offset; + while (ii < index) { + text += s.charAt(ii++); + } + text = text.replace(/\x01/gm,"<"); + if (text !== "") { + r += nextsep + "[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + text + "']]]]"; + nextsep = ","; + } + if (index === end) { + break; + } + offset = index; + } + offset += 3; + } + } else if (s.charAt(offset) === "?") { + offset++; + c = s.charAt(offset++); + nodename = ""; + while (seps_pi.indexOf(c) === -1) { + nodename += c; + c = s.charAt(offset++); + } + index = s.indexOf("?>", offset - 1); + if (index === -1) { + index = end; + } + if (nodename.toLowerCase() === "xml") { + throw Error("Invalid processing instruction"); + } else if (nodename !== "") { + text = ""; + ii = offset; + while (ii < index) { + text += s.charAt(ii++); + } + text = text.replace(/\x01/gm,"<"); + r0 = "[Fleur.XQueryX.computedPIConstructor,[[Fleur.XQueryX.piTarget,['" + nodename + "']],[Fleur.XQueryX.piValueExpr,[[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + text + "']]]]]]]]"; + if (r === "") { + return String(index + 2) + "." + r0; + } + r += nextsep + r0; + nextsep = ","; + } + if (index === end) { + break; + } + offset = index + 2; + } else if (s.charAt(offset) === "/") { + offset++; + c = s.charAt(offset++); + nodename = ""; + while (seps_close.indexOf(c) === -1 && offset <= end) { + nodename += c; + c = s.charAt(offset++); + } + if (nodename === currnodename) { + if (nextsep !== ",") { + r += "]]"; + } else { + r += "]]]]"; + } + nextsep = ","; + if (parents.length === 1) { + return offset + "." + r; + } + currnodename = parents.pop(); + } else { + throw Error("Malformed XML fragment"); + } + offset = s.indexOf(">", offset - 1) + 1; + if (offset === 0) { + break; + } + } else { + c = s.charAt(offset++); + nodename = ""; + while (seps_elt.indexOf(c) === -1 && offset <= end) { + nodename += c; + c = s.charAt(offset++); + } + index = s.indexOf(">", offset - 1); + if (nodename !== "") { + newnamespaces = {}; + for (prefix in namespaces) { + if (namespaces.hasOwnProperty(prefix)) { + newnamespaces[prefix] = namespaces[prefix]; + } + } + attrs = {}; + while (offset <= end) { + while (seps.indexOf(c) !== -1 && offset <= end) { + c = s.charAt(offset++); + } + if (c === "/" || c === ">" || offset === end) { + break; + } + attrname = ""; + while (seps_attr.indexOf(c) === -1 && offset <= end) { + attrname += c; + c = s.charAt(offset++); + } + if (attrname === "") { + throw new Error("Invalid character: " + c); + } + while (seps.indexOf(c) !== -1 && offset <= end) { + c = s.charAt(offset++); + } + if (c === "=") { + c = s.charAt(offset++); + while (seps.indexOf(c) !== -1 && offset <= end) { + c = s.charAt(offset++); + } + attrvalue = ""; + attrvalues = []; + if (c === "'" || c === "\"") { + c0 = c; + c1 = c; + c = s.charAt(offset++); + c2 = s.charAt(offset); + braces = 0; + attrvalue = ""; + ii = offset; + while ((c !== c0 || c2 === c0 || braces !== 0) && offset <= end) { + if (c === "{") { + if (braces === 0 && attrvalue !== "") { + attrvalues.push([0, attrvalue]); + attrvalue = ""; + } + if (c1 === c) { + braces--; + if (braces === 0) { + attrvalue = (attrvalues.length > 0 ? attrvalues.pop()[1] : "") + "{"; + } + } else { + braces++; + } + } else if (c === "}") { + if (braces === 1 && attrvalue !== "") { + attrvalues.push([1, attrvalue]); + attrvalue = ""; + } + if (c1 === c) { + braces++; + if (braces === 0) { + attrvalue += "}"; + } + } else { + braces--; + } + } else if (c === c2 && c === c0) { + attrvalue += c; + c1 = c; + c = s.charAt(++offset); + c2 = s.charAt(++offset); + continue; + } else { + attrvalue += c; + } + c1 = c; + c = c2; + c2 = s.charAt(++offset); + } + if (attrvalue !== "") { + attrvalues.push([0, attrvalue]); + } + c = c2; + offset++; + } else { + while (seps_elt.indexOf(c) === -1 && offset <= end) { + attrvalue += c; + c = s.charAt(offset++); + } + attrvalues = [[0, attrvalue]]; + } + } else { + attrvalues = [[0, attrname]]; + } + pindex = attrname.indexOf(":"); + prefix = pindex !== -1 ? attrname.substr(0, pindex) : " "; + localName = pindex !== -1 ? attrname.substr(pindex + 1) : attrname; + if (!attrs[prefix]) { + attrs[prefix] = {}; + } + attrs[prefix][localName] = attrvalues; + if (prefix === "xmlns") { + newnamespaces[localName] = attrvalues; + } else if (prefix === " " && localName === "xmlns") { + newnamespaces[" "] = attrvalues; + } + } + pindex = nodename.indexOf(":"); + if (pindex === -1) { + r0 = nextsep + "[Fleur.XQueryX.elementConstructor,[[Fleur.XQueryX.tagName,['" + nodename + "']]"; + } else { + r0 = nextsep + "[Fleur.XQueryX.elementConstructor,[[Fleur.XQueryX.tagName,['" + nodename.substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + nodename.substr(0, pindex) + "']]]]"; + } + if (Object.keys(attrs).length) { + nextsep = ",[Fleur.XQueryX.attributeList,["; + if (attrs[" "] && attrs[" "].xmlns) { + r0 += nextsep + "[Fleur.XQueryX.namespaceDeclaration,[[Fleur.XQueryX.uri,[" + (attrs[" "].xmlns.length !== 0 ? "'" + attrs[" "].xmlns[0][1] + "'" : "") + "]]]]"; + nextsep = ","; + delete attrs[" "].xmlns; + } + for (attrname in attrs.xmlns) { + if (attrs.xmlns.hasOwnProperty(attrname)) { + r0 += nextsep + "[Fleur.XQueryX.namespaceDeclaration,[[Fleur.XQueryX.prefixElt,['" + attrname + "']],[Fleur.XQueryX.uri,['" + attrs.xmlns[attrname][0][1] + "']]]]"; + nextsep = ","; + } + } + delete attrs.xmlns; + for (prefix in attrs) { + if (attrs.hasOwnProperty(prefix)) { + for (attrname in attrs[prefix]) { + if (attrs[prefix].hasOwnProperty(attrname)) { + r0 += nextsep + "[Fleur.XQueryX.attributeConstructor,[[Fleur.XQueryX.attributeName,['" + attrname + "'"; + if (prefix !== " ") { + r0 += ",[Fleur.XQueryX.prefix,['" + prefix + "']]"; + } + r0 += "]],"; + if (attrs[prefix][attrname].length === 0) { + r0 += "[Fleur.XQueryX.attributeValue,[]]"; + nextsep = ","; + } else if (attrs[prefix][attrname].length === 1 && attrs[prefix][attrname][0][0] === 0) { + r0 += "[Fleur.XQueryX.attributeValue,['" + Fleur.DocumentType.resolveEntities(null, attrs[prefix][attrname][0][1]).replace(/'/gm,"\\'").replace(/\x01/gm,"<") + "']]"; + nextsep = ","; + } else { + nextsep = "[Fleur.XQueryX.attributeValueExpr,["; + attrs[prefix][attrname].forEach(function(v) { + r0 += nextsep; + if (v[0] === 0) { + r0 += "[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,['" + Fleur.DocumentType.resolveEntities(null, v[1]).replace(/'/gm,"\\'") + "']]]]"; + } else { + r0 += Fleur.XPathEvaluator._xp2js(v[1], "", ""); + } + nextsep = ","; + }); + r0 += "]]"; + } + r0 += "]]"; + } + } + } + } + r0 += "]]"; + } + if (s.charAt(offset - 1) !== "/") { + nextsep = ",[Fleur.XQueryX.elementContent,["; + parents.push(currnodename); + currnodename = nodename; + r += r0; + } else { + if (r === "") { + return String(offset + 1) + "." + r0 + "]]"; + } + r += r0 + "]]"; + nextsep = ","; + } + } else { + throw Error("Invalid element name"); + } + offset = index + 1; + if (offset === 0) { + break; + } + } + } + }; + Fleur.XPathEvaluator._getPredParam = function(c, s, l, arg, allowpredicates, predstart, predarr, ops) { + var t; + l = l || 0; + var p, plen, arg20, arg2; + var isret = false; + if (c === "?") { + var i = Fleur.XPathEvaluator._skipSpaces(s, 0); + var c2 = s.charAt(i); + var d = s.substr(i + 1); + var r, t1; + if (c2 !== "" && "0123456789".indexOf(c2) !== -1) { + t1 = Fleur.XPathEvaluator._getNumber(c2 + d); + r = "[Fleur.XQueryX.lookup,[[Fleur.XQueryX.integerConstantExpr,[[Fleur.XQueryX.value,['" + t1.replace(/e\+/, "e") + "']]]]]]"; + t = (t1.length + 1) + "." + r; + plen = t1.length + 1; + } else if (c2 !== "" && "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(c2) !== -1) { + t1 = Fleur.XPathEvaluator._getName(c2 + d); + r = "[Fleur.XQueryX.lookup,[[Fleur.XQueryX.NCName,['" + t1 + "']]]]"; + t = (t1.length + 1) + "." + r; + plen = t1.length + 1; + } else if (c2 === "*") { + t = "2.[Fleur.XQueryX.lookup,[[Fleur.XQueryX.star,[]]]]"; + plen = 2; + } else if (c2 === "(") { + t = Fleur.XPathEvaluator._xp2js(s.substr(i + 1), "", "5.999.("); + plen = s.length - parseInt(t.substr(0, t.indexOf(".")), 10) + 1 + i; + t = String(plen) + "." + "[Fleur.XQueryX.lookup,[[Fleur.XQueryX.expr,[" + t.substr(t.indexOf(".") + 1) + "]]]]"; + } + } else { + var func = ""; + if (arg.indexOf("[Fleur.XQueryX.nameTest,['") !== -1) { + var func0 = arg.substr(arg.indexOf("[Fleur.XQueryX.nameTest,['") + 25); + func = func0.substr(0, func0.length - 6); + } + if (func === "'function'") { + t = "function"; + plen = s.length; + } else { + t = Fleur.XPathEvaluator._xp2js(s, "", l === 0 ? "" : arg.substr(0, 57) === "[Fleur.XQueryX.quantifiedExpr,[[Fleur.XQueryX.quantifier," ? "5.999.q" : "5.999.("); + plen = s.length - parseInt(t.substr(0, t.indexOf(".")), 10) + 1; + } + } + if (t.indexOf("~~~~") !== -1) { + var t0 = t + "~#~#"; + t0 = t0.substr(0, t0.indexOf("~#~#")); + t0 = t0.replace('"', ""); + var msg = '"~~~~' + t0.substr(t0.indexOf("~~~~") + 4) + "in '" + s + "'~#~#" + '"'; + p = plen + "." + msg; + throw Error(t0.substr(t0.indexOf("~~~~") + 4) + "in '" + s + "'"); + } else if (t === "") { + var msg2 = '"' + "~~~~Unrecognized expression '" + s + "'~#~#" + '"'; + p = plen + "." + msg2; + throw Error("Unrecognized expression '" + s + "'"); + } else if (c === "{") { + var cargs = t.substr(t.indexOf(".") + 1); + if (cargs.substr(0, 25) === "[Fleur.XQueryX.arguments,") { + cargs = "[Fleur.XQueryX.sequenceExpr," + cargs.substr(25); + } + if (arg.substr(0, 40) === "[Fleur.XQueryX.computedEntryConstructor," || arg.substr(0, 42) === "[Fleur.XQueryX.computedElementConstructor," || arg.substr(0, 44) === "[Fleur.XQueryX.computedAttributeConstructor,") { + p = plen + "." + arg.substr(0, arg.length - 2) + ",[Fleur.XQueryX.valueExpr,[" + cargs + "]]]]"; + } else if (arg.substr(0, 37) === "[Fleur.XQueryX.computedPIConstructor,") { + p = plen + "." + arg.substr(0, arg.length - 2) + ",[Fleur.XQueryX.piValueExpr,[" + cargs + "]]]]"; + } else { + var cname0 = arg.substr(arg.indexOf("[Fleur.XQueryX.nameTest,['") + 25); + var cname = cname0.substr(0, cname0.length - 6); + switch (cname) { + case "'document'": + p = plen + "." + "[Fleur.XQueryX.computedDocumentConstructor,[[Fleur.XQueryX.argExpr,[" + cargs + "]]]]"; + break; + case "'comment'": + p = plen + "." + "[Fleur.XQueryX.computedCommentConstructor,[[Fleur.XQueryX.argExpr,[" + cargs + "]]]]"; + break; + case "'map'": + var cargs2 = cargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? cargs.substr(26, cargs.length - 28) : cargs; + p = plen + "." + "[Fleur.XQueryX.mapConstructor,[" + cargs2 + "]]"; + break; + case "'array'": + var cargs3 = cargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? cargs.substr(26, cargs.length - 28) : cargs; + p = plen + "." + "[Fleur.XQueryX.arrayConstructor,[" + cargs3 + "]]"; + break; + case "'entry'": + p = plen + "." + "[Fleur.XQueryX.computedEntryConstructor,[[Fleur.XQueryX.tagNameExpr,[" + cargs + "]]]]"; + break; + case "'element'": + p = plen + "." + "[Fleur.XQueryX.computedElementConstructor,[[Fleur.XQueryX.tagNameExpr,[" + cargs + "]]]]"; + break; + case "'attribute'": + p = plen + "." + "[Fleur.XQueryX.computedAttributeConstructor,[[Fleur.XQueryX.tagNameExpr,[" + cargs + "]]]]"; + break; + case "'processing-instruction'": + p = plen + "." + "[Fleur.XQueryX.computedPIConstructor,[[Fleur.XQueryX.piTargetExpr,[" + cargs + "]]]]"; + break; + case "'text'": + p = plen + "." + "[Fleur.XQueryX.computedTextConstructor,[[Fleur.XQueryX.argExpr,[" + cargs + "]]]]"; + break; + case "'try'": + p = plen + "." + "[Fleur.XQueryX.tryCatchExpr,[[Fleur.XQueryX.tryClause,[" + cargs + "]]]]"; + break; + default: + if (ops.startsWith("8.31.catch") || ops.startsWith("3.8.|8.31.catch")) { + arg20 = arg.substr(86); + arg2 = arg20.substr(0, arg20.length - 4); + p = plen + "." + "[Fleur.XQueryX.catchErrorList,[" + arg2 + "]],[Fleur.XQueryX.catchExpr,[" + cargs + "]]"; + } + break; + } + } + } else if (c === "(") { + if (arg.substr(0, 77) === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['") { + var fname0 = arg.substr(arg.indexOf("[Fleur.XQueryX.nameTest,['") + 25); + var fname = fname0.substr(0, fname0.length - 6); + var fargs = t.substr(t.indexOf(".") + 1); + var fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; + var parg0, parg; + switch (fname) { + case "'array'": + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['array']]]]")) + "[Fleur.XQueryX.arrayTest,[]]]]]]"; + break; + case "'attribute'": + parg = Fleur.XPathEvaluator._testFormat(fargs2, "Fleur.XQueryX.attributeName"); + p = plen + "." + "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['attribute']],[Fleur.XQueryX.attributeTest,[" + parg + "]]]]]]"; + break; + case "'comment'": + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['comment']]]]")) + "[Fleur.XQueryX.commentTest,[]]]]]]"; + break; + case "'document-node'": + if (fargs2 !== "") { + parg0 = fargs2.substr(fargs2.indexOf("[Fleur.XQueryX.elementTest,[")); + parg = parg0.substr(0, parg0.length - 4); + } else { + parg = ""; + } + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['document-node']]]]")) + "[Fleur.XQueryX.documentTest,[" + parg + "]]]]]]"; + break; + case "'element'": + parg = Fleur.XPathEvaluator._testFormat(fargs2, "Fleur.XQueryX.elementName"); + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['element']]]]")) + "[Fleur.XQueryX.elementTest,[" + parg + "]]]]]]"; + break; + case "'entry'": + parg = Fleur.XPathEvaluator._testFormat(fargs2, "Fleur.XQueryX.entryName"); + p = plen + "." + "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['entry']],[Fleur.XQueryX.entryTest,[" + parg + "]]]]]]"; + break; + case "'function'": + var j = -1; + var xq = s; + var pindex, np, nbpar = 0; + var fres = "[Fleur.XQueryX.paramList,["; + var end = xq.length; + do { + j = Fleur.XPathEvaluator._skipSpaces(xq, j + 1); + c = xq.charAt(j); + if (c !== ")") { + if (c !== "$") { + throw Error("Unexpected char at '" + xq.substr(j) + "'"); + } + j++; + c = xq.charAt(j); + d = xq.substr(j + 1); + if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) === -1) { + throw Error("Unexpected char at '" + xq.substr(j) + "'"); + } + var pname = Fleur.XPathEvaluator._getName(c + d); + j = Fleur.XPathEvaluator._skipSpaces(xq, j + pname.length); + c = xq.charAt(j); + var tdecl = ""; + if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) !== -1) { + d = xq.substr(j + 1); + r = Fleur.XPathEvaluator._getName(c + d); + if (r === "as") { + j = Fleur.XPathEvaluator._skipSpaces(xq, j + r.length); + c = xq.charAt(j); + if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) !== -1) { + d = xq.substr(j + 1); + var ptype = Fleur.XPathEvaluator._getName(c + d); + pindex = ptype.indexOf(":"); + np = pindex === -1 ? "'" + ptype + "'" : "'" + ptype.substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + ptype.substr(0, pindex) + "']]"; + c = xq.charAt(j + ptype.length); + tdecl = ",[Fleur.XQueryX.typeDeclaration,[[Fleur.XQueryX.atomicType,[" + np + "]]"; + if ("?+*".indexOf(c) !== -1) { + tdecl += ",[Fleur.XQueryX.occurrenceIndicator,['" + c + "']]"; + j++; + } + tdecl += "]]"; + j = Fleur.XPathEvaluator._skipSpaces(xq, j + ptype.length); + c = xq.charAt(j); + } + } + } + if (nbpar !== 0) { + fres += ","; + } + fres += "[Fleur.XQueryX.param,[[Fleur.XQueryX.varName,['" + pname + "']]" + tdecl + "]]"; + nbpar++; + } + } while (c === ","); + if (c !== ")") { + throw Error("Unexpected char at '" + xq.substr(j) + "'"); + } + fres += "]]"; + j = Fleur.XPathEvaluator._skipSpaces(xq, j + 1); + c = xq.charAt(j); + if (c === "a") { + d = xq.substr(j + 1); + r = Fleur.XPathEvaluator._getName(c + d); + if (r === "as") { + j = Fleur.XPathEvaluator._skipSpaces(xq, j + r.length); + c = xq.charAt(j); + if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) !== -1) { + d = xq.substr(j + 1); + ptype = Fleur.XPathEvaluator._getName(c + d); + pindex = ptype.indexOf(":"); + np = pindex === -1 ? "'" + ptype + "'" : "'" + ptype.substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + ptype.substr(0, pindex) + "']]"; + c = xq.charAt(j + ptype.length); + fres += ",[Fleur.XQueryX.typeDeclaration,[[Fleur.XQueryX.atomicType,[" + np + "]]"; + if ("?+*".indexOf(c) !== -1) { + fres += ",[Fleur.XQueryX.occurrenceIndicator,['" + c + "']]"; + j++; + } + fres += "]]"; + j = Fleur.XPathEvaluator._skipSpaces(xq, j + ptype.length); + c = xq.charAt(j); + } + } + } + if (c === "{") { + fres += ",[Fleur.XQueryX.functionBody,["; + var braces = 1; + var body = ""; + while ((c !== "}" || braces !== 0) && j !== end) { + c = xq.charAt(++j); + if (c === "{") { + braces++; + } else if (c === "}") { + braces--; + } + if (braces !== 0) { + body += c; + } + } + if (body !== "") { + fres += Fleur.XPathEvaluator._xp2js(body, "", ""); + } + fres += "]]"; + } else { + throw Error("Unexpected char at '" + xq.substr(j) + "'"); + } + plen = j + 2; + p = plen + ".[Fleur.XQueryX.inlineFunctionExpr,[" + fres + "]]"; + break; + case "'item'": + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['item']]]]")) + "[Fleur.XQueryX.anyItemType,[]]]]]]"; + break; + case "'map'": + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['map']]]]")) + "[Fleur.XQueryX.mapTest,[]]]]]]"; + break; + case "'namespace-node'": + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['namespace-node']]]]")) + "[Fleur.XQueryX.namespaceTest,[]]]]]]"; + break; + case "'node'": + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['node']]]]")) + "[Fleur.XQueryX.anyKindTest,[]]]]]]"; + break; + case "'processing-instruction'": + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['processing-instruction']]]]")) + "[Fleur.XQueryX.piTest,[" + (fargs2 ? "[Fleur.XQueryX.piTarget,[" + fargs2.substr(57) : "]]") + "]]]]"; + break; + case "'schema-attribute'": + parg0 = fargs.substr(fargs.indexOf("[Fleur.XQueryX.nameTest,['") + 25); + parg = parg0.substr(0, parg0.length - 6); + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['schema-attribute']]]]")) + "[Fleur.XQueryX.schemaAttributeTest,[" + parg + "]]]]]]"; + break; + case "'schema-element'": + parg0 = fargs.substr(fargs.indexOf("[Fleur.XQueryX.nameTest,['") + 25); + parg = parg0.substr(0, parg0.length - 6); + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['schema-element']]]]")) + "[Fleur.XQueryX.schemaElementTest,[" + parg + "]]]]]]"; + break; + case "'text'": + p = plen + "." + arg.substr(0, arg.indexOf("[Fleur.XQueryX.nameTest,['text']]]]")) + "[Fleur.XQueryX.textTest,[]]]]]]"; + break; + default: + p = plen + ".[Fleur.XQueryX.functionCallExpr,[[Fleur.XQueryX.functionName,[" + fname + "]],[Fleur.XQueryX.arguments,[" + fargs2 + "]]]]"; + } + } else if (arg.substr(0, 77) === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[") { + var arg1, lookup = false; + if (arg.indexOf(",[Fleur.XQueryX.predicates,[") !== -1) { + arg1 = arg.substr(0, arg.indexOf(",[Fleur.XQueryX.predicates,[")).substr(77); + arg20 = arg.substr(arg.indexOf(",[Fleur.XQueryX.predicates,[") + 28); + arg2 = arg20.substr(0, arg20.length - 6); + } else if (arg.indexOf(",[Fleur.XQueryX.lookup,[") !== -1) { + lookup = true; + arg1 = arg.substr(0, arg.indexOf(",[Fleur.XQueryX.lookup,[")).substr(77); + arg20 = arg.substr(arg.indexOf(",[Fleur.XQueryX.lookup,[") + 24); + arg2 = arg20.substr(0, arg20.length - 6); + } else { + arg1 = arg.substr(0, arg.length - 8).substr(77); + arg2 = ""; + } + fargs = t.substr(t.indexOf(".") + 1); + fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; + p = plen + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[[Fleur.XQueryX.dynamicFunctionInvocationExpr,[[Fleur.XQueryX.functionItem,[" + arg1 + (arg2 === "" ? "" : (lookup ? ",[Fleur.XQueryX.lookup,[" : ",[Fleur.XQueryX.predicates,[")+ arg2 + "]]") + (fargs2 === "" ? "" : ",[Fleur.XQueryX.arguments,[" + fargs2 + "]]") + "]]]]]]]]"; + } else if (arg.substr(0, 32) === "[Fleur.XQueryX.namedFunctionRef,") { + p = plen + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[[Fleur.XQueryX.dynamicFunctionInvocationExpr,[[Fleur.XQueryX.functionItem,[" + arg + "]]]]]]]]]]"; + } else if (arg === "[Fleur.XQueryX.flworExpr,[]]") { + fargs = t.substr(t.indexOf(".") + 1); + fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; + p = plen + ".[Fleur.XQueryX.flworExpr,[" + fargs2 + "]]"; + isret = true; + } else if (arg.substr(0, 57) === "[Fleur.XQueryX.quantifiedExpr,[[Fleur.XQueryX.quantifier,") { + fargs = t.substr(t.indexOf(".") + 1); + fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; + p = plen + "." + arg.substr(0, arg.length - 2) + "," + fargs2 + "]]"; + isret = true; + } else if (arg !== "") { + fargs = t.substr(t.indexOf(".") + 1); + fargs2 = fargs.substr(0, 26) === "[Fleur.XQueryX.arguments,[" ? fargs.substr(26, fargs.length - 28) : fargs; + p = plen + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[[Fleur.XQueryX.dynamicFunctionInvocationExpr,[[Fleur.XQueryX.functionItem,[" + arg + "]]" + (fargs2 === "" ? "" : ",[Fleur.XQueryX.arguments,[" + fargs2 + "]]") + "]]]]]]]]"; + } else { + p = plen + "." + t.substr(t.indexOf(".") + 1); + } + } else { + if (arg.substr(0, 25) !== "[Fleur.XQueryX.pathExpr,[") { + arg = "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[" + arg + "]]]]]]"; + } + if (c === "?") { + if (arg.indexOf(",[Fleur.XQueryX.predicates,[") === -1) { + p = plen + "." + arg.substr(0, arg.length - 4) + "," + t.substr(t.indexOf(".") + 1) + "]]]]"; + } else { + p = plen + "." + arg.substr(0, predstart) + predarr.reduce(function(s, pr) {return s + ",[Fleur.XQueryX.predicate,[" + pr + "]]";}, "") + "," + t.substr(t.indexOf(".") + 1) + "]]]]";; + } + allowpredicates = false; + } else if (arg.indexOf(",[Fleur.XQueryX.predicates,[") === -1) { + if (allowpredicates) { + predarr = []; + predarr.push(t.substr(t.indexOf(".") + 1)); + predstart = arg.length - 4; + } + p = plen + "." + arg.substr(0, arg.length - 4) + ",[" + (allowpredicates ? "Fleur.XQueryX.predicates" : "Fleur.XQueryX.predicate") + ",[" + t.substr(t.indexOf(".") + 1) + "]]]]]]"; + } else { + if (allowpredicates) { + predarr.push(t.substr(t.indexOf(".") + 1)); + } + p = plen + "." + arg.substr(0, arg.length - 6) + "," + t.substr(t.indexOf(".") + 1) + "]]]]]]"; + } + } + if (!isret) { + var inext = Fleur.XPathEvaluator._skipSpaces(s, plen - 1); + var cnext = s.charAt(inext); + if (cnext === "(" || cnext === "[" || cnext === "{" || cnext === "?") { + return Fleur.XPathEvaluator._getPredParam(cnext, s.substr(inext + 1), l + inext + 1, p.substr(p.indexOf(".") + 1), allowpredicates, predstart, predarr, ops); + } + } + return (l + plen) + "." + p.substr(p.indexOf(".") + 1); + }; + Fleur.XPathEvaluator._getPredParams = function(s, len, arg, ops) { + var i = Fleur.XPathEvaluator._skipSpaces(s, 0); + if (s.charAt(i) === "(" || s.charAt(i) === "[" || s.charAt(i) === "{" || (s.charAt(i) === "?" && ops.substr(0, 16) !== "13.6.instance of" && ops.substr(0, 16) !== "9.3.cast as" && ops.substr(0, 16) !== "13.4.castable as")) { + return Fleur.XPathEvaluator._getPredParam(s.charAt(i), s.substr(i + 1), len + i, arg, true, 0, [], ops); + } + return (len + i) + "." + arg; + }; + Fleur.XPathEvaluator._getStringLiteral = function(s) { + var i = Fleur.XPathEvaluator._skipSpaces(s, 0); + var d = s.substr(i + 1); + if (s.charAt(i) === "'") { + var sep2 = d.indexOf("'"); + var t2 = d.substr(0, d.indexOf("'")); + while (d.substr(sep2 + 1, 1) === "'") { + var d2 = d.substr(sep2 + 2); + t2 += "\\'" + d2.substr(0, d2.indexOf("'")); + sep2 += 2 + d2.indexOf("'"); + } + var t2b = "'" + Fleur.DocumentType.resolveEntities(null, t2) + "'"; + if (t2b === "''") { + t2b = ""; + } + return (sep2 + 2) + "." + t2b; + } else if (s.charAt(i) === '"') { + var sep3 = d.indexOf('"'); + var t3 = d.substr(0, d.indexOf('"')); + while (d.substr(sep3 + 1, 1) === '"') { + var d3 = d.substr(sep3 + 2); + t3 += '\\"' + d3.substr(0, d3.indexOf('"')); + sep3 += 2 + d3.indexOf('"'); + } + var t3b = '"' + Fleur.DocumentType.resolveEntities(null, t3) + '"'; + if (t3b === '""') { + t3b = ""; + } + return (sep3 + 2) + "." + t3b; + } + }; + Fleur.XPathEvaluator._getNumber = function(s, r) { + r = r || ""; + if (s === "") { + return r; + } + var c = s.charAt(0); + if (c === "E") { + c = "e"; + } + if ("0123456789".indexOf(c) !== -1 || ((c === "." || c === "e") && r.indexOf(c) === -1) || + ((c === "-" || c === "+") && r.endsWith("e"))) { + return Fleur.XPathEvaluator._getNumber(s.substr(1), r + c); + } + return r; + }; + Fleur.XPathEvaluator._xp2js = function(xp, args, ops) { + var i = Fleur.XPathEvaluator._skipSpaces(xp, 0); + var c = xp.charAt(i); + var d = xp.substr(i + 1); + var d2; + var r = ""; + if (c === "." && (d === "" || "0123456789".indexOf(d.charAt(0)) === -1)) { + if (d.charAt(0) === ".") { + r = "2.[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['parent']],[Fleur.XQueryX.anyKindTest,[]]]]]]"; + } else { + r = "1.[Fleur.XQueryX.contextItemExpr,[]]"; + } + } else if (c === ")" || c === "}") { + r = "0."; + } else if (c === "/") { + var ir = Fleur.XPathEvaluator._skipSpaces(d, 0); + r = (d.charAt(0) === "" || "/@*.(_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(d.charAt(ir)) === -1 ? "1" : "0") + ".[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.rootExpr,[]]]]"; + } else if (c === "@") { + r = Fleur.XPathEvaluator._getNameStep(d, 1); + } else if (c === "'") { + var sep2 = d.indexOf("'"); + var t2 = Fleur.DocumentType.resolveEntities(null, d.substr(0, d.indexOf("'"))).replace(/[\\]/g, '\\\\').replace(/[\"]/g, '\\\"').replace(/[\/]/g, '\\/').replace(/[\b]/g, '\\b').replace(/[\f]/g, '\\f').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r').replace(/[\t]/g, '\\t'); + while (d.substr(sep2 + 1, 1) === "'") { + d2 = d.substr(sep2 + 2); + t2 += "\\'" + Fleur.DocumentType.resolveEntities(null, d2.substr(0, d2.indexOf("'"))).replace(/[\\]/g, '\\\\').replace(/[\"]/g, '\\\"').replace(/[\/]/g, '\\/').replace(/[\b]/g, '\\b').replace(/[\f]/g, '\\f').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r').replace(/[\t]/g, '\\t'); + sep2 += 2 + d2.indexOf("'"); + } + var t2b = "'" + t2 + "'"; + if (t2b === "''") { + t2b = ""; + } + r = (sep2 + 2) + ".[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,[" + t2b + "]]]]"; + } else if (c === '"') { + var sep3 = d.indexOf('"'); + var t3 = Fleur.DocumentType.resolveEntities(null, d.substr(0, d.indexOf('"'))).replace(/[\\]/g, '\\\\').replace(/[\']/g, "\\\'").replace(/[\/]/g, '\\/').replace(/[\b]/g, '\\b').replace(/[\f]/g, '\\f').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r').replace(/[\t]/g, '\\t'); + while (d.substr(sep3 + 1, 1) === '"') { + var d3 = d.substr(sep3 + 2); + t3 += '\\"' + Fleur.DocumentType.resolveEntities(null, d3.substr(0, d3.indexOf('"'))).replace(/[\\]/g, '\\\\').replace(/[\']/g, "\\\'").replace(/[\/]/g, '\\/').replace(/[\b]/g, '\\b').replace(/[\f]/g, '\\f').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r').replace(/[\t]/g, '\\t'); + sep3 += 2 + d3.indexOf('"'); + } + var t3b = '"' + t3 + '"'; + if (t3b === '""') { + t3b = ""; + } + r = (sep3 + 2) + ".[Fleur.XQueryX.stringConstantExpr,[[Fleur.XQueryX.value,[" + t3b + "]]]]"; + } else if (c === "(") { + var endseq = Fleur.XPathEvaluator._skipSpaces(d, 0); + if (d.charAt(endseq) === ")") { + r = String(2 + endseq) + ".[Fleur.XQueryX.sequenceExpr,[]]"; + } else { + r = "0."; + } + } else if (c === "-" || c === "+") { + c = "~" + c; + r = "0."; + } else if (c !== "" && ".0123456789".indexOf(c) !== -1) { + var t5 = Fleur.XPathEvaluator._getNumber(c + d); + r = t5.length + ".[" + (t5.indexOf("e") !== -1 ? "Fleur.XQueryX.doubleConstantExpr" : t5.indexOf(".") !== -1 ? "Fleur.XQueryX.decimalConstantExpr" : "Fleur.XQueryX.integerConstantExpr") + ",[[Fleur.XQueryX.value,['" + t5.replace(/e\+/, "e") + "']]]]"; + } else if (c === "$") { + var t51 = Fleur.XPathEvaluator._getName(d); + var pt51 = (t51.indexOf(":") === -1 ? ":" : "") + t51; + var instr; + if (ops.startsWith("11.30.group by") || ops.startsWith("5.29.~,11.30.group by")) { + instr = "[Fleur.XQueryX.groupingSpec,[[Fleur.XQueryX.varName,["; + } else { + instr = "[Fleur.XQueryX.varRef,[[Fleur.XQueryX.name,["; + } + r = (t51.length + 1) + "." + instr + "'" + pt51.substr(pt51.indexOf(":") + 1) + "'" + (pt51.charAt(0) === ":" ? "" : ",[Fleur.XQueryX.prefix,['" + pt51.substr(0, pt51.indexOf(":")) + "']]") + "]]]]"; + } else if (c === "?") { + var c2 = d.charAt(0); + d = d.substr(1); + var t52; + if (c2 !== "" && "0123456789".indexOf(c2) !== -1) { + t52 = Fleur.XPathEvaluator._getNumber(c2 + d); + r = String(t52.length) + ".[Fleur.XQueryX.unaryLookup,[[Fleur.XQueryX.integerConstantExpr,[[Fleur.XQueryX.value,['" + t52.replace(/e\+/, "e") + "']]]]]]"; + } else if (c2 !== "" && "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(c2) !== -1) { + t52 = Fleur.XPathEvaluator._getName(c2 + d); + r = String(t52.length) + ".[Fleur.XQueryX.unaryLookup,[[Fleur.XQueryX.NCName,['" + t52 + "']]]]"; + } else if (c2 === "*") { + r = "1.[Fleur.XQueryX.unaryLookup,[[Fleur.XQueryX.star,[]]]]"; + } else if (c2 === "(") { + t52 = Fleur.XPathEvaluator._xp2js(d, "", "5.999.("); + var plen52 = d.length - parseInt(t52.substr(0, t52.indexOf(".")), 10) + 1; + r = String(plen52) + "." + "[Fleur.XQueryX.unaryLookup,[[Fleur.XQueryX.expr,[" + t52.substr(t52.indexOf(".") + 1) + "]]]]"; + } + } else if (c !== "" && "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz*".indexOf(c) !== -1) { + var t61 = Fleur.XPathEvaluator._getName(c+d); + if (["element","attribute","entry","processing-instruction"].indexOf(t61) !== -1) { + var i61 = Fleur.XPathEvaluator._skipSpaces(xp, i + t61.length); + var c61 = xp.charAt(i61); + if (c61 !== "" && "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(c61) !== -1) { + var d61 = xp.substr(i61 + 1); + var t62 = Fleur.XPathEvaluator._getName(c61 + d61); + switch(t61) { + case "element": + r = String(i61 - i + t62.length) + ".[Fleur.XQueryX.computedElementConstructor,[[Fleur.XQueryX.tagName,['" + t62 + "']]]]"; + break; + case "attribute": + r = String(i61 - i + t62.length) + ".[Fleur.XQueryX.computedAttributeConstructor,[[Fleur.XQueryX.tagName,['" + t62 + "']]]]"; + break; + case "processing-instruction": + r = String(i61 - i + t62.length) + ".[Fleur.XQueryX.computedPIConstructor,[[Fleur.XQueryX.piTarget,['" + t62 + "']]]]"; + break; + case "entry": + r = String(i61 - i + t62.length) + ".[Fleur.XQueryX.computedEntryConstructor,[[Fleur.XQueryX.tagName,['" + t62 + "']]]]"; + } + } else { + r = Fleur.XPathEvaluator._getNameStep(c + d, 0); + } + } else { + r = Fleur.XPathEvaluator._getNameStep(c + d, 0); + } + } else if (c === "<") { + r = Fleur.XPathEvaluator._getNodeConstructor(c + d); + } else { + r = "~~~~Unexpected char at '" + c + d + "'~#~#"; + throw Error("Unexpected char at '" + c + d + "'"); + } + if (r.indexOf("~~~~") !== -1) { + return r; + } + var rlen = parseInt(r.substr(0, r.indexOf(".")), 10); + var rval = r.substr(r.indexOf(".") + 1); + d2 = rlen === 0 ? c + d : d.substr(rlen - 1); + r = Fleur.XPathEvaluator._getPredParams(d2, rlen, rval, ops); + rlen = parseInt(r.substr(0, r.indexOf(".")), 10); + rval = r.substr(r.indexOf(".") + 1); + var args2 = rval.length + "." + rval + args; + var f = rlen === 0 ? c + d : d.substr(rlen - 1); + var i4 = Fleur.XPathEvaluator._skipSpaces(f, 0); + var o = f.charAt(i4); + var p = f.substr(f.indexOf(o)); + var op = "null"; + var op2 = "null"; + if ((p.substr(0, 9) === "ascending" || p.substr(0, 10) === "descending") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(o === "a" ? 9 : 10)) === -1) { + var postprec0 = Fleur.XPathEvaluator._precedence.substr(Fleur.XPathEvaluator._precedence.indexOf(".~~" + (o === "a" ? "ascending" : "descending") + ".") + (o === "a" ? 13 : 14)); + var postprec00 = postprec0.substr(postprec0.indexOf("&") + 1); + var postprec = postprec00.substr(0, postprec00.indexOf(".")); + var poststacks = Fleur.XPathEvaluator._calc(args2, ops, parseInt(postprec, 10)); + var postargslen = poststacks.substr(0, poststacks.indexOf(".")); + args2 = poststacks.substr(poststacks.indexOf(".") + 1).substr(0, parseInt(postargslen, 10)); + var postnextstack = poststacks.substr(postargslen.length + 1 + parseInt(postargslen, 10)); + var postopslen = postnextstack.substr(0, postnextstack.indexOf(".")); + ops = (postprec.length + 1 + (o === "a" ? 11 : 12)) + "." + postprec + ".~~" + (o === "a" ? "ascending" : "descending") + postnextstack.substr(postnextstack.indexOf(".") + 1).substr(0, parseInt(postopslen, 10)); + f = f.substr(i4 + (o === "a" ? 9 : 10)); + i4 = Fleur.XPathEvaluator._skipSpaces(f, 0); + o = f.charAt(i4); + p = f.substr(f.indexOf(o)); + } + if (ops.substr(0, 16) === "13.6.instance of") { + if (o === "+" || o === "?" || o === "*") { + ops = "14.6.instance of" + o + ops.substr(16); + i4 = Fleur.XPathEvaluator._skipSpaces(f, 1); + o = f.charAt(i4); + p = f.substr(f.indexOf(o)); + } + } else if (ops.substr(0, 13) === "10.5.treat as") { + if (o === "+" || o === "?" || o === "*") { + ops = "11.5.treat as" + o + ops.substr(13); + i4 = Fleur.XPathEvaluator._skipSpaces(f, 1); + o = f.charAt(i4); + p = f.substr(f.indexOf(o)); + } + } else if (ops.substr(0, 11) === "9.3.cast as") { + if (o === "?") { + ops = "10.3.cast as" + o + ops.substr(11); + i4 = Fleur.XPathEvaluator._skipSpaces(f, 1); + o = f.charAt(i4); + p = f.substr(f.indexOf(o)); + } + } else if (ops.substr(0, 16) === "13.4.castable as") { + if (o === "?") { + ops = "14.4.castable as" + o + ops.substr(16); + i4 = Fleur.XPathEvaluator._skipSpaces(f, 1); + o = f.charAt(i4); + p = f.substr(f.indexOf(o)); + } + } + if (o === "") { + var stacks = Fleur.XPathEvaluator._calc(args2, ops, 9999999); + var reslen0 = stacks.substr(stacks.indexOf(".") + 1); + var reslen = reslen0.substr(0, reslen0.indexOf(".")); + var ret0 = stacks.substr(stacks.indexOf(".") + 1); + return ret0.substr(ret0.indexOf(".") + 1).substr(0, parseInt(reslen, 10)); + } + if (o === "]" || o === ")" || o === "}" || (p.substr(0, 6) === "return" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(6)) === -1) || (p.substr(0, 9) === "satisfies" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(9)) === -1)) { + var stacks2 = Fleur.XPathEvaluator._calc(args2, ops, 998); + var reslen20 = stacks2.substr(stacks2.indexOf(".") + 1); + var reslen2 = reslen20.substr(0, reslen20.indexOf(".")); + var ret20 = stacks2.substr(stacks2.indexOf(".") + 1); + return (f.substr(f.indexOf(o) + 1).length - (o === "r" ? 5 : o === "s" ? 8 : 0)) + "." + ret20.substr(ret20.indexOf(".") + 1).substr(0, parseInt(reslen2, 10)); + } + if (o === "$") { + switch(rval) { + case "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['for']]]]]]": + rval = "[Fleur.XQueryX.flworExpr,[]]"; + op = "for"; + break; + case "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['let']]]]]]": + rval = "[Fleur.XQueryX.flworExpr,[]]"; + op = "let"; + break; + case "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['every']]]]]]": + rval = "[Fleur.XQueryX.quantifiedExpr,[[Fleur.XQueryX.quantifier,['every']]]]"; + op = "every"; + break; + case "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.nameTest,['some']]]]]]": + rval = "[Fleur.XQueryX.quantifiedExpr,[[Fleur.XQueryX.quantifier,['some']]]]"; + op = "some"; + break; + } + if (op !== "null") { + r = Fleur.XPathEvaluator._getPredParams("(" + f, rlen, rval); + rlen = parseInt(r.substr(0, r.indexOf(".")), 10); + rval = r.substr(r.indexOf(".") + 1); + args2 = rval.length + "." + rval + args; + op = op === "for" || op === "let" ? "return" : "satisfies"; + f = d.substr(rlen - 2 - op.length); + p = f.substr(1); + } + } else if (p.substr(0, 9) === "intersect" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(9)) === -1) { + op = p.substr(0, 9); + } else if (p.substr(0, 8) === "allowing" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(8)) === -1) { + op = p.substr(0, 8); + } else if (p.substr(0, 8) === "instance" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(8)) === -1) { + op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 8) + 2); + op2 = "instance of"; + } else if (p.substr(0, 8) === "castable" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(8)) === -1) { + op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 8) + 2); + op2 = "castable as"; + } else if ((p.substr(0, 6) === "except" || p.substr(0, 6) === "before") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(6)) === -1) { + op = p.substr(0, 6); + } else if (p.substr(0, 5) === "treat" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(5)) === -1) { + op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 5) + 2); + op2 = "treat as"; + } else if (p.substr(0, 5) === "group" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(5)) === -1) { + op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 5) + 2); + op2 = "group by"; + } else if (p.substr(0, 5) === "order" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(5)) === -1) { + op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 5) + 2); + op2 = "order by"; + } else if ((p.substr(0, 5) === "union" || p.substr(0, 5) === "every" || p.substr(0, 5) === "nodes" || p.substr(0, 5) === "after" || p.substr(0, 5) === "value" || p.substr(0, 5) === "count" || p.substr(0, 5) === "where" || p.substr(0, 5) === "empty" || p.substr(0, 5) === "catch") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(5)) === -1) { + op = p.substr(0, 5); + } else if (p.substr(0, 4) === "cast" && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(4)) === -1) { + op = p.substr(0, Fleur.XPathEvaluator._skipSpaces(p, 4) + 2); + op2 = "cast as"; + } else if ((p.substr(0, 4) === "idiv" || p.substr(0, 4) === "some" || p.substr(0, 4) === "then" || p.substr(0, 4) === "else" || p.substr(0, 4) === "node" || p.substr(0, 4) === "with" || p.substr(0, 4) === "into") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(4)) === -1) { + op = p.substr(0, 4); + } else if ((p.substr(0, 3) === "div" || p.substr(0, 3) === "and" || p.substr(0, 3) === "mod" || p.substr(0, 3) === "let" || p.substr(0, 3) === "for") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(3)) === -1) { + op = p.substr(0, 3); + } else if ((p.substr(0, 2) === "or" || p.substr(0, 2) === "eq" || p.substr(0, 2) === "ne" || p.substr(0, 2) === "lt" || p.substr(0, 2) === "le" || p.substr(0, 2) === "gt" || p.substr(0, 2) === "ge" || p.substr(0, 2) === "is" || p.substr(0, 2) === "to" || p.substr(0, 2) === "in" || p.substr(0, 2) === "as" || p.substr(0, 2) === "at" || p.substr(0, 2) === "by") && "_.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:".indexOf(p.charAt(2)) === -1) { + op = p.substr(0, 2); + } else if (p.substr(0, 2) === "!=" || p.substr(0, 2) === "<=" || p.substr(0, 2) === ">=" || p.substr(0, 2) === "<<" || p.substr(0, 2) === ">>" || p.substr(0, 2) === "//" || p.substr(0, 2) === "~+" || p.substr(0, 2) === "~-" || p.substr(0, 2) === ":=" || p.substr(0, 2) === "||" || p.substr(0, 2) === "!!") { + op = p.substr(0, 2); + } else if ("+-*=|,;<>/!{:".indexOf(o) !== -1) { + op = o; + if (op === ",") { + if (ops.startsWith("5.18.:=") || ops.startsWith("11.30.group by") || ops.startsWith("5.29.~,11.30.group by")) { + op2 = "~,"; + } else { + var optrack = ops; + while (optrack !== "") { + if (optrack.startsWith("11.30.order by")) { + op2 = "~,"; + break; + } + var optracklen = parseInt(optrack.substr(0, optrack.indexOf(".")), 10); + var optrackprec0 = optrack.substring(optrack.indexOf(".") + 1, optracklen); + var optrackprec = parseInt(optrackprec0.substr(0, optrackprec0.indexOf(".")), 10); + if (optrackprec > 30) { + break; + } + optrack = optrack.substr(optrack.indexOf(".") + 1 + optracklen); + } + } + } + } + if (op !== "null") { + var opprec0 = Fleur.XPathEvaluator._precedence.substr(Fleur.XPathEvaluator._precedence.indexOf("." + (op2 !== "null" ? op2 : op) + ".") + (op2 !== "null" ? op2 : op).length + 2); + var opprec00 = opprec0.substr(opprec0.indexOf("&") + 1); + var opprec = opprec00.substr(0, opprec00.indexOf(".")); + var stacks3 = Fleur.XPathEvaluator._calc(args2, ops, parseInt(opprec, 10)); + var args3len = stacks3.substr(0, stacks3.indexOf(".")); + var args3 = stacks3.substr(stacks3.indexOf(".") + 1).substr(0, parseInt(args3len, 10)); + var nextstack = stacks3.substr(args3len.length + 1 + parseInt(args3len, 10)); + var ops3len = nextstack.substr(0, nextstack.indexOf(".")); + var ops3 = nextstack.substr(nextstack.indexOf(".") + 1).substr(0, parseInt(ops3len, 10)); + var xp3 = p.substr(op.length); + return Fleur.XPathEvaluator._xp2js(xp3, args3, (opprec.length + 1 + (op2 !== "null" ? op2 : op).length) + "." + opprec + "." + (op2 !== "null" ? op2 : op) + ops3); + } + throw Error("Unknown operator at '" + f + "'"); + }; + Fleur.XPathEvaluator._getVersion = function(xq) { + var i = Fleur.XPathEvaluator._skipSpaces(xq, 0); + var c = xq.charAt(i); + var d = xq.substr(i + 1); + var r = ""; + var v, e; + if (c === "" || "abcdefghijklmnopqrstuvwxyz".indexOf(c) === -1) { + return i + "."; + } + r = Fleur.XPathEvaluator._getName(c + d); + if (r === "xquery") { + var j = Fleur.XPathEvaluator._skipSpaces(xq, i + r.length); + c = xq.charAt(j); + d = xq.substr(j + 1); + if (c === "" || "abcdefghijklmnopqrstuvwxyz".indexOf(c) === -1) { + return i + "."; + } + r = Fleur.XPathEvaluator._getName(c + d); + if (r === "version") { + j = Fleur.XPathEvaluator._skipSpaces(xq, j + r.length); + c = xq.charAt(j); + d = xq.substr(j + 1); + if (c !== "'" && c !== '"') { + return i + "."; + } + r = Fleur.XPathEvaluator._getStringLiteral(c + d); + var vl = r.substr(0, r.indexOf(".")); + v = r.substr(vl.length + 1); + j = Fleur.XPathEvaluator._skipSpaces(xq, j + parseInt(vl, 10)); + c = xq.charAt(j); + if (c === ";") { + return (j + 1) + ".[Fleur.XQueryX.versionDecl,[[Fleur.XQueryX.version,[" + v + "]]]],"; + } + d = xq.substr(j + 1); + r = Fleur.XPathEvaluator._getName(c + d); + } + if (r === "encoding") { + j = Fleur.XPathEvaluator._skipSpaces(xq, j + r.length); + c = xq.charAt(j); + d = xq.substr(j + 1); + if (c !== "'" && c !== '"') { + return i + "."; + } + r = Fleur.XPathEvaluator._getStringLiteral(c + d); + var el = r.substr(0, r.indexOf(".")); + e = r.substr(el.length + 1); + j = Fleur.XPathEvaluator._skipSpaces(xq, j + parseInt(el, 10)); + c = xq.charAt(j); + if (c === ";") { + return (j + 1) + ".[Fleur.XQueryX.versionDecl,[" + (v ? "[Fleur.XQueryX.version,[" + v + "]]," : "") + "[Fleur.XQueryX.encoding,[" + e + "]]]],"; + } + } + } + return i + "."; + }; + })(typeof exports === 'undefined'? this.Fleur = {}: exports); } var XsltForms_xpathAxis = { - ANCESTOR_OR_SELF: 'ancestor-or-self', - ANCESTOR: 'ancestor', - ATTRIBUTE: 'attribute', - CHILD: 'child', - DESCENDANT_OR_SELF: 'descendant-or-self', - DESCENDANT: 'descendant', - ENTRY: 'entry', - FOLLOWING_SIBLING: 'following-sibling', - FOLLOWING: 'following', - NAMESPACE: 'namespace', - PARENT: 'parent', - PRECEDING_SIBLING: 'preceding-sibling', - PRECEDING: 'preceding', - SELF: 'self' -}; -console.info('XSLTForms 1.6 (663), XForms 1.1+ Engine, copyright (C) 2022 agenceXML - Alain Couthures, contact at xsltforms@agencexml.com\nYou can use fleur() Javascript function to evaluate an expression. Example: fleur(\"instance()\")'); + ANCESTOR_OR_SELF: 'ancestor-or-self', + ANCESTOR: 'ancestor', + ATTRIBUTE: 'attribute', + CHILD: 'child', + DESCENDANT_OR_SELF: 'descendant-or-self', + DESCENDANT: 'descendant', + ENTRY: 'entry', + FOLLOWING_SIBLING: 'following-sibling', + FOLLOWING: 'following', + NAMESPACE: 'namespace', + PARENT: 'parent', + PRECEDING_SIBLING: 'preceding-sibling', + PRECEDING: 'preceding', + SELF: 'self' +}; +console.info('XSLTForms 1.7 (664), XForms 1.1+ Engine, copyright (C) 2023 agenceXML - Alain Couthures, contact at xsltforms@agencexml.com\nYou can use fleur() Javascript function to evaluate an expression. Example: fleur(\"instance()\")'); var XsltForms_context; var XsltForms_globals = { - fileVersion: "1.6", - fileVersionNumber: 663, + fileVersion: "1.7", + fileVersionNumber: 664, language: "navigator", debugMode: false, debugButtons: [ @@ -2109,6 +2109,8 @@ var XsltForms_globals = { componentLoads: [], jslibraries: {}, htmlversion: "4", + hasusername: false, + haspassword: false, debugging : function() { if (document.documentElement.childNodes[0].nodeType === 8 || (XsltForms_browser.isIE && document.documentElement.childNodes[0].childNodes[1] && document.documentElement.childNodes[0].childNodes[1].nodeType === 8)) { var body = XsltForms_browser.isXhtml ? document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "body")[0] : document.getElementsByTagName("body")[0]; @@ -2492,7 +2494,7 @@ var XsltForms_globals = { this.refreshtime += d2 - d1; this.refreshcount++; }, - build : function(element, ctx, selected, varresolver) { + build : function(element, ctx, selected) { if (element.nodeType !== Fleur.Node.ELEMENT_NODE || element.id === "xsltforms-console" || element.hasXFElement === false) { return {ctx: ctx, hasXFElement: false}; } @@ -2504,10 +2506,10 @@ var XsltForms_globals = { if (xf) { if (xf instanceof Array) { for (var ixf = 0, lenxf = xf.length; ixf < lenxf; ixf++) { - xf[ixf].build(ctx, varresolver); + xf[ixf].build(ctx); } } else { - xf.build(ctx, varresolver); + xf.build(ctx); if (xf.isRepeat) { xf.refresh(selected); } @@ -2538,7 +2540,7 @@ var XsltForms_globals = { } if (!childs[i].getAttribute("cloned")) { var samechild = childs[i]; - var br = this.build(childs[i], curctx, selected, varresolver); + var br = this.build(childs[i], curctx, selected); if (childs[i] !== samechild) { i--; } else { @@ -2554,7 +2556,6 @@ var XsltForms_globals = { } } } - element.varScope = null; } if(this.building) { if (xf instanceof Array) { @@ -3629,17 +3630,19 @@ if (!Fleur.DOMParser && (XsltForms_browser.isIE || XsltForms_browser.isIE11)) { if (node.evaluate) { return node.evaluate(xpath, node, node.createNSResolver(node.documentElement), XPathResult.ANY_TYPE, null).iterateNext().textContent; } - return node.ownerDocument.evaluate(xpath, node, node.ownerDocument.createNSResolver(node), XPathResult.ANY_TYPE, null).iterateNext().textContent; - } catch (e) { - if (node.nodeName === "properties") { - for (var i = 0, l = node.childNodes.length; i < l; i++ ) { - if (node.childNodes[i].nodeName === xpath) { - return node.childNodes[i].textContent; - } + const ret = node.ownerDocument.evaluate(xpath, node, node.ownerDocument.createNSResolver(node), XPathResult.ANY_TYPE, null).iterateNext(); + if (ret) { + return ret.textContent; + } + } catch (e) {} + if (node.nodeName === "properties") { + for (var i = 0, l = node.childNodes.length; i < l; i++ ) { + if (node.childNodes[i].nodeName === xpath) { + return node.childNodes[i].textContent; } } - return defvalue || ""; } + return defvalue || ""; } if (node.nodeName === "properties") { for (var i = 0, l = node.childNodes.length; i < l; i++ ) { @@ -4646,21 +4649,6 @@ XsltForms_browser.dialog = { surround.style.display = "block"; surround.style.zIndex = (this.zindex + this.initzindex)*2; this.zindex++; - size = XsltForms_browser.getWindowSize(); - surround.style.height = size.height+"px"; - surround.style.width = size.width+"px"; - surround.style.top = size.scrollY+"px"; - surround.style.left = size.scrollX+"px"; - var surroundresize = function () { - var surround2 = document.getElementsByTagName("xforms-dialog-surround")[0]; - var size2 = XsltForms_browser.getWindowSize(); - surround2.style.height = size2.height+"px"; - surround2.style.width = size2.width+"px"; - surround2.style.top = size2.scrollY+"px"; - surround2.style.left = size2.scrollX+"px"; - }; - window.onscroll = surroundresize; - window.onresize = surroundresize; } div.style.display = "block"; div.style.zIndex = (this.zindex + this.initzindex)*2-1; @@ -5802,20 +5790,13 @@ XsltForms_browser.assert = function(condition, message) { XsltForms_globals.debugging(); } XsltForms_browser.debugConsole.write("Assertion failed: " + message); - if (XsltForms_browser.isIE) { // Internet Explorer - this.callstack = []; - for (var caller = arguments.caller; caller; caller = caller.caller) { - this.callstack.push(caller.name ? caller.name : ""); - } - } else { - try { - XsltForms_undefined(); - } catch (e) { - if (e.stack) { - this.callstack = e.stack.split("\n"); - this.callstack.shift(); - this.callstack.shift(); - } + try { + XsltForms_undefined(); + } catch (e) { + if (e.stack) { + this.callstack = e.stack.split("\n"); + this.callstack.shift(); + this.callstack.shift(); } } if (this.callstack) { @@ -5899,6 +5880,10 @@ XsltForms_browser.getValueItemsetCopy = function(node) { }; XsltForms_browser.setValue = function(node, value) { XsltForms_browser.assert(node); + const instance = document.getElementById(XsltForms_browser.getDocMeta(node.nodeType === Fleur.Node.DOCUMENT_NODE ? node : node.ownerDocument, "instance")); + if (instance && instance.xfElement) { + instance.xfElement.modified = true; + } if (node.nodeType === Fleur.Node.ATTRIBUTE_NODE || node.nodeType === Fleur.Node.TEXT_NODE) { node.nodeValue = value; } else if (XsltForms_browser.isIE && node.innerHTML && !(value instanceof Array)) { @@ -5985,12 +5970,12 @@ function fleur(expression) { let result; let compiled; const current = XsltForms_globals.defaultModel.getInstanceDocument().documentElement; - let ctx = new XsltForms_exprContext(XsltForms_subform.subforms["xsltforms-mainform"], current, null, null, null, Fleur.XPathNSResolver_default, current, null); + let ctx = new XsltForms_exprContext(XsltForms_subform.subforms["xsltforms-mainform"], current, null, null, null, new Fleur.XPathNSResolver(), current, null); let arr; if (Fleur.minimal) { try { compiled = Fleur.XPathEvaluator._xp2js(expression, "", ""); - eval("arr = " + compiled + ";"); + arr = eval(compiled); compiled = XsltForms_FleurConv[arr[0]](arr[1]); compiled = eval(compiled); let res = compiled.evaluate(ctx); @@ -6045,7 +6030,7 @@ const XsltForms_debugger = { XsltForms_debugger.xfbody.appendChild(document.body.firstChild); } XsltForms_debugger.xfboard.innerHTML = ''; - XsltForms_debugger.xfboard.innerHTML += "XForms Debugger (XSLTForms " + XsltForms_globals.fileVersion + (Fleur.version ? " + Fleur " + Fleur.version : "") + ")
"; + XsltForms_debugger.xfboard.innerHTML += "XForms Debugger (XSLTForms " + XsltForms_globals.fileVersion + (Fleur.version ? " + Fleur " + Fleur.version : "") + ")
> XPath expression
"; XsltForms_debugger.xfhistory = document.createElement("xforms-console-history"); XsltForms_debugger.xfboard.appendChild(XsltForms_debugger.xfhistory); const xfexprbody = document.createElement("xforms-body"); @@ -6077,10 +6062,10 @@ const XsltForms_debugger = { XsltForms_debugger.xfhistory.appendChild(expr); } else { const expr = document.createElement("xforms-expression"); - expr.textContent = "-> " + evt.target.value; + expr.textContent = "> " + evt.target.value; XsltForms_debugger.xfhistory.appendChild(expr); const value = document.createElement("xforms-result"); - value.textContent = "<- " + fleur(evt.target.value); + value.textContent = fleur(evt.target.value); XsltForms_debugger.xfhistory.appendChild(value); } XsltForms_debugger.textarea.value = ""; @@ -6102,679 +6087,684 @@ const XsltForms_debugger = { } }; function XsltForms_subform(subform, id, eltid) { - this.subform = subform; - this.id = id; - this.eltid = eltid; - if (eltid) { - document.getElementById(eltid).xfSubform = this; - } - this.models = []; - this.schemas = []; - this.instances = []; - this.binds = []; - this.xpaths = []; - this.expressions = {}; - this.subforms = []; - this.listeners = []; - this.ready = false; - if (subform) { - subform.subforms.push(this); - } - XsltForms_subform.subforms[id] = this; + this.subform = subform; + this.id = id; + this.eltid = eltid; + if (eltid) { + document.getElementById(eltid).xfSubform = this; + } + this.models = []; + this.schemas = []; + this.instances = []; + this.binds = []; + this.xpaths = []; + this.expressions = {}; + this.subforms = []; + this.listeners = []; + this.ready = false; + if (subform) { + subform.subforms.push(this); + } + XsltForms_subform.subforms[id] = this; } XsltForms_subform.subforms = {}; new XsltForms_subform(null, "xsltforms-mainform"); XsltForms_subform.prototype.construct = function() { - for (var i = 0, len = this.instances.length; i < len; i++) { - this.instances[i].construct(this); - } - XsltForms_browser.forEach(this.binds, "refresh"); - for (i = 0, len = this.instances.length; i < len; i++) { - this.instances[i].revalidate(); - } - window.setTimeout("XsltForms_xmlevents.dispatchList(XsltForms_subform.subforms[\""+ this.id + "\"].models, \"xforms-subform-ready\")", 1); - this.ready = true; + for (var i = 0, len = this.instances.length; i < len; i++) { + this.instances[i].construct(this); + } + XsltForms_browser.forEach(this.binds, "refresh"); + for (i = 0, len = this.instances.length; i < len; i++) { + this.instances[i].revalidate(); + } + window.setTimeout("XsltForms_xmlevents.dispatchList(XsltForms_subform.subforms[\""+ this.id + "\"].models, \"xforms-subform-ready\")", 1); + this.ready = true; }; XsltForms_subform.prototype.dispose = function() { - for (var h = 0, len0 = this.subforms.length; h < len0; h++) { - this.subforms[0].dispose(); - } - this.subforms = null; - XsltForms_globals.dispose(document.getElementById(this.eltid)); - for (var i0 = 0, len00 = this.schemas.length; i0 < len00; i0++) { - this.schemas[i0].dispose(this); - this.schemas[i0] = null; - } - this.schemas = null; - for (var j = 0, len2 = this.instances.length; j < len2; j++) { - this.instances[j].dispose(this); - this.instances[j] = null; - } - this.instances = null; - for (var i = 0, len = this.models.length; i < len; i++) { - this.models[i].dispose(this); - this.models[i] = null; - } - this.models = null; - for (var k = 0, len3 = this.xpaths.length; k < len3; k++) { - this.xpaths[k].dispose(this); - this.xpaths[k] = null; - } - this.xpaths = null; - this.expressions = null; - this.binds = null; - XsltForms_subform.subforms[this.id] = null; - var parentform = this.subform; - if (parentform) { - var parentsubforms = parentform.subforms; - for (var l = 0, len4 = parentsubforms.length; l < len4; l++) { - if (parentsubforms[l] === this) { - if (l < len4 - 1) { - parentsubforms[l] = parentsubforms[len4 - 1]; - } - parentsubforms.pop(); - break; - } - } - } - for (var m = 0, len5 = this.listeners.length; m < len5; m++) { - this.listeners[m].detach(); - this.listeners[m] = null; - } - this.listeners = null; + for (var h = 0, len0 = this.subforms.length; h < len0; h++) { + this.subforms[0].dispose(); + } + this.subforms = null; + XsltForms_globals.dispose(document.getElementById(this.eltid)); + for (var i0 = 0, len00 = this.schemas.length; i0 < len00; i0++) { + this.schemas[i0].dispose(this); + this.schemas[i0] = null; + } + this.schemas = null; + for (var j = 0, len2 = this.instances.length; j < len2; j++) { + this.instances[j].dispose(this); + this.instances[j] = null; + } + this.instances = null; + for (var i = 0, len = this.models.length; i < len; i++) { + this.models[i].dispose(this); + this.models[i] = null; + } + this.models = null; + for (var k = 0, len3 = this.xpaths.length; k < len3; k++) { + this.xpaths[k].dispose(this); + this.xpaths[k] = null; + } + this.xpaths = null; + this.expressions = null; + this.binds = null; + XsltForms_subform.subforms[this.id] = null; + var parentform = this.subform; + if (parentform) { + var parentsubforms = parentform.subforms; + for (var l = 0, len4 = parentsubforms.length; l < len4; l++) { + if (parentsubforms[l] === this) { + if (l < len4 - 1) { + parentsubforms[l] = parentsubforms[len4 - 1]; + } + parentsubforms.pop(); + break; + } + } + } + for (var m = 0, len5 = this.listeners.length; m < len5; m++) { + this.listeners[m].detach(); + this.listeners[m] = null; + } + this.listeners = null; }; function XsltForms_binding(subform, elt, mip, miptype, model) { - var xpath = mip ? mip.startsWith("xf-template-") ? XsltForms_binding.t2c(elt.getAttribute(mip)) : elt.getAttribute(mip) : elt.getAttribute("xf-ref") || elt.getAttribute("xf-value"); - var modelid = elt.getAttribute("xf-model"); - var bind = elt.getAttribute(mip === "xf-repeat-ref" ? "xf-repeat-bind" : mip === "data-xf-repeat-ref" ? "data-xf-repeat-bind" : "xf-bind"); - this.type = miptype || (elt.localName.toLowerCase() === "xforms-var" ? "#nodes or constant" : (elt.hasAttribute("xf-value") && !elt.hasAttribute("xf-ref") && mip !== "xf-repeat-ref" && mip !== "data-xf-repeat-ref" ? "xsd:string" : null)); - this.bind = bind ? bind : null; - this.xpath = xpath ? XsltForms_xpath.create(subform, xpath) : null; - var modelelt; - if( modelid ) { - modelelt = document.getElementById(modelid); - } - this.model = modelelt ? modelelt.xfElement : modelid || model; - this.result = null; + var xpath = mip ? mip.startsWith("xf-template-") ? XsltForms_binding.t2c(elt.getAttribute(mip)) : elt.getAttribute(mip) : elt.getAttribute("xf-ref") || elt.getAttribute("xf-value"); + var modelid = elt.getAttribute("xf-model"); + var bind = elt.getAttribute(mip === "xf-repeat-ref" ? "xf-repeat-bind" : mip === "data-xf-repeat-ref" ? "data-xf-repeat-bind" : "xf-bind"); + this.type = miptype || (elt.localName.toLowerCase() === "xforms-var" ? "#nodes or constant" : (elt.hasAttribute("xf-value") && !elt.hasAttribute("xf-ref") && mip !== "xf-repeat-ref" && mip !== "data-xf-repeat-ref" ? "xsd:string" : null)); + this.bind = bind ? bind : null; + this.xpath = xpath ? XsltForms_xpath.create(subform, xpath) : null; + var modelelt; + if( modelid ) { + modelelt = document.getElementById(modelid); + } + this.model = modelelt ? modelelt.xfElement : modelid || model; + this.result = null; } XsltForms_binding.t2c = function(s) { - var i = 0; - var l = s.length; - var c = s.charAt(i); - var instrpart = true; - var strpart = ""; - var exprpart = ""; - var parts = []; - while (i < l) { - if (instrpart) { - if (c === "{" && s.charAt(i + 1) !== "{") { - if (strpart !== "") { - parts.push('"' + strpart + '"'); - strpart = ""; - } - instrpart = false; - } else { - if (c === '"') { - strpart += '""'; - } else if (c === "{") { - strpart += "{"; - i++; - } else { - strpart += c; - } - } - } else { - if (c === "}") { - parts.push(exprpart); - exprpart = ""; - instrpart = true; - } else { - exprpart += c; - } - } - c = s.charAt(++i); - } - if (strpart !== "") { - parts.push('"' + strpart + '"'); - } - if (parts.length !== 1) { - return "concat(" + parts.join(",") + ")"; - } - return parts[0]; + var i = 0; + var l = s.length; + var c = s.charAt(i); + var instrpart = true; + var strpart = ""; + var exprpart = ""; + var parts = []; + while (i < l) { + if (instrpart) { + if (c === "{" && s.charAt(i + 1) !== "{") { + if (strpart !== "") { + parts.push('"' + strpart + '"'); + strpart = ""; + } + instrpart = false; + } else { + if (c === '"') { + strpart += '""'; + } else if (c === "{") { + strpart += "{"; + i++; + } else { + strpart += c; + } + } + } else { + if (c === "}") { + parts.push(exprpart); + exprpart = ""; + instrpart = true; + } else { + exprpart += c; + } + } + c = s.charAt(++i); + } + if (strpart !== "") { + parts.push('"' + strpart + '"'); + } + if (parts.length !== 1) { + return "concat(" + parts.join(",") + ")"; + } + return parts[0]; }; XsltForms_binding.prototype.evaluate = function() { - alert("Error"); -}; -XsltForms_binding.prototype.bind_evaluate = function(subform, ctx, varresolver, depsNodes, depsId, depsElements) { - var result = null; - if( typeof this.model === "string" ) { - return null; - } - if (this.bind) { - if (typeof this.bind === "string") { - var idel = document.getElementById(this.bind); - if (!idel) { - XsltForms_browser.debugConsole.write("Binding evaluation returned null for bind: " + this.bind); - return null; // A 'null' signifies bind-ID not found. - } - this.bind = idel.xfElement; - } - result = this.bind.nodes; - XsltForms_browser.copyArray(this.bind.depsNodes, depsNodes); - XsltForms_browser.copyArray(this.bind.depsElements, depsElements); - } else { - var exprCtx = new XsltForms_exprContext(subform, !ctx || (this.model && this.model !== document.getElementById(XsltForms_browser.getDocMeta(ctx.ownerDocument, "model")).xfElement) ? this.model ? this.model.getInstanceDocument().documentElement : XsltForms_globals.defaultModel.getInstanceDocument().documentElement : ctx, - null, null, null, null, ctx, varresolver, depsNodes, depsId, depsElements, this.model); - result = this.xpath.xpath_evaluate(exprCtx); - } - XsltForms_browser.assert(this.type || !result || typeof result === "object", "Binding evaluation didn't returned a nodeset but '"+(typeof result === "object" ? "" : result)+"' for " + (this.bind ? "bind: " + this.bind : "XPath expression: " + this.xpath.expression)); - switch (this.type) { - case "xsd:string": - result = XsltForms_globals.stringValue(result); - break; - case "xsd:boolean": - result = XsltForms_globals.booleanValue(result); - break; - case "xsd:anyAtomicType": - if (typeof result === "object") { - result = XsltForms_globals.stringValue(result); - } - break; - } - this.result = result; - return result; + alert("Error"); +}; +XsltForms_binding.prototype.bind_evaluate = function(subform, ctx, element, depsNodes, depsId, depsElements) { + var result = null; + if( typeof this.model === "string" ) { + return null; + } + if (this.bind) { + if (typeof this.bind === "string") { + var idel = document.getElementById(this.bind); + if (!idel) { + XsltForms_browser.debugConsole.write("Binding evaluation returned null for bind: " + this.bind); + return null; // A 'null' signifies bind-ID not found. + } + this.bind = idel.xfElement; + } + result = this.bind.nodes; + XsltForms_browser.copyArray(this.bind.depsNodes, depsNodes); + XsltForms_browser.copyArray(this.bind.depsElements, depsElements); + } else { + var exprCtx = new XsltForms_exprContext(subform, !ctx || (this.model && this.model !== document.getElementById(XsltForms_browser.getDocMeta(ctx.ownerDocument, "model")).xfElement) ? this.model ? this.model.getInstanceDocument().documentElement : XsltForms_globals.defaultModel.getInstanceDocument().documentElement : ctx, + null, null, null, null, ctx, element, depsNodes, depsId, depsElements, this.model); + result = this.xpath.xpath_evaluate(exprCtx); + } + XsltForms_browser.assert(this.type || result === null || typeof result === "object", "Binding evaluation didn't returned a nodeset but '"+(typeof result === "object" ? "" : result)+"' for " + (this.bind ? "bind: " + this.bind : "XPath expression: " + this.xpath.expression)); + switch (this.type) { + case "xsd:string": + result = XsltForms_globals.stringValue(result); + break; + case "xsd:boolean": + result = XsltForms_globals.booleanValue(result); + break; + case "xsd:anyAtomicType": + if (typeof result === "object") { + result = XsltForms_globals.stringValue(result); + } + break; + } + this.result = result; + return result; }; function XsltForms_mipbinding(subform, elt, mip, miptype, model) { - this.binding = new XsltForms_binding(subform, elt, mip, miptype, model); - this.nodes = []; - this.depsElements = []; - this.depsNodes = []; + this.binding = new XsltForms_binding(subform, elt, mip, miptype, model); + this.nodes = []; + this.depsElements = []; + this.depsNodes = []; } XsltForms_mipbinding.prototype.evaluate = function(ctx, node) { - var deps = null; - var depsN = null; - var curn = this.nodes.length; - for (var i0 = 0, len0 = this.nodes.length; i0 < len0; i0++ ) { - if (node === this.nodes[i0].node) { - deps = this.nodes[i0].deps; - depsN = this.nodes[i0].depsN; - curn = i0; - break; - } - } - if (!deps && !depsN) { - this.nodes.push({node: node, deps: [], depsN: []}); - deps = depsN = []; - } - var build = !XsltForms_globals.ready || (deps.length === 0); - var changes = XsltForms_globals.changes; - for (var i1 = 0, len1 = depsN.length; !build && i1 < len1; i1++) { - build = depsN[i1].nodeName === ""; - } - for (var i = 0, len = deps.length; !build && i < len; i++) { - var el = deps[i]; - for (var j = 0, len2 = changes.length; !build && j < len2; j++) { - if (el === changes[j]) { - if (el.instances) { //model - if (el.rebuilded || el.newRebuilded) { - build = true; - } else { - for (var k = 0, len3 = depsN.length; !build && k < len3; k++) { - build = XsltForms_browser.inArray(depsN[k], el.nodesChanged); - } - } - } else { - build = true; - } - } - } - } - if (build) { - depsN.length = 0; - deps.length = 0; - this.nodes[curn].result = this.binding.bind_evaluate(ctx.subform, ctx.node, null, this.nodes[curn].depsN, null, this.nodes[curn].deps); - return this.nodes[curn].result; - } - return this.nodes[curn].result; + var deps = null; + var depsN = null; + var curn = this.nodes.length; + for (var i0 = 0, len0 = this.nodes.length; i0 < len0; i0++ ) { + if (node === this.nodes[i0].node) { + deps = this.nodes[i0].deps; + depsN = this.nodes[i0].depsN; + curn = i0; + break; + } + } + if (!deps && !depsN) { + this.nodes.push({node: node, deps: [], depsN: []}); + deps = depsN = []; + } + var build = !XsltForms_globals.ready || (deps.length === 0); + var changes = XsltForms_globals.changes; + for (var i1 = 0, len1 = depsN.length; !build && i1 < len1; i1++) { + build = depsN[i1].nodeName === ""; + } + for (var i = 0, len = deps.length; !build && i < len; i++) { + var el = deps[i]; + for (var j = 0, len2 = changes.length; !build && j < len2; j++) { + if (el === changes[j]) { + if (el.instances) { //model + if (el.rebuilded || el.newRebuilded) { + build = true; + } else { + for (var k = 0, len3 = depsN.length; !build && k < len3; k++) { + build = XsltForms_browser.inArray(depsN[k], el.nodesChanged); + } + } + } else { + build = true; + } + } + } + } + if (build) { + depsN.length = 0; + deps.length = 0; + this.nodes[curn].result = this.binding.bind_evaluate(ctx.subform, ctx.node, null, this.nodes[curn].depsN, null, this.nodes[curn].deps); + return this.nodes[curn].result; + } + return this.nodes[curn].result; }; XsltForms_mipbinding.prototype.nodedispose_ = function(node) { - for (var i = 0, len = this.nodes.length; i < len; i++ ) { - if (node === this.nodes[i].node) { - this.nodes[i] = this.nodes[len-1]; - this.nodes.pop(); - break; - } - } + for (var i = 0, len = this.nodes.length; i < len; i++ ) { + if (node === this.nodes[i].node) { + this.nodes[i] = this.nodes[len-1]; + this.nodes.pop(); + break; + } + } }; XsltForms_mipbinding.nodedispose = function(node) { - var bindids = XsltForms_browser.getMeta(node, "bind"); - if (bindids) { - var binds = bindids.split(" "); - for (var j = 0, len2 = binds.length; j < len2; j++) { - var bind = XsltForms_collection[binds[j]].xfElement; - if (bind.required) { - bind.required.nodedispose_(node); - } - if (bind.relevant) { - bind.relevant.nodedispose_(node); - } - if (bind.readonly) { - bind.readonly.nodedispose_(node); - } - if (bind.constraint) { - bind.constraint.nodedispose_(node); - } - if (bind.calculate) { - bind.calculate.nodedispose_(node); - } - } - } - for (var n = node.firstChild; n; n = n.nextSibling) { - if (n.nodeType === Fleur.Node.ELEMENT_NODE) { - XsltForms_mipbinding.nodedispose(n); - } - } + var bindids = XsltForms_browser.getMeta(node, "bind"); + if (bindids) { + var binds = bindids.split(" "); + for (var j = 0, len2 = binds.length; j < len2; j++) { + var bind = XsltForms_collection[binds[j]].xfElement; + if (bind.required) { + bind.required.nodedispose_(node); + } + if (bind.relevant) { + bind.relevant.nodedispose_(node); + } + if (bind.readonly) { + bind.readonly.nodedispose_(node); + } + if (bind.constraint) { + bind.constraint.nodedispose_(node); + } + if (bind.calculate) { + bind.calculate.nodedispose_(node); + } + } + } + for (var n = node.firstChild; n; n = n.nextSibling) { + if (n.nodeType === Fleur.Node.ELEMENT_NODE) { + XsltForms_mipbinding.nodedispose(n); + } + } }; var XsltForms_idManager = { - cloneId : function(element) { - XsltForms_browser.assert(element && element.id); - var id = element.getAttribute("oldid") || element.id; - var list = this.data[id]; - if (!list) { - list = []; - this.data[id] = list; - } - var newId = "clonedId" + this.index++; - list.push(newId); - element.setAttribute("oldid", id); - element.id = newId; - }, + cloneId : function(element) { + XsltForms_browser.assert(element && element.id); + var id = element.getAttribute("oldid") || element.id; + var list = this.data[id]; + if (!list) { + list = []; + this.data[id] = list; + } + var newId = "clonedId" + this.index++; + list.push(newId); + element.setAttribute("oldid", id); + element.id = newId; + }, find : function(id) { - var ids = this.data[id]; - if (ids) { - for (var i = 0, len = ids.length; i < len; i++) { - var element = document.getElementById(ids[i]); - if (element) { - var parentElt = element.parentNode; - while (parentElt.nodeType === Fleur.Node.ELEMENT_NODE) { - if (parentElt.localName.toLowerCase() === "xforms-repeat-item" || parentElt.getAttribute("xforms-name" === "repeat-item")) { - if (parentElt.getAttribute("xf-selected") === "true") { - return element; - } - break; - } - parentElt = parentElt.parentNode; - } - } - } - } - var res = document.getElementById(id); - return res; - }, - clear : function() { - for (var i = 0, len = this.data.length; i < len; i++) { - this.data[i] = null; - } - this.data = []; - this.index = 0; - }, - data : [], - index : 0 + var ids = this.data[id]; + if (ids) { + for (var i = 0, len = ids.length; i < len; i++) { + var element = document.getElementById(ids[i]); + if (element) { + var parentElt = element.parentNode; + while (parentElt.nodeType === Fleur.Node.ELEMENT_NODE) { + if (parentElt.localName.toLowerCase() === "xforms-repeat-item" || parentElt.getAttribute("xforms-name" === "repeat-item")) { + if (parentElt.getAttribute("xf-selected") === "true") { + return element; + } + break; + } + parentElt = parentElt.parentNode; + } + } + } + } + var res = document.getElementById(id); + return res; + }, + clear : function() { + for (var i = 0, len = this.data.length; i < len; i++) { + this.data[i] = null; + } + this.data = []; + this.index = 0; + }, + data : [], + index : 0 }; var XsltForms_classes = {}; var XsltForms_collection = []; function XsltForms_class(className, parentName, customElementName, template) { - XsltForms_classes[customElementName] = this; - this.className = className; - this.parentName = parentName; - this.customElementName = customElementName; - this.template = document.createElement(this.customElementName); - this.template.innerHTML = template; - this.template = Array.prototype.slice.call(this.template.children); - this.classbinding = new Function("subform", "elt", "if (!elt.xfElement) { XsltForms_classes[elt.localName.toLowerCase()].applyTemplate(elt); elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); elt.xfElement = new " + this.className + "(subform, elt); }"); - if (typeof customElements !== "undefined") { - var instr; - this.upperClassName = this.customElementName.replace(/([-_]\w)/g, function(g) { return g[1].toUpperCase(); }); - instr = "class " + this.upperClassName + " extends " + this.parentName + " { constructor() { super(); } };"; - instr += " customElements.define('" + this.customElementName + "', " + this.upperClassName + ");"; - try { - eval(instr); - } catch(e) {} - } + XsltForms_classes[customElementName] = this; + this.className = className; + this.parentName = parentName; + this.customElementName = customElementName; + this.template = document.createElement(this.customElementName); + this.template.innerHTML = template; + this.template = Array.prototype.slice.call(this.template.children); + this.classbinding = new Function("subform", "elt", "if (!elt.xfElement) { XsltForms_classes[elt.localName.toLowerCase()].applyTemplate(elt); elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); elt.xfElement = new " + this.className + "(subform, elt); }"); + if (typeof customElements !== "undefined") { + var instr; + this.upperClassName = this.customElementName.replace(/([-_]\w)/g, function(g) { return g[1].toUpperCase(); }); + instr = "class " + this.upperClassName + " extends " + this.parentName + " { constructor() { super(); } };"; + instr += " customElements.define('" + this.customElementName + "', " + this.upperClassName + ");"; + try { + eval(instr); + } catch(e) {} + } } XsltForms_class.activateAll = function(subform, elt, callback) { - var scharr = []; - Array.prototype.slice.call(elt.querySelectorAll("xforms-model[xf-schema]")).forEach(function(m) { - scharr = scharr.concat(m.getAttribute("xf-schema").split(" ").map(function(sch) { - return [m, sch]; - })); - }); - var schback = function() { - for (var xcname in XsltForms_classes) { - if (XsltForms_classes.hasOwnProperty(xcname)) { - Array.prototype.slice.call(elt.getElementsByTagName(xcname)).forEach(function(elt2) { XsltForms_classes[elt2.localName].classbinding(subform, elt2); }); - } - } - Array.prototype.slice.call(elt.querySelectorAll('*[xf-repeat-ref]')).forEach(function(elt2) { if (!elt2.xfElement) { elt2.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt2); elt2.xfElement = new XsltForms_repeat(subform, elt2); } }); - Array.prototype.slice.call(elt.querySelectorAll('*[xf-repeat-bind]')).forEach(function(elt2) { if (!elt2.xfElement) { elt2.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt2); elt2.xfElement = new XsltForms_repeat(subform, elt2); } }); - Array.prototype.slice.call(elt.querySelectorAll('*[xforms-name="repeat"]')).forEach(function(elt2) { if (!elt2.xfElement) { elt2.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt2); elt2.xfElement = eval("new " + XsltForms_classes["xforms-" + elt.getAttribute("xforms-name")].classname + "(subform, elt2)"); } }); - Array.prototype.slice.call(elt.querySelectorAll('*[xf-avt]')).forEach(function(elt2) { - if (!elt2.xfElement) { - elt2.xfIndex = XsltForms_collection.length; - XsltForms_collection.push(elt2); - } - Array.prototype.slice.call(elt2.attributes).filter(function(a) { - return a.nodeName.startsWith('xf-template-'); - }).forEach(function(a) { - new XsltForms_avt(subform, elt2, a.nodeName.substr(12)); - }); - }); - callback(); - }; - var schloader = function(arr, callback) { - if (arr.length === 0) { - return callback(); - } - var sch = arr.pop(); - var m = sch[0]; - sch = sch[1]; - var req = XsltForms_browser.openRequest("GET", sch, true); - var func = function() { - if (req.readyState !== 4) { - return; - } - try { - if (req.status === 1223) { - req.status = 204; - req.statusText = "No Content"; - } - if (req.status !== 0 && (req.status < 200 || req.status >= 300)) { - XsltForms_globals.error(m.xfElement, "xforms-link-exception", "Schema not found"); - throw new Error("Error"); - } - var ndoc = XsltForms_browser.createXMLDocument(req.responseText); - new XsltForms_schema(subform, ndoc.documentElement.getAttribute("targetNamespace"), sch, {}, ndoc); - } catch (e) { - } - schloader(arr, callback); - }; - req.onreadystatechange = func; - if (req.overrideMimeType) { - req.overrideMimeType("application/xml"); - } - try { - req.send(null); - } catch(e) { - alert("File not found: " + sch); - } - }; - schloader(scharr.reverse(), schback); + var scharr = []; + Array.prototype.slice.call(elt.querySelectorAll("xforms-model[xf-schema]")).forEach(function(m) { + scharr = scharr.concat(m.getAttribute("xf-schema").split(" ").map(function(sch) { + return [m, sch]; + })); + }); + var schback = function() { + Array.prototype.slice.call(elt.getElementsByTagName("xforms-var")).forEach(function(elt2) { XsltForms_classes[elt2.localName].classbinding(subform, elt2); }); + for (var xcname in XsltForms_classes) { + if (XsltForms_classes.hasOwnProperty(xcname) && xcname !== "xforms-var") { + Array.prototype.slice.call(elt.getElementsByTagName(xcname)).forEach(function(elt2) { XsltForms_classes[elt2.localName].classbinding(subform, elt2); }); + } + } + Array.prototype.slice.call(elt.querySelectorAll('*[xf-repeat-ref]')).forEach(function(elt2) { if (!elt2.xfElement) { elt2.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt2); elt2.xfElement = new XsltForms_repeat(subform, elt2); } }); + Array.prototype.slice.call(elt.querySelectorAll('*[xf-repeat-bind]')).forEach(function(elt2) { if (!elt2.xfElement) { elt2.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt2); elt2.xfElement = new XsltForms_repeat(subform, elt2); } }); + Array.prototype.slice.call(elt.querySelectorAll('*[xforms-name="repeat"]')).forEach(function(elt2) { if (!elt2.xfElement) { elt2.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt2); elt2.xfElement = eval("new " + XsltForms_classes["xforms-" + elt.getAttribute("xforms-name")].classname + "(subform, elt2)"); } }); + Array.prototype.slice.call(elt.querySelectorAll('*[xf-avt]')).forEach(function(elt2) { + if (!elt2.xfElement) { + elt2.xfIndex = XsltForms_collection.length; + XsltForms_collection.push(elt2); + } + Array.prototype.slice.call(elt2.attributes).filter(function(a) { + return a.nodeName.startsWith('xf-template-'); + }).forEach(function(a) { + new XsltForms_avt(subform, elt2, a.nodeName.substr(12)); + }); + }); + callback(); + }; + var schloader = function(arr, callback) { + if (arr.length === 0) { + return callback(); + } + var sch = arr.pop(); + var m = sch[0]; + sch = sch[1]; + var req = XsltForms_browser.openRequest("GET", sch, true); + var func = function() { + if (req.readyState !== 4) { + return; + } + try { + if (req.status === 1223) { + req.status = 204; + req.statusText = "No Content"; + } + if (req.status !== 0 && (req.status < 200 || req.status >= 300)) { + XsltForms_globals.error(m.xfElement, "xforms-link-exception", "Schema not found"); + throw new Error("Error"); + } + var ndoc = XsltForms_browser.createXMLDocument(req.responseText); + new XsltForms_schema(subform, ndoc.documentElement.getAttribute("targetNamespace"), sch, {}, ndoc); + } catch (e) { + } + schloader(arr, callback); + }; + req.onreadystatechange = func; + if (req.overrideMimeType) { + req.overrideMimeType("application/xml"); + } + try { + req.send(null); + } catch(e) { + alert("File not found: " + sch); + } + }; + schloader(scharr.reverse(), schback); }; XsltForms_class._applyTemplate = function(elt, template) { - var children = elt.children || elt.childNodes; - var childarr = Array.prototype.slice.call(children).map(function(e) { return e.localName.toLowerCase(); }); - var pos = 0; - template.forEach(function(t) { - var inc = childarr.indexOf(t.localName); - var n = t.localName; - if (!n.startsWith("xforms-")) { - n = "xforms-" + t.getAttribute("xforms-name"); - } - if (inc !== -1) { - pos = inc + 1; - } else if (n === "xforms-body" || n === "xforms-alert" || n === "xforms-required" || t.childNodes.length !== 0) { - elt.insertBefore(t.cloneNode(true), children[pos]); - childarr = Array.prototype.slice.call(children).map(function(e) { return e.localName.toLowerCase(); }); - pos++; - } - }); - var label; - Array.prototype.slice.call(children).forEach(function(child) { - var n = child.localName.toLowerCase(); - if (((n === "xforms-hint" && child.getAttribute("xf-appearance") !== "minimal") || (n === "xforms-help" && child.getAttribute("xf-appearance") !== "minimal") || n === "xforms-alert") && (!child.previousSibling || !child.previousSibling.localName || child.previousSibling.localName.toLowerCase() !== n + "-mark")) { - elt.insertBefore(document.createElement(n + "-mark"), child); - } else if (n === "xforms-label") { - label = child; - } - }); - if (label) { - Array.prototype.slice.call(children).forEach(function(child) { - var n = child.localName.toLowerCase(); - if (n === "xforms-help" && child.getAttribute("xf-appearance") === "minimal") { - elt.insertBefore(child, label.nextSibling); - } - }); - } + var children = elt.children || elt.childNodes; + var childarr = Array.prototype.slice.call(children).map(function(e) { return e.localName.toLowerCase(); }); + var pos = 0; + template.forEach(function(t) { + var inc = childarr.indexOf(t.localName); + var n = t.localName; + if (!n.startsWith("xforms-")) { + n = "xforms-" + t.getAttribute("xforms-name"); + } + if (inc !== -1) { + pos = inc + 1; + } else if (n === "xforms-body" || n === "xforms-alert" || n === "xforms-required" || t.childNodes.length !== 0) { + elt.insertBefore(t.cloneNode(true), children[pos]); + childarr = Array.prototype.slice.call(children).map(function(e) { return e.localName.toLowerCase(); }); + pos++; + } + }); + var label; + Array.prototype.slice.call(children).forEach(function(child) { + var n = child.localName.toLowerCase(); + if (((n === "xforms-hint" && child.getAttribute("xf-appearance") !== "minimal") || (n === "xforms-help" && child.getAttribute("xf-appearance") !== "minimal") || n === "xforms-alert") && (!child.previousSibling || !child.previousSibling.localName || child.previousSibling.localName.toLowerCase() !== n + "-mark")) { + elt.insertBefore(document.createElement(n + "-mark"), child); + } else if (n === "xforms-label") { + label = child; + } + }); + if (label) { + Array.prototype.slice.call(children).forEach(function(child) { + var n = child.localName.toLowerCase(); + if (n === "xforms-help" && child.getAttribute("xf-appearance") === "minimal") { + elt.insertBefore(child, label.nextSibling); + } + }); + } }; XsltForms_class.prototype.applyTemplate = function(elt) { - XsltForms_class._applyTemplate(elt, this.template); + XsltForms_class._applyTemplate(elt, this.template); }; function XsltForms_listener(subform, observer, evtTarget, evtname, phase, handler, defaultaction) { - if (!observer) { - return; - } - phase = phase || "default"; - if (phase !== "default" && phase !== "capture") { - XsltForms_globals.error(XsltForms_globals.defaultModel, "xforms-compute-exception", - "Unknown event-phase(" + phase +") for event(" + evtname + ")"+(observer ? " on element(" + observer.id + ")":"") + "!"); - return; - } - this.subform = subform; - this.observer = observer; - this.evtTarget = evtTarget; - this.name = evtname; - this.evtName = document.addEventListener? evtname : "errorupdate"; - this.phase = phase; - this.handler = handler; - this.defaultaction = defaultaction; - if (observer.listeners) { - if (evtname === "xforms-subform-ready") { - for (var i = 0, l = observer.listeners.length; i < l; i++) { - if (observer.listeners[i].name === evtname) { - return; - } - } - } - } else { - observer.listeners = []; - } - observer.listeners.push(this); - this.callback = function(evt) { - if (!document.addEventListener) { - evt = evt || window.event; - evt.target = evt.srcElement; - evt.currentTarget = observer; - XsltForms_browser.debugConsole.write("observer:"+observer.id); - XsltForms_browser.debugConsole.write("name:"+evtname); - XsltForms_browser.debugConsole.write("target:"+evt.target.id); - XsltForms_browser.debugConsole.write("trueName:"+evt.trueName); - if (evt.trueName && evt.trueName !== evtname) { - return; - } - if (!evt.phase) { - if (phase === "capture") { - return; - } - } else if (evt.phase !== phase) { - return; - } - if (phase === "capture") { - evt.cancelBubble = true; - } - evt.preventDefault = function() { - this.returnValue = false; - }; - evt.stopPropagation = function() { - this.cancelBubble = true; - this.stopped = true; - }; - } - var effectiveTarget = true; - if (evt.target && evt.target.nodeType === 3) { - evt.target = evt.target.parentNode; - } - if (evt.currentTarget && (evt.target.nodeName.toUpperCase() === "BUTTON" || evt.target.nodeName.toUpperCase() === "A" || evt.target.nodeName.toUpperCase() === "INPUT" || evt.target.nodeName.toUpperCase() === "XFORMS-LABEL" || (XsltForms_browser.isChrome && (evt.eventPhase === 3 || evt instanceof UIEvent) && this.xfElement && this.xfElement.controlName === "trigger")) && !XsltForms_browser.isFF2) { - effectiveTarget = false; - } - if (evt.eventPhase === 3 && evt.target.xfElement && evt.target === evt.currentTarget && !XsltForms_browser.isFF2) { - effectiveTarget = false; - } - if (evtTarget && evt.target !== evtTarget) { - effectiveTarget = false; - } - XsltForms_browser.debugConsole.write("effectiveTarget:"+effectiveTarget); - if (effectiveTarget) { // && !(typeof UIEvent !== 'undefined' && evt instanceof UIEvent)) { - XsltForms_browser.debugConsole.write("Captured event " + evtname + " on <" + evt.target.nodeName + - (evt.target.className? " class=\"" + (typeof evt.target.className === "string" ? evt.target.className : evt.target.className.baseVal) + "\"" : "") + - (evt.target.id? " id=\"" + evt.target.id + "\"" : "") + "/>"); - handler.call(evt.target, evt); - } - if (!defaultaction) { - evt.preventDefault(); - } - if (!document.addEventListener) { - try { - evt.preventDefault = null; - evt.stopPropagation = null; - } catch (e) {} - } - }; - this.attach(); - if (subform) { - subform.listeners.push(this); - } + if (!observer) { + return; + } + phase = phase || "default"; + if (phase !== "default" && phase !== "capture") { + XsltForms_globals.error(XsltForms_globals.defaultModel, "xforms-compute-exception", + "Unknown event-phase(" + phase +") for event(" + evtname + ")"+(observer ? " on element(" + observer.id + ")":"") + "!"); + return; + } + this.subform = subform; + this.observer = observer; + this.evtTarget = evtTarget; + this.name = evtname; + this.evtName = document.addEventListener? evtname : "errorupdate"; + this.phase = phase; + this.handler = handler; + this.defaultaction = defaultaction; + if (observer.listeners) { + if (evtname === "xforms-subform-ready") { + for (var i = 0, l = observer.listeners.length; i < l; i++) { + if (observer.listeners[i].name === evtname) { + return; + } + } + } + } else { + observer.listeners = []; + } + observer.listeners.push(this); + this.callback = function(evt) { + if (!document.addEventListener) { + evt = evt || window.event; + evt.target = evt.srcElement; + evt.currentTarget = observer; + XsltForms_browser.debugConsole.write("observer:"+observer.id); + XsltForms_browser.debugConsole.write("name:"+evtname); + XsltForms_browser.debugConsole.write("target:"+evt.target.id); + XsltForms_browser.debugConsole.write("trueName:"+evt.trueName); + if (evt.trueName && evt.trueName !== evtname) { + return; + } + if (!evt.phase) { + if (phase === "capture") { + return; + } + } else if (evt.phase !== phase) { + return; + } + if (phase === "capture") { + evt.cancelBubble = true; + } + evt.preventDefault = function() { + this.returnValue = false; + }; + evt.stopPropagation = function() { + this.cancelBubble = true; + this.stopped = true; + }; + } + var effectiveTarget = true; + if (evt.target && evt.target.nodeType === 3) { + evt.target = evt.target.parentNode; + } + if (evt.currentTarget && (evt.target.nodeName.toUpperCase() === "BUTTON" || evt.target.nodeName.toUpperCase() === "A" || evt.target.nodeName.toUpperCase() === "INPUT" || evt.target.nodeName.toUpperCase() === "XFORMS-LABEL" || (XsltForms_browser.isChrome && (evt.eventPhase === 3 || evt instanceof UIEvent) && this.xfElement && this.xfElement.controlName === "trigger")) && !XsltForms_browser.isFF2) { + effectiveTarget = false; + } + if (evt.eventPhase === 3 && evt.target.xfElement && evt.target === evt.currentTarget && !XsltForms_browser.isFF2) { + effectiveTarget = false; + } + if (evtTarget && evt.target !== evtTarget) { + effectiveTarget = false; + } + XsltForms_browser.debugConsole.write("effectiveTarget:"+effectiveTarget); + if (effectiveTarget) { // && !(typeof UIEvent !== 'undefined' && evt instanceof UIEvent)) { + XsltForms_browser.debugConsole.write("Captured event " + evtname + " on <" + evt.target.nodeName + + (evt.target.className? " class=\"" + (typeof evt.target.className === "string" ? evt.target.className : evt.target.className.baseVal) + "\"" : "") + + (evt.target.id? " id=\"" + evt.target.id + "\"" : "") + "/>"); + handler.call(evt.target, evt); + } + if (!defaultaction) { + evt.preventDefault(); + } + if (!document.addEventListener) { + try { + evt.preventDefault = null; + evt.stopPropagation = null; + } catch (e) {} + } + }; + this.attach(); + if (subform) { + subform.listeners.push(this); + } } XsltForms_listener.destructs = []; XsltForms_listener.prototype.attach = function() { - XsltForms_browser.events.attach(this.observer, this.evtName, this.callback, this.phase === "capture"); - if (this.evtName === "xforms-model-destruct") { - XsltForms_listener.destructs.push({observer: this.observer, callback: this.callback}); - } + XsltForms_browser.events.attach(this.observer, this.evtName, this.callback, this.phase === "capture"); + if (this.evtName === "xforms-model-destruct") { + XsltForms_listener.destructs.push({observer: this.observer, callback: this.callback}); + } }; XsltForms_listener.prototype.detach = function() { - if( this.observer.listeners ) { - for (var i = 0, l = this.observer.listeners.length; i < l; i++) { - if (this.observer.listeners[i] === this) { - this.observer.listeners.splice(i, 1); - break; - } - } - } - XsltForms_browser.events.detach(this.observer, this.evtName, this.callback, this.phase === "capture"); + if( this.observer.listeners ) { + for (var i = 0, l = this.observer.listeners.length; i < l; i++) { + if (this.observer.listeners[i] === this) { + this.observer.listeners.splice(i, 1); + break; + } + } + } + XsltForms_browser.events.detach(this.observer, this.evtName, this.callback, this.phase === "capture"); }; XsltForms_listener.prototype.clone = function(element) { - return new XsltForms_listener(this.subform, element, this.evtTarget, this.name, this.phase, this.handler); + return new XsltForms_listener(this.subform, element, this.evtTarget, this.name, this.phase, this.handler); }; var XsltForms_xmlevents = { - REGISTRY : [], - EventContexts : [], - define : function(evtname, bubbles, cancelable, defaultAction) { - XsltForms_xmlevents.REGISTRY[evtname] = { - bubbles: bubbles, - cancelable: cancelable, - defaultAction: defaultAction? defaultAction : function() { } - }; - }, - makeEventContext : function(evcontext, type, targetid, bubbles, cancelable) { - if (!evcontext) { - evcontext = {}; - } - if (!evcontext.type) { - evcontext.type = type; - } - try { - evcontext.targetid = targetid; - evcontext.bubbles = bubbles; - evcontext.cancelable = cancelable; - } catch (e) { - } - return evcontext; - } + REGISTRY : [], + EventContexts : [], + define : function(evtname, bubbles, cancelable, defaultAction) { + XsltForms_xmlevents.REGISTRY[evtname] = { + bubbles: bubbles, + cancelable: cancelable, + defaultAction: defaultAction? defaultAction : function() { } + }; + }, + makeEventContext : function(evcontext, type, targetid, bubbles, cancelable) { + if (!evcontext) { + evcontext = {}; + } + if (!evcontext.type) { + evcontext.type = type; + } + try { + evcontext.targetid = targetid; + if (!evcontext.bubbles || Object.getOwnPropertyDescriptor(evcontext, "bubbles")) { + evcontext.bubbles = bubbles; + } + if (!evcontext.cancelable || Object.getOwnPropertyDescriptor(evcontext, "cancelable")) { + evcontext.cancelable = cancelable; + } + } catch (e) { + } + return evcontext; + } }; XsltForms_xmlevents.dispatchList = function(list, evtname) { - for (var id = 0, len = list.length; id < len; id++) { - XsltForms_xmlevents.dispatch(list[id], evtname); - } + for (var id = 0, len = list.length; id < len; id++) { + XsltForms_xmlevents.dispatch(list[id], evtname); + } }; XsltForms_xmlevents.dispatch = function(target, evtname, type, bubbles, cancelable, defaultAction, evcontext) { - if (!target) { - XsltForms_browser.debugConsole.write("ERROR: Cannot dispatch event " + name + " as the target is null"); - return; - } - target = target.element || target; - XsltForms_browser.assert(target && typeof(target.nodeName) !== "undefined"); - XsltForms_browser.debugConsole.write("Dispatching event " + evtname + " on <" + target.nodeName.toLowerCase() + - (target.className? " class=\"" + (typeof target.className === "string" ? target.className : target.className.baseVal) + "\"" : "") + - (target.id? " id=\"" + target.id + "\"" : "") + "/>"); - var reg = XsltForms_xmlevents.REGISTRY[evtname]; - if (reg) { - bubbles = reg.bubbles; - cancelable = reg.cancelable; - defaultAction = reg.defaultAction; - } - if (!defaultAction) { - defaultAction = function() { }; - } - evcontext = XsltForms_xmlevents.makeEventContext(evcontext, evtname, target.id, bubbles, cancelable); - XsltForms_xmlevents.EventContexts.push(evcontext); - try { - var evt, res; - if (target.dispatchEvent) { - evt = document.createEvent("Event"); - evt.initEvent(evtname, bubbles, cancelable); - res = target.dispatchEvent(evt); - if ((res && !evt.stopped) || !cancelable) { - defaultAction.call(target.xfElement, evt); - } - } else { - var canceler = null; - var ancestors = []; - for (var a = target.parentNode; a; a = a.parentNode) { - ancestors.unshift(a); - } - for (var i = 0, len = ancestors.length; i < len; i++) { - evt = document.createEventObject(); - evt.trueName = evtname; - evt.phase = "capture"; - ancestors[i].fireEvent("onerrorupdate", evt); - if (evt.stopped) { - return; - } - } - evt = document.createEventObject(); - evt.trueName = evtname; - evt.phase = "capture"; - evt.target = target; - target.fireEvent("onerrorupdate" , evt); - if (!bubbles) { - canceler = new XsltForms_listener(null, target, null, evtname, "default", function(evt) { evt.cancelBubble = true; }); - } - evt = document.createEventObject(); - evt.trueName = evtname; - evt.phase = "default"; - evt.target = target; - res = target.fireEvent("onerrorupdate", evt); - try { - if ((res && !evt.stopped) || !cancelable) { - defaultAction.call(target.xfElement, evt); - } - if (!bubbles) { - canceler.detach(); - } - } catch (e2) { - } - } - } catch (e) { - alert("XSLTForms Exception\n--------------------------\n\nError dispatching event '"+evtname+"' :\n\n"+(typeof(e.stack)==="undefined"?"":e.stack)+"\n\n"+(e.name?e.name+(e.message?"\n\n"+e.message:""):e)); - } finally { - if (XsltForms_xmlevents.EventContexts[XsltForms_xmlevents.EventContexts.length - 1].rheadsdoc) { - XsltForms_xmlevents.EventContexts[XsltForms_xmlevents.EventContexts.length - 1].rheadsdoc = null; - } - if (XsltForms_xmlevents.EventContexts[XsltForms_xmlevents.EventContexts.length - 1]["response-body"]) { - XsltForms_xmlevents.EventContexts[XsltForms_xmlevents.EventContexts.length - 1]["response-body"] = null; - } - XsltForms_xmlevents.EventContexts.pop(); - } + if (!target) { + XsltForms_browser.debugConsole.write("ERROR: Cannot dispatch event " + name + " as the target is null"); + return; + } + target = target.element || target; + XsltForms_browser.assert(target && typeof(target.nodeName) !== "undefined"); + XsltForms_browser.debugConsole.write("Dispatching event " + evtname + " on <" + target.nodeName.toLowerCase() + + (target.className? " class=\"" + (typeof target.className === "string" ? target.className : target.className.baseVal) + "\"" : "") + + (target.id? " id=\"" + target.id + "\"" : "") + "/>"); + var reg = XsltForms_xmlevents.REGISTRY[evtname]; + if (reg) { + bubbles = reg.bubbles; + cancelable = reg.cancelable; + defaultAction = reg.defaultAction; + } + if (!defaultAction) { + defaultAction = function() { }; + } + evcontext = XsltForms_xmlevents.makeEventContext(evcontext, evtname, target.id, bubbles, cancelable); + XsltForms_xmlevents.EventContexts.push(evcontext); + try { + var evt, res; + if (target.dispatchEvent) { + evt = document.createEvent("Event"); + evt.initEvent(evtname, bubbles, cancelable); + res = target.dispatchEvent(evt); + if ((res && !evt.stopped) || !cancelable) { + defaultAction.call(target.xfElement, evt); + } + } else { + var canceler = null; + var ancestors = []; + for (var a = target.parentNode; a; a = a.parentNode) { + ancestors.unshift(a); + } + for (var i = 0, len = ancestors.length; i < len; i++) { + evt = document.createEventObject(); + evt.trueName = evtname; + evt.phase = "capture"; + ancestors[i].fireEvent("onerrorupdate", evt); + if (evt.stopped) { + return; + } + } + evt = document.createEventObject(); + evt.trueName = evtname; + evt.phase = "capture"; + evt.target = target; + target.fireEvent("onerrorupdate" , evt); + if (!bubbles) { + canceler = new XsltForms_listener(null, target, null, evtname, "default", function(evt) { evt.cancelBubble = true; }); + } + evt = document.createEventObject(); + evt.trueName = evtname; + evt.phase = "default"; + evt.target = target; + res = target.fireEvent("onerrorupdate", evt); + try { + if ((res && !evt.stopped) || !cancelable) { + defaultAction.call(target.xfElement, evt); + } + if (!bubbles) { + canceler.detach(); + } + } catch (e2) { + } + } + } catch (e) { + alert("XSLTForms Exception\n--------------------------\n\nError dispatching event '"+evtname+"' :\n\n"+(typeof(e.stack)==="undefined"?"":e.stack)+"\n\n"+(e.name?e.name+(e.message?"\n\n"+e.message:""):e)); + } finally { + if (XsltForms_xmlevents.EventContexts[XsltForms_xmlevents.EventContexts.length - 1].rheadsdoc) { + XsltForms_xmlevents.EventContexts[XsltForms_xmlevents.EventContexts.length - 1].rheadsdoc = null; + } + if (XsltForms_xmlevents.EventContexts[XsltForms_xmlevents.EventContexts.length - 1]["response-body"]) { + XsltForms_xmlevents.EventContexts[XsltForms_xmlevents.EventContexts.length - 1]["response-body"] = null; + } + XsltForms_xmlevents.EventContexts.pop(); + } }; XsltForms_xmlevents.define("xforms-model-construct", true, false, function() { this.construct(); }); XsltForms_xmlevents.define("xforms-model-construct-done", true, false); @@ -6821,794 +6811,802 @@ XsltForms_xmlevents.define("xforms-unload-done", true, false); XsltForms_xmlevents.define("xforms-upload-done", true, false); XsltForms_xmlevents.define("xforms-upload-error", true, false); function XsltForms_binaryExpr(expr1, op, expr2) { - this.expr1 = expr1; - this.expr2 = expr2; - this.op = op.replace(">", ">").replace("<", "<"); + this.expr1 = expr1; + this.expr2 = expr2; + this.op = op.replace(">", ">").replace("<", "<"); } XsltForms_binaryExpr.prototype.evaluate = function(ctx) { - var v1 = this.expr1.evaluate(ctx); - var v2 = this.expr2.evaluate(ctx); - var n1; - var n2; - if (v1 && v2 && (((typeof v1) === "object" && v1.length > 1) || ((typeof v2) === "object" && v2.length > 1)) && - (this.op === "=" || this.op === "!=" || this.op === "<" || this.op === "<=" || this.op === ">" || this.op === ">=")) { - if (typeof v1 !== "object") { - v1 = [v1]; - } - if (typeof v2 !== "object") { - v2 = [v2]; - } - for (var i = 0, len = v1.length; i < len; i++) { - n1 = XsltForms_globals.numberValue([v1[i]]); - if (isNaN(n1)) { - n1 = XsltForms_globals.stringValue([v1[i]]); - } - for (var j = 0, len1 = v2.length; j < len1; j++) { - n2 = XsltForms_globals.numberValue([v2[j]]); - if (isNaN(n2)) { - n2 = XsltForms_globals.stringValue([v2[j]]); - } - switch (this.op) { - case '=': - if (n1 == n2) { - return true; - } - break; - case '!=': - if (n1 != n2) { - return true; - } - break; - case '<': - if (n1 < n2) { - return true; - } - break; - case '<=': - if (n1 <= n2) { - return true; - } - break; - case '>': - if (n1 > n2) { - return true; - } - break; - case '>=': - if (n1 >= n2) { - return true; - } - break; - } - } - } - return false; - } - n1 = XsltForms_globals.numberValue(v1); - n2 = XsltForms_globals.numberValue(v2); - if (isNaN(n1) || isNaN(n2)) { - n1 = XsltForms_globals.stringValue(v1); - n2 = XsltForms_globals.stringValue(v2); - } - var res = 0; - switch (this.op) { - case 'or' : res = XsltForms_globals.booleanValue(v1) || XsltForms_globals.booleanValue(v2); break; - case 'and' : res = XsltForms_globals.booleanValue(v1) && XsltForms_globals.booleanValue(v2); break; - case '+' : res = n1 + n2; break; - case '-' : res = n1 - n2; break; - case '*' : res = n1 * n2; break; - case 'mod' : res = n1 % n2; break; - case 'div' : res = n1 / n2; break; - case '=' : res = n1 === n2; break; - case '!=' : res = n1 !== n2; break; - case '<' : res = n1 < n2; break; - case '<=' : res = n1 <= n2; break; - case '>' : res = n1 > n2; break; - case '>=' : res = n1 >= n2; break; - } - return typeof res === "number" ? Math.round(res*1000000)/1000000 : res; -}; -function XsltForms_exprContext(subform, node, position, nodelist, parentNode, nsresolver, current, varresolver, depsNodes, depsId, depsElements) { - this.subform = subform; - this.node = node; - this.current = current || node; - if(!position) { - var repeat = node && node.nodeType ? XsltForms_browser.getMeta(node, "repeat") : null; - if(repeat) { - var eltrepeat = XsltForms_collection[repeat]; - if (eltrepeat) { - var xrepeat = eltrepeat.xfElement; - var len; - for(position = 1, len = xrepeat.nodes.length; position <= len; position++) { - if(node === xrepeat.nodes[position-1]) { - break; - } - } - } - } - } - this.position = position || 1; - this.nodelist = nodelist || [ node ]; - this.parent = parentNode; - this.root = parentNode ? parentNode.root : node ? node.ownerDocument : null; - this.nsresolver = nsresolver; - this.varresolver = varresolver; - this.depsId = depsId; - this.initDeps(depsNodes, depsElements); + var v1 = this.expr1.evaluate(ctx); + var v2 = this.expr2.evaluate(ctx); + var n1; + var n2; + if (v1 && v2 && (((typeof v1) === "object" && v1.length > 1) || ((typeof v2) === "object" && v2.length > 1)) && + (this.op === "=" || this.op === "!=" || this.op === "<" || this.op === "<=" || this.op === ">" || this.op === ">=")) { + if (typeof v1 !== "object") { + v1 = [v1]; + } + if (typeof v2 !== "object") { + v2 = [v2]; + } + for (var i = 0, len = v1.length; i < len; i++) { + n1 = XsltForms_globals.numberValue([v1[i]]); + if (isNaN(n1)) { + n1 = XsltForms_globals.stringValue([v1[i]]); + } + for (var j = 0, len1 = v2.length; j < len1; j++) { + n2 = XsltForms_globals.numberValue([v2[j]]); + if (isNaN(n2)) { + n2 = XsltForms_globals.stringValue([v2[j]]); + } + switch (this.op) { + case '=': + if (n1 == n2) { + return true; + } + break; + case '!=': + if (n1 != n2) { + return true; + } + break; + case '<': + if (n1 < n2) { + return true; + } + break; + case '<=': + if (n1 <= n2) { + return true; + } + break; + case '>': + if (n1 > n2) { + return true; + } + break; + case '>=': + if (n1 >= n2) { + return true; + } + break; + } + } + } + return false; + } + n1 = XsltForms_globals.numberValue(v1); + n2 = XsltForms_globals.numberValue(v2); + if (isNaN(n1) || isNaN(n2)) { + n1 = XsltForms_globals.stringValue(v1); + n2 = XsltForms_globals.stringValue(v2); + } + var res = 0; + switch (this.op) { + case 'or' : res = XsltForms_globals.booleanValue(v1) || XsltForms_globals.booleanValue(v2); break; + case 'and' : res = XsltForms_globals.booleanValue(v1) && XsltForms_globals.booleanValue(v2); break; + case '+' : res = n1 + n2; break; + case '-' : res = n1 - n2; break; + case '*' : res = n1 * n2; break; + case 'mod' : res = n1 % n2; break; + case 'div' : res = n1 / n2; break; + case '=' : res = n1 === n2; break; + case '!=' : res = n1 !== n2; break; + case '<' : res = n1 < n2; break; + case '<=' : res = n1 <= n2; break; + case '>' : res = n1 > n2; break; + case '>=' : res = n1 >= n2; break; + } + return typeof res === "number" ? Math.round(res*1000000)/1000000 : res; +}; +function XsltForms_exprContext(subform, node, position, nodelist, parentNode, nsresolver, current, elt, depsNodes, depsId, depsElements) { + this.subform = subform; + this.node = node; + this.current = current || node; + if (!position) { + var repeat = node && node.nodeType ? XsltForms_browser.getMeta(node, "repeat") : null; + if (repeat) { + var eltrepeat = XsltForms_collection[repeat]; + if (eltrepeat) { + var xrepeat = eltrepeat.xfElement; + var len; + for (position = 1, len = xrepeat.nodes.length; position <= len; position++) { + if (node === xrepeat.nodes[position - 1]) { + break; + } + } + } + } + } + this.position = position || 1; + this.nodelist = nodelist || [node]; + this.parent = parentNode; + this.root = parentNode ? parentNode.root : node ? node.ownerDocument : null; + this.nsresolver = nsresolver; + this.element = elt; + this.depsId = depsId; + this.initDeps(depsNodes, depsElements); } XsltForms_exprContext.prototype.clone = function(node, position, nodelist) { - return new XsltForms_exprContext(this.subform, node || this.node, - typeof position === "undefined" ? this.position : position, - nodelist || this.nodelist, this, this.nsresolver, this.current, this.varresolver, - this.depsNodes, this.depsId, this.depsElements); + return new XsltForms_exprContext(this.subform, node || this.node, + typeof position === "undefined" ? this.position : position, + nodelist || this.nodelist, this, this.nsresolver, this.current, this.element, + this.depsNodes, this.depsId, this.depsElements); }; XsltForms_exprContext.prototype.setNode = function(node, position) { - this.node = node; - this.position = position; + this.node = node; + this.position = position; }; XsltForms_exprContext.prototype.initDeps = function(depsNodes, depsElements) { - this.depsNodes = depsNodes || []; - this.depsElements = depsElements || []; + this.depsNodes = depsNodes || []; + this.depsElements = depsElements || []; }; XsltForms_exprContext.prototype.addDepNode = function(node) { - var deps = this.depsNodes; - if (deps && node.nodeType && node.nodeType !== Fleur.Node.DOCUMENT_NODE && (!this.depsId || !XsltForms_browser.inValueMeta(node, "depfor", this.depsId))) { // !inArray(node, deps)) { - if (this.depsId) { - XsltForms_browser.addValueMeta(node, "depfor", this.depsId); - } - deps.push(node); - } + var deps = this.depsNodes; + if (deps && node.nodeType && node.nodeType !== Fleur.Node.DOCUMENT_NODE && (!this.depsId || !XsltForms_browser.inValueMeta(node, "depfor", this.depsId))) { // !inArray(node, deps)) { + if (this.depsId) { + XsltForms_browser.addValueMeta(node, "depfor", this.depsId); + } + deps.push(node); + } }; XsltForms_exprContext.prototype.addDepElement = function(element) { - var deps = this.depsElements; - if (deps && !XsltForms_browser.inArray(element, deps)) { - deps.push(element); - } + var deps = this.depsElements; + if (deps && !XsltForms_browser.inArray(element, deps)) { + deps.push(element); + } }; function XsltForms_tokenExpr(m) { - this.value = m; + this.value = m; } XsltForms_tokenExpr.prototype.evaluate = function() { - return XsltForms_globals.stringValue(this.value); + return XsltForms_globals.stringValue(this.value); }; function XsltForms_unaryMinusExpr(expr) { - this.expr = expr; + this.expr = expr; } XsltForms_unaryMinusExpr.prototype.evaluate = function(ctx) { - return -XsltForms_globals.numberValue(this.expr.evaluate(ctx)); + return -XsltForms_globals.numberValue(this.expr.evaluate(ctx)); }; function XsltForms_cteExpr(value) { - this.value = XsltForms_browser.isEscaped ? typeof value === "string" ? XsltForms_browser.unescape(value) : value : value; + this.value = XsltForms_browser.isEscaped ? typeof value === "string" ? XsltForms_browser.unescape(value) : value : value; } XsltForms_cteExpr.prototype.evaluate = function() { - return this.value; + return this.value; }; function XsltForms_filterExpr(expr, predicate) { - this.expr = expr; - this.predicate = predicate; + this.expr = expr; + this.predicate = predicate; } XsltForms_filterExpr.prototype.evaluate = function(ctx) { - var nodes = XsltForms_globals.nodeSetValue(this.expr.evaluate(ctx)); - for (var i = 0, len = this.predicate.length; i < len; ++i) { - var nodes0 = nodes; - nodes = []; - for (var j = 0, len1 = nodes0.length; j < len1; ++j) { - var n = nodes0[j]; - var newCtx = ctx.clone(n, j, nodes0); - if (XsltForms_globals.booleanValue(this.predicate[i].evaluate(newCtx))) { - nodes.push(n); - } - } - } - return nodes; + var nodes = XsltForms_globals.nodeSetValue(this.expr.evaluate(ctx)); + for (var i = 0, len = this.predicate.length; i < len; ++i) { + var nodes0 = nodes; + nodes = []; + for (var j = 0, len1 = nodes0.length; j < len1; ++j) { + var n = nodes0[j]; + var newCtx = ctx.clone(n, j, nodes0); + if (XsltForms_globals.booleanValue(this.predicate[i].evaluate(newCtx))) { + nodes.push(n); + } + } + } + return nodes; }; var XsltForms_FleurConv = []; var XsltForms_FleurConv_unsupported = function() { - return "~~~~Unsupported syntax~#~#"; + return "~~~~Unsupported syntax~#~#"; }; for (var XsltForms_i = 0; XsltForms_i < Fleur.Xlength; XsltForms_i++) { - XsltForms_FleurConv[XsltForms_i] = XsltForms_FleurConv_unsupported; + XsltForms_FleurConv[XsltForms_i] = XsltForms_FleurConv_unsupported; } XsltForms_FleurConv[Fleur.XQueryX.anyKindTest] = function() { - return "new XsltForms_nodeTestAny()"; + return "new XsltForms_nodeTestAny()"; }; XsltForms_FleurConv[Fleur.XQueryX.arrayTest] = function() { - return "new XsltForms_nodeTestType(131)"; + return "new XsltForms_nodeTestType(131)"; }; XsltForms_FleurConv[Fleur.XQueryX.commentTest] = function() { - return "new XsltForms_nodeTestType(8)"; + return "new XsltForms_nodeTestType(8)"; }; XsltForms_FleurConv[Fleur.XQueryX.contextItemExpr] = function() { - return "new XsltForms_locationExpr(false,new XsltForms_stepExpr('self',new XsltForms_nodeTestAny()))"; + return "new XsltForms_locationExpr(false,new XsltForms_stepExpr('self',new XsltForms_nodeTestAny()))"; }; XsltForms_FleurConv[Fleur.XQueryX.decimalConstantExpr] = function(children) { - return "new XsltForms_cteExpr(" + children[0][1][0] + ")"; + return "new XsltForms_cteExpr(" + children[0][1][0] + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.doubleConstantExpr] = function(children) { - return "new XsltForms_cteExpr(" + children[0][1][0] + ")"; + return "new XsltForms_cteExpr(" + children[0][1][0] + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.entryTest] = function() { - return "new XsltForms_nodeTestType(133)"; + return "new XsltForms_nodeTestType(133)"; }; XsltForms_FleurConv[Fleur.XQueryX.filterExpr] = function() { - return "new XsltForms_stepExpr('self',new XsltForms_nodeTestAny())"; + return "new XsltForms_stepExpr('self',new XsltForms_nodeTestAny())"; }; XsltForms_FleurConv[Fleur.XQueryX.functionCallExpr] = function(children) { - var fname = children[0][1][0]; - var uri = "http://www.w3.org/2005/xpath-functions"; - var args = children[1][1]; - if (children[0][1][1] && children[0][1][1][0] === Fleur.XQueryX.prefix) { - var pf = children[0][1][1][1][0]; - if (pf === "xf" || pf === "xform" || pf === "xforms") { - uri = "http://www.w3.org/2002/xforms"; - } else if (pf === "math") { - uri = "http://exslt.org/math"; - } else { - uri = Fleur.XPathNSResolver_default.uri[Fleur.XPathNSResolver_default.pf.indexOf(pf)]; - } - } else if (" boolean-from-string is-card-number count-non-empty index power random if choose property digest hmac local-date local-dateTime now days-from-date days-to-date seconds-from-dateTime seconds-to-dateTime adjust-dateTime-to-timezone seconds months instance current context event nodeindex is-valid serialize transform ".indexOf(" " + fname + " ") !== -1) { - uri = "http://www.w3.org/2002/xforms"; - } - var ret = "new XsltForms_functionCallExpr('" + uri + " " + fname + "'"; - for (var i = 0, l = args.length; i < l; i++) { - ret += "," + XsltForms_FleurConv[args[i][0]](args[i][1]); - } - ret += ")"; - return ret; + var fname = children[0][1][0]; + var uri = "http://www.w3.org/2005/xpath-functions"; + var args = children[1][1]; + if (children[0][1][1] && children[0][1][1][0] === Fleur.XQueryX.prefix) { + var pf = children[0][1][1][1][0]; + if (pf === "xf" || pf === "xform" || pf === "xforms") { + uri = "http://www.w3.org/2002/xforms"; + } else if (pf === "math") { + uri = "http://exslt.org/math"; + } else { + uri = Fleur.XPathNSResolver_default.uri[Fleur.XPathNSResolver_default.pf.indexOf(pf)]; + } + } else if (" boolean-from-string is-card-number count-non-empty index power random if choose property digest hmac local-date local-dateTime now days-from-date days-to-date seconds-from-dateTime seconds-to-dateTime adjust-dateTime-to-timezone seconds months instance current context event nodeindex is-valid serialize transform ".indexOf(" " + fname + " ") !== -1) { + uri = "http://www.w3.org/2002/xforms"; + } + var ret = "new XsltForms_functionCallExpr('" + uri + " " + fname + "'"; + for (var i = 0, l = args.length; i < l; i++) { + ret += "," + XsltForms_FleurConv[args[i][0]](args[i][1]); + } + ret += ")"; + return ret; }; XsltForms_FleurConv[Fleur.XQueryX.integerConstantExpr] = function(children) { - return "new XsltForms_cteExpr(" + children[0][1][0] + ")"; + return "new XsltForms_cteExpr(" + children[0][1][0] + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.mapTest] = function() { - return "new XsltForms_nodeTestType(132)"; + return "new XsltForms_nodeTestType(132)"; }; XsltForms_FleurConv[Fleur.XQueryX.nameTest] = function(children, axis) { - var ret = "new XsltForms_nodeTestName("; - if (children.length !== 1 && children[1][0] === Fleur.XQueryX.prefix) { - ret += "'" + children[1][1][0] + "'"; - } else if (axis === "attribute") { - ret += "null"; - } else { - ret += "''"; - } - ret += ",'"; - ret += children[0]; - ret += "')"; - return ret; + var ret = "new XsltForms_nodeTestName("; + if (children.length !== 1 && children[1][0] === Fleur.XQueryX.prefix) { + ret += "'" + children[1][1][0] + "'"; + } else if (axis === "attribute") { + ret += "null"; + } else { + ret += "''"; + } + ret += ",'"; + ret += children[0]; + ret += "')"; + return ret; }; XsltForms_FleurConv[Fleur.XQueryX.pathExpr] = function(children) { - var ret = ""; - var i = 0; - var pathexpr = false; - if (children[0][0] === Fleur.XQueryX.stepExpr && children[0][1][0][0] === Fleur.XQueryX.filterExpr && children[0][1][0][1][0][0] !== Fleur.XQueryX.contextItemExpr) { - pathexpr = true; - ret = "new XsltForms_pathExpr("; - ret += XsltForms_FleurConv[children[0][1][0][1][0][0]](children[0][1][0][1][0][1]); - ret += ","; - i++; - } - ret += "new XsltForms_locationExpr("; - if (children[0][0] !== Fleur.XQueryX.rootExpr) { - ret += "false"; - if (!pathexpr) { - ret += ","; - } - } - for (var l = children.length; i < l; i++) { - ret += (i !== 0 ? "," : "") + XsltForms_FleurConv[children[i][0]](children[i][1]); - } - ret += ")"; - if (pathexpr) { - ret += ")"; - } - return ret; + var ret = ""; + var i = 0; + var pathexpr = false; + if (children[0][0] === Fleur.XQueryX.stepExpr && children[0][1][0][0] === Fleur.XQueryX.filterExpr && children[0][1][0][1][0][0] !== Fleur.XQueryX.contextItemExpr) { + pathexpr = true; + ret = "new XsltForms_pathExpr("; + ret += XsltForms_FleurConv[children[0][1][0][1][0][0]](children[0][1][0][1][0][1]); + ret += ","; + i++; + } + ret += "new XsltForms_locationExpr("; + if (children[0][0] !== Fleur.XQueryX.rootExpr) { + ret += "false"; + if (!pathexpr) { + ret += ","; + } + } + for (var l = children.length; i < l; i++) { + ret += (i !== 0 ? "," : "") + XsltForms_FleurConv[children[i][0]](children[i][1]); + } + ret += ")"; + if (pathexpr) { + ret += ")"; + } + return ret; }; XsltForms_FleurConv[Fleur.XQueryX.piTest] = function(children) { - return "new XsltForms_nodeTestPi(" + (children.length !== 0 ? "'" + children[0][1][0] + "'" : "") + ")"; + return "new XsltForms_nodeTestPi(" + (children.length !== 0 ? "'" + children[0][1][0] + "'" : "") + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.predicates] = function(children) { - var ret = ""; - for (var i = 0, l = children.length; i < l; i++) { - ret += ",new XsltForms_predicateExpr(" + XsltForms_FleurConv[children[i][0]](children[i][1]) + ")"; - } - return ret; + var ret = ""; + for (var i = 0, l = children.length; i < l; i++) { + ret += ",new XsltForms_predicateExpr(" + XsltForms_FleurConv[children[i][0]](children[i][1]) + ")"; + } + return ret; }; XsltForms_FleurConv[Fleur.XQueryX.rootExpr] = function() { - return "true"; + return "true"; }; XsltForms_FleurConv[Fleur.XQueryX.stepExpr] = function(children) { - if (children.length === 1) { - return XsltForms_FleurConv[children[0][0]](children[0][1]); - } - var lpred; - var ret = "new XsltForms_stepExpr('"; - if (children[0][0] === Fleur.XQueryX.xpathAxis) { - ret += children[0][1][0]; - ret += "',"; - ret += XsltForms_FleurConv[children[1][0]](children[1][1], children[0][1][0]); - lpred = 3; - } else { - ret += "self',new XsltForms_nodeTestAny()"; - lpred = 2; - } - if (children.length === lpred) { - ret += XsltForms_FleurConv[children[lpred - 1][0]](children[lpred - 1][1]); - } - ret += ")"; - return ret; + if (children.length === 1) { + return XsltForms_FleurConv[children[0][0]](children[0][1]); + } + var lpred; + var ret = "new XsltForms_stepExpr('"; + if (children[0][0] === Fleur.XQueryX.xpathAxis) { + ret += children[0][1][0]; + ret += "',"; + ret += XsltForms_FleurConv[children[1][0]](children[1][1], children[0][1][0]); + lpred = 3; + } else { + ret += "self',new XsltForms_nodeTestAny()"; + lpred = 2; + } + if (children.length === lpred) { + ret += XsltForms_FleurConv[children[lpred - 1][0]](children[lpred - 1][1]); + } + ret += ")"; + return ret; }; XsltForms_FleurConv[Fleur.XQueryX.stringConstantExpr] = function(children) { - return "new XsltForms_cteExpr('" + (children[0][1][0] || "").replace(/\'/g, "\\'") + "')"; + return "new XsltForms_cteExpr('" + (children[0][1][0] || "").replace(/\'/g, "\\'") + "')"; }; XsltForms_FleurConv[Fleur.XQueryX.textTest] = function() { - return "new XsltForms_nodeTestType(3)"; + return "new XsltForms_nodeTestType(3)"; }; XsltForms_FleurConv[Fleur.XQueryX.varRef] = function(children) { - var nsURI; - if (children[0][1].length === 1) { - nsURI = ""; - } else { - nsURI = children[0][1][1][1][0] + ":"; - } - return "new XsltForms_varRef(\"" + nsURI + children[0][1][0] + "\")"; + var nsURI; + if (children[0][1].length === 1) { + nsURI = ""; + } else { + nsURI = children[0][1][1][1][0] + ":"; + } + return "new XsltForms_varRef(\"" + nsURI + children[0][1][0] + "\")"; }; XsltForms_FleurConv[Fleur.XQueryX.Wildcard] = function(children, axis) { - if (axis !== 'attribute') { - if (children.length === 0) { - return "new XsltForms_nodeTestType(1)"; - } - if (children[0][0] === Fleur.XQueryX.NCName) { - return "new XsltForms_nodeTestName('" + children[0][1][0] + "','')),new XsltForms_stepExpr('" + axis + "',new XsltForms_nodeTestType(1)"; - } - return "new XsltForms_nodeTestName('*','" + children[1][1][0] + "')"; - } - if (children.length === 0) { - return "new XsltForms_nodeTestAny()"; - } - if (children[0][0] === Fleur.XQueryX.NCName) { - return "new XsltForms_nodeTestName('" + children[0][1][0] + "','*')"; - } - return "new XsltForms_nodeTestName('*','" + children[1][1][0] + "')"; + if (axis !== 'attribute') { + if (children.length === 0) { + return "new XsltForms_nodeTestType(1)"; + } + if (children[0][0] === Fleur.XQueryX.NCName) { + return "new XsltForms_nodeTestName('" + children[0][1][0] + "','')),new XsltForms_stepExpr('" + axis + "',new XsltForms_nodeTestType(1)"; + } + return "new XsltForms_nodeTestName('*','" + children[1][1][0] + "')"; + } + if (children.length === 0) { + return "new XsltForms_nodeTestAny()"; + } + if (children[0][0] === Fleur.XQueryX.NCName) { + return "new XsltForms_nodeTestName('" + children[0][1][0] + "','*')"; + } + return "new XsltForms_nodeTestName('*','" + children[1][1][0] + "')"; }; XsltForms_FleurConv[Fleur.XQueryX.addOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'+'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'+'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.andOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'and'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'and'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.divOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'div'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'div'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.equalOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'='," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'='," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.greaterThanOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'>'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'>'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.greaterThanOrEqualOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'>='," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'>='," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.lessThanOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'<'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'<'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.lessThanOrEqualOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'<='," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'<='," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.modOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'mod'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'mod'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.multiplyOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'*'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'*'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.notEqualOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'!='," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'!='," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.orOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'or'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'or'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.subtractOp] = function(children) { - return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'-'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_binaryExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + ",'-'," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; XsltForms_FleurConv[Fleur.XQueryX.unaryMinusOp] = function(children) { - var operand = children[0][1][0][0]; - if (operand === Fleur.XQueryX.integerConstantExpr || operand === Fleur.XQueryX.decimalConstantExpr || operand === Fleur.XQueryX.doubleConstantExpr) { - return "new XsltForms_cteExpr(-" + children[0][1][0][1][0][1] + ")"; - } + var operand = children[0][1][0][0]; + if (operand === Fleur.XQueryX.integerConstantExpr || operand === Fleur.XQueryX.decimalConstantExpr || operand === Fleur.XQueryX.doubleConstantExpr) { + return "new XsltForms_cteExpr(-" + children[0][1][0][1][0][1] + ")"; + } }; XsltForms_FleurConv[Fleur.XQueryX.unionOp] = function(children) { - return "new XsltForms_unionExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + "," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; + return "new XsltForms_unionExpr(" + XsltForms_FleurConv[children[0][1][0][0]](children[0][1][0][1]) + "," + XsltForms_FleurConv[children[1][1][0][0]](children[1][1][0][1]) + ")"; }; function XsltForms_locationExpr(absolute) { - this.absolute = absolute; - this.steps = []; - for (var i = 1, len = arguments.length; i < len; i++) { - this.steps.push(arguments[i]); - } + this.absolute = absolute; + this.steps = []; + for (var i = 1, len = arguments.length; i < len; i++) { + this.steps.push(arguments[i]); + } } XsltForms_locationExpr.prototype.evaluate = function(ctx) { - var start = (this.absolute && ctx.root )|| !ctx.node ? ctx.root : ctx.node; - var m = XsltForms_browser.getDocMeta((start.nodeType === Fleur.Node.DOCUMENT_NODE ? start : start.ownerDocument), "model"); - if (m) { - ctx.addDepElement(document.getElementById(m).xfElement); - } - var nodes = []; - if (this.steps[0]) { - this.xPathStep(nodes, this.steps, 0, start, ctx); - } else { - nodes[0] = start; - } - return nodes; + var start = (this.absolute && ctx.root )|| !ctx.node ? ctx.root : ctx.node; + var m = XsltForms_browser.getDocMeta((start.nodeType === Fleur.Node.DOCUMENT_NODE ? start : start.ownerDocument), "model"); + if (m) { + ctx.addDepElement(document.getElementById(m).xfElement); + } + var nodes = []; + if (this.steps[0]) { + this.xPathStep(nodes, this.steps, 0, start, ctx); + } else { + nodes[0] = start; + } + return nodes; }; XsltForms_locationExpr.prototype.xPathStep = function(nodes, steps, step, input, ctx) { - var s = steps[step]; - var nodelist = s.evaluate(ctx.clone(input)); - for (var i = 0, len = nodelist.length; i < len; ++i) { - var node = nodelist[i]; - if (step === steps.length - 1) { - if (!XsltForms_browser.inArray(node, nodes)) { - nodes.push(node); - } - ctx.addDepNode(node); - } else { - this.xPathStep(nodes, steps, step + 1, node, ctx); - } - } + var s = steps[step]; + var nodelist = s.evaluate(ctx.clone(input)); + for (var i = 0, len = nodelist.length; i < len; ++i) { + var node = nodelist[i]; + if (step === steps.length - 1) { + if (!XsltForms_browser.inArray(node, nodes)) { + nodes.push(node); + } + ctx.addDepNode(node); + } else { + this.xPathStep(nodes, steps, step + 1, node, ctx); + } + } }; function XsltForms_nodeTestAny() { } XsltForms_nodeTestAny.prototype.evaluate = function(node) { - var n = node.localName || node.baseName; - return !n || (n.substr(0, 10) !== "xsltforms_" && node.namespaceURI !== "http://www.w3.org/2000/xmlns/"); + var n = node.localName || node.baseName; + return !n || (n.substr(0, 10) !== "xsltforms_" && node.namespaceURI !== "http://www.w3.org/2000/xmlns/"); }; function XsltForms_nodeTestName(prefix, tname) { - this.prefix = prefix; - this.name = tname; - this.uppercase = tname.toUpperCase(); - this.wildcard = tname === "*"; - this.notwildcard = tname !== "*"; - this.notwildcardprefix = prefix !== "*"; - this.hasprefix = prefix && this.notwildcardprefix; + this.prefix = prefix; + this.name = tname; + this.uppercase = tname.toUpperCase(); + this.wildcard = tname === "*"; + this.notwildcard = tname !== "*"; + this.notwildcardprefix = prefix !== "*"; + this.hasprefix = prefix && this.notwildcardprefix; } XsltForms_nodeTestName.prototype.evaluate = function(node, nsresolver, csensitive) { - var nodename = node.localName || node.baseName; - if (this.notwildcard && (nodename !== this.name || (csensitive && nodename.toUpperCase() !== this.uppercase))) { - return false; - } - if (this.wildcard) { - return this.hasprefix ? node.namespaceURI === nsresolver.lookupNamespaceURI(this.prefix) : true; - } - var ns = node.namespaceURI; - return this.hasprefix ? ns === nsresolver.lookupNamespaceURI(this.prefix) : - (this.notwildcardprefix ? !ns || ns === "" || ns === nsresolver.lookupNamespaceURI("") : true); + var nodename = node.localName || node.baseName; + if (this.notwildcard && (nodename !== this.name || (csensitive && nodename.toUpperCase() !== this.uppercase))) { + return false; + } + if (this.wildcard) { + return this.hasprefix ? node.namespaceURI === nsresolver.lookupNamespaceURI(this.prefix) : true; + } + var ns = node.namespaceURI; + return this.hasprefix ? ns === nsresolver.lookupNamespaceURI(this.prefix) : + (this.notwildcardprefix ? !ns || ns === "" || ns === nsresolver.lookupNamespaceURI("") : true); }; function XsltForms_nodeTestPI(target) { - this.target = target; + this.target = target; } XsltForms_nodeTestPI.prototype.evaluate = function(node) { - return node.nodeType === Fleur.Node.PROCESSING_INSTRUCTION_NODE && - (!this.target || node.nodeName === this.target); + return node.nodeType === Fleur.Node.PROCESSING_INSTRUCTION_NODE && + (!this.target || node.nodeName === this.target); }; function XsltForms_nodeTestType(type) { - this.type = type; + this.type = type; } XsltForms_nodeTestType.prototype.evaluate = function(node) { - return node.nodeType === this.type; + return node.nodeType === this.type; }; function XsltForms_pathExpr(filter, rel) { - this.filter = filter; - this.rel = rel; + this.filter = filter; + this.rel = rel; } XsltForms_pathExpr.prototype.evaluate = function(ctx) { - var nodes = XsltForms_globals.nodeSetValue(this.filter.evaluate(ctx)); - var nodes1 = []; - for (var i = 0, len = nodes.length; i < len; i++) { - var newCtx = ctx.clone(nodes[i], i, nodes); - var nodes0 = XsltForms_globals.nodeSetValue(this.rel.evaluate(newCtx)); - for (var j = 0, len1 = nodes0.length; j < len1; j++) { - nodes1.push(nodes0[j]); - } - } - return nodes1; + var nodes = XsltForms_globals.nodeSetValue(this.filter.evaluate(ctx)); + var nodes1 = []; + for (var i = 0, len = nodes.length; i < len; i++) { + var newCtx = ctx.clone(nodes[i], i, nodes); + var nodes0 = XsltForms_globals.nodeSetValue(this.rel.evaluate(newCtx)); + for (var j = 0, len1 = nodes0.length; j < len1; j++) { + nodes1.push(nodes0[j]); + } + } + return nodes1; }; function XsltForms_predicateExpr(expr) { - this.expr = expr; + this.expr = expr; } XsltForms_predicateExpr.prototype.evaluate = function(ctx) { - var v = this.expr.evaluate(ctx); - return typeof v === "number" ? ctx.position === v : XsltForms_globals.booleanValue(v); + var v = this.expr.evaluate(ctx); + return typeof v === "number" ? ctx.position === v : XsltForms_globals.booleanValue(v); }; function XsltForms_stepExpr(axis, nodetest) { - this.axis = axis; - this.nodetest = nodetest; - this.predicates = []; - for (var i = 2, len = arguments.length; i < len; i++) { - this.predicates.push(arguments[i]); - } + this.axis = axis; + this.nodetest = nodetest; + this.predicates = []; + for (var i = 2, len = arguments.length; i < len; i++) { + this.predicates.push(arguments[i]); + } } XsltForms_stepExpr.prototype.evaluate = function(ctx) { - var input = ctx.node; - var list = []; - switch(this.axis) { - case XsltForms_xpathAxis.ANCESTOR_OR_SELF : - XsltForms_stepExpr.push(ctx, list, input, this.nodetest); - if (input.nodeType === Fleur.Node.ATTRIBUTE_NODE) { - input = input.ownerElement ? input.ownerElement : input.selectSingleNode(".."); - XsltForms_stepExpr.push(ctx, list, input, this.nodetest); - } else if (input.nodeType === Fleur.Node.ENTRY_NODE) { - input = input.ownerMap; - XsltForms_stepExpr.push(ctx, list, input, this.nodetest); - } - for (var pn = input.parentNode; pn.parentNode; pn = pn.parentNode) { - XsltForms_stepExpr.push(ctx, list, pn, this.nodetest); - } - break; - case XsltForms_xpathAxis.ANCESTOR : - if (input.nodeType === Fleur.Node.ATTRIBUTE_NODE) { - input = input.ownerElement ? input.ownerElement : input.selectSingleNode(".."); - XsltForms_stepExpr.push(ctx, list, input, this.nodetest); - } else if (input.nodeType === Fleur.Node.ENTRY_NODE) { - input = input.ownerMap; - XsltForms_stepExpr.push(ctx, list, input, this.nodetest); - } - for (var pn2 = input.parentNode; pn2.parentNode; pn2 = pn2.parentNode) { - XsltForms_stepExpr.push(ctx, list, pn2, this.nodetest); - } - break; - case XsltForms_xpathAxis.ATTRIBUTE : - XsltForms_stepExpr.pushList(ctx, list, input.attributes, this.nodetest, !input.namespaceURI || input.namespaceURI === "http://www.w3.org/1999/xhtml"); - break; - case XsltForms_xpathAxis.CHILD : - XsltForms_stepExpr.pushList(ctx, list, input.childNodes, this.nodetest); - break; - case XsltForms_xpathAxis.DESCENDANT_OR_SELF : - XsltForms_stepExpr.push(ctx, list, input, this.nodetest); - XsltForms_stepExpr.pushDescendants(ctx, list, input, this.nodetest); - break; - case XsltForms_xpathAxis.DESCENDANT : - XsltForms_stepExpr.pushDescendants(ctx, list, input, this.nodetest); - break; - case XsltForms_xpathAxis.ENTRY : - XsltForms_stepExpr.pushList(ctx, list, input.entries, this.nodetest); - break; - case XsltForms_xpathAxis.FOLLOWING : - var n = input.nodeType === Fleur.Node.ATTRIBUTE_NODE ? (input.ownerElement ? input.ownerElement : input.selectSingleNode("..")) : (input.nodeType === Fleur.Node.ENTRY_NODE ? input.ownerMap : input); - while (n.nodeType !== Fleur.Node.DOCUMENT_NODE) { - for (var nn = n.nextSibling; nn; nn = nn.nextSibling) { - XsltForms_stepExpr.push(ctx, list, nn, this.nodetest); - XsltForms_stepExpr.pushDescendants(ctx, list, nn, this.nodetest); - } - n = n.parentNode; - } - break; - case XsltForms_xpathAxis.FOLLOWING_SIBLING : - for (var ns = input.nextSibling; ns; ns = ns.nextSibling) { - XsltForms_stepExpr.push(ctx, list, ns, this.nodetest); - } - break; - case XsltForms_xpathAxis.NAMESPACE : - alert('not implemented: axis namespace'); - break; - case XsltForms_xpathAxis.PARENT : - if (input.parentNode) { - XsltForms_stepExpr.push(ctx, list, input.parentNode, this.nodetest); - } else { - if (input.nodeType === Fleur.Node.ATTRIBUTE_NODE) { - XsltForms_stepExpr.push(ctx, list, input.ownerElement ? input.ownerElement : input.selectSingleNode(".."), this.nodetest); - } else if (input.nodeType === Fleur.Node.ENTRY_NODE) { - XsltForms_stepExpr.push(ctx, list, input.ownerMap, this.nodetest); - } - } - break; - case XsltForms_xpathAxis.PRECEDING : - var p = input.nodeType === Fleur.Node.ATTRIBUTE_NODE ? (input.ownerElement ? input.ownerElement : input.selectSingleNode("..")) : (input.nodeType === Fleur.Node.ENTRY_NODE ? input.ownerMap : input); - while (p.nodeType !== Fleur.Node.DOCUMENT_NODE) { - for (var ps = p.previousSibling; ps; ps = ps.previousSibling) { - XsltForms_stepExpr.pushDescendantsRev(ctx, list, ps, this.nodetest); - XsltForms_stepExpr.push(ctx, list, ps, this.nodetest); - } - p = p.parentNode; - } - break; - case XsltForms_xpathAxis.PRECEDING_SIBLING : - for (var ps2 = input.previousSibling; ps2; ps2 = ps2.previousSibling) { - XsltForms_stepExpr.push(ctx, list, ps2, this.nodetest); - } - break; - case XsltForms_xpathAxis.SELF : - XsltForms_stepExpr.push(ctx, list, input, this.nodetest); - break; - default : - throw new Error({name:'ERROR -- NO SUCH AXIS: ' + this.axis}); - } - for (var i = 0, len = this.predicates.length; i < len; i++) { - var pred = this.predicates[i]; - var newList = []; - for (var j = 0, len1 = list.length; j < len1; j++) { - var x = list[j]; - var newCtx = ctx.clone(x, j + 1, list); - if (XsltForms_globals.booleanValue(pred.evaluate(newCtx))) { - newList.push(x); - } - } - list = newList; - } - return list; + var input = ctx.node; + var list = []; + switch(this.axis) { + case XsltForms_xpathAxis.ANCESTOR_OR_SELF : + XsltForms_stepExpr.push(ctx, list, input, this.nodetest); + if (input.nodeType === Fleur.Node.ATTRIBUTE_NODE) { + input = input.ownerElement ? input.ownerElement : input.selectSingleNode(".."); + XsltForms_stepExpr.push(ctx, list, input, this.nodetest); + } else if (input.nodeType === Fleur.Node.ENTRY_NODE) { + input = input.ownerMap; + XsltForms_stepExpr.push(ctx, list, input, this.nodetest); + } + for (var pn = input.parentNode; pn.parentNode; pn = pn.parentNode) { + XsltForms_stepExpr.push(ctx, list, pn, this.nodetest); + } + break; + case XsltForms_xpathAxis.ANCESTOR : + if (input.nodeType === Fleur.Node.ATTRIBUTE_NODE) { + input = input.ownerElement ? input.ownerElement : input.selectSingleNode(".."); + XsltForms_stepExpr.push(ctx, list, input, this.nodetest); + } else if (input.nodeType === Fleur.Node.ENTRY_NODE) { + input = input.ownerMap; + XsltForms_stepExpr.push(ctx, list, input, this.nodetest); + } + for (var pn2 = input.parentNode; pn2.parentNode; pn2 = pn2.parentNode) { + XsltForms_stepExpr.push(ctx, list, pn2, this.nodetest); + } + break; + case XsltForms_xpathAxis.ATTRIBUTE : + XsltForms_stepExpr.pushList(ctx, list, input.attributes, this.nodetest, !input.namespaceURI || input.namespaceURI === "http://www.w3.org/1999/xhtml"); + break; + case XsltForms_xpathAxis.CHILD : + XsltForms_stepExpr.pushList(ctx, list, input.childNodes, this.nodetest); + break; + case XsltForms_xpathAxis.DESCENDANT_OR_SELF : + XsltForms_stepExpr.push(ctx, list, input, this.nodetest); + XsltForms_stepExpr.pushDescendants(ctx, list, input, this.nodetest); + break; + case XsltForms_xpathAxis.DESCENDANT : + XsltForms_stepExpr.pushDescendants(ctx, list, input, this.nodetest); + break; + case XsltForms_xpathAxis.ENTRY : + XsltForms_stepExpr.pushList(ctx, list, input.entries, this.nodetest); + break; + case XsltForms_xpathAxis.FOLLOWING : + var n = input.nodeType === Fleur.Node.ATTRIBUTE_NODE ? (input.ownerElement ? input.ownerElement : input.selectSingleNode("..")) : (input.nodeType === Fleur.Node.ENTRY_NODE ? input.ownerMap : input); + while (n.nodeType !== Fleur.Node.DOCUMENT_NODE) { + for (var nn = n.nextSibling; nn; nn = nn.nextSibling) { + XsltForms_stepExpr.push(ctx, list, nn, this.nodetest); + XsltForms_stepExpr.pushDescendants(ctx, list, nn, this.nodetest); + } + n = n.parentNode; + } + break; + case XsltForms_xpathAxis.FOLLOWING_SIBLING : + for (var ns = input.nextSibling; ns; ns = ns.nextSibling) { + XsltForms_stepExpr.push(ctx, list, ns, this.nodetest); + } + break; + case XsltForms_xpathAxis.NAMESPACE : + alert('not implemented: axis namespace'); + break; + case XsltForms_xpathAxis.PARENT : + if (input.parentNode) { + XsltForms_stepExpr.push(ctx, list, input.parentNode, this.nodetest); + } else { + if (input.nodeType === Fleur.Node.ATTRIBUTE_NODE) { + XsltForms_stepExpr.push(ctx, list, input.ownerElement ? input.ownerElement : input.selectSingleNode(".."), this.nodetest); + } else if (input.nodeType === Fleur.Node.ENTRY_NODE) { + XsltForms_stepExpr.push(ctx, list, input.ownerMap, this.nodetest); + } + } + break; + case XsltForms_xpathAxis.PRECEDING : + var p = input.nodeType === Fleur.Node.ATTRIBUTE_NODE ? (input.ownerElement ? input.ownerElement : input.selectSingleNode("..")) : (input.nodeType === Fleur.Node.ENTRY_NODE ? input.ownerMap : input); + while (p.nodeType !== Fleur.Node.DOCUMENT_NODE) { + for (var ps = p.previousSibling; ps; ps = ps.previousSibling) { + XsltForms_stepExpr.pushDescendantsRev(ctx, list, ps, this.nodetest); + XsltForms_stepExpr.push(ctx, list, ps, this.nodetest); + } + p = p.parentNode; + } + break; + case XsltForms_xpathAxis.PRECEDING_SIBLING : + for (var ps2 = input.previousSibling; ps2; ps2 = ps2.previousSibling) { + XsltForms_stepExpr.push(ctx, list, ps2, this.nodetest); + } + break; + case XsltForms_xpathAxis.SELF : + XsltForms_stepExpr.push(ctx, list, input, this.nodetest); + break; + default : + throw new Error({name:'ERROR -- NO SUCH AXIS: ' + this.axis}); + } + for (var i = 0, len = this.predicates.length; i < len; i++) { + var pred = this.predicates[i]; + var newList = []; + for (var j = 0, len1 = list.length; j < len1; j++) { + var x = list[j]; + var newCtx = ctx.clone(x, j + 1, list); + if (XsltForms_globals.booleanValue(pred.evaluate(newCtx))) { + newList.push(x); + } + } + list = newList; + } + return list; }; XsltForms_stepExpr.push = function(ctx, list, node, test, csensitive) { - if (test.evaluate(node, ctx.nsresolver, csensitive) && !XsltForms_browser.inArray(node, list)) { - list[list.length] = node; - } + if (test.evaluate(node, ctx.nsresolver, csensitive) && !XsltForms_browser.inArray(node, list)) { + list[list.length] = node; + } }; XsltForms_stepExpr.pushList = function(ctx, list, l, test, csensitive) { - for (var i = 0, len = l ? l.length : 0; i < len; i++) { - XsltForms_stepExpr.push(ctx, list, l[i], test, csensitive); - } + for (var i = 0, len = l ? l.length : 0; i < len; i++) { + XsltForms_stepExpr.push(ctx, list, l[i], test, csensitive); + } }; XsltForms_stepExpr.pushDescendants = function(ctx, list, node, test) { - for (var n = node.firstChild; n; n = n.nextSibling) { - XsltForms_stepExpr.push(ctx, list, n, test); - XsltForms_stepExpr.pushDescendants(ctx, list, n, test); - } + for (var n = node.firstChild; n; n = n.nextSibling) { + XsltForms_stepExpr.push(ctx, list, n, test); + XsltForms_stepExpr.pushDescendants(ctx, list, n, test); + } }; XsltForms_stepExpr.pushDescendantsRev = function(ctx, list, node, test) { - for (var n = node.lastChild; n; n = n.previousSibling) { - XsltForms_stepExpr.push(ctx, list, n, test); - XsltForms_stepExpr.pushDescendantsRev(ctx, list, n, test); - } + for (var n = node.lastChild; n; n = n.previousSibling) { + XsltForms_stepExpr.push(ctx, list, n, test); + XsltForms_stepExpr.pushDescendantsRev(ctx, list, n, test); + } }; function XsltForms_unionExpr(expr1, expr2) { - this.expr1 = expr1; - this.expr2 = expr2; + this.expr1 = expr1; + this.expr2 = expr2; } XsltForms_unionExpr.prototype.evaluate = function(ctx) { - var nodes1 = XsltForms_globals.nodeSetValue(this.expr1.evaluate(ctx)); - var nodes2 = XsltForms_globals.nodeSetValue(this.expr2.evaluate(ctx)); - var len1 = nodes1.length; - for (var i2 = 0, len = nodes2.length; i2 < len; i2++) { - var found = false; - for (var i1 = 0; i1 < len1; i1++) { - found = nodes1[i1] === nodes2[i2]; - if (found) { - break; - } - } - if (!found) { - nodes1.push(nodes2[i2]); - } - } - var posres = []; - for (var i3 = 0, len3 = nodes1.length; i3 < len3; i3++) { - posres.push({count: XsltForms_browser.selectNodesLength("preceding::* | ancestor::*", nodes1[i3]), node: nodes1[i3]}); - } - posres.sort(function(a,b){return a.count - b.count;}); - for (var i4 = 0, len4 = posres.length; i4 < len4; i4++) { - nodes1[i4] = posres[i4].node; - } - return nodes1; + var nodes1 = XsltForms_globals.nodeSetValue(this.expr1.evaluate(ctx)); + var nodes2 = XsltForms_globals.nodeSetValue(this.expr2.evaluate(ctx)); + var len1 = nodes1.length; + for (var i2 = 0, len = nodes2.length; i2 < len; i2++) { + var found = false; + for (var i1 = 0; i1 < len1; i1++) { + found = nodes1[i1] === nodes2[i2]; + if (found) { + break; + } + } + if (!found) { + nodes1.push(nodes2[i2]); + } + } + var posres = []; + for (var i3 = 0, len3 = nodes1.length; i3 < len3; i3++) { + posres.push({count: XsltForms_browser.selectNodesLength("preceding::* | ancestor::*", nodes1[i3]), node: nodes1[i3]}); + } + posres.sort(function(a,b){return a.count - b.count;}); + for (var i4 = 0, len4 = posres.length; i4 < len4; i4++) { + nodes1[i4] = posres[i4].node; + } + return nodes1; }; function XsltForms_varRef(vname) { - this.name = vname; + this.name = vname; } XsltForms_varRef.prototype.evaluate = function(ctx) { - if (!ctx.varresolver || !ctx.varresolver[this.name]) { - return ""; - } - if (ctx.varresolver[this.name] instanceof XsltForms_var) { - var varxf = ctx.varresolver[this.name]; - for (var i = 0, l = varxf.depsNodesRefresh.length; i < l ; i++) { - ctx.addDepNode(varxf.depsNodesRefresh[i]); - } - for (i = 0, l = varxf.depsNodesBuild.length; i < l ; i++) { - ctx.addDepNode(varxf.depsNodesBuild[i]); - } - for (var j = 0, l2 = varxf.depsElements.length; j < l2 ; j++) { - ctx.addDepElement(varxf.depsElements[j]); - } - return varxf.boundnodes; - } - return ctx.varresolver[this.name][0]; + let varxf = XsltForms_varResolver(ctx.element, this.name); + for (var i = 0, l = varxf.depsNodesRefresh.length; i < l ; i++) { + ctx.addDepNode(varxf.depsNodesRefresh[i]); + } + for (i = 0, l = varxf.depsNodesBuild.length; i < l ; i++) { + ctx.addDepNode(varxf.depsNodesBuild[i]); + } + for (var j = 0, l2 = varxf.depsElements.length; j < l2 ; j++) { + ctx.addDepElement(varxf.depsElements[j]); + } + return varxf.boundnodes; }; +function XsltForms_varResolver(elt, name) { + let p = elt; + while (p) { + if (p.previousSibling) { + p = p.previousSibling; + if (p.localName === "xforms-var" && p.xfElement.name === name) { + return p.xfElement; + } + } else { + p = p.parentNode; + } + } + XsltForms_globals.error(null, "xforms-compute-exception", "Variable $" + name + " not found"); +} XsltForms_globals.stringValue = function(value) { - if (Fleur.minimal) { - return typeof value !== "object"? "" + value : (!value || value.length === 0 ? "" : XsltForms_globals.xmlValue(value.head())); - } - return XsltForms_globals.xmlValue(value.head ? value.head() : value); + if (Fleur.minimal) { + return typeof value !== "object"? "" + value : (!value || value.length === 0 ? "" : XsltForms_globals.xmlValue(value.head())); + } + return XsltForms_globals.xmlValue(value.head ? value.head() : value); }; XsltForms_globals.booleanValue = function(value) { - if (Fleur.minimal) { - return typeof value === "undefined" || !value ? false : (typeof value.length !== "undefined"? value.length > 0 : !!value); - } - return value.data === "true"; + if (Fleur.minimal) { + return typeof value === "undefined" || !value ? false : (typeof value.length !== "undefined"? value.length > 0 : !!value); + } + return value.data === "true"; }; XsltForms_globals.numberValue = function(value) { - if (Fleur.minimal) { - if (typeof value === "boolean") { - return 'A' - 0; - } else { - var v = typeof value === "object"? XsltForms_globals.stringValue(value) : value; - return v === '' ? NaN : v - 0; - } - } - return Number(XsltForms_globals.stringValue(value)); + if (Fleur.minimal) { + if (typeof value === "boolean") { + return 'A' - 0; + } else { + var v = typeof value === "object"? XsltForms_globals.stringValue(value) : value; + return v === '' ? NaN : v - 0; + } + } + return Number(XsltForms_globals.stringValue(value)); }; XsltForms_globals.nodeSetValue = function(value) { - return value; + return value; }; if (XsltForms_browser.isIE) { - XsltForms_globals.xmlValue = function(node) { - if (typeof node !== "object") { - return node; - } - var ret = node.text; - var schtyp = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string"); - if (schtyp["eval"]) { - try { - ret = ret === "" ? 0 : eval(ret); - } catch (e) {} - } - return ret; - }; + XsltForms_globals.xmlValue = function(node) { + if (typeof node !== "object") { + return node; + } + var ret = node.text; + var schtyp = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string"); + if (schtyp["eval"]) { + try { + ret = ret === "" ? 0 : eval(ret); + } catch (e) {} + } + return ret; + }; } else { - XsltForms_globals.xmlValue = function(node) { - if (typeof node !== "object") { - return node; - } - var ret = typeof node.text !== "undefined" ? node.text : typeof node.textContent !== "undefined" ? node.textContent : typeof node.documentElement.text !== "undefined" ? node.documentElement.text : node.documentElement.textContent; - var schtyp = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string"); - if (schtyp["eval"]) { - try { - ret = ret === "" ? 0 : eval(ret); - } catch (e) {} - } - return ret; - }; + XsltForms_globals.xmlValue = function(node) { + if (typeof node !== "object") { + return node; + } + var ret = typeof node.text !== "undefined" ? node.text : typeof node.textContent !== "undefined" ? node.textContent : typeof node.documentElement.text !== "undefined" ? node.documentElement.text : node.documentElement.textContent; + var schtyp = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string"); + if (schtyp["eval"]) { + try { + ret = ret === "" ? 0 : eval(ret); + } catch (e) {} + } + return ret; + }; } XsltForms_globals.xmlResolveEntities = function(s) { - var parts = XsltForms_globals.stringSplit(s, '&'); - var ret = parts[0]; - for (var i = 1, len = parts.length; i < len; ++i) { - var p = parts[i]; - var index = p.indexOf(";"); - if (index === -1) { - ret += parts[i]; - continue; - } - var rp = p.substring(0, index); - var ch; - switch (rp) { - case 'lt': ch = '<'; break; - case 'gt': ch = '>'; break; - case 'amp': ch = '&'; break; - case 'quot': ch = '"'; break; - case 'apos': ch = '\''; break; - case 'nbsp': ch = String.fromCharCode(160); break; - default: - var span = XsltForms_browser.isXhtml ? document.createElementNS("http://www.w3.org/1999/xhtml", 'span') : document.createElement('span'); - span.innerHTML = '&' + rp + '; '; - ch = span.childNodes[0].nodeValue.charAt(0); - } - ret += ch + p.substring(index + 1); - } - return ret; + var parts = XsltForms_globals.stringSplit(s, '&'); + var ret = parts[0]; + for (var i = 1, len = parts.length; i < len; ++i) { + var p = parts[i]; + var index = p.indexOf(";"); + if (index === -1) { + ret += parts[i]; + continue; + } + var rp = p.substring(0, index); + var ch; + switch (rp) { + case 'lt': ch = '<'; break; + case 'gt': ch = '>'; break; + case 'amp': ch = '&'; break; + case 'quot': ch = '"'; break; + case 'apos': ch = '\''; break; + case 'nbsp': ch = String.fromCharCode(160); break; + default: + var span = XsltForms_browser.isXhtml ? document.createElementNS("http://www.w3.org/1999/xhtml", 'span') : document.createElement('span'); + span.innerHTML = '&' + rp + '; '; + ch = span.childNodes[0].nodeValue.charAt(0); + } + ret += ch + p.substring(index + 1); + } + return ret; }; XsltForms_globals.stringSplit = function(s, c) { - var a = s.indexOf(c); - if (a === -1) { - return [s]; - } - var cl = c.length; - var parts = []; - parts.push(s.substr(0,a)); - while (a !== -1) { - var a1 = s.indexOf(c, a + cl); - if (a1 !== -1) { - parts.push(s.substr(a + cl, a1 - a - cl)); - } else { - parts.push(s.substr(a + cl)); - } - a = a1; - } - return parts; + var a = s.indexOf(c); + if (a === -1) { + return [s]; + } + var cl = c.length; + var parts = []; + parts.push(s.substr(0,a)); + while (a !== -1) { + var a1 = s.indexOf(c, a + cl); + if (a1 !== -1) { + parts.push(s.substr(a + cl, a1 - a - cl)); + } else { + parts.push(s.substr(a + cl)); + } + a = a1; + } + return parts; }; function XsltForms_xpath(subform, expression) { this.subform = subform; @@ -7618,8 +7616,7 @@ function XsltForms_xpath(subform, expression) { try { if (Fleur.minimal) { compiled = Fleur.XPathEvaluator._xp2js(expression, "", ""); - var arr; - eval("arr = " + compiled + ";"); + var arr = eval(compiled); compiled = Fleur.minimal ? XsltForms_FleurConv[arr[0]](arr[1]) : (new Fleur.Transpiler("ctx", " ")).funcdef(arr); compiled = eval(compiled); } else { @@ -7639,11 +7636,11 @@ function XsltForms_xpath(subform, expression) { XsltForms_xpath.prototype.evaluate = function() { alert("XPath error"); }; -XsltForms_xpath.prototype.xpath_evaluate = function(ctx, current, subform, varresolver) { +XsltForms_xpath.prototype.xpath_evaluate = function(ctx, current, subform, element) { var d1 = new Date(); XsltForms_browser.assert(ctx); if (!ctx.node) { - ctx = new XsltForms_exprContext(subform, ctx, null, null, null, this.nsresolver, current, varresolver); + ctx = new XsltForms_exprContext(subform, ctx, null, null, null, this.nsresolver, current, element); } else if (!ctx.nsresolver) { ctx.nsresolver = this.nsresolver; } @@ -7692,37 +7689,37 @@ XsltForms_xpath.registerNS = function(prefix, uri) { } }; function XsltForms_xpathFunction(acceptContext, defaultTo, returnNodes, body) { - this.evaluate = body; - this.defaultTo = defaultTo; - this.acceptContext = acceptContext; - this.returnNodes = returnNodes; + this.evaluate = body; + this.defaultTo = defaultTo; + this.acceptContext = acceptContext; + this.returnNodes = returnNodes; } XsltForms_xpathFunction.DEFAULT_NONE = null; XsltForms_xpathFunction.DEFAULT_NODE = 0; XsltForms_xpathFunction.DEFAULT_NODESET = 1; XsltForms_xpathFunction.DEFAULT_STRING = 2; XsltForms_xpathFunction.prototype.call = function(context, arguments_) { - if (arguments_.length === 0) { - switch (this.defaultTo) { - case XsltForms_xpathFunction.DEFAULT_NODE: - if (context.node) { - arguments_ = [context.node]; - } - break; - case XsltForms_xpathFunction.DEFAULT_NODESET: - if (context.node) { - arguments_ = [[context.node]]; - } - break; - case XsltForms_xpathFunction.DEFAULT_STRING: - arguments_ = [XsltForms_xpathCoreFunctions.string.evaluate([context.node])]; - break; - } - } - if (this.acceptContext) { - arguments_.unshift(context); - } - return this.evaluate.apply(null, arguments_); + if (arguments_.length === 0) { + switch (this.defaultTo) { + case XsltForms_xpathFunction.DEFAULT_NODE: + if (context.node) { + arguments_ = [context.node]; + } + break; + case XsltForms_xpathFunction.DEFAULT_NODESET: + if (context.node) { + arguments_ = [[context.node]]; + } + break; + case XsltForms_xpathFunction.DEFAULT_STRING: + arguments_ = [XsltForms_xpathCoreFunctions.string.evaluate([context.node])]; + break; + } + } + if (this.acceptContext) { + arguments_.unshift(context); + } + return this.evaluate.apply(null, arguments_); }; var XsltForms_mathConstants = { "PI": "3.14159265358979323846264338327950288419716939937510582", @@ -9777,1566 +9774,1627 @@ XsltForms_globals.validate_ = function(node) { return true; }; Fleur.XPathNSResolver_default = { - pf: [ - "xml", - "xmlns", - "xs", - "xsd", - "xsd_", - "xsi", - "xf", - "xforms", - "xsltforms", - " function", - "fn", - "local", - "math", - "map", - "array", - "err", - "b", - "bin", - "file", - "http", - "request", - "prof", - "proc", - "js", - "fleur", - "dgram", - "base64", - "internal", - "unit", - "ietf", - "excel", - "zip", - "matrix", - "xpath", - "xquery" - ], - uri: [ - "http://www.w3.org/XML/1998/namespace", - "http://www.w3.org/2000/xmlns/", - "http://www.w3.org/2001/XMLSchema", - "http://www.w3.org/2001/XMLSchema", - "http://www.w3.org/2001/XMLSchema", - "http://www.w3.org/2001/XMLSchema-instance", - "http://www.w3.org/2002/xforms", - "http://www.w3.org/2002/xforms", - "http://www.agencexml.com/xsltforms", - "http://www.w3.org/2005/xpath-functions", - "http://www.w3.org/2005/xpath-functions", - "http://www.w3.org/2005/xpath", - "http://www.w3.org/2005/xpath-functions/math", - "http://www.w3.org/2005/xpath-functions/map", - "http://www.w3.org/2005/xpath-functions/array", - "http://www.w3.org/2005/xqt-errors", - "http://xqib.org", - "http://expath.org/ns/binary", - "http://expath.org/ns/file", - "http://expath.org/ns/http-client", - "http://exquery.org/ns/request", - "http://basex.org/modules/prof", - "http://basex.org/modules/proc", - "http://www.w3.org/standards/webdesign/script", - "http://www.agencexml.com/fleur", - "http://www.agencexml.com/fleur/dgram", - "http://www.agencexml.com/fleur/base64", - "http://www.agencexml.com/fleur/internal", - "http://www.agencexml.com/fleur/unit", - "https://tools.ietf.org/rfc/index", - "http://schemas.openxmlformats.org/spreadsheetml/2006/main", - "http://expath.org/ns/zip", - "http://www.mathunion.org/matrix", - "http://www.w3.org/2005/xpath", - "http://www.w3.org/2005/xquery" - ] + pf: [ + "xml", + "xmlns", + "xs", + "xsd", + "xsd_", + "xsi", + "xf", + "xforms", + "xsltforms", + " function", + "fn", + "local", + "math", + "map", + "array", + "err", + "b", + "bin", + "file", + "http", + "request", + "prof", + "proc", + "js", + "fleur", + "dgram", + "base64", + "internal", + "unit", + "ietf", + "excel", + "zip", + "matrix", + "xpath", + "xquery" + ], + uri: [ + "http://www.w3.org/XML/1998/namespace", + "http://www.w3.org/2000/xmlns/", + "http://www.w3.org/2001/XMLSchema", + "http://www.w3.org/2001/XMLSchema", + "http://www.w3.org/2001/XMLSchema", + "http://www.w3.org/2001/XMLSchema-instance", + "http://www.w3.org/2002/xforms", + "http://www.w3.org/2002/xforms", + "http://www.agencexml.com/xsltforms", + "http://www.w3.org/2005/xpath-functions", + "http://www.w3.org/2005/xpath-functions", + "http://www.w3.org/2005/xpath", + "http://www.w3.org/2005/xpath-functions/math", + "http://www.w3.org/2005/xpath-functions/map", + "http://www.w3.org/2005/xpath-functions/array", + "http://www.w3.org/2005/xqt-errors", + "http://xqib.org", + "http://expath.org/ns/binary", + "http://expath.org/ns/file", + "http://expath.org/ns/http-client", + "http://exquery.org/ns/request", + "http://basex.org/modules/prof", + "http://basex.org/modules/proc", + "http://www.w3.org/standards/webdesign/script", + "http://www.agencexml.com/fleur", + "http://www.agencexml.com/fleur/dgram", + "http://www.agencexml.com/fleur/base64", + "http://www.agencexml.com/fleur/internal", + "http://www.agencexml.com/fleur/unit", + "https://tools.ietf.org/rfc/index", + "http://schemas.openxmlformats.org/spreadsheetml/2006/main", + "http://expath.org/ns/zip", + "http://www.mathunion.org/matrix", + "http://www.w3.org/2005/xpath", + "http://www.w3.org/2005/xquery" + ] }; if (Fleur.minimal) { - Fleur.XPathNSResolver = function(node) { - this.pf = Fleur.XPathNSResolver_default.pf.slice(); - this.uri = Fleur.XPathNSResolver_default.uri.slice(); - this.node = node; -}; -Fleur.XPathNSResolver.prototype.lookupNamespaceURI = function(prefix) { - var uri; - var index = this.pf.lastIndexOf(prefix); - if (index !== -1) { - return this.uri[index]; - } - if (this.node) { - uri = this.node.lookupNamespaceURI(prefix); - if (uri) { - this.pf.push(prefix); - this.uri.push(uri); - } - } - return uri; -}; -Fleur.XPathNSResolver.prototype.lookupPrefix = function(namespaceURI) { - var pf; - var index = this.uri.lastIndexOf(namespaceURI); - if (index !== -1) { - return this.pf[index]; - } - if (this.node) { - pf = this.node.lookupPrefix(namespaceURI); - if (pf) { - this.pf.push(pf); - this.uri.push(namespaceURI); - } - } - return pf; -}; -Fleur.XPathNSResolver.prototype.declareNamespace = function(prefix, uri) { - this.pf.push(prefix); - this.uri.push(uri); -}; + Fleur.XPathNSResolver = function(node) { + this.pf = Fleur.XPathNSResolver_default.pf.slice(); + this.uri = Fleur.XPathNSResolver_default.uri.slice(); + this.node = node; + }; + Fleur.XPathNSResolver.prototype.lookupNamespaceURI = function(prefix) { + var uri; + var index = this.pf.lastIndexOf(prefix); + if (index !== -1) { + return this.uri[index]; + } + if (this.node) { + uri = this.node.lookupNamespaceURI(prefix); + if (uri) { + this.pf.push(prefix); + this.uri.push(uri); + } + } + return uri; + }; + Fleur.XPathNSResolver.prototype.lookupPrefix = function(namespaceURI) { + var pf; + var index = this.uri.lastIndexOf(namespaceURI); + if (index !== -1) { + return this.pf[index]; + } + if (this.node) { + pf = this.node.lookupPrefix(namespaceURI); + if (pf) { + this.pf.push(pf); + this.uri.push(namespaceURI); + } + } + return pf; + }; + Fleur.XPathNSResolver.prototype.declareNamespace = function(prefix, uri) { + this.pf.push(prefix); + this.uri.push(uri); + }; } function XsltForms_functionCallExpr(fname) { - this.name = fname; - this.func = XsltForms_xpathCoreFunctions[fname]; - this.xpathfunc = !!this.func; - this.args = []; - if (!this.xpathfunc) { - try { - this.func = eval(fname.split(" ")[1]); - } catch (e) { - alert(e); - } - } - if (!this.func && !XsltForms_debugger.active) { - XsltForms_globals.error(this, "xforms-compute-exception", "Function " + this.name + "() not found"); - } - for (var i = 1, len = arguments.length; i < len; i++) { - this.args.push(arguments[i]); - } + this.name = fname; + this.func = XsltForms_xpathCoreFunctions[fname]; + this.xpathfunc = !!this.func; + this.args = []; + if (!this.xpathfunc) { + try { + this.func = eval(fname.split(" ")[1]); + } catch (e) { + alert(e); + } + } + if (!this.func && !XsltForms_debugger.active) { + XsltForms_globals.error(this, "xforms-compute-exception", "Function " + this.name + "() not found"); + } + for (var i = 1, len = arguments.length; i < len; i++) { + this.args.push(arguments[i]); + } } XsltForms_functionCallExpr.prototype.evaluate = function(ctx) { - var arguments_ = []; - if (this.xpathfunc) { - for (var i = 0, len = this.args.length; i < len; i++) { - arguments_[i] = this.args[i].evaluate(ctx); - } - return this.func.call(ctx, arguments_); - } else { - for (var i2 = 0, len2 = this.args.length; i2 < len2; i2++) { - arguments_[i2] = XsltForms_globals.stringValue(this.args[i2].evaluate(ctx)); - } - XsltForms_context = {ctx: ctx}; - return this.func.apply(null,arguments_); - } + var arguments_ = []; + if (this.xpathfunc) { + for (var i = 0, len = this.args.length; i < len; i++) { + arguments_[i] = this.args[i].evaluate(ctx); + } + return this.func.call(ctx, arguments_); + } else { + for (var i2 = 0, len2 = this.args.length; i2 < len2; i2++) { + arguments_[i2] = XsltForms_globals.stringValue(this.args[i2].evaluate(ctx)); + } + XsltForms_context = {ctx: ctx}; + return this.func.apply(null,arguments_); + } }; function XsltForms_coreElement() { } XsltForms_coreElement.prototype.init = function(subform, elt) { - this.subforms = []; - this.subforms[subform] = true; - this.nbsubforms = 1; - this.subform = subform; - this.element = elt; + this.subforms = []; + this.subforms[subform] = true; + this.nbsubforms = 1; + this.subform = subform; + this.element = elt; }; XsltForms_coreElement.prototype.build = function() {}; XsltForms_coreElement.prototype.dispose = function() { - if (this.element) { - this.element.xfElement = null; - this.element.parentNode.removeChild(this.element); - } - this.element = null; - this.model = null; + if (this.element) { + this.element.xfElement = null; + this.element.parentNode.removeChild(this.element); + } + this.element = null; + this.model = null; }; new XsltForms_class("XsltForms_options", "HTMLElement", "xforms-options"); function XsltForms_options(subform, elt) { - this.init(subform, elt); - var debug = elt.getAttribute("xf-debug"); - if (debug && debug.toLowerCase() === "yes") { - XsltForms_globals.debugMode = true; - XsltForms_globals.debugging(); - } - var lang = elt.getAttribute("xf-lang"); - if (lang) { - XsltForms_globals.language = lang; - } + this.init(subform, elt); + var debug = elt.getAttribute("xf-debug"); + if (debug && debug.toLowerCase() === "yes") { + XsltForms_globals.debugMode = true; + XsltForms_globals.debugging(); + } + var lang = elt.getAttribute("xf-lang"); + if (lang) { + XsltForms_globals.language = lang; + } } XsltForms_options.prototype = new XsltForms_coreElement(); +new XsltForms_class("XsltForms_form", "HTMLElement", "xforms-form"); +function XsltForms_form(subform, elt) { + Array.prototype.slice.call(elt.attributes).forEach(function(n) { + if (n.nodeName.substr(0, 6) === "xmlns:" || n.nodeName.substr(0, 6) === "xmlns-") { + Fleur.XPathNSResolver_default.pf.push(n.nodeName.substr(6)); + Fleur.XPathNSResolver_default.uri.push(n.nodeValue); + } else if (n.localName === "xmlns" && n.prefix) { + Fleur.XPathNSResolver_default.pf.push(n.prefix.toLowerCase()); + Fleur.XPathNSResolver_default.uri.push(n.namespaceURI); + } else if (n.prefix && n.prefix !== "") { + Fleur.XPathNSResolver_default.pf.push(n.prefix.toLowerCase()); + Fleur.XPathNSResolver_default.uri.push(n.namespaceURI); + } + }); + this.init(subform, elt); + let xmodelconfig, xdialog, xbody; + const contents = []; + Array.prototype.slice.call(elt.children).forEach(function(n) { + switch(n.localName.toLowerCase()) { + case "xforms-model": + xmodelconfig = n; + break; + case "xforms-dialog": + xdialog = n; + break; + case "xforms-body": + xbody = n; + break; + default: + contents.push(n); + } + }); + if (!xdialog) { + const xcons = document.createElement("xforms-dialog"); + xcons.setAttribute("id", "xsltforms-console"); + elt.appendChild(xcons); + const stap = document.createElement("xforms-dialog"); + stap.setAttribute("id", "xsltforms-status-panel"); + elt.appendChild(stap); + } + if (!xbody) { + const frm = document.createElement("form"); + contents.forEach(n => frm.appendChild(n)); + const xbo = document.createElement("xforms-body"); + xbo.appendChild(frm); + elt.appendChild(xbo); + } + XsltForms_globals.formelt = elt.querySelector("form"); +} +XsltForms_form.prototype = new XsltForms_coreElement(); Array.prototype.slice.call(document.documentElement.attributes).forEach(function(n) { - if (n.nodeName.substr(0, 6) === "xmlns:" || n.nodeName.substr(0, 6) === "xmlns-") { - Fleur.XPathNSResolver_default.pf.push(n.nodeName.substr(6)); - Fleur.XPathNSResolver_default.uri.push(n.nodeValue); - } else if (n.localName === "xmlns" && n.prefix) { - Fleur.XPathNSResolver_default.pf.push(n.prefix.toLowerCase()); - Fleur.XPathNSResolver_default.uri.push(n.namespaceURI); - } else if (n.prefix && n.prefix !== "") { - Fleur.XPathNSResolver_default.pf.push(n.prefix.toLowerCase()); - Fleur.XPathNSResolver_default.uri.push(n.namespaceURI); - } + if (n.nodeName.substr(0, 6) === "xmlns:" || n.nodeName.substr(0, 6) === "xmlns-") { + Fleur.XPathNSResolver_default.pf.push(n.nodeName.substr(6)); + Fleur.XPathNSResolver_default.uri.push(n.nodeValue); + } else if (n.localName === "xmlns" && n.prefix) { + Fleur.XPathNSResolver_default.pf.push(n.prefix.toLowerCase()); + Fleur.XPathNSResolver_default.uri.push(n.namespaceURI); + } else if (n.prefix && n.prefix !== "") { + Fleur.XPathNSResolver_default.pf.push(n.prefix.toLowerCase()); + Fleur.XPathNSResolver_default.uri.push(n.namespaceURI); + } }); Array.prototype.slice.call(document.querySelectorAll("script[data-uri]")).forEach(function(n) { - XsltForms_globals.jslibraries[n.getAttribute("data-uri")] = n.getAttribute("data-version"); + XsltForms_globals.jslibraries[n.getAttribute("data-uri")] = n.getAttribute("data-version"); }); new XsltForms_class("XsltForms_model", "HTMLElement", "xforms-model"); function XsltForms_model(subform, elt) { - if (!elt.id && !document.getElementById(subform.id + "-model-default")) { - elt.id = subform.id + "-model-default"; - } - var children = elt.children; - for (var i = 0, l = children.length; i < l; i++) { - if (children[i].localName.toLowerCase() === "xforms-instance") { - break; - } - } - if (i === l) { - var definst = document.createElement("xforms-instance"); - definst.innerHTML = ' - - -

Background Colors

-

Use of Attribute Value Templates, Direct Javascript Function Calls and Javascript Evaluation.

- -    - -

Javascript function source for luminosity extracted from HTML DOM: -

-

- + + + Background Colors + + + + + + + + + + + + + + + + + +

Background Colors

+

Use of Attribute Value Templates, Direct Javascript Function Calls and Javascript Evaluation.

+ +    + +

Javascript function source for luminosity extracted from HTML DOM: +

+

+ \ No newline at end of file diff --git a/public/samples/wikipediasearch.xml b/public/samples/wikipediasearch.xml index c83215b..90a6db2 100644 --- a/public/samples/wikipediasearch.xml +++ b/public/samples/wikipediasearch.xml @@ -24,7 +24,7 @@ diff --git a/public/xquerytests/data/xqtests.json b/public/xquerytests/data/xqtests.json new file mode 100644 index 0000000..b8b6966 --- /dev/null +++ b/public/xquerytests/data/xqtests.json @@ -0,0 +1,2203 @@ +[ + { + "name": "fn-abs", + "tests": [ + { + "test": "fn:abs(xs:int('-2147483648'))", + "result": "xs:long('2147483648')" + }, + { + "test": "fn:abs(xs:int('-1873914410'))", + "result": "xs:int('1873914410')" + }, + { + "test": "fn:abs(xs:int('2147483647'))", + "result": "xs:int('2147483647')" + }, + { + "test": "fn:abs(xs:integer('-999999999999999999'))", + "result": "xs:integer('999999999999999999')" + }, + { + "test": "fn:abs(xs:integer('830993497117024304'))", + "result": "xs:integer('830993497117024304')" + }, + { + "test": "fn:abs(xs:integer('999999999999999999'))", + "result": "xs:integer('999999999999999999')" + }, + { + "test": "fn:abs(xs:decimal('-999999999999999999'))", + "result": "xs:decimal('999999999999999999')" + }, + { + "test": "fn:abs(xs:decimal('617375191608514839'))", + "result": "xs:decimal('617375191608514839')" + }, + { + "test": "fn:abs(xs:decimal('999999999999999999'))", + "result": "xs:decimal('999999999999999999')" + }, + { + "test": "fn:abs(xs:double('-1.7976931348623157E308'))", + "result": "xs:double('1.7976931348623157E308')" + }, + { + "test": "fn:abs(xs:double('0'))", + "result": "xs:double('0')" + }, + { + "test": "fn:abs(xs:double('1.7976931348623157E308'))", + "result": "xs:double('1.7976931348623157E308')" + }, + { + "test": "fn:abs(xs:float('-3.4028235E38'))", + "result": "xs:float('3.4028235E38')" + }, + { + "test": "fn:abs(xs:float('0'))", + "result": "xs:float('0')" + }, + { + "test": "fn:abs(xs:float('3.4028235E38'))", + "result": "xs:float('3.4028235E38')" + }, + { + "test": "fn:abs(xs:long('-92233720368547758'))", + "result": "xs:long('92233720368547758')" + }, + { + "test": "fn:abs(xs:long('-47175562203048468'))", + "result": "xs:long('47175562203048468')" + }, + { + "test": "fn:abs(xs:long('92233720368547758'))", + "result": "xs:long('92233720368547758')" + }, + { + "test": "fn:abs(xs:unsignedShort('0'))", + "result": "xs:unsignedShort('0')" + }, + { + "test": "fn:abs(xs:unsignedShort('44633'))", + "result": "xs:unsignedShort('44633')" + }, + { + "test": "fn:abs(xs:unsignedShort('65535'))", + "result": "xs:unsignedShort('65535')" + }, + { + "test": "fn:abs(xs:negativeInteger('-999999999999999999'))", + "result": "xs:positiveInteger('999999999999999999')" + }, + { + "test": "fn:abs(xs:negativeInteger('-297014075999096793'))", + "result": "xs:positiveInteger('297014075999096793')" + }, + { + "test": "fn:abs(xs:negativeInteger('-1'))", + "result": "xs:positiveInteger('1')" + }, + { + "test": "fn:abs(xs:positiveInteger('1'))", + "result": "xs:positiveInteger('1')" + }, + { + "test": "fn:abs(xs:positiveInteger('52704602390610033'))", + "result": "xs:positiveInteger('52704602390610033')" + }, + { + "test": "fn:abs(xs:positiveInteger('999999999999999999'))", + "result": "xs:positiveInteger('999999999999999999')" + }, + { + "test": "fn:abs(xs:unsignedLong('0'))", + "result": "xs:unsignedLong('0')" + }, + { + "test": "fn:abs(xs:unsignedLong('130747108607674654'))", + "result": "xs:unsignedLong('130747108607674654')" + }, + { + "test": "fn:abs(xs:unsignedLong('184467440737095516'))", + "result": "xs:unsignedLong('184467440737095516')" + }, + { + "test": "fn:abs(xs:nonPositiveInteger('-999999999999999999'))", + "result": "xs:nonNegativeInteger('999999999999999999')" + }, + { + "test": "fn:abs(xs:nonPositiveInteger('-475688437271870490'))", + "result": "xs:nonNegativeInteger('475688437271870490')" + }, + { + "test": "fn:abs(xs:nonPositiveInteger('0'))", + "result": "xs:nonNegativeInteger('0')" + }, + { + "test": "fn:abs(xs:nonNegativeInteger('0'))", + "result": "xs:nonNegativeInteger('0')" + }, + { + "test": "fn:abs(xs:nonNegativeInteger('303884545991464527'))", + "result": "xs:nonNegativeInteger('303884545991464527')" + }, + { + "test": "fn:abs(xs:nonNegativeInteger('999999999999999999'))", + "result": "xs:nonNegativeInteger('999999999999999999')" + }, + { + "test": "fn:abs(xs:short('-32768'))", + "result": "xs:int('32768')" + }, + { + "test": "fn:abs(xs:short('-5324'))", + "result": "xs:short('5324')" + }, + { + "test": "fn:abs(xs:short('32767'))", + "result": "xs:short('32767')" + }, + { + "test": "fn:abs(xs:double('-0'))", + "result": "xs:double('0')" + }, + { + "test": "fn:abs(xs:double('-INF'))", + "result": "xs:double('INF')" + }, + { + "test": "fn:abs(xs:double('INF'))", + "result": "xs:double('INF')" + }, + { + "test": "fn:abs(xs:double('NaN'))", + "result": "xs:double('NaN')" + }, + { + "test": "fn:abs(xs:double('NaN'))", + "result": "xs:double('NaN')" + }, + { + "test": "fn:abs(xs:decimal('-0'))", + "result": "xs:decimal('0')" + }, + { + "test": "fn:abs(xs:decimal('0'))", + "result": "xs:decimal('0')" + }, + { + "test": "fn:abs(xs:float('-0'))", + "result": "xs:float('0')" + }, + { + "test": "fn:abs(xs:float('-INF'))", + "result": "xs:float('INF')" + }, + { + "test": "fn:abs(xs:float('INF'))", + "result": "xs:float('INF')" + }, + { + "test": "fn:abs(xs:float('NaN'))", + "result": "xs:float('NaN')" + }, + { + "test": "fn:abs(xs:float('NaN'))", + "result": "xs:float('NaN')" + }, + { + "test": "fn:abs(xs:int('0'))", + "result": "xs:int('0')" + }, + { + "test": "fn:abs(xs:int('-0'))", + "result": "xs:int('0')" + }, + { + "test": "fn:abs(xs:integer('0'))", + "result": "xs:integer('0')" + }, + { + "test": "fn:abs(xs:integer('-0'))", + "result": "xs:integer('0')" + }, + { + "test": "fn:abs(xs:long('0'))", + "result": "xs:long('0')" + }, + { + "test": "fn:abs(xs:long('-0'))", + "result": "xs:long('0')" + }, + { + "test": "fn:abs(xs:nonNegativeInteger('-0'))", + "result": "xs:nonNegativeInteger('0')" + }, + { + "test": "fn:abs(xs:nonPositiveInteger('-0'))", + "result": "xs:nonNegativeInteger('0')" + }, + { + "test": "fn:abs(xs:short('0'))", + "result": "xs:short('0')" + }, + { + "test": "fn:abs(xs:short('-0'))", + "result": "xs:short('0')" + }, + { + "test": "fn:abs(xs:unsignedLong('-0'))", + "result": "xs:unsignedLong('0')" + }, + { + "test": "fn:abs(xs:unsignedShort('-0'))", + "result": "xs:unsignedShort('0')" + }, + { + "test": "fn:abs(xs:decimal('-INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:decimal('INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:decimal('-NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:decimal('NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:int('-INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:int('INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:int('-NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:int('NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:integer('-INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:integer('INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:integer('-NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:integer('NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:long('-INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:long('INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:long('-NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:long('NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:negativeInteger('-0'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:negativeInteger('0'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:negativeInteger('2'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:negativeInteger('-INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:negativeInteger('INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:negativeInteger('-NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:negativeInteger('NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:nonNegativeInteger('-2'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:nonNegativeInteger('-INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:nonNegativeInteger('INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:nonNegativeInteger('-NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:nonNegativeInteger('NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:nonPositiveInteger('2'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:nonPositiveInteger('-INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:nonPositiveInteger('INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:nonPositiveInteger('-NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:nonPositiveInteger('NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:positiveInteger('0'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:positiveInteger('-0'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:positiveInteger('-2'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:positiveInteger('-INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:positiveInteger('INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:positiveInteger('-NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:positiveInteger('NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:short('-INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:short('INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:short('-NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:short('NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:unsignedLong('-INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:unsignedLong('INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:unsignedLong('-NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:unsignedLong('NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:unsignedShort('-INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:unsignedShort('INF'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:unsignedShort('-NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:unsignedShort('NaN'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FORG0001'))" + }, + { + "test": "fn:abs(xs:string('1'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:XPTY0004'))" + }, + { + "test": "fn:abs(xs:string('hello'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:XPTY0004'))" + }, + { + "test": "fn:abs(xs:boolean('1'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:XPTY0004'))" + }, + { + "test": "fn:abs(xs:boolean('0'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:XPTY0004'))" + }, + { + "test": "fn:abs(xs:boolean(fn:true()))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:XPTY0004'))" + }, + { + "test": "fn:abs(xs:boolean(fn:false()))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:XPTY0004'))" + }, + { + "test": "fn:abs(xs:date('2002-10-09'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:XPTY0004'))" + }, + { + "test": "fn:abs(xs:time('13:20:00-05:00'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:XPTY0004'))" + }, + { + "test": "fn:abs(xs:dateTime('2002-10-10T12:00:00-05:00'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:XPTY0004'))" + }, + { + "test": "fn:abs(xs:anyURI('www.examples.org'))", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:XPTY0004'))" + }, + { + "test": "abs()", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:XPST0017'))" + }, + { + "test": "abs(1, 2)", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:XPST0017'))" + }, + { + "test": "empty(abs(()))", + "result": "xs:boolean('true')" + }, + { + "test": "abs(10.5) eq 10.5", + "result": "xs:boolean('true')" + }, + { + "test": "abs(-10.5) eq 10.5", + "result": "xs:boolean('true')" + }, + { + "test": "abs('a string')", + "result": "fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:XPTY0004'))" + }, + { + "test": "fn:abs(xs:integer(-4))", + "result": "xs:integer('4')" + }, + { + "test": "fn:abs(xs:nonPositiveInteger(-4))", + "result": "xs:nonNegativeInteger('4')" + }, + { + "test": "fn:abs(xs:negativeInteger(-4))", + "result": "xs:positiveInteger('4')" + }, + { + "test": "fn:abs(xs:long(-4))", + "result": "xs:long('4')" + }, + { + "test": "fn:abs(xs:int(-4))", + "result": "xs:int('4')" + }, + { + "test": "fn:abs(xs:short(-4))", + "result": "xs:short('4')" + }, + { + "test": "fn:abs(xs:byte(-4))", + "result": "xs:byte('4')" + }, + { + "test": "fn:abs(xs:nonNegativeInteger(4))", + "result": "xs:nonNegativeInteger('4')" + }, + { + "test": "fn:abs(xs:unsignedLong(4))", + "result": "xs:unsignedLong('4')" + }, + { + "test": "fn:abs(xs:unsignedInt(4))", + "result": "xs:unsignedInt('4')" + }, + { + "test": "fn:abs(xs:unsignedShort(4))", + "result": "xs:unsignedShort('4')" + }, + { + "test": "fn:abs(xs:unsignedByte(4))", + "result": "xs:unsignedByte('4')" + }, + { + "test": "fn:abs(xs:positiveInteger(4))", + "result": "xs:positiveInteger('4')" + }, + { + "test": "fn:abs(xs:integer(-4)) instance of xs:integer", + "result": "xs:boolean('true')" + }, + { + "test": "fn:abs(xs:nonPositiveInteger(-4)) instance of xs:integer", + "result": "xs:boolean('true')" + }, + { + "test": "fn:abs(xs:negativeInteger(-4)) instance of xs:integer", + "result": "xs:boolean('true')" + }, + { + "test": "fn:abs(xs:long(-4)) instance of xs:integer", + "result": "xs:boolean('true')" + }, + { + "test": "fn:abs(xs:int(-4)) instance of xs:integer", + "result": "xs:boolean('true')" + }, + { + "test": "fn:abs(xs:short(-4)) instance of xs:integer", + "result": "xs:boolean('true')" + }, + { + "test": "fn:abs(xs:byte(-4)) instance of xs:integer", + "result": "xs:boolean('true')" + }, + { + "test": "fn:abs(xs:nonNegativeInteger(4)) instance of xs:integer", + "result": "xs:boolean('true')" + }, + { + "test": "fn:abs(xs:unsignedLong(4)) instance of xs:integer", + "result": "xs:boolean('true')" + }, + { + "test": "fn:abs(xs:unsignedInt(4)) instance of xs:integer", + "result": "xs:boolean('true')" + }, + { + "test": "fn:abs(xs:unsignedShort(4)) instance of xs:integer", + "result": "xs:boolean('true')" + }, + { + "test": "fn:abs(xs:unsignedByte(4)) instance of xs:integer", + "result": "xs:boolean('true')" + }, + { + "test": "fn:abs(xs:positiveInteger(4)) instance of xs:integer", + "result": "xs:boolean('true')" + }, + { + "test": "fn:abs(1.1) instance of xs:integer", + "result": "xs:boolean('false')" + }, + { + "test": "fn:abs(1e1) instance of xs:integer", + "result": "xs:boolean('false')" + }, + { + "test": "fn:abs(xs:float(1)) instance of xs:double", + "result": "xs:boolean('false')" + }, + { + "test": "fn:abs(xs:float(1)) instance of xs:double", + "result": "xs:boolean('false')" + }, + { + "test": "fn:abs(1.1) instance of xs:decimal", + "result": "xs:boolean('true')" + }, + { + "test": "fn:abs(1e1) instance of xs:double", + "result": "xs:boolean('true')" + }, + { + "test": "fn:abs(xs:float(1)) instance of xs:float", + "result": "xs:boolean('true')" + }, + { + "test": "fn:abs(xs:integer(1)) instance of xs:integer", + "result": "xs:boolean('true')" + }, + { + "test": "abs(xs:unsignedShort(.)) instance of xs:unsignedShort", + "result": "xs:boolean('true')" + }, + { + "test": "abs(xs:unsignedLong(.)) instance of xs:unsignedLong", + "result": "xs:boolean('true')" + }, + { + "test": "abs(xs:unsignedInt(.)) instance of xs:unsignedInt", + "result": "xs:boolean('true')" + }, + { + "test": "abs(xs:unsignedByte(.)) instance of xs:unsignedByte", + "result": "xs:boolean('true')" + }, + { + "test": "abs(xs:positiveInteger(.)) instance of xs:positiveInteger", + "result": "xs:boolean('true')" + }, + { + "test": "abs(xs:nonPositiveInteger(.)) instance of xs:nonPositiveInteger", + "result": "xs:boolean('false')" + }, + { + "test": "abs(xs:nonNegativeInteger(.)) instance of xs:nonNegativeInteger", + "result": "xs:boolean('true')" + }, + { + "test": "abs(xs:negativeInteger(.)) instance of xs:negativeInteger", + "result": "xs:boolean('false')" + }, + { + "test": "abs(xs:long(.)) instance of xs:long", + "result": "xs:boolean('true')" + }, + { + "test": "abs(xs:int(.)) instance of xs:int", + "result": "xs:boolean('true')" + }, + { + "test": "abs(xs:short(.)) instance of xs:short", + "result": "xs:boolean('true')" + }, + { + "test": "abs(xs:byte(.)) instance of xs:byte", + "result": "xs:boolean('true')" + }, + { + "test": "fn:abs(xs:float('-INF'))", + "result": "xs:float('INF')" + }, + { + "test": "fn:abs(xs:double('-INF'))", + "result": "xs:double('INF')" + }, + { + "test": "fn:abs(xs:float('INF'))", + "result": "xs:float('INF')" + }, + { + "test": "fn:abs(xs:double('INF'))", + "result": "xs:double('INF')" + }, + { + "test": "string-join(for $x in (1, xs:decimal(2), xs:float(3), xs:double(4)) return if ((abs($x)) instance of xs:integer) then 'integer' else if ((abs($x)) instance of xs:decimal) then 'decimal' else if ((abs($x)) instance of xs:float) then 'float' else if ((abs($x)) instance of xs:double) then 'double' else error(),' ')", + "result": "xs:string('integer decimal float double')" + }, + { + "test": "fn:abs( fn:reverse( (1, xs:decimal(2.2), xs:float(3.3), xs:double(4.4)) )[2] )", + "result": "xs:float('3.3')" + } + ] + }, + { + "name": "fn-adjust-date-to-timezone", + "tests": [] + }, + { + "name": "fn-adjust-dateTime-to-timezone", + "tests": [] + }, + { + "name": "fn-adjust-time-to-timezone", + "tests": [] + }, + { + "name": "fn-analyze-string", + "tests": [] + }, + { + "name": "fn-available-environment-variables", + "tests": [] + }, + { + "name": "fn-avg", + "tests": [] + }, + { + "name": "fn-base-uri", + "tests": [] + }, + { + "name": "fn-boolean", + "tests": [] + }, + { + "name": "fn-ceiling", + "tests": [] + }, + { + "name": "fn-codepoint-equal", + "tests": [] + }, + { + "name": "fn-codepoints-to-string", + "tests": [] + }, + { + "name": "fn-collection", + "tests": [] + }, + { + "name": "fn-compare", + "tests": [] + }, + { + "name": "fn-concat", + "tests": [] + }, + { + "name": "fn-contains", + "tests": [] + }, + { + "name": "fn-count", + "tests": [] + }, + { + "name": "fn-current-date", + "tests": [] + }, + { + "name": "fn-current-dateTime", + "tests": [] + }, + { + "name": "fn-current-time", + "tests": [] + }, + { + "name": "fn-data", + "tests": [] + }, + { + "name": "fn-dateTime", + "tests": [] + }, + { + "name": "fn-day-from-date", + "tests": [] + }, + { + "name": "fn-day-from-dateTime", + "tests": [] + }, + { + "name": "fn-days-from-duration", + "tests": [] + }, + { + "name": "fn-deep-equal", + "tests": [] + }, + { + "name": "fn-default-collation", + "tests": [] + }, + { + "name": "fn-distinct-values", + "tests": [] + }, + { + "name": "fn-doc", + "tests": [] + }, + { + "name": "fn-doc-available", + "tests": [] + }, + { + "name": "fn-document-uri", + "tests": [] + }, + { + "name": "fn-element-with-id", + "tests": [] + }, + { + "name": "fn-empty", + "tests": [] + }, + { + "name": "fn-encode-for-uri", + "tests": [] + }, + { + "name": "fn-ends-with", + "tests": [] + }, + { + "name": "fn-environment-variable", + "tests": [] + }, + { + "name": "fn-error", + "tests": [] + }, + { + "name": "fn-escape-html-uri", + "tests": [] + }, + { + "name": "fn-exactly-one", + "tests": [] + }, + { + "name": "fn-exists", + "tests": [] + }, + { + "name": "fn-false", + "tests": [] + }, + { + "name": "fn-filter", + "tests": [] + }, + { + "name": "fn-floor", + "tests": [] + }, + { + "name": "fn-fold-left", + "tests": [] + }, + { + "name": "fn-fold-right", + "tests": [] + }, + { + "name": "fn-format-date", + "tests": [] + }, + { + "name": "fn-format-dateTime", + "tests": [] + }, + { + "name": "fn-format-integer", + "tests": [] + }, + { + "name": "fn-format-number", + "tests": [] + }, + { + "name": "fn-format-time", + "tests": [] + }, + { + "name": "fn-function-lookup", + "tests": [] + }, + { + "name": "fn-function-arity", + "tests": [] + }, + { + "name": "fn-function-name", + "tests": [] + }, + { + "name": "fn-generate-id", + "tests": [] + }, + { + "name": "fn-has-children", + "tests": [] + }, + { + "name": "fn-head", + "tests": [] + }, + { + "name": "fn-hours-from-dateTime", + "tests": [] + }, + { + "name": "fn-hours-from-duration", + "tests": [] + }, + { + "name": "fn-hours-from-time", + "tests": [] + }, + { + "name": "fn-id", + "tests": [] + }, + { + "name": "fn-idref", + "tests": [] + }, + { + "name": "fn-implicit-timezone", + "tests": [] + }, + { + "name": "fn-innermost", + "tests": [] + }, + { + "name": "fn-index-of", + "tests": [] + }, + { + "name": "fn-insert-before", + "tests": [] + }, + { + "name": "fn-in-scope-prefixes", + "tests": [] + }, + { + "name": "fn-iri-to-uri", + "tests": [] + }, + { + "name": "fn-lang", + "tests": [] + }, + { + "name": "fn-last", + "tests": [] + }, + { + "name": "fn-local-name", + "tests": [] + }, + { + "name": "fn-local-name-from-Qname", + "tests": [] + }, + { + "name": "fn-lower-case", + "tests": [] + }, + { + "name": "fn-for-each", + "tests": [] + }, + { + "name": "fn-max", + "tests": [] + }, + { + "name": "fn-for-each-pair", + "tests": [] + }, + { + "name": "fn-matches", + "tests": [] + }, + { + "name": "fn-matches.re", + "tests": [] + }, + { + "name": "fn-min", + "tests": [] + }, + { + "name": "fn-minutes-from-dateTime", + "tests": [] + }, + { + "name": "fn-minutes-from-duration", + "tests": [] + }, + { + "name": "fn-minutes-from-time", + "tests": [] + }, + { + "name": "fn-month-from-date", + "tests": [] + }, + { + "name": "fn-months-from-duration", + "tests": [] + }, + { + "name": "fn-month-from-dateTime", + "tests": [] + }, + { + "name": "fn-name", + "tests": [] + }, + { + "name": "fn-namespace-uri", + "tests": [] + }, + { + "name": "fn-namespace-uri-for-prefix", + "tests": [] + }, + { + "name": "fn-namespace-uri-from-Qname", + "tests": [] + }, + { + "name": "fn-nilled", + "tests": [] + }, + { + "name": "fn-node-name", + "tests": [] + }, + { + "name": "fn-normalize-space", + "tests": [] + }, + { + "name": "fn-normalize-unicode", + "tests": [] + }, + { + "name": "fn-not", + "tests": [] + }, + { + "name": "fn-number", + "tests": [] + }, + { + "name": "fn-one-or-more", + "tests": [] + }, + { + "name": "fn-outermost", + "tests": [] + }, + { + "name": "fn-parse-json", + "tests": [] + }, + { + "name": "fn-parse-xml", + "tests": [] + }, + { + "name": "fn-parse-xml-fragment", + "tests": [] + }, + { + "name": "fn-path", + "tests": [] + }, + { + "name": "fn-position", + "tests": [] + }, + { + "name": "fn-prefix-from-Qname", + "tests": [] + }, + { + "name": "fn-Qname", + "tests": [] + }, + { + "name": "fn-remove", + "tests": [] + }, + { + "name": "fn-replace", + "tests": [] + }, + { + "name": "fn-resolve-Qname", + "tests": [] + }, + { + "name": "fn-resolve-uri", + "tests": [] + }, + { + "name": "fn-reverse", + "tests": [] + }, + { + "name": "fn-root", + "tests": [] + }, + { + "name": "fn-round", + "tests": [] + }, + { + "name": "fn-round-half-to-even", + "tests": [] + }, + { + "name": "fn-seconds-from-dateTime", + "tests": [] + }, + { + "name": "fn-seconds-from-duration", + "tests": [] + }, + { + "name": "fn-seconds-from-time", + "tests": [] + }, + { + "name": "fn-serialize", + "tests": [] + }, + { + "name": "fn-serialize-json", + "tests": [] + }, + { + "name": "fn-starts-with", + "tests": [] + }, + { + "name": "fn-static-base-uri", + "tests": [] + }, + { + "name": "fn-string", + "tests": [] + }, + { + "name": "fn-string-join", + "tests": [] + }, + { + "name": "fn-string-length", + "tests": [] + }, + { + "name": "fn-string-to-codepoints", + "tests": [] + }, + { + "name": "fn-subsequence", + "tests": [] + }, + { + "name": "fn-substring", + "tests": [] + }, + { + "name": "fn-substring-after", + "tests": [] + }, + { + "name": "fn-substring-before", + "tests": [] + }, + { + "name": "fn-sum", + "tests": [] + }, + { + "name": "fn-tail", + "tests": [] + }, + { + "name": "fn-timezone-from-date", + "tests": [] + }, + { + "name": "fn-timezone-from-dateTime", + "tests": [] + }, + { + "name": "fn-timezone-from-time", + "tests": [] + }, + { + "name": "fn-tokenize", + "tests": [] + }, + { + "name": "fn-trace", + "tests": [] + }, + { + "name": "fn-translate", + "tests": [] + }, + { + "name": "fn-true", + "tests": [] + }, + { + "name": "fn-unordered", + "tests": [] + }, + { + "name": "fn-unparsed-text", + "tests": [] + }, + { + "name": "fn-unparsed-text-available", + "tests": [] + }, + { + "name": "fn-unparsed-text-lines", + "tests": [] + }, + { + "name": "fn-upper-case", + "tests": [] + }, + { + "name": "fn-uri-collection", + "tests": [] + }, + { + "name": "fn-year-from-date", + "tests": [] + }, + { + "name": "fn-years-from-duration", + "tests": [] + }, + { + "name": "fn-year-from-dateTime", + "tests": [] + }, + { + "name": "fn-zero-or-one", + "tests": [] + }, + { + "name": "math-acos", + "tests": [] + }, + { + "name": "math-asin", + "tests": [] + }, + { + "name": "math-atan", + "tests": [] + }, + { + "name": "math-atan2", + "tests": [] + }, + { + "name": "math-cos", + "tests": [] + }, + { + "name": "math-exp", + "tests": [] + }, + { + "name": "math-exp10", + "tests": [] + }, + { + "name": "math-log", + "tests": [] + }, + { + "name": "math-log10", + "tests": [] + }, + { + "name": "math-pi", + "tests": [] + }, + { + "name": "math-pow", + "tests": [] + }, + { + "name": "math-sin", + "tests": [] + }, + { + "name": "math-sqrt", + "tests": [] + }, + { + "name": "math-tan", + "tests": [] + }, + { + "name": "map-new", + "tests": [] + }, + { + "name": "map-contains", + "tests": [] + }, + { + "name": "map-get", + "tests": [] + }, + { + "name": "map-entry", + "tests": [] + }, + { + "name": "map-size", + "tests": [] + }, + { + "name": "map-keys", + "tests": [] + }, + { + "name": "map-remove", + "tests": [] + }, + { + "name": "map-collation", + "tests": [] + }, + { + "name": "xs-anyURI", + "tests": [] + }, + { + "name": "xs-base64Binary", + "tests": [] + }, + { + "name": "xs-dateTimeStamp", + "tests": [] + }, + { + "name": "xs-double", + "tests": [] + }, + { + "name": "xs-error", + "tests": [] + }, + { + "name": "xs-float", + "tests": [] + }, + { + "name": "xs-hexBinary", + "tests": [] + }, + { + "name": "xs-normalizedString", + "tests": [] + }, + { + "name": "xs-token", + "tests": [] + }, + { + "name": "op-add-dayTimeDurations", + "tests": [] + }, + { + "name": "op-add-dayTimeDuration-to-date", + "tests": [] + }, + { + "name": "op-add-dayTimeDuration-to-dateTime", + "tests": [] + }, + { + "name": "op-add-dayTimeDuration-to-time", + "tests": [] + }, + { + "name": "op-add-yearMonthDurations", + "tests": [] + }, + { + "name": "op-add-yearMonthDuration-to-date", + "tests": [] + }, + { + "name": "op-add-yearMonthDuration-to-dateTime", + "tests": [] + }, + { + "name": "op-anyURI-equal", + "tests": [] + }, + { + "name": "op-anyURI-greater-than", + "tests": [] + }, + { + "name": "op-anyURI-less-than", + "tests": [] + }, + { + "name": "op-bang", + "tests": [] + }, + { + "name": "op-base64Binary-equal", + "tests": [] + }, + { + "name": "op-boolean-equal", + "tests": [] + }, + { + "name": "op-boolean-greater-than", + "tests": [] + }, + { + "name": "op-boolean-less-than", + "tests": [] + }, + { + "name": "op-concat", + "tests": [] + }, + { + "name": "op-concatenate", + "tests": [] + }, + { + "name": "op-date-equal", + "tests": [] + }, + { + "name": "op-date-greater-than", + "tests": [] + }, + { + "name": "op-date-less-than", + "tests": [] + }, + { + "name": "op-dateTime-equal", + "tests": [] + }, + { + "name": "op-dateTime-greater-than", + "tests": [] + }, + { + "name": "op-dateTime-less-than", + "tests": [] + }, + { + "name": "op-dayTimeDuration-greater-than", + "tests": [] + }, + { + "name": "op-dayTimeDuration-less-than", + "tests": [] + }, + { + "name": "op-divide-dayTimeDuration", + "tests": [] + }, + { + "name": "op-divide-dayTimeDuration-by-dayTimeDuration", + "tests": [] + }, + { + "name": "op-divide-yearMonthDuration", + "tests": [] + }, + { + "name": "op-divide-yearMonthDuration-by-yearMonthDuration", + "tests": [] + }, + { + "name": "op-duration-equal", + "tests": [] + }, + { + "name": "op-except", + "tests": [] + }, + { + "name": "op-gDay-equal", + "tests": [] + }, + { + "name": "op-gMonth-equal", + "tests": [] + }, + { + "name": "op-gMonthDay-equal", + "tests": [] + }, + { + "name": "op-gYear-equal", + "tests": [] + }, + { + "name": "op-gYearMonth-equal", + "tests": [] + }, + { + "name": "op-hexBinary-equal", + "tests": [] + }, + { + "name": "op-intersect", + "tests": [] + }, + { + "name": "op-is-same-node", + "tests": [] + }, + { + "name": "op-multiply-dayTimeDuration", + "tests": [] + }, + { + "name": "op-multiply-yearMonthDuration", + "tests": [] + }, + { + "name": "op-node-after", + "tests": [] + }, + { + "name": "op-node-before", + "tests": [] + }, + { + "name": "op-NOTATION-equal", + "tests": [] + }, + { + "name": "op-numeric-add", + "tests": [] + }, + { + "name": "op-numeric-equal", + "tests": [] + }, + { + "name": "op-numeric-divide", + "tests": [] + }, + { + "name": "op-numeric-greater-than", + "tests": [] + }, + { + "name": "op-numeric-integer-divide", + "tests": [] + }, + { + "name": "op-numeric-less-than", + "tests": [] + }, + { + "name": "op-numeric-mod", + "tests": [] + }, + { + "name": "op-numeric-multiply", + "tests": [] + }, + { + "name": "op-numeric-subtract", + "tests": [] + }, + { + "name": "op-numeric-unary-minus", + "tests": [] + }, + { + "name": "op-numeric-unary-plus", + "tests": [] + }, + { + "name": "op-Qname-equal", + "tests": [] + }, + { + "name": "op-string-equal", + "tests": [] + }, + { + "name": "op-string-greater-than", + "tests": [] + }, + { + "name": "op-string-less-than", + "tests": [] + }, + { + "name": "op-subtract-dates", + "tests": [] + }, + { + "name": "op-subtract-dateTimes", + "tests": [] + }, + { + "name": "op-subtract-dayTimeDuration-from-date", + "tests": [] + }, + { + "name": "op-subtract-dayTimeDuration-from-dateTime", + "tests": [] + }, + { + "name": "op-subtract-dayTimeDuration-from-time", + "tests": [] + }, + { + "name": "op-subtract-dayTimeDurations", + "tests": [] + }, + { + "name": "op-subtract-times", + "tests": [] + }, + { + "name": "op-subtract-yearMonthDuration-from-date", + "tests": [] + }, + { + "name": "op-subtract-yearMonthDuration-from-dateTime", + "tests": [] + }, + { + "name": "op-subtract-yearMonthDurations", + "tests": [] + }, + { + "name": "op-time-equal", + "tests": [] + }, + { + "name": "op-time-greater-than", + "tests": [] + }, + { + "name": "op-time-less-than", + "tests": [] + }, + { + "name": "op-to", + "tests": [] + }, + { + "name": "op-union", + "tests": [] + }, + { + "name": "op-yearMonthDuration-greater-than", + "tests": [] + }, + { + "name": "op-yearMonthDuration-less-than", + "tests": [] + }, + { + "name": "prod-AllowingEmpty", + "tests": [] + }, + { + "name": "prod-Annotation", + "tests": [] + }, + { + "name": "prod-AxisStep", + "tests": [] + }, + { + "name": "prod-AxisStep.abbr", + "tests": [] + }, + { + "name": "prod-AxisStep.ancestor", + "tests": [] + }, + { + "name": "prod-AxisStep.ancestor-or-self", + "tests": [] + }, + { + "name": "prod-AxisStep.following", + "tests": [] + }, + { + "name": "prod-AxisStep.following-sibling", + "tests": [] + }, + { + "name": "prod-AxisStep.preceding", + "tests": [] + }, + { + "name": "prod-AxisStep.preceding-sibling", + "tests": [] + }, + { + "name": "prod-AxisStep.static-typing", + "tests": [] + }, + { + "name": "prod-AxisStep.unabbr", + "tests": [] + }, + { + "name": "prod-BaseURIDecl", + "tests": [] + }, + { + "name": "prod-BoundarySpaceDecl", + "tests": [] + }, + { + "name": "prod-CastableExpr", + "tests": [] + }, + { + "name": "prod-CastExpr", + "tests": [] + }, + { + "name": "prod-CastExpr.derived", + "tests": [] + }, + { + "name": "prod-CastExpr.schema", + "tests": [] + }, + { + "name": "prod-Comment", + "tests": [] + }, + { + "name": "prod-CompAttrConstructor", + "tests": [] + }, + { + "name": "prod-CompDocConstructor", + "tests": [] + }, + { + "name": "prod-CompCommentConstructor", + "tests": [] + }, + { + "name": "prod-CompElemConstructor", + "tests": [] + }, + { + "name": "prod-CompnamespaceConstructor", + "tests": [] + }, + { + "name": "prod-CompPIConstructor", + "tests": [] + }, + { + "name": "prod-CompTextConstructor", + "tests": [] + }, + { + "name": "prod-ConstructionDecl", + "tests": [] + }, + { + "name": "prod-ConstructionDecl.schema", + "tests": [] + }, + { + "name": "prod-ContextItemDecl", + "tests": [] + }, + { + "name": "prod-ContextItemExpr", + "tests": [] + }, + { + "name": "prod-CopynamespacesDecl", + "tests": [] + }, + { + "name": "prod-CountClause", + "tests": [] + }, + { + "name": "prod-DecimalFormatDecl", + "tests": [] + }, + { + "name": "prod-DefaultCollationDecl", + "tests": [] + }, + { + "name": "prod-DefaultnamespaceDecl", + "tests": [] + }, + { + "name": "prod-DirAttributeList", + "tests": [] + }, + { + "name": "prod-DirectConstructor", + "tests": [] + }, + { + "name": "prod-DirElemConstructor", + "tests": [] + }, + { + "name": "prod-DirElemContent", + "tests": [] + }, + { + "name": "prod-DirElemContent.namespace", + "tests": [] + }, + { + "name": "prod-DirElemContent.whitespace", + "tests": [] + }, + { + "name": "prod-EmptyOrderDecl", + "tests": [] + }, + { + "name": "prod-EQname", + "tests": [] + }, + { + "name": "prod-ExtensionExpr", + "tests": [] + }, + { + "name": "prod-FLWORExpr", + "tests": [] + }, + { + "name": "prod-FLWORExpr.static-typing", + "tests": [] + }, + { + "name": "prod-ForClause", + "tests": [] + }, + { + "name": "prod-FunctionCall", + "tests": [] + }, + { + "name": "prod-FunctionDecl", + "tests": [] + }, + { + "name": "prod-GeneralComp.eq", + "tests": [] + }, + { + "name": "prod-GeneralComp.ge", + "tests": [] + }, + { + "name": "prod-GeneralComp.gt", + "tests": [] + }, + { + "name": "prod-GeneralComp.le", + "tests": [] + }, + { + "name": "prod-GeneralComp.lt", + "tests": [] + }, + { + "name": "prod-GeneralComp.ne", + "tests": [] + }, + { + "name": "prod-GroupByClause", + "tests": [] + }, + { + "name": "prod-IfExpr", + "tests": [] + }, + { + "name": "prod-InstanceofExpr", + "tests": [] + }, + { + "name": "prod-LetClause", + "tests": [] + }, + { + "name": "prod-Literal", + "tests": [] + }, + { + "name": "prod-ModuleImport", + "tests": [] + }, + { + "name": "prod-namedFunctionRef", + "tests": [] + }, + { + "name": "prod-namespaceDecl", + "tests": [] + }, + { + "name": "prod-nameTest", + "tests": [] + }, + { + "name": "prod-NodeTest", + "tests": [] + }, + { + "name": "prod-OptionDecl", + "tests": [] + }, + { + "name": "prod-OptionDecl.serialization", + "tests": [] + }, + { + "name": "prod-OrExpr", + "tests": [] + }, + { + "name": "prod-OrderByClause", + "tests": [] + }, + { + "name": "prod-OrderingModeDecl", + "tests": [] + }, + { + "name": "prod-PathExpr", + "tests": [] + }, + { + "name": "prod-ParenthesizedExpr", + "tests": [] + }, + { + "name": "prod-PositionalVar", + "tests": [] + }, + { + "name": "prod-Predicate", + "tests": [] + }, + { + "name": "prod-QuantifiedExpr", + "tests": [] + }, + { + "name": "prod-ReturnClause", + "tests": [] + }, + { + "name": "prod-SchemaImport", + "tests": [] + }, + { + "name": "prod-SequenceType", + "tests": [] + }, + { + "name": "prod-StepExpr", + "tests": [] + }, + { + "name": "prod-SwitchExpr", + "tests": [] + }, + { + "name": "prod-TreatExpr", + "tests": [] + }, + { + "name": "prod-TryCatchExpr", + "tests": [] + }, + { + "name": "prod-TypeswitchExpr", + "tests": [] + }, + { + "name": "prod-UnorderedExpr", + "tests": [] + }, + { + "name": "prod-ValidateExpr", + "tests": [] + }, + { + "name": "prod-ValueComp", + "tests": [] + }, + { + "name": "prod-VarDecl", + "tests": [] + }, + { + "name": "prod-VarDecl.external", + "tests": [] + }, + { + "name": "prod-VarDefaultValue", + "tests": [] + }, + { + "name": "prod-VersionDecl", + "tests": [] + }, + { + "name": "prod-WhereClause", + "tests": [] + }, + { + "name": "prod-WindowClause", + "tests": [] + }, + { + "name": "misc-CombinedErrorCodes", + "tests": [] + }, + { + "name": "misc-AnnexE", + "tests": [] + }, + { + "name": "misc-AppendixA4", + "tests": [] + }, + { + "name": "misc-ErrorsAndOptimization", + "tests": [] + }, + { + "name": "misc-HigherOrderFunctions", + "tests": [] + }, + { + "name": "misc-MiscFunctions", + "tests": [] + }, + { + "name": "misc-StaticContext", + "tests": [] + }, + { + "name": "misc-Serialization", + "tests": [] + }, + { + "name": "misc-Surrogates", + "tests": [] + }, + { + "name": "misc-XMLEdition", + "tests": [] + }, + { + "name": "app-CatalogCheck", + "tests": [] + }, + { + "name": "app-Demos", + "tests": [] + }, + { + "name": "app-FunctxFn", + "tests": [] + }, + { + "name": "app-FunctxFunctx", + "tests": [] + }, + { + "name": "app-UseCaseNS", + "tests": [] + }, + { + "name": "app-UseCasePARTS", + "tests": [] + }, + { + "name": "app-UseCaseR", + "tests": [] + }, + { + "name": "app-UseCaseSEQ", + "tests": [] + }, + { + "name": "app-UseCaseSGML", + "tests": [] + }, + { + "name": "app-UseCaseSTRING", + "tests": [] + }, + { + "name": "app-UseCaseTREE", + "tests": [] + }, + { + "name": "app-UseCaseXMP", + "tests": [] + }, + { + "name": "app-XMark", + "tests": [] + } +] \ No newline at end of file diff --git a/src/css/xsltforms.css/console.css b/src/css/xsltforms.css/console.css index 8fab012..55d4ee0 100644 --- a/src/css/xsltforms.css/console.css +++ b/src/css/xsltforms.css/console.css @@ -1,6 +1,6 @@ #xsltforms-console { - font-size: 0.8em; - color: #888888; - border-top: thin solid #888888; - display: none; + font-size: 0.8em; + color: #888888; + border-top: thin solid #888888; + display: none; } \ No newline at end of file diff --git a/src/css/xsltforms.css/dialog.css b/src/css/xsltforms.css/dialog.css index cfd351f..446a8b9 100644 --- a/src/css/xsltforms.css/dialog.css +++ b/src/css/xsltforms.css/dialog.css @@ -1,28 +1,28 @@ xforms-dialog { - display: none; - position: absolute; - width: 400px; - height: 300px; - background-color: white; - border-top: 1px solid black; - border-left: 1px solid black; - border-bottom: 3px solid black; - border-right: 3px solid black; - padding: 10px; - z-index: 10; - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; - box-sizing: border-box; + display: none; + position: absolute; + width: 400px; + height: 300px; + background-color: white; + border-top: 1px solid black; + border-left: 1px solid black; + border-bottom: 3px solid black; + border-right: 3px solid black; + padding: 10px; + z-index: 10; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; } xforms-dialog-surround { - display: none; - position: absolute; - left: 0; - top: 0; - width: 100%; - height: 100%; - background-color: green; - filter:alpha(opacity=40); - opacity:0.4; - -moz-opacity:0.4; + display: none; + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 100%; + background-color: green; + filter:alpha(opacity=40); + opacity:0.4; + -moz-opacity:0.4; } \ No newline at end of file diff --git a/src/css/xsltforms.css/display.css b/src/css/xsltforms.css/display.css index 473a331..87fc062 100644 --- a/src/css/xsltforms.css/display.css +++ b/src/css/xsltforms.css/display.css @@ -1,3 +1,14 @@ +xforms-form > xforms-body > form { + display: inline; +} + +xforms-status-panel { + display: none; + z-index: 99; + top: 294.5px; + left: 490px; +} + xforms-action, xforms-alert-mark, xforms-bind, @@ -66,7 +77,7 @@ xforms-select1:not([xf-appearance="full"]) > xforms-body > xforms-item, xforms-select1:not([xf-appearance="full"]) > xforms-body > xforms-itemset, xforms-select1:not([xf-appearance="full"]) > xforms-body > xforms-choices, xforms-itemset > xforms-label { - display: none; + display: none; } xforms-group:not([xf-ref]):not([xf-bind]), @@ -83,13 +94,13 @@ xforms-select1[xf-appearance="full"] > xforms-body > xforms-itemset > xforms-ite xforms-select1[xf-appearance="full"] > xforms-body > xforms-choices > xforms-label, xforms-select1[xf-appearance="full"] > xforms-body > xforms-choices > xforms-item, xforms-select1[xf-appearance="full"] > xforms-body > xforms-choices > xforms-itemset > xforms-item { - display: block; + display: block; } xforms-repeat[xf-bound]:not([xf-notrelevant]) > xforms-repeat-item { - display: table-row; + display: inherit; } - +/* xforms-repeat-item > xforms-output[xf-value], xforms-repeat-item > xforms-output[xf-bound]:not([xf-notrelevant]), @@ -105,9 +116,9 @@ xforms-repeat-item > xforms-select[xf-bound]:not([xf-notrelevant])[xf-appearance xforms-repeat-item > xforms-select1[xf-bound]:not([xf-notrelevant])[xf-appearance="full"], xforms-repeat-item > xforms-select[xf-bound]:not([xf-notrelevant]):not([xf-appearance="full"]), xforms-repeat-item > xforms-select1[xf-bound]:not([xf-notrelevant]):not([xf-appearance="full"]) { - display: inline-table; + display: inline; } - +*/ xforms-output[xf-value], xforms-output[xf-bound]:not([xf-notrelevant]), xforms-input[xf-bound]:not([xf-notrelevant]), @@ -130,5 +141,5 @@ xforms-select1[xf-appearance="full"] > xforms-body > xforms-item > xforms-label, xforms-select1[xf-appearance="full"] > xforms-body > xforms-itemset > xforms-item > xforms-label, xforms-select1[xf-appearance="full"] > xforms-body > xforms-choices > xforms-item > xforms-label, xforms-select1[xf-appearance="full"] > xforms-body > xforms-choices > xforms-itemset > xforms-item > xforms-label { - display: inline-block; + display: inline-block; } \ No newline at end of file diff --git a/src/css/xsltforms.css/project.json b/src/css/xsltforms.css/project.json index 48172b3..1a2156d 100644 --- a/src/css/xsltforms.css/project.json +++ b/src/css/xsltforms.css/project.json @@ -19,10 +19,10 @@ "status.css", "trigger.css" ], - "VersionYear":"2022", - "VersionDate":"2022-02-07", + "VersionYear":"2023", + "VersionDate":"2023-01-29", "VersionDescription":"XForms 1.1+ Engine", - "VersionName":"1.6", - "VersionNumber":"663", + "VersionName":"1.7", + "VersionNumber":"664", "Licence":"XSLTForms $$$VersionName$$$ ($$$VersionNumber$$$)\n$$$VersionDescription$$$\n\nCopyright (C) $$$VersionYear$$$ agenceXML - Alain Couthures\nContact at : xsltforms@agencexml.com\n\nThis library is free software; you can redistribute it and/or\nmodify it under the terms of the GNU Lesser General Public\nLicense as published by the Free Software Foundation; either\nversion 2.1 of the License, or (at your option) any later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\nLesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public\nLicense along with this library; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA" } \ No newline at end of file diff --git a/src/js/fleur.js/DOM/DOMParser.js b/src/js/fleur.js/DOM/DOMParser.js index 2c27306..ce8d516 100644 --- a/src/js/fleur.js/DOM/DOMParser.js +++ b/src/js/fleur.js/DOM/DOMParser.js @@ -1,9 +1,7 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ diff --git a/src/js/fleur.js/DOM/Document.js b/src/js/fleur.js/DOM/Document.js index fee0abc..8d620c3 100644 --- a/src/js/fleur.js/DOM/Document.js +++ b/src/js/fleur.js/DOM/Document.js @@ -1,38 +1,36 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Document_index = 0; Fleur.Document = function() { - Fleur.Node.apply(this); - this.nodeType = Fleur.Node.DOCUMENT_NODE; - this.nodeName = "#document"; - this.inputEncoding = "UTF-8"; - this.xmlStandalone = false; - this.xmlVersion = "1.0"; - this._elementById = {}; - this._elementsByTagName = {}; - this.internal_id = String(Fleur.Document_index++); - this.internal_id = String.fromCharCode(64 + this.internal_id.length) + this.internal_id; + Fleur.Node.apply(this); + this.nodeType = Fleur.Node.DOCUMENT_NODE; + this.nodeName = "#document"; + this.inputEncoding = "UTF-8"; + this.xmlStandalone = false; + this.xmlVersion = "1.0"; + this._elementById = {}; + this._elementsByTagName = {}; + this.internal_id = String(Fleur.Document_index++); + this.internal_id = String.fromCharCode(64 + this.internal_id.length) + this.internal_id; }; Fleur.Document.prototype = new Fleur.Node(); Object.defineProperties(Fleur.Document.prototype, { - documentElement: { - get: function() { - return this.children[0] ? this.children[0] : null; - } - }, - nodeValue: { - set: function() {}, - get: function() { - return null; - } - } + documentElement: { + get: function() { + return this.children[0] ? this.children[0] : null; + } + }, + nodeValue: { + set: function() {}, + get: function() { + return null; + } + } }); /** * @name Fleur.Document#_adoptNode @@ -41,17 +39,17 @@ Object.defineProperties(Fleur.Document.prototype, { * @returns {Fleur.Node} */ Fleur.Document.prototype._adoptNode = function(source) { - var ic = 0, lc = source.childNodes ? source.childNodes.length : 0, ia = 0, la = source.attributes ? source.attributes.length : 0; - source.ownerDocument = this; - while (ia < la) { - this.adoptNode(source.attributes.item(ia)); - ia++; - } - while (ic < lc) { - this.adoptNode(source.childNodes[ic]); - ic++; - } - return source; + var ic = 0, lc = source.childNodes ? source.childNodes.length : 0, ia = 0, la = source.attributes ? source.attributes.length : 0; + source.ownerDocument = this; + while (ia < la) { + this.adoptNode(source.attributes.item(ia)); + ia++; + } + while (ic < lc) { + this.adoptNode(source.childNodes[ic]); + ic++; + } + return source; }; /** * @name Fleur.Document#adoptNode @@ -60,454 +58,454 @@ Fleur.Document.prototype._adoptNode = function(source) { * @returns {Fleur.Node} */ Fleur.Document.prototype.adoptNode = function(source) { - if (source.nodeType === Fleur.Node.DOCUMENT_NODE || source.nodeType === Fleur.Node.DOCUMENT_TYPE_NODE) { - throw new Fleur.DOMException(Fleur.DOMException.NOT_SUPPORTED_ERR); - } - if (source.nodeType === Fleur.Node.ATTRIBUTE_NODE) { - source.ownerElement = null; - } - return this._adoptNode(source); + if (source.nodeType === Fleur.Node.DOCUMENT_NODE || source.nodeType === Fleur.Node.DOCUMENT_TYPE_NODE) { + throw new Fleur.DOMException(Fleur.DOMException.NOT_SUPPORTED_ERR); + } + if (source.nodeType === Fleur.Node.ATTRIBUTE_NODE) { + source.ownerElement = null; + } + return this._adoptNode(source); }; Fleur.Document.prototype.createAttribute = function(attrname) { - return this.createAttributeNS(null, attrname); + return this.createAttributeNS(null, attrname); }; Fleur.Document.prototype.createAttributeNS = function(namespaceURI, qualifiedName) { - var node = new Fleur.Attr(); - if (!Fleur.Node.QNameReg.test(qualifiedName)) { - if (Fleur.Node.QNameCharsReg.test(qualifiedName)) { - throw new Fleur.DOMException(Fleur.DOMException.NAMESPACE_ERR); - } else { - console.log(qualifiedName); - throw new Fleur.DOMException(Fleur.DOMException.INVALID_CHARACTER_ERR); - } - } - if ((namespaceURI === null && qualifiedName.indexOf(":") !== -1) || - (qualifiedName.substr(0, 4) === "xml:" && namespaceURI !== "http://www.w3.org/XML/1998/namespace") || - ((qualifiedName === "xmlns" || qualifiedName.substr(0, 6) === "xmlns:") && namespaceURI !== "http://www.w3.org/2000/xmlns/") || - (namespaceURI === "http://www.w3.org/2000/xmlns/" && qualifiedName !== "xmlns" && qualifiedName.indexOf(":") !== -1 && qualifiedName.substr(0, 6) !== "xmlns:")) { - throw new Fleur.DOMException(Fleur.DOMException.NAMESPACE_ERR); - } - node._setOwnerDocument(this); - node._setNodeNameLocalNamePrefix(namespaceURI, qualifiedName); - node.name = qualifiedName; - node.textContent = ""; - return node; + var node = new Fleur.Attr(); + if (!Fleur.Node.QNameReg.test(qualifiedName)) { + if (Fleur.Node.QNameCharsReg.test(qualifiedName)) { + throw new Fleur.DOMException(Fleur.DOMException.NAMESPACE_ERR); + } else { + console.log(qualifiedName); + throw new Fleur.DOMException(Fleur.DOMException.INVALID_CHARACTER_ERR); + } + } + if ((namespaceURI === null && qualifiedName.indexOf(":") !== -1) || + (qualifiedName.substr(0, 4) === "xml:" && namespaceURI !== "http://www.w3.org/XML/1998/namespace") || + ((qualifiedName === "xmlns" || qualifiedName.substr(0, 6) === "xmlns:") && namespaceURI !== "http://www.w3.org/2000/xmlns/") || + (namespaceURI === "http://www.w3.org/2000/xmlns/" && qualifiedName !== "xmlns" && qualifiedName.indexOf(":") !== -1 && qualifiedName.substr(0, 6) !== "xmlns:")) { + throw new Fleur.DOMException(Fleur.DOMException.NAMESPACE_ERR); + } + node._setOwnerDocument(this); + node._setNodeNameLocalNamePrefix(namespaceURI, qualifiedName); + node.name = qualifiedName; + node.textContent = ""; + return node; }; Fleur.Document.prototype.createCDATASection = function(data) { - var node = new Fleur.CDATASection(); - node._setOwnerDocument(this); - node.appendData(data); - return node; + var node = new Fleur.CDATASection(); + node._setOwnerDocument(this); + node.appendData(data); + return node; }; Fleur.Document.prototype.createComment = function(data) { - var node = new Fleur.Comment(); - node._setOwnerDocument(this); - node.appendData(data); - return node; + var node = new Fleur.Comment(); + node._setOwnerDocument(this); + node.appendData(data); + return node; }; Fleur.Document.prototype.createDocumentFragment = function() { - var node = new Fleur.DocumentFragment(); - node._setOwnerDocument(this); - return node; + var node = new Fleur.DocumentFragment(); + node._setOwnerDocument(this); + return node; }; Fleur.Document.prototype.createElement = function(tagName) { - var node = new Fleur.Element(); - //if (!Fleur.Node.QNameReg.test(tagName) && (this.mediatype === "text/xml" || this.mediatype === "application/xml")) { - // if (Fleur.Node.QNameCharsReg.test(tagName)) { - // throw new Fleur.DOMException(Fleur.DOMException.NAMESPACE_ERR); - // } else { - // throw new Fleur.DOMException(Fleur.DOMException.INVALID_CHARACTER_ERR); - // } - //} - node._setOwnerDocument(this); - node.nodeName = tagName; - node.namespaceURI = null; - node.localName = tagName; - node.prefix = null; - node.childNodes = new Fleur.NodeList(); - node.children = new Fleur.NodeList(); - node.textContent = ""; - return node; + var node = new Fleur.Element(); + //if (!Fleur.Node.QNameReg.test(tagName) && (this.mediatype === "text/xml" || this.mediatype === "application/xml")) { + // if (Fleur.Node.QNameCharsReg.test(tagName)) { + // throw new Fleur.DOMException(Fleur.DOMException.NAMESPACE_ERR); + // } else { + // throw new Fleur.DOMException(Fleur.DOMException.INVALID_CHARACTER_ERR); + // } + //} + node._setOwnerDocument(this); + node.nodeName = tagName; + node.namespaceURI = null; + node.localName = tagName; + node.prefix = null; + node.childNodes = new Fleur.NodeList(); + node.children = new Fleur.NodeList(); + node.textContent = ""; + return node; }; Fleur.Document.prototype.createElementNS = function(namespaceURI, qualifiedName) { - var node = new Fleur.Element(); - //if (!Fleur.Node.QNameReg.test(qualifiedName)) { - // if (Fleur.Node.QNameCharsReg.test(qualifiedName)) { - // throw new Fleur.DOMException(Fleur.DOMException.NAMESPACE_ERR); - // } else { - // throw new Fleur.DOMException(Fleur.DOMException.INVALID_CHARACTER_ERR); - // } - //} - if ((namespaceURI === null && qualifiedName.indexOf(":") !== -1) || - (qualifiedName.substr(0, 4) === "xml:" && namespaceURI !== "http://www.w3.org/XML/1998/namespace") || - ((qualifiedName === "xmlns" || qualifiedName.substr(0, 6) === "xmlns:") && namespaceURI !== "http://www.w3.org/2000/xmlns/") || - (namespaceURI === "http://www.w3.org/2000/xmlns/" && qualifiedName !== "xmlns" && qualifiedName.indexOf(":") !== -1 && qualifiedName.substr(0, 6) !== "xmlns:")) { - throw new Fleur.DOMException(Fleur.DOMException.NAMESPACE_ERR); - } - node._setOwnerDocument(this); - node._setNodeNameLocalNamePrefix(namespaceURI, qualifiedName); - node.childNodes = new Fleur.NodeList(); - node.children = new Fleur.NodeList(); - node.textContent = ""; - return node; + var node = new Fleur.Element(); + //if (!Fleur.Node.QNameReg.test(qualifiedName)) { + // if (Fleur.Node.QNameCharsReg.test(qualifiedName)) { + // throw new Fleur.DOMException(Fleur.DOMException.NAMESPACE_ERR); + // } else { + // throw new Fleur.DOMException(Fleur.DOMException.INVALID_CHARACTER_ERR); + // } + //} + if ((namespaceURI === null && qualifiedName.indexOf(":") !== -1) || + (qualifiedName.substr(0, 4) === "xml:" && namespaceURI !== "http://www.w3.org/XML/1998/namespace") || + ((qualifiedName === "xmlns" || qualifiedName.substr(0, 6) === "xmlns:") && namespaceURI !== "http://www.w3.org/2000/xmlns/") || + (namespaceURI === "http://www.w3.org/2000/xmlns/" && qualifiedName !== "xmlns" && qualifiedName.indexOf(":") !== -1 && qualifiedName.substr(0, 6) !== "xmlns:")) { + throw new Fleur.DOMException(Fleur.DOMException.NAMESPACE_ERR); + } + node._setOwnerDocument(this); + node._setNodeNameLocalNamePrefix(namespaceURI, qualifiedName); + node.childNodes = new Fleur.NodeList(); + node.children = new Fleur.NodeList(); + node.textContent = ""; + return node; }; Fleur.Document.prototype.createEntityReference = function(entname) { - var node = new Fleur.EntityReference(); - node._setOwnerDocument(this); - node._setNodeNameLocalNamePrefix(null, entname); - node.nodeName = entname; - node.textContent = ""; - return node; + var node = new Fleur.EntityReference(); + node._setOwnerDocument(this); + node._setNodeNameLocalNamePrefix(null, entname); + node.nodeName = entname; + node.textContent = ""; + return node; }; Fleur.Document.prototype.createProcessingInstruction = function(target, data) { - var node = new Fleur.ProcessingInstruction(); - if (!Fleur.Node.QNameReg.test(target)) { - throw new Fleur.DOMException(Fleur.DOMException.INVALID_CHARACTER_ERR); - } - node._setOwnerDocument(this); - node.nodeName = node.target = target; - node.textContent = node.data = data; - return node; + var node = new Fleur.ProcessingInstruction(); + if (!Fleur.Node.QNameReg.test(target)) { + throw new Fleur.DOMException(Fleur.DOMException.INVALID_CHARACTER_ERR); + } + node._setOwnerDocument(this); + node.nodeName = node.target = target; + node.textContent = node.data = data; + return node; }; Fleur.Document.prototype.createSequence = function() { - var node = new Fleur.Sequence(); - node._setOwnerDocument(this); - node.childNodes = new Fleur.NodeList(); - node.children = new Fleur.NodeList(); - node.textContent = ""; - return node; + var node = new Fleur.Sequence(); + node._setOwnerDocument(this); + node.childNodes = new Fleur.NodeList(); + node.children = new Fleur.NodeList(); + node.textContent = ""; + return node; }; Fleur.Document.prototype.createArray = function() { - var node = new Fleur.Array(); - node._setOwnerDocument(this); - node.childNodes = new Fleur.NodeList(); - node.children = new Fleur.NodeList(); - node.textContent = ""; - return node; + var node = new Fleur.Array(); + node._setOwnerDocument(this); + node.childNodes = new Fleur.NodeList(); + node.children = new Fleur.NodeList(); + node.textContent = ""; + return node; }; Fleur.Document.prototype.createMap = function() { - var node = new Fleur.Map(); - node._setOwnerDocument(this); - return node; + var node = new Fleur.Map(); + node._setOwnerDocument(this); + return node; }; Fleur.Document.prototype.createEntry = function(entryname) { - var node = new Fleur.Entry(); - node._setOwnerDocument(this); - node.childNodes = new Fleur.NodeList(); - node.children = new Fleur.NodeList(); - node.nodeName = node.localName = entryname; - node.textContent = ""; - return node; + var node = new Fleur.Entry(); + node._setOwnerDocument(this); + node.childNodes = new Fleur.NodeList(); + node.children = new Fleur.NodeList(); + node.nodeName = node.localName = entryname; + node.textContent = ""; + return node; }; Fleur.Document.prototype.createTextNode = function(data) { - var node = new Fleur.Text(); - node._setOwnerDocument(this); - node.appendData(data); - node.schemaTypeInfo = Fleur.Type_untypedAtomic; - return node; + var node = new Fleur.Text(); + node._setOwnerDocument(this); + node.appendData(data); + node.schemaTypeInfo = Fleur.Type_untypedAtomic; + return node; }; Fleur.Document.prototype.createTypedValueNode = function(typeNamespace, typeName, data) { - var node = new Fleur.Text(); - node._setOwnerDocument(this); - node.appendData(data); - node.schemaTypeInfo = Fleur.Types[typeNamespace][typeName]; - return node; + var node = new Fleur.Text(); + node._setOwnerDocument(this); + node.appendData(data); + node.schemaTypeInfo = Fleur.Types[typeNamespace][typeName]; + return node; }; Fleur.Document.prototype.createNamespace = function(prefix, namespaceURI) { - var node = new Fleur.Namespace(); - node.name = prefix; - node.textContent = node.data = namespaceURI; - return node; + var node = new Fleur.Namespace(); + node.name = prefix; + node.textContent = node.data = namespaceURI; + return node; }; Fleur.Document.prototype.getElementById = function(elementId) { - return this._elementById[elementId]; + return this._elementById[elementId]; }; Fleur.Document.prototype.getElementsByTagName = function(tagName) { - var i = 0, l = this.children.length, elts = new Fleur.NodeList(); - while (i < l) { - this.children[i++]._getElementsByTagName(tagName, elts); - } - return elts; + var i = 0, l = this.children.length, elts = new Fleur.NodeList(); + while (i < l) { + this.children[i++]._getElementsByTagName(tagName, elts); + } + return elts; }; Fleur.Document.prototype.getElementsByTagNameNS = function(namespaceURI, localName) { - var i = 0, l = this.children.length, elts = new Fleur.NodeList(); - if (!namespaceURI) { - return this.getElementsByTagName(localName); - } - while (i < l) { - this.children[i++]._getElementsByTagNameNS(namespaceURI, localName, elts); - } - return elts; -// return this._elementsByTagName[namespaceURI] ? this._elementsByTagName[namespaceURI][localName] : null; + var i = 0, l = this.children.length, elts = new Fleur.NodeList(); + if (!namespaceURI) { + return this.getElementsByTagName(localName); + } + while (i < l) { + this.children[i++]._getElementsByTagNameNS(namespaceURI, localName, elts); + } + return elts; +// return this._elementsByTagName[namespaceURI] ? this._elementsByTagName[namespaceURI][localName] : null; }; Fleur.Document.prototype.importNode = function(importedNode, deep) { - var i = 0, li = 0, j = 0, lj = 0, node = null; - switch (importedNode.nodeType) { - case Fleur.Node.TEXT_NODE: - node = this.createTextNode(importedNode.data); - node.schemaTypeInfo = importedNode.schemaTypeInfo; - break; - case Fleur.Node.COMMENT_NODE: - node = this.createComment(importedNode.data); - break; - case Fleur.Node.CDATA_NODE: - node = this.createCDATASection(importedNode.data); - break; - case Fleur.Node.PROCESSING_INSTRUCTION_NODE: - node = this.createProcessingInstruction(importedNode.target, importedNode.data); - break; - case Fleur.Node.ATTRIBUTE_NODE: - node = this.createAttributeNS(importedNode.namespaceURI, importedNode.nodeName); - node.schemaTypeInfo = importedNode.schemaTypeInfo; - lj = importedNode.childNodes.length; - while (j < lj) { - node.appendChild(this.importNode(importedNode.childNodes[j++], true)); - } - break; - case Fleur.Node.ELEMENT_NODE: - node = this.createElementNS(importedNode.namespaceURI, importedNode.nodeName); - node.schemaTypeInfo = importedNode.schemaTypeInfo; - li = importedNode.attributes.length; - while (i < li) { - node.setAttributeNode(this.importNode(importedNode.attributes[i++], true)); - } - if (deep) { - lj = importedNode.childNodes.length; - while (j < lj) { - node.appendChild(this.importNode(importedNode.childNodes[j++], true)); - } - } - break; - case Fleur.Node.SEQUENCE_NODE: - node = this.createSequence(); - lj = importedNode.childNodes.length; - while (j < lj) { - node.appendChild(this.importNode(importedNode.childNodes[j++], true)); - } - break; - case Fleur.Node.ARRAY_NODE: - node = this.createArray(); - lj = importedNode.childNodes.length; - while (j < lj) { - node.appendChild(this.importNode(importedNode.childNodes[j++], true)); - } - break; - case Fleur.Node.MAP_NODE: - node = this.createMap(); - li = importedNode.entries.length; - while (i < li) { - node.setEntryNode(this.importNode(importedNode.entries[i++], true)); - } - break; - case Fleur.Node.ENTRY_NODE: - node = this.createEntry(importedNode.nodeName); - lj = importedNode.childNodes.length; - while (j < lj) { - node.appendChild(this.importNode(importedNode.childNodes[j++], true)); - } - break; - case Fleur.Node.DOCUMENT_FRAGMENT_NODE: - node = this.createDocumentFragment(); - if (deep) { - lj = importedNode.childNodes.length; - while (j < lj) { - node.appendChild(this.importNode(importedNode.childNodes[j++], true)); - } - } - break; - case Fleur.Node.DOCUMENT_NODE: - case Fleur.Node.DOCUMENT_TYPE_NODE: - throw new Fleur.DOMException(Fleur.DOMException.NOT_SUPPORTED_ERR); - } - return node; + var i = 0, li = 0, j = 0, lj = 0, node = null; + switch (importedNode.nodeType) { + case Fleur.Node.TEXT_NODE: + node = this.createTextNode(importedNode.data); + node.schemaTypeInfo = importedNode.schemaTypeInfo; + break; + case Fleur.Node.COMMENT_NODE: + node = this.createComment(importedNode.data); + break; + case Fleur.Node.CDATA_NODE: + node = this.createCDATASection(importedNode.data); + break; + case Fleur.Node.PROCESSING_INSTRUCTION_NODE: + node = this.createProcessingInstruction(importedNode.target, importedNode.data); + break; + case Fleur.Node.ATTRIBUTE_NODE: + node = this.createAttributeNS(importedNode.namespaceURI, importedNode.nodeName); + node.schemaTypeInfo = importedNode.schemaTypeInfo; + lj = importedNode.childNodes.length; + while (j < lj) { + node.appendChild(this.importNode(importedNode.childNodes[j++], true)); + } + break; + case Fleur.Node.ELEMENT_NODE: + node = this.createElementNS(importedNode.namespaceURI, importedNode.nodeName); + node.schemaTypeInfo = importedNode.schemaTypeInfo; + li = importedNode.attributes.length; + while (i < li) { + node.setAttributeNode(this.importNode(importedNode.attributes[i++], true)); + } + if (deep) { + lj = importedNode.childNodes.length; + while (j < lj) { + node.appendChild(this.importNode(importedNode.childNodes[j++], true)); + } + } + break; + case Fleur.Node.SEQUENCE_NODE: + node = this.createSequence(); + lj = importedNode.childNodes.length; + while (j < lj) { + node.appendChild(this.importNode(importedNode.childNodes[j++], true)); + } + break; + case Fleur.Node.ARRAY_NODE: + node = this.createArray(); + lj = importedNode.childNodes.length; + while (j < lj) { + node.appendChild(this.importNode(importedNode.childNodes[j++], true)); + } + break; + case Fleur.Node.MAP_NODE: + node = this.createMap(); + li = importedNode.entries.length; + while (i < li) { + node.setEntryNode(this.importNode(importedNode.entries[i++], true)); + } + break; + case Fleur.Node.ENTRY_NODE: + node = this.createEntry(importedNode.nodeName); + lj = importedNode.childNodes.length; + while (j < lj) { + node.appendChild(this.importNode(importedNode.childNodes[j++], true)); + } + break; + case Fleur.Node.DOCUMENT_FRAGMENT_NODE: + node = this.createDocumentFragment(); + if (deep) { + lj = importedNode.childNodes.length; + while (j < lj) { + node.appendChild(this.importNode(importedNode.childNodes[j++], true)); + } + } + break; + case Fleur.Node.DOCUMENT_NODE: + case Fleur.Node.DOCUMENT_TYPE_NODE: + throw new Fleur.DOMException(Fleur.DOMException.NOT_SUPPORTED_ERR); + } + return node; }; Fleur.Document.docImportNode = function(doc, importedNode, deep) { - var i = 0, li = 0, j = 0, lj = 0, node = null; - switch (importedNode.nodeType) { - case Fleur.Node.TEXT_NODE: - node = doc.createTextNode(importedNode.data); - node.schemaTypeInfo = importedNode.schemaTypeInfo; - break; - case Fleur.Node.COMMENT_NODE: - node = doc.createComment(importedNode.data); - break; - case Fleur.Node.CDATA_NODE: - node = doc.createCDATASection(importedNode.data); - break; - case Fleur.Node.PROCESSING_INSTRUCTION_NODE: - node = doc.createProcessingInstruction(importedNode.target, importedNode.data); - break; - case Fleur.Node.ATTRIBUTE_NODE: - node = doc.createAttributeNS(importedNode.namespaceURI || "", importedNode.nodeName); - node.schemaTypeInfo = importedNode.schemaTypeInfo; - node.value = importedNode.value; - break; - case Fleur.Node.ELEMENT_NODE: - node = doc.createElementNS(importedNode.namespaceURI || "http://www.w3.org/1999/xhtml", importedNode.nodeName); - node.schemaTypeInfo = importedNode.schemaTypeInfo; - li = importedNode.attributes.length; - while (i < li) { - node.setAttributeNode(Fleur.Document.docImportNode(doc, importedNode.attributes[i++], true)); - } - if (deep) { - lj = importedNode.childNodes.length; - while (j < lj) { - node.appendChild(Fleur.Document.docImportNode(doc, importedNode.childNodes[j++], true)); - } - } - break; - case Fleur.Node.DOCUMENT_FRAGMENT_NODE: - node = doc.createDocumentFragment(); - if (deep) { - lj = importedNode.childNodes.length; - while (j < lj) { - node.appendChild(Fleur.Document.docImportNode(doc, importedNode.childNodes[j++], true)); - } - } - break; - case Fleur.Node.DOCUMENT_NODE: - case Fleur.Node.DOCUMENT_TYPE_NODE: - throw new Fleur.DOMException(Fleur.DOMException.NOT_SUPPORTED_ERR); - } - return node; + var i = 0, li = 0, j = 0, lj = 0, node = null; + switch (importedNode.nodeType) { + case Fleur.Node.TEXT_NODE: + node = doc.createTextNode(importedNode.data); + node.schemaTypeInfo = importedNode.schemaTypeInfo; + break; + case Fleur.Node.COMMENT_NODE: + node = doc.createComment(importedNode.data); + break; + case Fleur.Node.CDATA_NODE: + node = doc.createCDATASection(importedNode.data); + break; + case Fleur.Node.PROCESSING_INSTRUCTION_NODE: + node = doc.createProcessingInstruction(importedNode.target, importedNode.data); + break; + case Fleur.Node.ATTRIBUTE_NODE: + node = doc.createAttributeNS(importedNode.namespaceURI || "", importedNode.nodeName); + node.schemaTypeInfo = importedNode.schemaTypeInfo; + node.value = importedNode.value; + break; + case Fleur.Node.ELEMENT_NODE: + node = doc.createElementNS(importedNode.namespaceURI || "http://www.w3.org/1999/xhtml", importedNode.nodeName); + node.schemaTypeInfo = importedNode.schemaTypeInfo; + li = importedNode.attributes.length; + while (i < li) { + node.setAttributeNode(Fleur.Document.docImportNode(doc, importedNode.attributes[i++], true)); + } + if (deep) { + lj = importedNode.childNodes.length; + while (j < lj) { + node.appendChild(Fleur.Document.docImportNode(doc, importedNode.childNodes[j++], true)); + } + } + break; + case Fleur.Node.DOCUMENT_FRAGMENT_NODE: + node = doc.createDocumentFragment(); + if (deep) { + lj = importedNode.childNodes.length; + while (j < lj) { + node.appendChild(Fleur.Document.docImportNode(doc, importedNode.childNodes[j++], true)); + } + } + break; + case Fleur.Node.DOCUMENT_NODE: + case Fleur.Node.DOCUMENT_TYPE_NODE: + throw new Fleur.DOMException(Fleur.DOMException.NOT_SUPPORTED_ERR); + } + return node; }; Fleur.Document.prototype.sortNodes = function(nodes) { - nodes.sort(function(a, b) { - var ia = a.internal_id; - var ib = b.internal_id; - return ia === ib ? 0 : ia < ib ? -1 : 1; - }); - return nodes; + nodes.sort(function(a, b) { + var ia = a.internal_id; + var ib = b.internal_id; + return ia === ib ? 0 : ia < ib ? -1 : 1; + }); + return nodes; }; Fleur.Document.prototype._serializeToString = function(indent) { - var s, i, l; - for (i = 0, l = this.childNodes.length; i < l; i++) { - s += this._serializeToString(this.childNodes[i], indent, ""); - } - return s; + var s, i, l; + for (i = 0, l = this.childNodes.length; i < l; i++) { + s += this._serializeToString(this.childNodes[i], indent, ""); + } + return s; }; Fleur.Document.prototype.compileXslt = function() { - return this.documentElement.compileXslt(); + return this.documentElement.compileXslt(); }; Fleur._evaluate = function(expression, contextNode, env, type, xpresult) { - var doc; - if (contextNode) { - if (contextNode.nodeType === Fleur.Node.DOCUMENT_NODE) { - doc = contextNode; - } else if (contextNode.ownerDocument) { - doc = contextNode.ownerDocument; - } - } - env = env || {}; - var d = new Date(); - if (!env.timezone) { - var jstz = d.getTimezoneOffset(); - env.timezone = Fleur.msToDayTimeDuration(-jstz * 60 * 1000); - } - if (!env.now) { - env.now = d; - } - if (!env.nsresolver) { - var nsResolver; - if (doc && doc.documentElement) { - nsResolver = function(element) { - return { - defaultNamespace: element.getAttribute("xmlns"), - nsresolver: element.ownerDocument.createNSResolver(element), - lookupNamespaceURI: function(prefix) { - if (prefix === "_") { - return this.defaultNamespace; - } - return this.nsresolver.lookupNamespaceURI(prefix); - }, - lookupPrefix: function(uri) { - return this.nsresolver.lookupPrefix(uri); - }, - declareNamespace: function(prefix, uri) { - return this.nsresolver.declareNamespace(prefix, uri); - } - }; - }; - env.nsresolver = nsResolver(doc.documentElement); - } else if (doc) { - nsResolver = function(document) { - return { - nsresolver: document.createNSResolver(), - lookupNamespaceURI: function(prefix) { - return this.nsresolver.lookupNamespaceURI(prefix); - }, - lookupPrefix: function(uri) { - return this.nsresolver.lookupPrefix(uri); - }, - declareNamespace: function(prefix, uri) { - return this.nsresolver.declareNamespace(prefix, uri); - } - }; - }; - env.nsresolver = nsResolver(doc); - } else { - env.nsresolver = new Fleur.XPathNSResolver(); - } - } - type = type || Fleur.XPathResult.ANY_TYPE; - var invalidmsg = ""; - if (typeof expression === "string") { - try { - var compiled = new Fleur.XPathExpression(expression); - expression = compiled; - } catch(e) { - invalidmsg = e.error; - } - } - if (!xpresult) { - xpresult = new Fleur.XPathResult(doc, invalidmsg === "" ? expression : null, contextNode, env, type); - if (!xpresult.expression) { - xpresult.expression = expression; - } - } else { - xpresult.document = doc; - xpresult.expression = expression; - xpresult.contextNode = contextNode; - xpresult.env = env; - xpresult.resultType = type; - xpresult._index = 0; - } - if (invalidmsg !== "") { - xpresult._result = new Fleur.Text(); - xpresult._result.schemaTypeInfo = Fleur.Type_error; - xpresult._result._setNodeNameLocalNamePrefix("http://www.w3.org/2005/xqt-errors", "err:XPST0003"); - xpresult._result.data = invalidmsg; - } - return xpresult; + var doc; + if (contextNode) { + if (contextNode.nodeType === Fleur.Node.DOCUMENT_NODE) { + doc = contextNode; + } else if (contextNode.ownerDocument) { + doc = contextNode.ownerDocument; + } + } + env = env || {}; + var d = new Date(); + if (!env.timezone) { + var jstz = d.getTimezoneOffset(); + env.timezone = Fleur.msToDayTimeDuration(-jstz * 60 * 1000); + } + if (!env.now) { + env.now = d; + } + if (!env.nsresolver) { + var nsResolver; + if (doc && doc.documentElement) { + nsResolver = function(element) { + return { + defaultNamespace: element.getAttribute("xmlns"), + nsresolver: element.ownerDocument.createNSResolver(element), + lookupNamespaceURI: function(prefix) { + if (prefix === "_") { + return this.defaultNamespace; + } + return this.nsresolver.lookupNamespaceURI(prefix); + }, + lookupPrefix: function(uri) { + return this.nsresolver.lookupPrefix(uri); + }, + declareNamespace: function(prefix, uri) { + return this.nsresolver.declareNamespace(prefix, uri); + } + }; + }; + env.nsresolver = nsResolver(doc.documentElement); + } else if (doc) { + nsResolver = function(document) { + return { + nsresolver: document.createNSResolver(), + lookupNamespaceURI: function(prefix) { + return this.nsresolver.lookupNamespaceURI(prefix); + }, + lookupPrefix: function(uri) { + return this.nsresolver.lookupPrefix(uri); + }, + declareNamespace: function(prefix, uri) { + return this.nsresolver.declareNamespace(prefix, uri); + } + }; + }; + env.nsresolver = nsResolver(doc); + } else { + env.nsresolver = new Fleur.XPathNSResolver(); + } + } + type = type || Fleur.XPathResult.ANY_TYPE; + var invalidmsg = ""; + if (typeof expression === "string") { + try { + var compiled = new Fleur.XPathExpression(expression); + expression = compiled; + } catch(e) { + invalidmsg = e.error; + } + } + if (!xpresult) { + xpresult = new Fleur.XPathResult(doc, invalidmsg === "" ? expression : null, contextNode, env, type); + if (!xpresult.expression) { + xpresult.expression = expression; + } + } else { + xpresult.document = doc; + xpresult.expression = expression; + xpresult.contextNode = contextNode; + xpresult.env = env; + xpresult.resultType = type; + xpresult._index = 0; + } + if (invalidmsg !== "") { + xpresult._result = new Fleur.Text(); + xpresult._result.schemaTypeInfo = Fleur.Type_error; + xpresult._result._setNodeNameLocalNamePrefix("http://www.w3.org/2005/xqt-errors", "err:XPST0003"); + xpresult._result.data = invalidmsg; + } + return xpresult; }; Fleur.Document.prototype._evaluate = function(expression, contextNode, env, type, xpresult) { - contextNode = contextNode || this; - return Fleur._evaluate(expression, contextNode, env, type, xpresult); + contextNode = contextNode || this; + return Fleur._evaluate(expression, contextNode, env, type, xpresult); }; Fleur.evaluate = function(expression, contextNode, env, type, xpresult) { - if (xpresult && xpresult._result) { - xpresult._result = null; - } - var xpr = Fleur._evaluate(expression, contextNode, env, type, xpresult); - return xpr._result ? xpr : new Promise(function(resolve, reject) { - xpr.evaluate(function(res) { - resolve(res); - }, function(res) { - reject(res); - }); - }); + if (xpresult && xpresult._result) { + xpresult._result = null; + } + var xpr = Fleur._evaluate(expression, contextNode, env, type, xpresult); + return xpr._result ? xpr : new Promise(function(resolve, reject) { + xpr.evaluate(function(res) { + resolve(res); + }, function(res) { + reject(res); + }); + }); }; Fleur.Document.prototype.evaluate = function(expression, contextNode, env, type, xpresult) { - contextNode = contextNode || this; - return Fleur.evaluate(expression, contextNode, env, type, xpresult); + contextNode = contextNode || this; + return Fleur.evaluate(expression, contextNode, env, type, xpresult); };; Fleur.createExpression = function(expression) { - expression = expression || ""; - return new Fleur.XPathExpression(expression); + expression = expression || ""; + return new Fleur.XPathExpression(expression); }; Fleur.Document.prototype.createExpression = Fleur.createExpression; Fleur.Document.prototype.createNSResolver = function(node) { - return new Fleur.XPathNSResolver(node); + return new Fleur.XPathNSResolver(node); }; /* Fleur.Document.prototype.normalizeDocument = function() { diff --git a/src/js/fleur.js/DOM/Function.js b/src/js/fleur.js/DOM/Function.js index b1daf5e..f70ed42 100644 --- a/src/js/fleur.js/DOM/Function.js +++ b/src/js/fleur.js/DOM/Function.js @@ -1,24 +1,19 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.Function = function(namespaceURI, nodeName, jsfunc, xqxfunc, argtypes, needctx, needcallback, restype, updating) { - Fleur.Node.apply(this); - if (namespaceURI && nodeName) { - this._setNodeNameLocalNamePrefix(namespaceURI, nodeName); - } - this.jsfunc = jsfunc; - this.xqxfunc = xqxfunc; - this.argtypes = argtypes; - this.needctx = needctx; - this.needcallback = needcallback; - this.restype = restype; - this.updating = Boolean(updating); - this.nodeType = Fleur.Node.FUNCTION_NODE; +Fleur.Function = function(namespaceURI, nodeName, jsfunc, argtypes, rettype, specifics) { + Fleur.Node.apply(this); + if (namespaceURI && nodeName) { + this._setNodeNameLocalNamePrefix(namespaceURI, nodeName); + } + this.jsfunc = jsfunc; + this.argtypes = argtypes; + this.rettype = rettype; + this.nodeType = Fleur.Node.FUNCTION_NODE; + Object.assign(this, specifics); }; Fleur.Function.prototype = new Fleur.Node(); \ No newline at end of file diff --git a/src/js/fleur.js/DOM/Namespace.js b/src/js/fleur.js/DOM/Namespace.js index 69ba2a3..dff9d4b 100644 --- a/src/js/fleur.js/DOM/Namespace.js +++ b/src/js/fleur.js/DOM/Namespace.js @@ -1,67 +1,65 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Namespace = function() { - Fleur.Node.apply(this); - this.nodeType = Fleur.Node.NAMESPACE_NODE; + Fleur.Node.apply(this); + this.nodeType = Fleur.Node.NAMESPACE_NODE; }; Fleur.Namespace.prototype = new Fleur.Node(); Object.defineProperties(Fleur.Namespace.prototype, { - nodeValue: { - set: function(value) { - if (value) { - if (!this.firstChild) { - this.appendChild(this.ownerDocument.createTextNode(value)); - return; - } - this.firstChild.nodeValue = value; - return; - } - if (this.firstChild) { - this.removeChild(this.firstChild); - } - }, - get: function() { - var s = "", i = 0, l = this.childNodes ? this.childNodes.length : 0; - while (i < l) { - s += this.childNodes[i].nodeValue; - i++; - } - return s; - } - }, - specified: { - get: function() { - return !!this.firstChild; - } - }, - value: { - set: function(value) { - if (value) { - if (!this.firstChild) { - this.appendChild(this.ownerDocument.createTextNode(value)); - return; - } - this.firstChild.nodeValue = value; - return; - } - if (this.firstChild) { - this.removeChild(this.firstChild); - } - }, - get: function() { - var s = "", i = 0, l = this.childNodes ? this.childNodes.length : 0; - while (i < l) { - s += this.childNodes[i].nodeValue; - i++; - } - return s; - } - } + nodeValue: { + set: function(value) { + if (value) { + if (!this.firstChild) { + this.appendChild(this.ownerDocument.createTextNode(value)); + return; + } + this.firstChild.nodeValue = value; + return; + } + if (this.firstChild) { + this.removeChild(this.firstChild); + } + }, + get: function() { + var s = "", i = 0, l = this.childNodes ? this.childNodes.length : 0; + while (i < l) { + s += this.childNodes[i].nodeValue; + i++; + } + return s; + } + }, + specified: { + get: function() { + return !!this.firstChild; + } + }, + value: { + set: function(value) { + if (value) { + if (!this.firstChild) { + this.appendChild(this.ownerDocument.createTextNode(value)); + return; + } + this.firstChild.nodeValue = value; + return; + } + if (this.firstChild) { + this.removeChild(this.firstChild); + } + }, + get: function() { + var s = "", i = 0, l = this.childNodes ? this.childNodes.length : 0; + while (i < l) { + s += this.childNodes[i].nodeValue; + i++; + } + return s; + } + } }); \ No newline at end of file diff --git a/src/js/fleur.js/DOM/Node.js b/src/js/fleur.js/DOM/Node.js index d4cbae7..04c8d49 100644 --- a/src/js/fleur.js/DOM/Node.js +++ b/src/js/fleur.js/DOM/Node.js @@ -12,6 +12,7 @@ Fleur.Node = function() { this.childNodes = new Fleur.NodeList(); this.children = new Fleur.NodeList(); }; +Fleur.Node.ANY_NODE = 0; Fleur.Node.ELEMENT_NODE = 1; Fleur.Node.ATTRIBUTE_NODE = 2; Fleur.Node.TEXT_NODE = 3; @@ -837,4 +838,21 @@ Fleur.Node.prototype.toArray = function() { }; Fleur.Node.prototype.hasNumericType = function() { return Fleur.numericTypes.indexOf(this.schemaTypeInfo) !== -1; +}; +Fleur.Node.prototype.instanceOf = function(seqtype) { + if (this.nodeType !== Fleur.Node.SEQUENCE_NODE) { + return seqtype.occurrence !== "0" && this.schemaTypeInfo.as(seqtype.schemaTypeInfo); + } + if (this.childNodes.length === 0) { + return seqtype.occurrence === "0" || seqtype.occurrence === "?" || seqtype.occurrence === "*"; + } + if (seqtype.occurrence !== "+" && seqtype.occurrence !== "*") { + return false; + } + for(let i = 0, l = this.childNodes.length; i < l; i++) { + if (!this.childNodes[i].schemaTypeInfo.as(seqtype.schemaTypeInfo)) { + return false; + } + } + return true; }; \ No newline at end of file diff --git a/src/js/fleur.js/DOM/SequenceType.js b/src/js/fleur.js/DOM/SequenceType.js new file mode 100644 index 0000000..5fee84e --- /dev/null +++ b/src/js/fleur.js/DOM/SequenceType.js @@ -0,0 +1,182 @@ +"use strict"; +/** + * @author Alain Couthures + * @license LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.SequenceType = function(nodeType, schemaTypeInfo, occurrence) { + this.nodeType = nodeType; + this.schemaTypeInfo = schemaTypeInfo; + this.occurrence = occurrence; +}; +Fleur.SequenceType.occurrenceastable = { + "00": true, + "0?": true, + "01": false, + "0*": true, + "0+": false, + "?0": false, + "??": true, + "?1": false, + "?*": true, + "?+": false, + "10": false, + "1?": true, + "11": true, + "1*": true, + "1+": true, + "*0": false, + "*?": false, + "*1": false, + "**": true, + "*+": false, + "+0": false, + "+?": false, + "+1": false, + "+*": true, + "++": true +}; +Fleur.SequenceType.prototype.as = function(sequenceType) { + if (!sequenceType) { + return true; + } + if (this.occurrence === "0") { + return Fleur.SequenceType.occurrenceastable["0" + sequenceType.occurrence]; + } + const nodeTypeTest = this.nodeType === sequenceType.nodeType || + sequenceType.nodeType === Fleur.Node.ANY_NODE || + ((this.nodeType === Fleur.Node.ATTRIBUTE_NODE || this.nodeType === Fleur.Node.ELEMENT_NODE || this.nodeType === Fleur.Node.ENTRY_NODE) && sequenceType.nodeType === Fleur.Node.ATOMIC_NODE); + return nodeTypeTest && Fleur.SequenceType.occurrenceastable[this.occurrence + sequenceType.occurrence] && this.schemaTypeInfo.as(sequenceType.schemaTypeInfo); +}; +Fleur.SequenceType.occurrenceortable = { + "00": "0", + "0?": "?", + "01": "?", + "0*": "*", + "0+": "*", + "?0": "?", + "??": "?", + "?1": "?", + "?*": "*", + "?+": "*", + "10": "?", + "1?": "?", + "11": "1", + "1*": "*", + "1+": "+", + "*0": "*", + "*?": "*", + "*1": "*", + "**": "*", + "*+": "*", + "+0": "*", + "+?": "*", + "+1": "+", + "+*": "*", + "++": "+" +}; +Fleur.SequenceType.or = function(sequenceType1, sequenceType2) { + if (!sequenceType1) { + return sequenceType2; + } + if (!sequenceType2) { + return sequenceType1; + } + const nodeType = sequenceType1.nodeType === sequenceType2.nodeType ? sequenceType1.nodeType : Fleur.Node.ANY_NODE; + const schemaTypeInfo = sequenceType1.schemaTypeInfo === sequenceType2.schemaTypeInfo ? sequenceType1.schemaTypeInfo : + sequenceType1.schemaTypeInfo.as(Fleur.Type_numeric) && sequenceType2.schemaTypeInfo.as(Fleur.Type_numeric) ? Fleur.Type_numeric : + new Fleur.TypeInfo(null, null, [ + [Fleur.TypeInfo.DERIVATION_UNION, sequenceType1.schemaTypeInfo], + [Fleur.TypeInfo.DERIVATION_UNION, sequenceType2.schemaTypeInfo] + ]); + const occurrence = Fleur.SequenceType.occurrenceortable[sequenceType1.occurrence + sequenceType2.occurrence]; + return new Fleur.SequenceType(nodeType, schemaTypeInfo, occurrence); +}; + +Fleur.SequenceType_anyAtomicType_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_anyAtomicType, "?"); +Fleur.SequenceType_anyAtomicType_0n = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_anyAtomicType, "*"); +Fleur.SequenceType_anyAtomicType_1 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_anyAtomicType, "1"); +Fleur.SequenceType_anyURI_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_anyURI, "?"); +Fleur.SequenceType_attribute_01 = new Fleur.SequenceType(Fleur.Node.ATTRIBUTE_NODE, Fleur.Type_anyType, "?"); +Fleur.SequenceType_attribute_1 = new Fleur.SequenceType(Fleur.Node.ATTRIBUTE_NODE, Fleur.Type_anyType, "1"); +Fleur.SequenceType_base64Binary_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_base64Binary, "?"); +Fleur.SequenceType_boolean_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_boolean, "?"); +Fleur.SequenceType_boolean_1 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_boolean, "1"); +Fleur.SequenceType_byte_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_byte, "?"); +Fleur.SequenceType_codepoint_0n = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_codepoint, "*"); +Fleur.SequenceType_codepoint_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_codepoint, "?"); +Fleur.SequenceType_collation_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_collation, "?"); +Fleur.SequenceType_collation_1 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_collation, "1"); +Fleur.SequenceType_comment_01 = new Fleur.SequenceType(Fleur.Node.COMMENT_NODE, Fleur.Type_anyType, "?"); +Fleur.SequenceType_date_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_date, "?"); +Fleur.SequenceType_date_1 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_date, "1"); +Fleur.SequenceType_dateTime_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_dateTime, "?"); +Fleur.SequenceType_dateTime_1 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_dateTime, "1"); +Fleur.SequenceType_dateTimeStamp_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_dateTimeStamp, "?"); +Fleur.SequenceType_dayTimeDuration_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_dayTimeDuration, "?"); +Fleur.SequenceType_dayTimeDuration_1 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_dayTimeDuration, "1"); +Fleur.SequenceType_decimal_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_decimal, "?"); +Fleur.SequenceType_document_01 = new Fleur.SequenceType(Fleur.Node.DOCUMENT_NODE, Fleur.Type_anyType, "?"); +Fleur.SequenceType_document_1 = new Fleur.SequenceType(Fleur.Node.DOCUMENT_NODE, Fleur.Type_anyType, "1"); +Fleur.SequenceType_double_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_double, "?"); +Fleur.SequenceType_duration_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_duration, "?"); +Fleur.SequenceType_element_0n = new Fleur.SequenceType(Fleur.Node.ELEMENT_NODE, Fleur.Type_anyType, "*"); +Fleur.SequenceType_element_1 = new Fleur.SequenceType(Fleur.Node.ELEMENT_NODE, Fleur.Type_anyType, "1"); +Fleur.SequenceType_empty_sequence = new Fleur.SequenceType(Fleur.Node.ANY_NODE, Fleur.Type_anyType, "0"); +Fleur.SequenceType_ENTITY_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_ENTITY, "?"); +Fleur.SequenceType_ENTITY_0n = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_ENTITY, "*"); +Fleur.SequenceType_entry_01 = new Fleur.SequenceType(Fleur.Node.ENTRY_NODE, Fleur.Type_anyType, "?"); +Fleur.SequenceType_entry_0n = new Fleur.SequenceType(Fleur.Node.ENTRY_NODE, Fleur.Type_anyType, "*"); +Fleur.SequenceType_entry_1 = new Fleur.SequenceType(Fleur.Node.ENTRY_NODE, Fleur.Type_anyType, "1"); +Fleur.SequenceType_float_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_float, "?"); +Fleur.SequenceType_function_01 = new Fleur.SequenceType(Fleur.Node.FUNCTION_NODE, Fleur.Type_anyType, "?"); +Fleur.SequenceType_function_1 = new Fleur.SequenceType(Fleur.Node.FUNCTION_NODE, Fleur.Type_anyType, "1"); +Fleur.SequenceType_gDay_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_gDay, "?"); +Fleur.SequenceType_gMonth_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_gMonth, "?"); +Fleur.SequenceType_gMonthDay_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_gMonthDay, "?"); +Fleur.SequenceType_gYear_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_gYear, "?"); +Fleur.SequenceType_gYearMonth_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_gYearMonth, "?"); +Fleur.SequenceType_hexBinary_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_hexBinary, "?"); +Fleur.SequenceType_ID_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_ID, "?"); +Fleur.SequenceType_IDREF_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_IDREF, "?"); +Fleur.SequenceType_IDREF_0n = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_IDREF, "*"); +Fleur.SequenceType_int_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_int, "?"); +Fleur.SequenceType_integer_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_integer, "?"); +Fleur.SequenceType_integer_0n = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_integer, "*"); +Fleur.SequenceType_integer_1 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_integer, "1"); +Fleur.SequenceType_item_01 = new Fleur.SequenceType(Fleur.Node.ANY_NODE, Fleur.Type_anyType, "?"); +Fleur.SequenceType_item_0n = new Fleur.SequenceType(Fleur.Node.ANY_NODE, Fleur.Type_anyType, "*"); +Fleur.SequenceType_item_1 = new Fleur.SequenceType(Fleur.Node.ANY_NODE, Fleur.Type_anyType, "1"); +Fleur.SequenceType_item_1n = new Fleur.SequenceType(Fleur.Node.ANY_NODE, Fleur.Type_anyType, "+"); +Fleur.SequenceType_language_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_language, "?"); +Fleur.SequenceType_language_1 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_language, "1"); +Fleur.SequenceType_long_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_long, "?"); +Fleur.SequenceType_map_1 = new Fleur.SequenceType(Fleur.Node.MAP_NODE, Fleur.Type_anyType, "1"); +Fleur.SequenceType_Name_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_Name, "?"); +Fleur.SequenceType_NCName_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_NCName, "?"); +Fleur.SequenceType_negativeInteger_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_negativeInteger, "?"); +Fleur.SequenceType_NMTOKEN_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_NMTOKEN, "?"); +Fleur.SequenceType_NMTOKEN_0n = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_NMTOKEN, "*"); +Fleur.SequenceType_nonNegativeInteger_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_nonNegativeInteger, "?"); +Fleur.SequenceType_nonPositiveInteger_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_nonPositiveInteger, "?"); +Fleur.SequenceType_normalizedString_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_normalizedString, "?"); +Fleur.SequenceType_numeric_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_numeric, "?"); +Fleur.SequenceType_numeric_1 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_numeric, "1"); +Fleur.SequenceType_positiveInteger_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_positiveInteger, "?"); +Fleur.SequenceType_processing_instruction_1 = new Fleur.SequenceType(Fleur.Node.PROCESSING_INSTRUCTION_NODE, Fleur.Type_anyType, "1"); +Fleur.SequenceType_QName_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_QName, "?"); +Fleur.SequenceType_QName_1 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_QName, "1"); +Fleur.SequenceType_short_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_short, "?"); +Fleur.SequenceType_string_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_string, "?"); +Fleur.SequenceType_string_0n = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_string, "*"); +Fleur.SequenceType_string_1 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_string, "1"); +Fleur.SequenceType_time_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_time, "?"); +Fleur.SequenceType_time_1 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_time, "1"); +Fleur.SequenceType_token_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_token, "?"); +Fleur.SequenceType_unsignedByte_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_unsignedByte, "?"); +Fleur.SequenceType_unsignedInt_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_unsignedInt, "?"); +Fleur.SequenceType_unsignedLong_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_unsignedLong, "?"); +Fleur.SequenceType_unsignedShort_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_unsignedShort, "?"); +Fleur.SequenceType_untypedAtomic_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_untypedAtomic, "?"); +Fleur.SequenceType_yearMonthDuration_01 = new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_yearMonthDuration, "?"); \ No newline at end of file diff --git a/src/js/fleur.js/DOM/Serializer.js b/src/js/fleur.js/DOM/Serializer.js index 2918a3e..cddf292 100644 --- a/src/js/fleur.js/DOM/Serializer.js +++ b/src/js/fleur.js/DOM/Serializer.js @@ -1,9 +1,7 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ @@ -192,6 +190,20 @@ Fleur.Serializer._serializeHTMLToString = function(node, indent, offset) { return s; } }; +Fleur.Serializer._serializeSequenceTypeToXQuery = function(sequenceType) { + const fschemaTypeInfo = sequenceType ? sequenceType.schemaTypeInfo : null; + return fschemaTypeInfo ? ( + sequenceType === Fleur.SequenceType_empty_sequence ? "empty-sequence()" : + sequenceType === Fleur.SequenceType_document_1 ? "document()" : + sequenceType === Fleur.SequenceType_element_1 ? "element()" : + sequenceType === Fleur.SequenceType_attribute_1 ? "attribute()" : + sequenceType === Fleur.SequenceType_processing_instruction_1 ? "processing-instruction()" : + sequenceType === Fleur.SequenceType_comment_01 ? "comment()?" : + sequenceType === Fleur.SequenceType_map_1 ? "map()" : + sequenceType === Fleur.SequenceType_entry_1 ? "entry()" : + (fschemaTypeInfo.typeNamespace === "http://www.w3.org/2001/XMLSchema" ? "xs:" : "Q{" + fschemaTypeInfo.typeNamespace + "}") + fschemaTypeInfo.typeName + (sequenceType.occurrence === "1" ? "" : sequenceType.occurrence)) : + "none"; +}; Fleur.Serializer._serializeNodeToXQuery = function(node, indent, offset, tree, postfix, inmap, defquot) { var s, i, l; postfix = postfix || ""; diff --git a/src/js/fleur.js/DOM/TypeInfo.js b/src/js/fleur.js/DOM/TypeInfo.js index e32da47..a96ff7e 100644 --- a/src/js/fleur.js/DOM/TypeInfo.js +++ b/src/js/fleur.js/DOM/TypeInfo.js @@ -6,9 +6,9 @@ * @description */ Fleur.TypeInfo = function(typeNamespace, typeName, derivations) { - this.typeNamespace = typeNamespace; - this.typeName = typeName; - Fleur.Types[typeNamespace][typeName] = this; + this.typeNamespace = typeNamespace || "#internal"; + this.typeName = typeName || "t" + String(Object.keys(Fleur.Types[this.typeNamespace]).length); + Fleur.Types[this.typeNamespace][this.typeName] = this; this.derivations = derivations; }; @@ -30,7 +30,7 @@ Fleur.TypeInfo.prototype.isDerivedFrom_ = function(typeArg, derivationMethod) { } if (this.derivations) { for (let i = 0, l = this.derivations.length; i < l; i++) { - if (typeArg === this.derivations[i][1] && (derivationMethod === 0 || (derivationMethod & this.derivations[i][0]) !== 0)) { + if (typeArg === this.derivations[i][1] && (derivationMethod === 0 || (derivationMethod && this.derivations[i][0]) !== 0)) { return true; } if (this.derivations[i][1].isDerivedFrom_(typeArg, derivationMethod)) { @@ -45,7 +45,7 @@ Fleur.TypeInfo.prototype.isDerivedFrom = function(typeNamespaceArg, typeNameArg, }; Fleur.TypeInfo.prototype.as = function(targetedType) { - if (this.isDerivedFrom_(targetedType, Fleur.DERIVATION_RESTRICTION)) { + if (!targetedType || this.isDerivedFrom_(targetedType, Fleur.DERIVATION_RESTRICTION)) { return true; } if (targetedType.derivations) { @@ -60,6 +60,33 @@ Fleur.TypeInfo.prototype.as = function(targetedType) { return false; }; +Fleur.TypeInfo.prototype._ancestors = function(ancestors) { + ancestors.push(this); + if (this.derivations) { + for (let i= 0, l = this.derivations.length; i < l; i++) { + if (this.derivations[i][0] === Fleur.TypeInfo.DERIVATION_RESTRICTION) { + this.derivations[i][1]._ancestors(ancestors); + } + } + } +}; + +Fleur.TypeInfo.prototype.aggregate = function(typeArg) { + let typeArgAncestors = []; + typeArg._ancestors(typeArgAncestors); + typeArgAncestors.reverse(); + let ancestors = []; + this._ancestors(ancestors); + ancestors.reverse(); + let a = ancestors[0]; + let i = 0; + while (i < ancestors.length && i < typeArgAncestors.length && ancestors[i] === typeArgAncestors[i]) { + a = ancestors[i]; + i++; + } + return a; +}; + Fleur.TypeInfo.prototype.getPrimitiveType = function(types, derivationMethod) { var propname, t, prim; switch (derivationMethod) { diff --git a/src/js/fleur.js/DOM/Types.js b/src/js/fleur.js/DOM/Types.js index c5a6644..064e086 100644 --- a/src/js/fleur.js/DOM/Types.js +++ b/src/js/fleur.js/DOM/Types.js @@ -1,13 +1,12 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Types = {}; +Fleur.Types["#internal"] = {}; Fleur.Types["http://www.w3.org/2001/XMLSchema"] = {}; Fleur.Types_XMLSchema = Fleur.Types["http://www.w3.org/2001/XMLSchema"]; @@ -21,8 +20,34 @@ Fleur.Type_anyAtomicType = new Fleur.TypeInfo_XMLSchema("anyAtomicType", [[Fleur Fleur.Type_untypedAtomic = new Fleur.TypeInfo_XMLSchema("untypedAtomic", [[Fleur.TypeInfo.DERIVATION_RESTRICTION, Fleur.Type_anyAtomicType]]); +Fleur.Type_numeric = new Fleur.TypeInfo_XMLSchema("numeric", [[Fleur.TypeInfo.DERIVATION_RESTRICTION, Fleur.Type_anyAtomicType]]); +// [Fleur.TypeInfo.DERIVATION_UNION, Fleur.Type_integer], +// [Fleur.TypeInfo.DERIVATION_UNION, Fleur.Type_decimal], +// [Fleur.TypeInfo.DERIVATION_UNION, Fleur.Type_float], +// [Fleur.TypeInfo.DERIVATION_UNION, Fleur.Type_double] +//]); +Fleur.Type_numeric.constructorName = "xs_numeric_1"; +Fleur.Type_numeric.canonicalize = function(s) { + try { + return Fleur.Type_integer.canonicalize(s); + } catch (e) {} + try { + return Fleur.Type_decimal.canonicalize(s); + } catch (e) {} + try { + return Fleur.Type_float.canonicalize(s); + } catch (e) {} + try { + return Fleur.Type_double.canonicalize(s); + } catch (e) {} + throw new Fleur.DOMException(Fleur.DOMException.VALIDATION_ERR); +}; + Fleur.Type_string = new Fleur.TypeInfo_XMLSchema("string", [[Fleur.TypeInfo.DERIVATION_RESTRICTION, Fleur.Type_anyAtomicType]]); Fleur.Type_string.constructorName = "xs_string_1"; +Fleur.Type_string.canonicalize = function(s) { + return s; +}; Fleur.Type_boolean = new Fleur.TypeInfo_XMLSchema("boolean", [[Fleur.TypeInfo.DERIVATION_RESTRICTION, Fleur.Type_anyAtomicType]]); Fleur.Type_boolean.constructorName = "xs_boolean_1"; @@ -40,7 +65,7 @@ Fleur.Type_boolean.canonicalize = function(s) { throw new Fleur.DOMException(Fleur.DOMException.VALIDATION_ERR); }; -Fleur.Type_decimal = new Fleur.TypeInfo_XMLSchema("decimal", [[Fleur.TypeInfo.DERIVATION_RESTRICTION, Fleur.Type_anyAtomicType]]); +Fleur.Type_decimal = new Fleur.TypeInfo_XMLSchema("decimal", [[Fleur.TypeInfo.DERIVATION_RESTRICTION, Fleur.Type_numeric]]); Fleur.Type_decimal.constructorName = "xs_decimal_1"; Fleur.Type_decimal.canonicalize = function(s) { if (/^\s*[\-+]?([0-9]+(\.[0-9]*)?|[\-+]?\.[0-9]+)\s*$/.test(s)) { @@ -86,7 +111,7 @@ Fleur.Type_decimal.canonicalize = function(s) { throw new Fleur.DOMException(Fleur.DOMException.VALIDATION_ERR); }; -Fleur.Type_float = new Fleur.TypeInfo_XMLSchema("float", [[Fleur.TypeInfo.DERIVATION_RESTRICTION, Fleur.Type_anyAtomicType]]); +Fleur.Type_float = new Fleur.TypeInfo_XMLSchema("float", [[Fleur.TypeInfo.DERIVATION_RESTRICTION, Fleur.Type_numeric]]); Fleur.Type_float.constructorName = "xs_float_1"; Fleur.Type_float.canonicalize = function(s) { if (/^\s*(([\-+]?([0-9]+(\.[0-9]*)?)|[\-+]?(\.[0-9]+))([eE][\-+]?[0-9]+)?|[\-+]?INF|NaN)\s*$/.test(s)) { @@ -128,7 +153,7 @@ Fleur.Type_float.canonicalize = function(s) { throw new Fleur.DOMException(Fleur.DOMException.VALIDATION_ERR); }; -Fleur.Type_double = new Fleur.TypeInfo_XMLSchema("double", [[Fleur.TypeInfo.DERIVATION_RESTRICTION, Fleur.Type_anyAtomicType]]); +Fleur.Type_double = new Fleur.TypeInfo_XMLSchema("double", [[Fleur.TypeInfo.DERIVATION_RESTRICTION, Fleur.Type_numeric]]); Fleur.Type_double.constructorName = "xs_double_1"; Fleur.Type_double.canonicalize = Fleur.Type_float.canonicalize; @@ -203,7 +228,7 @@ Fleur.Type_gYear.canonicalize = function(s) { Fleur.Type_gMonthDay = new Fleur.TypeInfo_XMLSchema("gMonthDay", [[Fleur.TypeInfo.DERIVATION_RESTRICTION, Fleur.Type_anyAtomicType]]); Fleur.Type_gMonthDay.constructorName = "xs_gMonthDay_1"; Fleur.Type_gMonthDay.canonicalize = function(s) { - if (/^\s*--(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])\s*$/.test(s)) { + if (/^\s*--((0[1-9]|1[0-2])-([01][1-9]|10|2[0-9]))|((0[13-9]|1[0-2])-30)|((0[13578]|1[02])-31)\s*$/.test(s)) { return s.trim(); } throw new Fleur.DOMException(Fleur.DOMException.VALIDATION_ERR); @@ -254,6 +279,21 @@ Fleur.Type_anyURI.canonicalize = function(s) { throw new Fleur.DOMException(Fleur.DOMException.VALIDATION_ERR); }; +Fleur.Type_collation = new Fleur.TypeInfo_XMLSchema("collation", [[Fleur.TypeInfo.DERIVATION_RESTRICTION, Fleur.Type_string]]); +Fleur.Type_collation.constructorName = "xs_collation_1"; +Fleur.Type_collation.canonicalize = function(s) { + var c = Fleur.Collations[s]; + if (!c && !s.startsWith("http://")) { + c = Fleur.Collations["http://www.w3.org/2005/xpath-functions/collation/" + s]; + if (c) { + return "http://www.w3.org/2005/xpath-functions/collation/" + s; + } + } else { + return s; + } + throw new Fleur.DOMException(Fleur.DOMException.VALIDATION_ERR); +}; + Fleur.Type_QName = new Fleur.TypeInfo_XMLSchema("QName", [[Fleur.TypeInfo.DERIVATION_RESTRICTION, Fleur.Type_anyAtomicType]]); Fleur.Type_QName.constructorName = "xs_QName_1"; Fleur.Type_QName.canonicalize = function(s) { @@ -280,6 +320,7 @@ Fleur.Type_NOTATION.constructorName = "xs_NOTATION_1"; Fleur.Type_NOTATION.canonicalize = Fleur.Type_token.canonicalize; Fleur.Type_language = new Fleur.TypeInfo_XMLSchema("language", [[Fleur.TypeInfo.DERIVATION_RESTRICTION, Fleur.Type_token]]); +Fleur.Type_language.constructorName = "xs_language_1"; Fleur.Type_language.canonicalize = function(s) { if (/^\s*[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*\s*$/.test(s)) { return s.trim(); @@ -378,14 +419,6 @@ Fleur.Type_integer.canonicalize = function(s) { throw new Fleur.DOMException(Fleur.DOMException.VALIDATION_ERR); }; -Fleur.Type_numeric = new Fleur.TypeInfo_XMLSchema("numeric", [ - [Fleur.TypeInfo.DERIVATION_UNION, Fleur.Type_integer], - [Fleur.TypeInfo.DERIVATION_UNION, Fleur.Type_decimal], - [Fleur.TypeInfo.DERIVATION_UNION, Fleur.Type_float], - [Fleur.TypeInfo.DERIVATION_UNION, Fleur.Type_double] -]); -Fleur.Type_numeric.constructorName = "xs_numeric_1"; - Fleur.Type_nonPositiveInteger = new Fleur.TypeInfo_XMLSchema("nonPositiveInteger", [[Fleur.TypeInfo.DERIVATION_RESTRICTION, Fleur.Type_integer]]); Fleur.Type_nonPositiveInteger.constructorName = "xs_nonPositiveInteger_1"; Fleur.Type_nonPositiveInteger.canonicalize = function(s) { @@ -552,6 +585,19 @@ Fleur.Type_unsignedShort.canonicalize = function(s) { throw new Fleur.DOMException(Fleur.DOMException.VALIDATION_ERR); }; +Fleur.Type_codepoint = new Fleur.TypeInfo_XMLSchema("codepoint", [[Fleur.TypeInfo.DERIVATION_RESTRICTION, Fleur.Type_unsignedShort]]); +Fleur.Type_codepoint.constructorName = "xs_codepoint_1"; +Fleur.Type_codepoint.canonicalize = function(s) { + if (/^\s*(\+?[0-9]+|-0+)\s*$/.test(s)) { + s = s.trim(); + var value = parseInt(s, 10); + if (value > 0 && value <= 65535) { + return String(value); + } + } + throw new Fleur.DOMException(Fleur.DOMException.VALIDATION_ERR); +}; + Fleur.Type_unsignedByte = new Fleur.TypeInfo_XMLSchema("unsignedByte", [[Fleur.TypeInfo.DERIVATION_RESTRICTION, Fleur.Type_unsignedShort]]); Fleur.Type_unsignedByte.constructorName = "xs_unsignedByte_1"; Fleur.Type_unsignedByte.canonicalize = function(s) { diff --git a/src/js/fleur.js/DOM/project.json b/src/js/fleur.js/DOM/project.json index 87051f5..d380b00 100644 --- a/src/js/fleur.js/DOM/project.json +++ b/src/js/fleur.js/DOM/project.json @@ -1,41 +1,42 @@ { - "Components":[ - "NodeList.js", - "Node.js", - "CharacterData.js", - "Array.js", - "Attr.js", - "CDATASection.js", - "Comment.js", - "Document.js", - "DocumentFragment.js", - "DocumentType.js", - "DOMConfiguration.js", - "DOMError.js", - "DOMException.js", - "DOMImplementationList.js", - "DOMImplementation.js", - "DOMImplementationSource.js", - "DOMLocator.js", - "DOMParser.js", - "DOMStringList.js", - "Element.js", - "Entity.js", - "Entry.js", - "Function.js", - "GrammarParser.js", - "Map.js", - "Multidim.js", - "NamedNodeMap.js", - "NameList.js", - "Namespace.js", - "ProcessingInstruction.js", - "Sequence.js", - "Serializer.js", - "Text.js", - "TypeInfo.js", - "Types.js", - "UserDataHandler.js", - "XMLSerializer.js" - ] + "Components":[ + "NodeList.js", + "Node.js", + "CharacterData.js", + "Array.js", + "Attr.js", + "CDATASection.js", + "Comment.js", + "Document.js", + "DocumentFragment.js", + "DocumentType.js", + "DOMConfiguration.js", + "DOMError.js", + "DOMException.js", + "DOMImplementationList.js", + "DOMImplementation.js", + "DOMImplementationSource.js", + "DOMLocator.js", + "DOMParser.js", + "DOMStringList.js", + "Element.js", + "Entity.js", + "Entry.js", + "Function.js", + "GrammarParser.js", + "Map.js", + "Multidim.js", + "NamedNodeMap.js", + "NameList.js", + "Namespace.js", + "ProcessingInstruction.js", + "Sequence.js", + "Serializer.js", + "Text.js", + "TypeInfo.js", + "Types.js", + "SequenceType.js", + "UserDataHandler.js", + "XMLSerializer.js" + ] } \ No newline at end of file diff --git a/src/js/fleur.js/XPath/Collations.js b/src/js/fleur.js/XPath/Collations.js index 1100971..67d99d5 100644 --- a/src/js/fleur.js/XPath/Collations.js +++ b/src/js/fleur.js/XPath/Collations.js @@ -1,78 +1,76 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Collations = {}; Fleur.getCollation = function(collation) { - var c = Fleur.Collations[collation]; - if (!c && !collation.startsWith("http://")) { - c = Fleur.Collations["http://www.w3.org/2005/xpath-functions/" + collation]; - } - return c; -} + var c = Fleur.Collations[collation]; + if (!c && !collation.startsWith("http://")) { + c = Fleur.Collations["http://www.w3.org/2005/xpath-functions/collation/" + collation]; + } + return c; +}; Fleur.Collations["http://www.w3.org/2005/xpath-functions/collation/codepoint"] = { - equals: function(a, b) { - return a === b; - }, - lessThan: function(a, b) { - return a < b; - }, - greaterThan: function(a, b) { - return a > b; - }, - startsWith: function(a, b) { - return a.startsWith(b); - }, - endsWith: function(a, b) { - return a.endsWith(b); - }, - contains: function(a, b) { - return a.indexOf(b) !== -1; - }, - substringBefore: function(a, b) { - var i = a.indexOf(b); - return i === -1 ? "" : a.substr(0, i); - }, - substringAfter: function(a, b) { - var i = a.indexOf(b); - return i === -1 ? "" : a.substr(i + b.length); - } + equals: function(a, b) { + return a === b; + }, + lessThan: function(a, b) { + return a < b; + }, + greaterThan: function(a, b) { + return a > b; + }, + startsWith: function(a, b) { + return a.startsWith(b); + }, + endsWith: function(a, b) { + return a.endsWith(b); + }, + contains: function(a, b) { + return a.indexOf(b) !== -1; + }, + substringBefore: function(a, b) { + var i = a.indexOf(b); + return i === -1 ? "" : a.substr(0, i); + }, + substringAfter: function(a, b) { + var i = a.indexOf(b); + return i === -1 ? "" : a.substr(i + b.length); + } }; Fleur.Collations["http://www.w3.org/2005/xpath-functions/collation/html-ascii-case-insensitive"] = { - equals: function(a, b) { - return a.toLowerCase() === b.toLowerCase(); - }, - lessThan: function(a, b) { - return a.toLowerCase() < b.toLowerCase(); - }, - greaterThan: function(a, b) { - return a.toLowerCase() > b.toLowerCase(); - }, - startsWith: function(a, b) { - return a.toLowerCase().startsWith(b.toLowerCase()); - }, - endsWith: function(a, b) { - return a.toLowerCase().endsWith(b.toLowerCase()); - }, - contains: function(a, b) { - return a.toLowerCase().indexOf(b.toLowerCase()) !== -1; - }, - substringBefore: function(a, b) { - var i = a.toLowerCase().indexOf(b.toLowerCase()); - return i === -1 ? "" : a.substr(0, i); - }, - substringAfter: function(a, b) { - var i = a.toLowerCase().indexOf(b.toLowerCase()); - return i === -1 ? "" : a.substr(i + b.length); - } + equals: function(a, b) { + return a.toLowerCase() === b.toLowerCase(); + }, + lessThan: function(a, b) { + return a.toLowerCase() < b.toLowerCase(); + }, + greaterThan: function(a, b) { + return a.toLowerCase() > b.toLowerCase(); + }, + startsWith: function(a, b) { + return a.toLowerCase().startsWith(b.toLowerCase()); + }, + endsWith: function(a, b) { + return a.toLowerCase().endsWith(b.toLowerCase()); + }, + contains: function(a, b) { + return a.toLowerCase().indexOf(b.toLowerCase()) !== -1; + }, + substringBefore: function(a, b) { + var i = a.toLowerCase().indexOf(b.toLowerCase()); + return i === -1 ? "" : a.substr(0, i); + }, + substringAfter: function(a, b) { + var i = a.toLowerCase().indexOf(b.toLowerCase()); + return i === -1 ? "" : a.substr(i + b.length); + } }; Fleur.Collations["http://www.w3.org/2010/09/qt-fots-catalog/collation/caseblind"] = Fleur.Collations["http://www.w3.org/2005/xpath-functions/collation/html-ascii-case-insensitive"]; \ No newline at end of file diff --git a/src/js/fleur.js/XPath/Context.js b/src/js/fleur.js/XPath/Context.js index 257ece4..be22238 100644 --- a/src/js/fleur.js/XPath/Context.js +++ b/src/js/fleur.js/XPath/Context.js @@ -1,12 +1,10 @@ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ - Fleur.Context = function(path, rs, nodedeps, xfdeps, position) { this.item = null; this.path = path; @@ -15,22 +13,25 @@ Fleur.Context = function(path, rs, nodedeps, xfdeps, position) { this.pathstack = []; this.tuplestack = []; this.tuple = null; - if (rs) { - this.rs = rs; - } - if (nodedeps) { - this.nodedeps = nodedeps; - this.nodedepset = new Set(); - const nodedepset = this.nodedepset; - this.nodedeps.forEach(nodedep => nodedepset.add(nodedep.internal_id)); - } - if (xfdeps) { - this.xfdeps = xfdeps; - this.xfdepset = new Set(); - const xfdepset = this.xfdepset; - this.xfdeps.forEach(xfdep => xfdepset.add(xfdep)); + if (!rs) { + rs = {}; + rs.now = Fleur.dateToDateTime(); + rs.nsresolver = new Fleur.XPathNSResolver(); + rs.varresolver = new Fleur.varMgr(); } + this.rs = rs; + nodedeps = nodedeps || []; + this.nodedeps = nodedeps; + this.nodedepset = new Set(); + const nodedepset = this.nodedepset; + this.nodedeps.forEach(nodedep => nodedepset.add(nodedep.internal_id)); + xfdeps = xfdeps || []; + this.xfdeps = xfdeps; + this.xfdepset = new Set(); + const xfdepset = this.xfdepset; + this.xfdeps.forEach(xfdep => xfdepset.add(xfdep)); this.position = position; + this.engine = Fleur; }; Fleur.Context.prototype.clone = function(path) { @@ -50,6 +51,12 @@ Fleur.Context.prototype.emptySequence = function() { return this; }; +Fleur.Context.prototype.current = function() { + this.itemstack.push(this.item); + this.item = this.path; + return this; +}; + Fleur.Context.XPATHAXIS_ANCESTOR = 0; Fleur.Context.XPATHAXIS_ANCESTOR_OR_SELF = 1; Fleur.Context.XPATHAXIS_ATTRIBUTE = 2; @@ -115,8 +122,11 @@ Fleur.Context.prototype.isFalse = function() { return val; }; -Fleur.Context.prototype.atomize = function() { +Fleur.Context.prototype.atomize = function(expectedSequenceType) { this.item = Fleur.Atomize(this.item); + if (expectedSequenceType && !this.item.schemaTypeInfo.as(expectedSequenceType.schemaTypeInfo)) { + Fleur.XQueryError_xqt("XPST0017", null, "Invalid type"); + } return this; }; @@ -124,17 +134,73 @@ Fleur.Context.prototype.typeConstructor = function(schemaType) { if (this.item.isEmpty()) { return this; } - this.item = Fleur.Atomize(this.item); +// this.item = Fleur.Atomize(this.item); + const res = new Fleur.Text(); + if (schemaType === Fleur.Type_numeric) { + try { + res.data = Fleur.Type_integer.canonicalize(this.item.data); + res.schemaTypeInfo = Fleur.Type_integer; + this.item = res; + return this; + } catch (e) {} + try { + res.data = Fleur.Type_decimal.canonicalize(this.item.data); + res.schemaTypeInfo = Fleur.Type_decimal; + this.item = res; + return this; + } catch (e) {} + try { + res.data = Fleur.Type_float.canonicalize(this.item.data); + res.schemaTypeInfo = Fleur.Type_float; + this.item = res; + return this; + } catch (e) {} + try { + res.data = Fleur.Type_double.canonicalize(this.item.data); + res.schemaTypeInfo = Fleur.Type_double; + this.item = res; + return this; + } catch (e) { + Fleur.XQueryError_xqt(e.code === Fleur.DOMException.VALIDATION_ERR ? "FORG0001" : "FODT0001", null, "Wrong argument for xs:" + schemaType.typeName + "#1", "", this.item); + } + } if (this.item.schemaTypeInfo === Fleur.Type_string || this.item.schemaTypeInfo === Fleur.Type_untypedAtomic) { if (!this.item.hasOwnProperty("data")) { - Fleur.XQueryError_xqt("FORG00001", null, "Wrong argument type for xs:" + schemaType.constructorName.substr(3, schemaType.constructorName - 5) + "#1", "", this.item); + Fleur.XQueryError_xqt("FORG00001", null, "Wrong argument for xs:" + schemaType.typeName + "#1", "", this.item); } } try { - this.item.data = schemaType.canonicalize(this.item.textContent); - this.item.schemaTypeInfo = schemaType; + res.data = schemaType.canonicalize(this.item.textContent); + res.schemaTypeInfo = schemaType; + this.item = res; return this; } catch (e) { - Fleur.XQueryError_xqt(e.code === Fleur.DOMException.VALIDATION_ERR ? "FORG0001" : "FODT0001", null, "Wrong argument type for xs:" + schemaType.constructorName.substr(3, schemaType.constructorName - 5) + "#1", "", this.item); + Fleur.XQueryError_xqt(e.code === Fleur.DOMException.VALIDATION_ERR ? "FORG0001" : "FODT0001", null, "Wrong argument for xs:" + schemaType.typeName + "#1", "", this.item); + } +}; + +Fleur.Context.prototype.notyet = function() { + Fleur.XQueryError_xqt("XPST0001", null, "Not yet implemented"); +}; + +Fleur.Context.prototype.staticinst = function(transp) { + if (this.item.isEmpty()) { + return { + inst: transp.inst("xqx_sequenceExpr(0)", false).inst, + sequenceType: Fleur.SequenceType_empty_sequence, + value: this.item + }; + } + return { + inst: transp.inst("xqx_constantExpr(Fleur.Type_" + this.item.schemaTypeInfo.typeName + ", '" + this.item.data + "')", false).inst, + sequenceType: new Fleur.SequenceType(Fleur.Node.TEXT_NODE, this.item.schemaTypeInfo, "1"), + value: this.item + }; +}; + +Fleur.Context.prototype.log = function() { + const ser = this.fn_serialize_1().item.data; + if (ser.length !== 0) { + console.log(ser); } }; \ No newline at end of file diff --git a/src/js/fleur.js/XPath/Transpiler.js b/src/js/fleur.js/XPath/Transpiler.js index 7daf684..9e88da5 100644 --- a/src/js/fleur.js/XPath/Transpiler.js +++ b/src/js/fleur.js/XPath/Transpiler.js @@ -1,32 +1,54 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module FleurConv - * @description === FleurConv === - * Converter from Fleur XQuery parser result to XPath engine + * @license LGPL - See file 'LICENSE.md' in this project. + * @module Transpiler + * @description === Transpiler === + * Transpiler from Fleur XQuery parser result to Javascript function */ -Fleur.Transpiler = function(ctxvarname, step) { - this.ctxvarname = ctxvarname; - this.step = step; +Fleur.Transpiler = function(ctxvarname, step, rs) { + this.ctxvarname = ctxvarname || "ctx"; + this.step = step || " "; this.indent = ""; this.async = false; + if (!rs) { + rs = {}; + rs.now = Fleur.dateToDateTime(); + rs.nsresolver = new Fleur.XPathNSResolver(); + rs.varresolver = new Fleur.varMgr(); + } + this.rs = rs; }; -Fleur.Transpiler.prototype.inst = function(s, isasync, expectedType, preinst) { +Fleur.Transpiler.prototype.inst = function(s, isasync, expectedSequenceType, preinst, dynseqtype) { return { - inst: (preinst || "") + "\n" + this.indent + (isasync ? "await " : "") + this.ctxvarname + "." + s + ";", - sequenceType: expectedType + inst: (preinst || "") + "\n" + this.indent + (isasync ? "await " : "") + this.ctxvarname + "." + s + ";" + + (expectedSequenceType && dynseqtype && dynseqtype.nodeType !== Fleur.Node.ANY_NODE ? "\n" + this.indent + this.ctxvarname + ".fn_data_1();" + + (expectedSequenceType.schemaTypeInfo.typeName !== "anyAtomicType" ? + "\n" + this.indent + this.ctxvarname + "." + expectedSequenceType.schemaTypeInfo.constructorName + "();" : "") : "" + ), + sequenceType: expectedSequenceType }; }; -Fleur.Transpiler.prototype.gen = function(arr, expectedType) { - return this[Fleur.XQueryXNames[1][arr[0]][2].replace(":", "_")](arr[1], expectedType); +Fleur.Transpiler.prototype.gen = function(arr, expectedSequenceType) { + const instname = Fleur.XQueryXNames[1][arr[0]][2]; + const jsfunc = this[instname.replace(":", "_")]; + if (jsfunc) { + const genret = this[instname.replace(":", "_")](arr[1], expectedSequenceType); + if (genret.sequenceType && !genret.sequenceType.as(expectedSequenceType)) { + Fleur.XQueryError_xqt("XPST0017", null, "Invalid type"); + } + return genret; + } + Fleur.XQueryError_xqt("XPST0000", null, "Unsupported instruction", "", new Fleur.Text(instname)); }; -Fleur.Transpiler.prototype.funcdef = function(arr, expectedType) { +Fleur.Transpiler.prototype.funcdef = function(arr, expectedType, main) { const previndent = this.indent; + const prevctxvarname = this.ctxvarname; + this.ctxvarname = "ctx"; this.indent += this.step; const prevasync = this.async; this.async = false; @@ -36,11 +58,43 @@ Fleur.Transpiler.prototype.funcdef = function(arr, expectedType) { this.async = prevasync; } let result = gen.inst; - result += "\n" + this.indent + "return "+ this.ctxvarname + ";"; + result += "\n" + this.indent + "return "+ this.ctxvarname + (main ? ".item" : "") + ";"; result += "\n" + previndent + "}"; this.indent = previndent; + this.ctxvarname = prevctxvarname; return { - inst: (this.indent === "" ? "" : "\n") + this.indent + (newasync ? "async " : "") + this.ctxvarname + " => {" + result, + inst: (this.indent === "" ? "" : "\n") + this.indent + (newasync ? "async " : "") + "ctx => {" + result, sequenceType: gen.sequenceType }; +}; + +Fleur.Transpiler.prototype.source = function(arr) { + this.indent += this.step; + const prevasync = this.async; + this.async = false; + const gen = this.gen(arr); + const newasync = this.async; + if (!this.async) { + this.async = prevasync; + } + let result = "\"use strict\";"; + result += "\nconst Fleur = require('./fleur.js');"; + result += "\n(" + (newasync ? "async " : "") + "() => {"; + result += "\n" + this.indent + "const " + this.ctxvarname + " = new Fleur.Context();"; + result += gen.inst; + result += "\n" + this.indent + this.ctxvarname + ".log();"; + result += "\n})();"; + this.indent = ""; + return result; +}; + +Fleur.Transpiler.prototype.staticargs = function(args) { + const ctx = new Fleur.Context(null, this.rs, []); + for (let i = 0; i < args.length - 1; i++) { + ctx.itemstack.push(args[i].value); + } + if (args.length !== 0) { + ctx.item = args[args.length - 1].value; + } + return ctx; }; \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathEvaluator.js b/src/js/fleur.js/XPath/XPathEvaluator.js index 0d7cb61..de82505 100644 --- a/src/js/fleur.js/XPath/XPathEvaluator.js +++ b/src/js/fleur.js/XPath/XPathEvaluator.js @@ -107,7 +107,7 @@ Fleur.XPathEvaluator._calc = function(args, ops, opprec, prevop) { var op = op0.substr(op0.indexOf(".") + 1); var curop = parseInt(ops.split(".")[1], 10); var prectest = ops === "" || curop > opprec || ((prevop === op || op === "then") && prevop === "return") || prevop === "then"; - console.log("Consider \"" + prevop + "\"[" + opprec + "] vs. \"" + op + "\"[" + curop + "]" + " => " + (prectest ? "Do nothing" : "Evaluate \"" + op + "\"")); + //console.log("Consider \"" + prevop + "\"[" + opprec + "] vs. \"" + op + "\"[" + curop + "]" + " => " + (prectest ? "Do nothing" : "Evaluate \"" + op + "\"")); if (prectest) { return args.length + "." + args + ops.length + "." + ops; } @@ -2180,7 +2180,7 @@ Fleur.XPathEvaluator._getProlog = function(xq, i) { return res; }; Fleur.XPathEvaluator._xq2js = function(xq) { - console.log("\n*********\nParse \"" + xq + "\""); + //console.log("\n*********\nParse \"" + xq + "\""); //xq = xq.replace(/^\s+|\s+$/gm, " "); var v = Fleur.XPathEvaluator._getVersion(xq); var vl = v.substr(0, v.indexOf(".")); @@ -2192,6 +2192,6 @@ Fleur.XPathEvaluator._xq2js = function(xq) { prolog += pc; } while (pc !== ""); var ret = "[Fleur.XQueryX.module,[" + v.substr(v.indexOf(".") + 1) + "[Fleur.XQueryX.mainModule,[" + (prolog === "" ? "" : "[Fleur.XQueryX.prolog,[" + prolog.substr(0, prolog.length - 1) + "]],") + "[Fleur.XQueryX.queryBody,[" + Fleur.XPathEvaluator._xp2js(xq.substr(pl), "", "") + ']]]],[Fleur.XQueryX.xqx,["http://www.w3.org/2005/XQueryX"]],[Fleur.XQueryX.xqxuf,["http://www.w3.org/2007/xquery-update-10"]],[Fleur.XQueryX.schemaLocation,["http://www.w3.org/2007/xquery-update-10 http://www.w3.org/2007/xquery-update-10/xquery-update-10-xqueryx.xsd http://www.w3.org/2005/XQueryX http://www.w3.org/2005/XQueryX/xqueryx.xsd"]],[Fleur.XQueryX.xsi,["http://www.w3.org/2001/XMLSchema-instance"]]]]'; - console.log("*********\n"); + //console.log("*********\n"); return ret; }; \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/file/write.js b/src/js/fleur.js/XPath/XPathFunctions/file/write.js index a6f5e77..33cd759 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/file/write.js +++ b/src/js/fleur.js/XPath/XPathFunctions/file/write.js @@ -1,50 +1,93 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ +Fleur.Context.prototype.file_write_2 = async function() { + await this.emptySequence().file_write_3(); + return this; +}; + +Fleur.Context.prototype.file_write_3 = async function() { + let serialization = this.item; + let node = this.itemstack.pop(); + let filename = this.itemstack.pop().data; + let contentType; + let indent = false; + let encoding = null; + let jsserial = {}; + if (serialization.isNotEmpty()) { + var a2 = Fleur.Atomize(serialization); + var op2 = Fleur.toJSObject(a2); + if (op2[0] < 0) { + return a2; + } + jsserial = op2[1]; + contentType = Fleur.toContentType(serialization, Fleur.extension2contentType[global.path.extname(filename).toLowerCase()] || "application/xml"); + indent = serialization.indent === "yes"; + if (jsserial.encoding) { + encoding = Fleur.encoding2encoding[jsserial.encoding.toLowerCase()]; + } + } + if (!contentType) { + contentType = Fleur.extension2contentType[global.path.extname(filename).toLowerCase()] || "application/xml"; + } + var ser = new Fleur.Serializer(); + if (!encoding) { + encoding = "utf8"; + } + await global.fsPromises.writeFile(filename, (encoding === "utf8" ? '\ufeff' : '') + ser.serializeToString(node, contentType, indent), encoding); + this.item = new Fleur.Sequence(); + return this; +}; + +Fleur.XPathFunctions_file["write#2"] = new Fleur.Function("http://expath.org/ns/file", "file:write", Fleur.Context.prototype.file_write_2, + [Fleur.SequenceType_string_01, Fleur.SequenceType_item_01], Fleur.SequenceType_empty_sequence, {dynonly: true, isasync: true}); + +Fleur.XPathFunctions_file["write#3"] = new Fleur.Function("http://expath.org/ns/file", "file:write", Fleur.Context.prototype.file_write_3, + [Fleur.SequenceType_string_01, Fleur.SequenceType_item_01, Fleur.SequenceType_item_01], Fleur.SequenceType_empty_sequence, {dynonly: true, isasync: true}); +/* Fleur.XPathFunctions_file["write#2"] = new Fleur.Function("http://expath.org/ns/file", "file:write", - function(filename, node, ctx, callback) { - return Fleur.XPathFunctions_file["write#3"].jsfunc(filename, node, null, ctx, callback); - }, - null, [{type: Fleur.Type_string}, {type: Fleur.Node, occurence: "?"}], true, true, {type: Fleur.EmptySequence}); + function(filename, node, ctx, callback) { + return Fleur.XPathFunctions_file["write#3"].jsfunc(filename, node, null, ctx, callback); + }, + null, [{type: Fleur.Type_string}, {type: Fleur.Node, occurence: "?"}], true, true, {type: Fleur.EmptySequence}); Fleur.XPathFunctions_file["write#3"] = new Fleur.Function("http://expath.org/ns/file", "file:write", - function(filename, node, serialization, ctx, callback) { - var contentType; - var indent = false; - var encoding; - if (serialization) { - var a2 = Fleur.Atomize(serialization); - var op2 = Fleur.toJSObject(a2); - if (op2[0] < 0) { - callback(a2); - return; - } - serialization = op2[1]; - contentType = Fleur.toContentType(serialization, Fleur.extension2contentType[global.path.extname(filename).toLowerCase()] || "application/xml"); - indent = serialization.indent === "yes"; - if (serialization["encoding"]) { - encoding = Fleur.encoding2encoding[serialization["encoding"].toLowerCase()]; - } - } - if (!contentType) { - contentType = Fleur.extension2contentType[global.path.extname(filename).toLowerCase()] || "application/xml"; - } - var ser = new Fleur.Serializer(); - if (!encoding) { - encoding = "utf8"; - } - global.fs.writeFile(filename, (encoding === "utf8" ? '\ufeff' : '') + ser.serializeToString(node, contentType, indent), encoding, function(err) { - if (err) { - callback(Fleur.error(ctx, "FODC0002")); - } else { - callback(Fleur.EmptySequence); - } - }); - }, - null, [{type: Fleur.Type_string}, {type: Fleur.Node, occurence: "?"}, {type: Fleur.Node, occurence: "?"}], true, true, {type: Fleur.EmptySequence}); \ No newline at end of file + function(filename, node, serialization, ctx, callback) { + var contentType; + var indent = false; + var encoding; + if (serialization) { + var a2 = Fleur.Atomize(serialization); + var op2 = Fleur.toJSObject(a2); + if (op2[0] < 0) { + callback(a2); + return; + } + serialization = op2[1]; + contentType = Fleur.toContentType(serialization, Fleur.extension2contentType[global.path.extname(filename).toLowerCase()] || "application/xml"); + indent = serialization.indent === "yes"; + if (serialization["encoding"]) { + encoding = Fleur.encoding2encoding[serialization["encoding"].toLowerCase()]; + } + } + if (!contentType) { + contentType = Fleur.extension2contentType[global.path.extname(filename).toLowerCase()] || "application/xml"; + } + var ser = new Fleur.Serializer(); + if (!encoding) { + encoding = "utf8"; + } + global.fs.writeFile(filename, (encoding === "utf8" ? '\ufeff' : '') + ser.serializeToString(node, contentType, indent), encoding, function(err) { + if (err) { + callback(Fleur.error(ctx, "FODC0002")); + } else { + callback(Fleur.EmptySequence); + } + }); + }, + null, [{type: Fleur.Type_string}, {type: Fleur.Node, occurence: "?"}, {type: Fleur.Node, occurence: "?"}], true, true, {type: Fleur.EmptySequence}); + */ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/QName.js b/src/js/fleur.js/XPath/XPathFunctions/fn/QName.js index 8093375..1d00523 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/QName.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/QName.js @@ -1,37 +1,27 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_QName_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_QName, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - } - ] +Fleur.Context.prototype.fn_QName_2 = function() { + const paramQName = this.item; + const paramURI = this.itemstack.pop(); + this.item = new Fleur.Text(); + this.item.schemaTypeInfo = Fleur.Type_QName; + this.item._setNodeNameLocalNamePrefix(paramURI.isNotEmpty() ? paramURI.data : "", paramQName.data); + return this; }; -Fleur.XPathFunctions_fn["QName#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:QName", +Fleur.XPathFunctions_fn["QName#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:QName", Fleur.Context.prototype.fn_QName_2, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_1], Fleur.SequenceType_QName_1, {dynonly: true}); +/* function(paramURI, paramQName) { var a = new Fleur.Text(); a.schemaTypeInfo = Fleur.Type_QName; a._setNodeNameLocalNamePrefix(paramURI, paramQName); return a; }, - null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_QName}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_QName}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/abs.js b/src/js/fleur.js/XPath/XPathFunctions/fn/abs.js index 5a0920f..5f18820 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/abs.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/abs.js @@ -1,34 +1,18 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_abs_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - } - ] -}; - Fleur.Context.prototype.fn_abs_1 = function() { if (this.item.isNotEmpty()) { const op = Fleur.toJSValue(this.item, true, false, false, false, false, false); if (op[0] >= 0) { - const a2 = op[1] < 0 ? -op[1] : op[1] + const a2 = op[1] < 0 ? -op[1] : op[1]; const t = this.item.schemaTypeInfo; - this.item.data = String(a2); + const res = new Fleur.Text(); + res.data = String(a2); let t2; switch (t.getPrimitiveType([Fleur.Type_nonPositiveInteger, Fleur.Type_negativeInteger, Fleur.Type_byte, Fleur.Type_short, Fleur.Type_int, Fleur.Type_long], Fleur.TypeInfo.DERIVATION_RESTRICTION)) { case Fleur.Type_nonPositiveInteger: @@ -52,43 +36,12 @@ Fleur.Context.prototype.fn_abs_1 = function() { default: t2 = t; } - this.item.schemaTypeInfo = t2; + res.schemaTypeInfo = t2; + this.item = res; } } return this; }; -Fleur.XPathFunctions_fn["abs#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:abs", - function(arg) { - if (arg === null) { - return [null, null]; - } - var a = arg[0]; - var t = arg[1]; - var a2, t2; - a2 = a < 0 ? -a : a; - switch (t.getPrimitiveType([Fleur.Type_nonPositiveInteger, Fleur.Type_negativeInteger, Fleur.Type_byte, Fleur.Type_short, Fleur.Type_int, Fleur.Type_long], Fleur.TypeInfo.DERIVATION_RESTRICTION)) { - case Fleur.Type_nonPositiveInteger: - t2 = Fleur.Type_nonNegativeInteger; - break; - case Fleur.Type_negativeInteger: - t2 = Fleur.Type_positiveInteger; - break; - case Fleur.Type_byte: - t2 = a2 === Fleur.BigInt(128) ? Fleur.Type_short : Fleur.Type_byte; - break; - case Fleur.Type_short: - t2 = a2 === Fleur.BigInt(32768) ? Fleur.Type_int : Fleur.Type_short; - break; - case Fleur.Type_int: - t2 = a2 === Fleur.BigInt(2147483648) ? Fleur.Type_long : Fleur.Type_int; - break; - case Fleur.Type_long: - t2 = a2 === Fleur.BigInt(9223372036854775808) ? Fleur.Type_integer : Fleur.Type_long; - break; - default: - t2 = t; - } - return [a2, t2]; - }, - null, [{type: Fleur.numericTypes, adaptative: true, occurence: "?"}], false, false, {type: Fleur.numericTypes, adaptative: true, occurence: "?"}); \ No newline at end of file +Fleur.XPathFunctions_fn["abs#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:abs", Fleur.Context.prototype.fn_abs_1, + [Fleur.SequenceType_numeric_01], Fleur.SequenceType_numeric_01); \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/adjust-date-to-timezone.js b/src/js/fleur.js/XPath/XPathFunctions/fn/adjust-date-to-timezone.js index a35d11c..14edad7 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/adjust-date-to-timezone.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/adjust-date-to-timezone.js @@ -1,31 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_adjust$_date$_to$_timezone_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_date, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_date, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dayTimeDuration, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.fn_adjust$_date$_to$_timezone_1 = function() { if (this.item.isNotEmpty()) { var dt = Fleur.toDate(this.item.data); @@ -43,7 +22,11 @@ Fleur.Context.prototype.fn_adjust$_date$_to$_timezone_2 = function() { return this; }; -Fleur.XPathFunctions_fn["adjust-date-to-timezone#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:adjust-date-to-timezone", +Fleur.XPathFunctions_fn["adjust-date-to-timezone#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:adjust-date-to-timezone", Fleur.Context.prototype.fn_adjust$_date$_to$_timezone_1, + [Fleur.SequenceType_date_01], Fleur.SequenceType_date_01); +Fleur.XPathFunctions_fn["adjust-date-to-timezone#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:adjust-date-to-timezone", Fleur.Context.prototype.fn_adjust$_date$_to$_timezone_2, + [Fleur.SequenceType_date_01, Fleur.SequenceType_dayTimeDuration_01], Fleur.SequenceType_date_01); +/* function(arg) { if (arg === null) { return null; @@ -60,9 +43,10 @@ Fleur.XPathFunctions_fn["adjust-date-to-timezone#1"] = new Fleur.Function("http: return Fleur.XPathFunctions_fn["adjust-dateTime-to-timezone#2"].jsfunc(arg, timezone, true, false); }, null, [{type: Fleur.Type_date, occurence: "?"}], false, false, {type: Fleur.Type_date, occurence: "?"}); - -Fleur.XPathFunctions_fn["adjust-date-to-timezone#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:adjust-date-to-timezone", + */ +/* function(arg, timezone) { return Fleur.XPathFunctions_fn["adjust-dateTime-to-timezone#2"].jsfunc(arg, timezone, true, false); }, - null, [{type: Fleur.Type_date, occurence: "?"}, {type: Fleur.Type_dayTimeDuration, occurence: "?"}], false, false, {type: Fleur.Type_date, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_date, occurence: "?"}, {type: Fleur.Type_dayTimeDuration, occurence: "?"}], false, false, {type: Fleur.Type_date, occurence: "?"}); + */ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/adjust-dateTime-to-timezone.js b/src/js/fleur.js/XPath/XPathFunctions/fn/adjust-dateTime-to-timezone.js index fdaa0db..8fcf9dd 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/adjust-dateTime-to-timezone.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/adjust-dateTime-to-timezone.js @@ -1,31 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_adjust$_dateTime$_to$_timezone_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_date, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dateTime, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dayTimeDuration, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.fn_adjust$_dateTime$_to$_timezone_1 = function() { if (this.item.isNotEmpty()) { var dt = Fleur.toDateTime(this.item.data); @@ -42,6 +21,7 @@ Fleur.Context.prototype.fn_adjust$_date$_to$_timezone_2 = function(noTime, noDat const arg2 = this.item; const arg1 = this.itemstack.pop(); if (arg1.isNotEmpty()) { + const res = new Fleur.Text(); let dt; if (noTime) { dt = Fleur.toDate(arg1); @@ -63,20 +43,25 @@ Fleur.Context.prototype.fn_adjust$_date$_to$_timezone_2 = function(noTime, noDat } else { dt.tz = null; } - var res; + res.schemaTypeInfo = arg1.schemaTypeInfo; if (noTime) { - this.item.data = Fleur.dateToDate(dt); + res.data = Fleur.dateToDate(dt); } else if (noDate) { - this.item.data = Fleur.dateToTime(dt); + res.data = Fleur.dateToTime(dt); } else { - this.item.data = Fleur.dateToDateTime(dt); + res.data = Fleur.dateToDateTime(dt); } + this.item = res; } return this; }; -Fleur.XPathFunctions_fn["adjust-dateTime-to-timezone#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:adjust-dateTime-to-timezone", - function(arg) { +Fleur.XPathFunctions_fn["adjust-dateTime-to-timezone#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:adjust-dateTime-to-timezone", Fleur.Context.prototype.fn_adjust$_dateTime$_to$_timezone_1, + [Fleur.SequenceType_dateTime_01], Fleur.SequenceType_dateTime_01); +Fleur.XPathFunctions_fn["adjust-dateTime-to-timezone#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:adjust-dateTime-to-timezone", Fleur.Context.prototype.fn_adjust$_dateTime$_to$_timezone_2, + [Fleur.SequenceType_dateTime_01, Fleur.SequenceType_dayTimeDuration_01], Fleur.SequenceType_dateTime_01); +/* +function(arg) { if (arg === null) { return null; } @@ -92,9 +77,9 @@ Fleur.XPathFunctions_fn["adjust-dateTime-to-timezone#1"] = new Fleur.Function("h return Fleur.XPathFunctions_fn["adjust-dateTime-to-timezone#2"].jsfunc(arg, timezone, false, false); }, null, [{type: Fleur.Type_dateTime, occurence: "?"}], false, false, {type: Fleur.Type_dateTime, occurence: "?"}); - -Fleur.XPathFunctions_fn["adjust-dateTime-to-timezone#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:adjust-dateTime-to-timezone", - function(arg, timezone, notime, nodate) { +*/ +/* +function(arg, timezone, notime, nodate) { var dt; if (arg === null) { return null; @@ -130,4 +115,5 @@ Fleur.XPathFunctions_fn["adjust-dateTime-to-timezone#2"] = new Fleur.Function("h } return res; }, - null, [{type: Fleur.Type_dateTime, occurence: "?"}, {type: Fleur.Type_dayTimeDuration, occurence: "?"}], false, false, {type: Fleur.Type_dateTime, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_dateTime, occurence: "?"}, {type: Fleur.Type_dayTimeDuration, occurence: "?"}], false, false, {type: Fleur.Type_dateTime, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/adjust-time-to-timezone.js b/src/js/fleur.js/XPath/XPathFunctions/fn/adjust-time-to-timezone.js index aa1a121..5103fc7 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/adjust-time-to-timezone.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/adjust-time-to-timezone.js @@ -1,31 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_adjust$_time$_to$_timezone_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_time, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_time, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dayTimeDuration, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.fn_adjust$_time$_to$_timezone_1 = function() { if (this.item.isNotEmpty()) { var dt = Fleur.toTime(this.item.data); @@ -43,8 +22,12 @@ Fleur.Context.prototype.fn_adjust$_time$_to$_timezone_2 = function() { return this; }; -Fleur.XPathFunctions_fn["adjust-time-to-timezone#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:adjust-time-to-timezone", - function(arg) { +Fleur.XPathFunctions_fn["adjust-time-to-timezone#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:adjust-time-to-timezone", Fleur.Context.prototype.fn_adjust$_time$_to$_timezone_1, + [Fleur.SequenceType_time_01], Fleur.SequenceType_time_01); +Fleur.XPathFunctions_fn["adjust-time-to-timezone#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:adjust-time-to-timezone", Fleur.Context.prototype.fn_adjust$_time$_to$_timezone_2, + [Fleur.SequenceType_time_01, Fleur.SequenceType_dayTimeDuration_01], Fleur.SequenceType_time_01); +/* +function(arg) { if (arg === null) { return null; } @@ -60,9 +43,10 @@ Fleur.XPathFunctions_fn["adjust-time-to-timezone#1"] = new Fleur.Function("http: return Fleur.XPathFunctions_fn["adjust-dateTime-to-timezone#2"].jsfunc(arg, timezone, false, true); }, null, [{type: Fleur.Type_time, occurence: "?"}], false, false, {type: Fleur.Type_time, occurence: "?"}); - -Fleur.XPathFunctions_fn["adjust-time-to-timezone#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:adjust-time-to-timezone", - function(arg, timezone) { +*/ +/* +function(arg, timezone) { return Fleur.XPathFunctions_fn["adjust-dateTime-to-timezone#2"].jsfunc(arg, timezone, false, true); }, - null, [{type: Fleur.Type_time, occurence: "?"}, {type: Fleur.Type_dayTimeDuration, occurence: "?"}], false, false, {type: Fleur.Type_time, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_time, occurence: "?"}, {type: Fleur.Type_dayTimeDuration, occurence: "?"}], false, false, {type: Fleur.Type_time, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/avg.js b/src/js/fleur.js/XPath/XPathFunctions/fn/avg.js index 304214a..4670a09 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/avg.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/avg.js @@ -1,29 +1,18 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_avg_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "*" - } - ] +Fleur.Context.prototype.fn_avg_1 = function() { + this.notyet(); }; -Fleur.XPathFunctions_fn["avg#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:avg", - function(arg) { +Fleur.XPathFunctions_fn["avg#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:avg", Fleur.Context.prototype.fn_avg_1, + [Fleur.SequenceType_anyAtomicType_0n], Fleur.SequenceType_anyAtomicType_01); +/* +function(arg) { if (arg === null) { return [null, null]; } @@ -70,4 +59,5 @@ Fleur.XPathFunctions_fn["avg#1"] = new Fleur.Function("http://www.w3.org/2005/xp } return arg; }, - null, [{type: Fleur.numericTypes, adaptative: true, occurence: "*"}], false, false, {type: Fleur.numericTypes, adaptative: true, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.numericTypes, adaptative: true, occurence: "*"}], false, false, {type: Fleur.numericTypes, adaptative: true, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/base-uri.js b/src/js/fleur.js/XPath/XPathFunctions/fn/base-uri.js index 3432fde..3012568 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/base-uri.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/base-uri.js @@ -1,31 +1,29 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_base_$uri_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyURI, - occurrence: "?" - }, - params_type: [null] +Fleur.Context.prototype.fn_base_$uri_0 = function() { + this.notyet(); }; Fleur.Context.prototype.fn_base_$uri_1 = function() { + this.notyet(); }; -Fleur.XPathFunctions_fn["base-uri#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:base-uri", - function(ctx) { +Fleur.XPathFunctions_fn["base-uri#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:base-uri", Fleur.Context.prototype.fn_base_$uri_0, + [], Fleur.SequenceType_anyURI_01); +Fleur.XPathFunctions_fn["base-uri#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:base-uri", Fleur.Context.prototype.fn_base_$uri_1, + [Fleur.SequenceType_item_01], Fleur.SequenceType_anyURI_01); +/* +function(ctx) { return Fleur.XPathFunctions_fn["base-uri#1"].jsfunc(ctx._curr); }, null, [], true, false, {type: Fleur.Type_anyURI}); - -Fleur.XPathFunctions_fn["base-uri#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:base-uri", - function(node) { +*/ +/* +function(node) { if (node === Fleur.EmptySequence) { return null; } @@ -36,4 +34,5 @@ Fleur.XPathFunctions_fn["base-uri#1"] = new Fleur.Function("http://www.w3.org/20 } return ""; }, - null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_anyURI}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_anyURI}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/boolean.js b/src/js/fleur.js/XPath/XPathFunctions/fn/boolean.js index 7401428..165e27f 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/boolean.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/boolean.js @@ -1,20 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_boolean_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "?" - }, - params_type: [null] -}; Fleur.Context.prototype.fn_boolean_1 = function() { const newitem = new Fleur.Text(); newitem.schemaTypeInfo = Fleur.Type_boolean; @@ -56,8 +46,10 @@ Fleur.Context.prototype.fn_boolean_1 = function() { return this; }; -Fleur.XPathFunctions_fn["boolean#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:boolean", - function(arg) { +Fleur.XPathFunctions_fn["boolean#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:boolean", Fleur.Context.prototype.fn_boolean_1, + [Fleur.SequenceType_item_0n], Fleur.SequenceType_boolean_1); +/* +function(arg) { var e; if (arg === Fleur.EmptySequence) { return false; @@ -98,4 +90,5 @@ Fleur.XPathFunctions_fn["boolean#1"] = new Fleur.Function("http://www.w3.org/200 e.name = "FORG0006"; return e; }, - null, [{type: Fleur.Node, occurence: "*"}], true, false, {type: Fleur.Type_boolean}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "*"}], true, false, {type: Fleur.Type_boolean}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/ceiling.js b/src/js/fleur.js/XPath/XPathFunctions/fn/ceiling.js index 715094b..d823375 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/ceiling.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/ceiling.js @@ -1,39 +1,28 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_ceiling_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.fn_ceiling_1 = function() { if (this.item.isNotEmpty()) { + const res = new Fleur.Text(); const op = Fleur.toJSValue(this.item, true, false, false, false, false, false); if (op[0] >= 0) { - this.item.data = String(Math.ceil(Number(op[1]))); - this.item.schemaTypeInfo = Fleur.Type_double; + res.data = String(Math.ceil(Number(op[1]))); + res.schemaTypeInfo = Fleur.Type_double; } + this.item = res; } return this; }; -Fleur.XPathFunctions_fn["ceiling#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:ceiling", +Fleur.XPathFunctions_fn["ceiling#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:ceiling", Fleur.Context.prototype.fn_ceiling_1, + [Fleur.SequenceType_numeric_01], Fleur.SequenceType_numeric_01); +/* function(a) { return a ? [typeof a[0] === "bigint" ? a[0] : Math.ceil(a[0]), a[1]] : null; }, - null, [{type: Fleur.numericTypes, adaptative: true, occurence: "?"}], false, false, {type: Fleur.numericTypes, adaptative: true, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.numericTypes, adaptative: true, occurence: "?"}], false, false, {type: Fleur.numericTypes, adaptative: true, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/codepoint-equal.js b/src/js/fleur.js/XPath/XPathFunctions/fn/codepoint-equal.js index 2359a4f..aa8a206 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/codepoint-equal.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/codepoint-equal.js @@ -1,34 +1,32 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_codepoint$_equal_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_codepoint$_equal_2 = function() { + const arg1 = this.itemstack.pop(); + const arg2 = this.item; + if (arg1.isEmpty()) { + this.item = arg1; + return this; + } + if (arg2.isEmpty()) { + return this; + } + const newitem = new Fleur.Text(); + newitem.schemaTypeInfo = Fleur.Type_boolean; + newitem.appendData(String(arg1.data === arg2.data)); + this.item = newitem; + return this; }; -Fleur.XPathFunctions_fn["codepoint-equal#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:codepoint-equal", +Fleur.XPathFunctions_fn["codepoint-equal#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:codepoint-equal", Fleur.Context.prototype.fn_codepoint$_equal_2, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_01], Fleur.SequenceType_boolean_01); +/* function(comparand1, comparand2) { return comparand1 === null || comparand2 === null ? null : comparand1 === comparand2; }, - null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_boolean, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_boolean, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/codepoints-to-string.js b/src/js/fleur.js/XPath/XPathFunctions/fn/codepoints-to-string.js index 3441012..e56ef0d 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/codepoints-to-string.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/codepoints-to-string.js @@ -1,29 +1,30 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_codepoint$_to$_string_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "*" - } - ] +Fleur.Context.prototype.fn_codepoints$_to$_string_1 = function() { + const newitem = new Fleur.Text(); + newitem.schemaTypeInfo = Fleur.Type_string; + if (this.item.isEmpty()) { + newitem.appendData(""); + } else if (this.item.nodeType === Fleur.Node.SEQUENCE_NODE) { + newitem.appendData(this.item.childNodes.reduce((a, c) => { + return a + String.fromCodePoint(Number(c.data)); + }, "")); + } else { + newitem.appendData(String.fromCodePoint(Number(this.item.data))); + } + this.item = newitem; + return this; }; -Fleur.XPathFunctions_fn["codepoints-to-string#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:codepoints-to-string", - function(arg) { +Fleur.XPathFunctions_fn["codepoints-to-string#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:codepoints-to-string", Fleur.Context.prototype.fn_codepoints$_to$_string_1, + [Fleur.SequenceType_codepoint_0n], Fleur.SequenceType_string_1); +/* +function(arg) { if (arg === null) { return ""; } @@ -48,4 +49,5 @@ Fleur.XPathFunctions_fn["codepoints-to-string#1"] = new Fleur.Function("http://w } return String.fromCodePoint(Number(arg)); }, - null, [{type: Fleur.Type_integer, occurence: "*"}], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [{type: Fleur.Type_integer, occurence: "*"}], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/compare.js b/src/js/fleur.js/XPath/XPathFunctions/fn/compare.js index 0fbf5e1..1cf3472 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/compare.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/compare.js @@ -1,41 +1,52 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_compare_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_compare_2 = function() { + const arg2 = this.item; + const arg1 = this.itemstack.pop(); + if (arg1.isEmpty()) { + this.item = arg1; + } else if (!arg2.isEmpty()) { + const res = new Fleur.Text(); + res.schemaTypeInfo = Fleur.Type_integer; + res.data = arg1.data === arg2.data ? "0" : arg1.data < arg2.data ? "-1" : "1"; + this.item = res; + } + return this; +}; +Fleur.Context.prototype.fn_compare_3 = function() { + const collation = this.item; + const arg2 = this.itemstack.pop(); + const arg1 = this.itemstack.pop(); + if (arg1.isEmpty()) { + this.item = arg1; + } else if (!arg2.isEmpty()) { + const res = new Fleur.Text(); + res.schemaTypeInfo = Fleur.Type_integer; + const c = Fleur.getCollation(collation.data); + res.data = c.equals(arg1.data, arg2.data) ? "0" : c.lessThan(arg1.data, arg2.data) ? "-1" : "1"; + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["compare#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:compare", +Fleur.XPathFunctions_fn["compare#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:compare", Fleur.Context.prototype.fn_compare_2, +[Fleur.SequenceType_string_01, Fleur.SequenceType_string_01], Fleur.SequenceType_integer_01); + +Fleur.XPathFunctions_fn["compare#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:compare", Fleur.Context.prototype.fn_compare_3, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_01, Fleur.SequenceType_collation_1], Fleur.SequenceType_integer_01); +/* + function(comparand1, comparand2) { return comparand1 === null || comparand2 === null ? null : comparand1 === comparand2 ? 0 : comparand1 < comparand2 ? -1 : 1; }, null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_integer, occurence: "?"}); - -Fleur.XPathFunctions_fn["compare#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:compare", +*/ +/* function(comparand1, comparand2, collation) { var c = Fleur.getCollation(collation); if (!c) { @@ -45,4 +56,5 @@ Fleur.XPathFunctions_fn["compare#3"] = new Fleur.Function("http://www.w3.org/200 } return comparand1 === null || comparand2 === null ? null : c.equals(comparand1, comparand2) ? 0 : c.lessThan(comparand1, comparand2) ? -1 : 1; }, - null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_integer, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_integer, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/concat.js b/src/js/fleur.js/XPath/XPathFunctions/fn/concat.js index b82dd45..ee24a4f 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/concat.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/concat.js @@ -1,43 +1,30 @@ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_concat = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.fn_concat = function(count) { if (this.item.isEmpty()) { this.item = new Fleur.Text(); this.item.data = ""; - this.item.schemaTypeInfo = Fleur.Type_string; } + const res = new Fleur.Text(this.item.data); for (let i = 1; i < count; i++) { const arg = this.itemstack.pop(); if (arg.isNotEmpty()) { - this.item.data = arg.data + this.item.data; + res.data = arg.data + res.data; } } + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; return this; }; -Fleur.XPathFunctions_fn["concat#"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:concat", +Fleur.XPathFunctions_fn["concat#"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:concat", Fleur.Context.prototype.fn_concat, + [], Fleur.SequenceType_string_1); +/* function() { var s = ""; var e; @@ -61,4 +48,5 @@ Fleur.XPathFunctions_fn["concat#"] = new Fleur.Function("http://www.w3.org/2005/ } return s; }, - null, [], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/contains-token.js b/src/js/fleur.js/XPath/XPathFunctions/fn/contains-token.js index 2660ad8..26c1a7c 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/contains-token.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/contains-token.js @@ -1,42 +1,67 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_contains$_token_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "*" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" +Fleur.Context.prototype.fn_contains$_token_2 = function() { + this.itemstack.push(this.item); + this.item = new Fleur.Text(); + this.item.data = "http://www.w3.org/2005/xpath-functions/collation/codepoint"; + this.item.schemaTypeInfo = Fleur.Type_collation; + this.fn_contains$_token_3(); + return this; +}; +Fleur.Context.prototype.fn_contains$_token_3 = function() { + const collation = this.item; + const token = this.itemstack.pop(); + const input = this.itemstack.pop(); + const res = new Fleur.Text(); + if (input.isEmpty() || token.isEmpty()) { + res.data = "false"; + } else { + const c = Fleur.getCollation(collation.data); + let result = "false"; + const ftokens = inputdata => { + const tokens = inputdata.split(" "); + for (let i = 0, l = tokens.length; i < l; i++) { + if (c.equals(tokens[i], token.data)) { + return true; + } + } + return false; + }; + if (input.nodeType !== Fleur.Node.SEQUENCE_NODE) { + result = String(ftokens(input.data)); + } else { + for (let i = 0, l = input.childNodes.length; i < l; i++) { + if (ftokens(input.childNodes[i].data)) { + result = "true"; + break; + } + } } - ] + res.data = result; + } + res.schemaTypeInfo = Fleur.Type_boolean; + this.item = res; + return this; }; -Fleur.XPathFunctions_fn["contains-token#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:contains-token", - function(input, token) { +Fleur.XPathFunctions_fn["contains-token#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:contains-token", Fleur.Context.prototype.fn_contains$_token_2, + [Fleur.SequenceType_string_0n, Fleur.SequenceType_string_1], Fleur.SequenceType_boolean_1); + +Fleur.XPathFunctions_fn["contains-token#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:contains-token", Fleur.Context.prototype.fn_contains$_token_3, + [Fleur.SequenceType_string_0n, Fleur.SequenceType_string_1, Fleur.SequenceType_string_1], Fleur.SequenceType_boolean_1); +/* +function(input, token) { return Fleur.XPathFunctions_fn["contains-token#3"].jsfunc(input, token, "http://www.w3.org/2005/xpath-functions/collation/codepoint"); }, null, [{type: Fleur.Type_string, occurence: "*"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_boolean}); - -Fleur.XPathFunctions_fn["contains-token#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:contains-token", - function(input, token, collation) { +*/ +/* +function(input, token, collation) { var c = Fleur.getCollation(collation); if (!c) { var e = new Error(""); @@ -63,4 +88,5 @@ Fleur.XPathFunctions_fn["contains-token#3"] = new Fleur.Function("http://www.w3. } return false; }, - null, [{type: Fleur.Type_string, occurence: "*"}, {type: Fleur.Type_string}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_boolean}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "*"}, {type: Fleur.Type_string}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_boolean}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/contains.js b/src/js/fleur.js/XPath/XPathFunctions/fn/contains.js index 80908c6..9d377df 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/contains.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/contains.js @@ -1,56 +1,58 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ - Fleur.signatures.fn_contains_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.fn_contains_2 = function() { const arg2 = this.item; const arg1 = this.itemstack.pop(); + const res = new Fleur.Text(); if (arg2.isNotEmpty()) { if (arg1.isNotEmpty()) { - this.item.data = String(arg1.data.indexOf(arg2.data) !== -1); + res.data = String(arg1.data.indexOf(arg2.data) !== -1); } else { - this.item = new Fleur.Text(); - this.item.data = String(arg2.data.length === 0); + res.data = String(arg2.data.length === 0); } } else { - this.item = new Fleur.Text(); - this.item.data = "true"; + res.data = "true"; } - this.item.schemaTypeInfo = Fleur.Type_boolean; + res.schemaTypeInfo = Fleur.Type_boolean; + this.item = res; + return this; +}; +Fleur.Context.prototype.fn_contains_3 = function() { + const collation = this.item; + const arg2 = this.itemstack.pop(); + const arg1 = this.itemstack.pop(); + const res = new Fleur.Text(); + if (arg2.isNotEmpty()) { + if (arg1.isNotEmpty()) { + const c = Fleur.getCollation(collation.data); + res.data = String(c.contains(arg1.data,arg2.data)); + } else { + res.data = String(arg2.data.length === 0); + } + } else { + res.data = "true"; + } + res.schemaTypeInfo = Fleur.Type_boolean; + this.item = res; return this; }; -Fleur.XPathFunctions_fn["contains#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:contains", - function(a, b) { +Fleur.XPathFunctions_fn["contains#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:contains", Fleur.Context.prototype.fn_contains_2, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_01], Fleur.SequenceType_boolean_01); +Fleur.XPathFunctions_fn["contains#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:contains", Fleur.Context.prototype.fn_contains_3, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_01, Fleur.SequenceType_string_1], Fleur.SequenceType_boolean_01); +/* +function(a, b) { return !b ? true : !a ? false : a.indexOf(b) !== -1; }, null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_boolean}); - -Fleur.XPathFunctions_fn["contains#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:contains", +*/ +/* function(a, b, collation) { var c = Fleur.getCollation(collation); if (!c) { @@ -60,4 +62,5 @@ Fleur.XPathFunctions_fn["contains#3"] = new Fleur.Function("http://www.w3.org/20 } return !b ? true : !a ? false : c.contains(a, b); }, - null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_boolean}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_boolean}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/count.js b/src/js/fleur.js/XPath/XPathFunctions/fn/count.js index e658166..4f54c0a 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/count.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/count.js @@ -1,24 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_count_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "1" - }, - params_type: [ - { - occurrence: "*" - } - ] -}; Fleur.Context.prototype.fn_count_1 = function() { const count = this.item.nodeType === Fleur.Node.SEQUENCE_NODE ? this.item.childNodes.length : 1; this.item = new Fleur.Text(); @@ -27,8 +13,11 @@ Fleur.Context.prototype.fn_count_1 = function() { return this; }; -Fleur.XPathFunctions_fn["count#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:count", +Fleur.XPathFunctions_fn["count#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:count", Fleur.Context.prototype.fn_count_1, + [Fleur.SequenceType_item_0n], Fleur.SequenceType_integer_1); +/* function(arg) { return arg === Fleur.EmptySequence ? 0 : arg.nodeType === Fleur.Node.SEQUENCE_NODE ? arg.childNodes.length : 1; }, - null, [{type: Fleur.Node, occurence: "*"}], false, false, {type: Fleur.Type_integer}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "*"}], false, false, {type: Fleur.Type_integer}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/current-date.js b/src/js/fleur.js/XPath/XPathFunctions/fn/current-date.js index 0b412bc..fd8fd8a 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/current-date.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/current-date.js @@ -1,23 +1,23 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_current$_date_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_date, - occurrence: "1" - }, - params_type: [] +Fleur.Context.prototype.fn_current$_date_0 = function() { + this.itemstack.push(this.item); + const item = new Fleur.Text(); + item.appendData(Fleur.dateToDate(Fleur.toDate(this.rs.now))); + item.schemaTypeInfo = Fleur.Type_date; + this.item = item; + return this; }; -Fleur.XPathFunctions_fn["current-date#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:current-date", - function(ctx) { +Fleur.XPathFunctions_fn["current-date#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:current-date", Fleur.Context.prototype.fn_current$_date_0, + [], Fleur.SequenceType_date_1, {dynonly: true}); +/* function(ctx) { return ctx.env.now; }, - null, [], true, false, {type: Fleur.Type_date}); \ No newline at end of file + null, [], true, false, {type: Fleur.Type_date}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/current-dateTime.js b/src/js/fleur.js/XPath/XPathFunctions/fn/current-dateTime.js index ead9ff1..4ed6616 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/current-dateTime.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/current-dateTime.js @@ -1,23 +1,24 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_current$_dateTime_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dateTime, - occurrence: "1" - }, - params_type: [] +Fleur.Context.prototype.fn_current$_dateTime_0 = function() { + this.itemstack.push(this.item); + const item = new Fleur.Text(); + item.appendData(this.rs.now); + item.schemaTypeInfo = Fleur.Type_dateTime; + this.item = item; + return this; }; -Fleur.XPathFunctions_fn["current-dateTime#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:current-dateTime", +Fleur.XPathFunctions_fn["current-dateTime#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:current-dateTime", Fleur.Context.prototype.fn_current$_dateTime_0, + [], Fleur.SequenceType_dateTime_1, {dynonly: true}); +/* function(ctx) { return ctx.env.now; }, - null, [], true, false, {type: Fleur.Type_dateTime}); \ No newline at end of file + null, [], true, false, {type: Fleur.Type_dateTime}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/current-time.js b/src/js/fleur.js/XPath/XPathFunctions/fn/current-time.js index 3df1f12..e0b111b 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/current-time.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/current-time.js @@ -1,23 +1,24 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_current$_time_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_time, - occurrence: "1" - }, - params_type: [] +Fleur.Context.prototype.fn_current$_time_0 = function() { + this.itemstack.push(this.item); + const item = new Fleur.Text(); + item.appendData(Fleur.dateToTime(Fleur.toTime(this.rs.now))); + item.schemaTypeInfo = Fleur.Type_date; + this.item = item; + return this; }; -Fleur.XPathFunctions_fn["current-time#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:current-time", +Fleur.XPathFunctions_fn["current-time#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:current-time", Fleur.Context.prototype.fn_current$_time_0, + [], Fleur.SequenceType_time_1, {dynonly: true}); +/* function(ctx) { return ctx.env.now; }, - null, [], true, false, {type: Fleur.Type_time}); \ No newline at end of file + null, [], true, false, {type: Fleur.Type_time}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/current.js b/src/js/fleur.js/XPath/XPathFunctions/fn/current.js index 54659b5..10c20e8 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/current.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/current.js @@ -1,19 +1,21 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_current_0 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [] +Fleur.Context.prototype.fn_current_0 = function() { + this.itemstack.push(this.item); + this.item = this.initialpath; + return this; }; -Fleur.XPathFunctions_fn["current#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:current", +Fleur.XPathFunctions_fn["current#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:current", Fleur.Context.prototype.fn_current_0, + [], Fleur.SequenceType_item_01); +/* function(ctx) { return ctx._item || ctx._curr; }, - null, [], true, false, {type: Fleur.Node}); \ No newline at end of file + null, [], true, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/data.js b/src/js/fleur.js/XPath/XPathFunctions/fn/data.js index 0188bc5..823463c 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/data.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/data.js @@ -1,25 +1,34 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_data_0 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [] +Fleur.Context.prototype.fn_data_0 = function() { + this.itemstack.push(this.item); + this.item = Fleur.Atomize(this.path, true); + return this; }; +Fleur.Context.prototype.fn_data_1 = function() { + this.item = Fleur.Atomize(this.item, true); + return this; +}; + +Fleur.XPathFunctions_fn["data#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:data", Fleur.Context.prototype.fn_data_0, + [], Fleur.SequenceType_anyAtomicType_0n); -Fleur.XPathFunctions_fn["data#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:data", - function(ctx) { +Fleur.XPathFunctions_fn["data#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:data", Fleur.Context.prototype.fn_data_1, + [Fleur.SequenceType_item_0n], Fleur.SequenceType_anyAtomicType_0n); +/* +function(ctx) { return Fleur.XPathFunctions_fn["data#1"].jsfunc(ctx._curr); }, null, [], true, false, {type: Fleur.Node, occurence: "*"}); - -Fleur.XPathFunctions_fn["data#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:data", - function(arg) { +*/ +/* +function(arg) { return Fleur.Atomize(arg, true); }, - null, [{type: Fleur.Node, occurence: "*"}], true, false, {type: Fleur.Node, occurence: "*"}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "*"}], true, false, {type: Fleur.Node, occurence: "*"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/dateTime.js b/src/js/fleur.js/XPath/XPathFunctions/fn/dateTime.js index 1bac594..f0e544b 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/dateTime.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/dateTime.js @@ -1,33 +1,38 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_dateTime_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dateTime, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_date, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_time, - occurrence: "?" +Fleur.Context.prototype.fn_dateTime_2 = function() { + const arg2 = this.item; + const arg1 = this.itemstack.pop(); + if (arg1.isEmpty()) { + this.item = arg1; + } else if (!arg2.isEmpty()) { + const res = new Fleur.Text(); + const dt = Fleur.toDate(arg1.data); + const tm = Fleur.toTime(arg2.data); + if (dt.tz === null) { + dt.tz = tm.tz; + } else if (dt.tz !== tm.tz && tm.tz !== null) { + Fleur.XQueryError_xqt("FORG0008", null, "Different time zones"); } - ] + dt.d.setHours(tm.d.getHours()); + dt.d.setMinutes(tm.d.getMinutes()); + dt.d.setSeconds(tm.d.getSeconds()); + dt.d.setMilliseconds(tm.d.getMilliseconds()); + res.schemaTypeInfo = Fleur.Type_dateTime; + res.data = Fleur.dateToDateTime(dt); + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["dateTime#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:dateTime", +Fleur.XPathFunctions_fn["dateTime#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:dateTime", Fleur.Context.prototype.fn_dateTime_2, + [Fleur.SequenceType_date_01, Fleur.SequenceType_time_01], Fleur.SequenceType_dateTime_01); +/* function(arg1, arg2) { if (arg1 === null || arg2 === null) { return null; @@ -47,4 +52,5 @@ Fleur.XPathFunctions_fn["dateTime#2"] = new Fleur.Function("http://www.w3.org/20 dt.d.setMilliseconds(tm.d.getMilliseconds()); return Fleur.dateToDateTime(dt); }, - null, [{type: Fleur.Type_date, occurence: "?"}, {type: Fleur.Type_time, occurence: "?"}], false, false, {type: Fleur.Type_dateTime, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_date, occurence: "?"}, {type: Fleur.Type_time, occurence: "?"}], false, false, {type: Fleur.Type_dateTime, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/day-from-date.js b/src/js/fleur.js/XPath/XPathFunctions/fn/day-from-date.js index c0b6174..4d51395 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/day-from-date.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/day-from-date.js @@ -1,29 +1,25 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_day$_from$_date_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_date, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_day$_from$_date_1 = function() { + if (this.item.isNotEmpty()) { + const res = new Fleur.Text(); + res.data = String(parseInt(this.item.data.match(/^\d{4}-\d{2}-(\d{2})(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10)); + res.schemaTypeInfo = Fleur.Type_integer; + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["day-from-date#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:day-from-date", +Fleur.XPathFunctions_fn["day-from-date#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:day-from-date", Fleur.Context.prototype.fn_day$_from$_date_1, + [Fleur.SequenceType_date_01], Fleur.SequenceType_integer_01); +/* function(arg) { return arg !== null ? parseInt(arg.match(/^\d{4}-\d{2}-(\d{2})(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10) : null; }, - null, [{type: Fleur.Type_date, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_date, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/day-from-dateTime.js b/src/js/fleur.js/XPath/XPathFunctions/fn/day-from-dateTime.js index d30d3d9..5c240a4 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/day-from-dateTime.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/day-from-dateTime.js @@ -1,29 +1,25 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_day$_from$_dateTime_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dateTime, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_day$_from$_dateTime_1 = function() { + if (this.item.isNotEmpty()) { + const res = new Fleur.Text(); + res.data = String(parseInt(this.item.data.match(/^\d{4}-\d{2}-(\d{2})T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10)); + res.schemaTypeInfo = Fleur.Type_integer; + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["day-from-dateTime#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:day-from-dateTime", +Fleur.XPathFunctions_fn["day-from-dateTime#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:day-from-dateTime", Fleur.Context.prototype.fn_day$_from$_dateTime_1, + [Fleur.SequenceType_dateTime_01], Fleur.SequenceType_integer_01); +/* function(arg) { return arg !== null ? parseInt(arg.match(/^\d{4}-\d{2}-(\d{2})T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10) : null; }, - null, [{type: Fleur.Type_dateTime, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_dateTime, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/days-from-duration.js b/src/js/fleur.js/XPath/XPathFunctions/fn/days-from-duration.js index 4726409..b4c81f3 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/days-from-duration.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/days-from-duration.js @@ -1,28 +1,33 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ - Fleur.signatures.fn_days$_from$_duration_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_duration, - occurrence: "?" +Fleur.Context.prototype.fn_days$_from$_duration_1 = function() { + if (this.item.isNotEmpty()) { + const a = this.item; + let signedd = 0; + if (a.schemaTypeInfo === Fleur.Type_dayTimeDuration) { + const d = Fleur.toJSONDayTimeDuration(a.data); + signedd = d.sign * d.day; + } + if (a.schemaTypeInfo !== Fleur.Type_yearMonthDuration) { + const d = Fleur.toJSONDuration(a.data); + signedd = d.sign * d.day; } - ] + const res = new Fleur.Text(); + res.schemaTypeInfo = Fleur.Type_integer; + res.data = Number(signedd); + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["days-from-duration#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:days-from-duration", +Fleur.XPathFunctions_fn["days-from-duration#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:days-from-duration", Fleur.Context.prototype.fn_days$_from$_duration_1, + [Fleur.SequenceType_duration_01], Fleur.SequenceType_integer_01); +/* function(arg) { var a = Fleur.Atomize(arg); var d; @@ -44,4 +49,5 @@ Fleur.XPathFunctions_fn["days-from-duration#1"] = new Fleur.Function("http://www e.name = "XPTY0004"; return e; }, - null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_integer, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_integer, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/deep-equal.js b/src/js/fleur.js/XPath/XPathFunctions/fn/deep-equal.js index 2c05d84..4c0e1c5 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/deep-equal.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/deep-equal.js @@ -1,26 +1,100 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_deep$_equal_2 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [null] +Fleur.Context.prototype.fn_deep$_equal_2 = function() { + this.itemstack.push(this.item); + this.item = new Fleur.Text(); + this.item.data = "http://www.w3.org/2005/xpath-functions/collation/codepoint"; + this.item.schemaTypeInfo = Fleur.Type_collation; + this.fn_deep$_equal_3(); + return this; +}; +Fleur.Context.fn_deep$_equal_3_ = function(parameter1, parameter2, c) { + if (parameter1.nodeType !== parameter2.nodeType) { + return false; + } + switch (parameter1.nodeType) { + case Fleur.Node.ELEMENT_NODE: + if (parameter1.localName !== parameter2.localName || parameter1.namespaceURI !== parameter2.namespaceURI) { + return false; + } + if (parameter1.attributes.some(function(attr) { + if ((attr.localName === "xmlns" && attr.namespaceURI === "http://www.w3.org/XML/1998/namespace") || attr.namespaceURI === "http://www.w3.org/2000/xmlns/") { + return false; + } + var attr2value = parameter2.getAttributeNS(attr.namespaceURI, attr.localName); + return !c.equals(attr.textContent, attr2value); + })) { + return false; + } + var r1 = parameter1.attributes.reduce(function(acc, attr) { + return (attr.localName === "xmlns" && attr.namespaceURI === "http://www.w3.org/XML/1998/namespace") || attr.namespaceURI === "http://www.w3.org/2000/xmlns/" ? acc : acc + 1; + }, 0); + var r2 = parameter2.attributes.reduce(function(acc, attr) { + return (attr.localName === "xmlns" && attr.namespaceURI === "http://www.w3.org/XML/1998/namespace") || attr.namespaceURI === "http://www.w3.org/2000/xmlns/" ? acc : acc + 1; + }, 0); + if (r1 !== r2) { + return false; + } + break; + case Fleur.Node.ATTRIBUTE_NODE: + return parameter1.localName === parameter2.localName && parameter1.namespaceURI === parameter2.namespaceURI && c.equals(parameter1.textContent, parameter2.textContent); + case Fleur.Node.PROCESSING_INSTRUCTION_NODE: + return parameter1.nodeName === parameter2.nodeName && c.equals(parameter1.data, parameter2.data); + case Fleur.Node.TEXT_NODE: + if ((parameter1.schemaTypeInfo === Fleur.Type_string || parameter1.schemaTypeInfo === Fleur.Type_untypedAtomic || parameter1.schemaTypeInfo === Fleur.Type_anyURI) && + (parameter2.schemaTypeInfo === Fleur.Type_string || parameter2.schemaTypeInfo === Fleur.Type_untypedAtomic || parameter2.schemaTypeInfo === Fleur.Type_anyURI)) { + return c.equals(parameter1.data, parameter2.data); + } + if (parameter1.schemaTypeInfo.as(Fleur.Type_numeric) && parameter2.schemaTypeInfo.as(Fleur.Type_numeric)) { + return (parameter1.data === "INF" && parameter2.data === "INF") || + (parameter1.data === "-INF" && parameter2.data === "-INF") || + (parameter1.data === "NaN" && parameter2.data === "NaN") || + parseFloat(parameter1.data) === parseFloat(parameter2.data); + } + return parameter1.schemaTypeInfo === parameter2.schemaTypeInfo && parameter1.data === parameter2.data; + } + if (parameter1.childNodes) { + if (parameter2.childNodes && parameter1.childNodes.length === parameter2.childNodes.length) { + return parameter1.childNodes.every(function(child, i) { + return Fleur.Context.fn_deep$_equal_3_(child, parameter2.childNodes[i], c); + }); + } + return false; + } + return true; +}; +Fleur.Context.prototype.fn_deep$_equal_3 = function() { + const collation = this.item; + const parameter2 = this.itemstack.pop(); + const parameter1 = this.itemstack.pop(); + const c = Fleur.getCollation(collation.data); + if (parameter1.nodeType === Fleur.Node.FUNCTION_NODE || parameter2.nodeType === Fleur.Node.FUNCTION_NODE) { + Fleur.XQueryError_xqt("FOTY0015", null, "Functions cannot be compared"); + } + const newitem = new Fleur.Text(); + newitem.schemaTypeInfo = Fleur.Type_boolean; + newitem.data = String(Fleur.Context.fn_deep$_equal_3_(parameter1, parameter2, c)); + this.item = newitem; + return this; }; -Fleur.XPathFunctions_fn["deep-equal#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:deep-equal", +Fleur.XPathFunctions_fn["deep-equal#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:deep-equal", Fleur.Context.prototype.fn_deep$_equal_2, + [Fleur.SequenceType_item_0n, Fleur.SequenceType_item_0n], Fleur.SequenceType_boolean_1); +/* function(parameter1, parameter2) { return Fleur.XPathFunctions_fn["deep-equal#3"].jsfunc(parameter1, parameter2, "http://www.w3.org/2005/xpath-functions/collation/codepoint"); }, null, [{type: Fleur.Node, occurence: "*"}, {type: Fleur.Node, occurence: "*"}], false, false, {type: Fleur.Type_boolean}); +*/ -Fleur.XPathFunctions_fn["deep-equal#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:deep-equal", +Fleur.XPathFunctions_fn["deep-equal#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:deep-equal", Fleur.Context.prototype.fn_deep$_equal_3, + [Fleur.SequenceType_item_0n, Fleur.SequenceType_item_0n, Fleur.SequenceType_string_1], Fleur.SequenceType_boolean_1); +/* function(parameter1, parameter2, collation) { var e; if (parameter1.nodeType === Fleur.Node.FUNCTION_NODE || parameter2.nodeType === Fleur.Node.FUNCTION_NODE) { @@ -89,4 +163,5 @@ Fleur.XPathFunctions_fn["deep-equal#3"] = new Fleur.Function("http://www.w3.org/ } return true; }, - null, [{type: Fleur.Node, occurence: "*"}, {type: Fleur.Node, occurence: "*"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_boolean}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "*"}, {type: Fleur.Node, occurence: "*"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_boolean}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/default-collation.js b/src/js/fleur.js/XPath/XPathFunctions/fn/default-collation.js index 7f0dfe0..fb0e0a1 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/default-collation.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/default-collation.js @@ -1,25 +1,24 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_default$_collation_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [] +Fleur.Context.prototype.fn_default$_collation_0 = function() { + this.itemstack.push(this.item); + const item = new Fleur.Text(); + item.appendData("http://www.w3.org/2005/xpath-functions/collation/codepoint"); + item.schemaTypeInfo = Fleur.Type_collation; + this.item = item; + return this; }; -Fleur.XPathFunctions_fn["default-collation#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:default-collation", +Fleur.XPathFunctions_fn["default-collation#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:default-collation", Fleur.Context.prototype.fn_default$_collation_0, + [], Fleur.SequenceType_string_1); +/* function() { return "http://www.w3.org/2005/xpath-functions/collation/codepoint"; }, - null, [], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/default-language.js b/src/js/fleur.js/XPath/XPathFunctions/fn/default-language.js new file mode 100644 index 0000000..94ff411 --- /dev/null +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/default-language.js @@ -0,0 +1,18 @@ +"use strict"; +/** + * @author Alain Couthures + * @license LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.Context.prototype.fn_default$_language_0 = function() { + this.itemstack.push(this.item); + const item = new Fleur.Text(); + item.appendData("en"); + item.schemaTypeInfo = Fleur.Type_language; + this.item = item; + return this; +}; + +Fleur.XPathFunctions_fn["default-language#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:default-language", Fleur.Context.prototype.fn_default$_language_0, + [], Fleur.SequenceType_language_1); \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/distinct-values.js b/src/js/fleur.js/XPath/XPathFunctions/fn/distinct-values.js index d07c0bf..96d51de 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/distinct-values.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/distinct-values.js @@ -1,27 +1,56 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ - Fleur.signatures.fn_distinct$_values_1 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [null] +Fleur.Context.prototype.fn_distinct$_values_1 = function() { + this.itemstack.push(this.item); + this.item = new Fleur.Text(); + this.item.data = "http://www.w3.org/2005/xpath-functions/collation/codepoint"; + this.item.schemaTypeInfo = Fleur.Type_collation; + this.fn_distinct$_values_2(); + return this; }; +Fleur.Context.prototype.fn_distinct$_values_2 = function() { + const collation = this.item; + const arg = this.itemstack.pop(); + if (arg.nodeType === Fleur.Node.SEQUENCE_NODE) { + const c = Fleur.getCollation(collation.data); + let result = new Fleur.Sequence(); + arg.childNodes.forEach(function(a) { + const opa = Fleur.toJSValue(a, true, true, true, true, false, false, true); + if (!result.childNodes.some(function(r) { + const opr = Fleur.toJSValue(r, true, true, true, true, false, false, true); + return Fleur.eqOp(opa, opr, c); + })) { + result.appendChild(a); + } + }); + if (result.childNodes.length === 1) { + result = result.childNodes[0]; + } + this.item = result; + } else { + this.item = arg; + } + return this; +}; + +Fleur.XPathFunctions_fn["distinct-values#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:distinct-values", Fleur.Context.prototype.fn_distinct$_values_1, + [Fleur.SequenceType_anyAtomicType_0n], Fleur.SequenceType_anyAtomicType_0n); -Fleur.XPathFunctions_fn["distinct-values#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:distinct-values", +Fleur.XPathFunctions_fn["distinct-values#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:distinct-values", Fleur.Context.prototype.fn_distinct$_values_2, + [Fleur.SequenceType_anyAtomicType_0n, Fleur.SequenceType_string_1], Fleur.SequenceType_anyAtomicType_0n); +/* function(arg) { return Fleur.XPathFunctions_fn["distinct-values#2"].jsfunc(arg, "http://www.w3.org/2005/xpath-functions/collation/codepoint"); }, null, [{type: Fleur.Node, occurence: "*"}], false, false, {type: Fleur.Node, occurence: "*"}); - -Fleur.XPathFunctions_fn["distinct-values#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:distinct-values", - function(arg, collation) { +*/ +/* +function(arg, collation) { var c = Fleur.getCollation(collation); if (!c) { var e = new Error(""); @@ -62,7 +91,7 @@ Fleur.XPathFunctions_fn["distinct-values#2"] = new Fleur.Function("http://www.w3 if (a.schemaTypeInfo && a.schemaTypeInfo.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "duration", Fleur.TypeInfo.DERIVATION_RESTRICTION) && r.schemaTypeInfo && r.schemaTypeInfo.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "duration", Fleur.TypeInfo.DERIVATION_RESTRICTION)) { return a.data === r.data; } - return a.schemaTypeInfo === r.schemaTypeInfo && a.data === r.data;*/ + return a.schemaTypeInfo === r.schemaTypeInfo && a.data === r.data; })) { result.appendChild(a); } @@ -72,4 +101,5 @@ Fleur.XPathFunctions_fn["distinct-values#2"] = new Fleur.Function("http://www.w3 } return result; }, - null, [{type: Fleur.Node, occurence: "*"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Node, occurence: "*"}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "*"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Node, occurence: "*"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/doc.js b/src/js/fleur.js/XPath/XPathFunctions/fn/doc.js index 987f1e6..419f686 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/doc.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/doc.js @@ -1,8 +1,7 @@ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ @@ -59,54 +58,15 @@ Fleur.encoding2encoding = { "utf-16": "utf16le" }; -Fleur.signatures.fn_doc_1 = { - need_ctx: false, - is_async: true, - return_type: null, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - } - ] -}; -Fleur.signatures.fn_doc_2 = { - need_ctx: false, - is_async: true, - return_type: null, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - null - ] -}; -Fleur.signatures.fn_doc_3 = { - need_ctx: false, - is_async: true, - return_type: null, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - null, - null - ] -}; -Fleur.Context.prototype.fn_doc_1_async = async function() { - await this.emptySequence().emptySequence().fn_doc_3_async(); +Fleur.Context.prototype.fn_doc_1 = async function() { + await this.emptySequence().emptySequence().fn_doc_3(); return this; }; -Fleur.Context.prototype.fn_doc_2_async = async function() { - await this.emptySequence().fn_doc_3_async(); +Fleur.Context.prototype.fn_doc_2 = async function() { + await this.emptySequence().fn_doc_3(); return this; }; -Fleur.Context.prototype.fn_doc_3_async = async function() { +Fleur.Context.prototype.fn_doc_3 = async function() { let contentType = null; let encoding = null; let jsserial = {}; @@ -147,7 +107,7 @@ Fleur.Context.prototype.fn_doc_3_async = async function() { options.headers["Content-Length"] = postdata.length; //console.log(postdata); } - var resdata = ""; + //var resdata = ""; } else { const response = await fetch(docname); this.item = parser.parseFromString(await response.text(), contentType || response.headers.get("Content-Type")); @@ -167,16 +127,8 @@ Fleur.Context.prototype.fn_doc_3_async = async function() { encoding = "utf8"; } //console.log(docname);console.log(process.cwd()); - const thisisit = this; - global.fs.readFile(docname, encoding, function(err, file) { - if (err) { - //console.log(err); - thisisit.item = Fleur.error(thisisit.ctx, "FODC0002"); - } else { - //console.log(file.charCodeAt(1)); - thisisit.item = parser.parseFromString(file.startsWith('\uFEFF') ? file.substr(1) : file, contentType); - } - }); + const file = await global.fsPromises.readFile(docname, encoding); + this.item = parser.parseFromString(file.startsWith('\uFEFF') ? file.substr(1) : file, contentType); } else if (cmdexec || ps1exec) { docname = decodeURIComponent(docname.substr(6)); if (!contentType) { @@ -210,19 +162,27 @@ Fleur.Context.prototype.fn_doc_3_async = async function() { } }; -Fleur.XPathFunctions_fn["doc#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:doc", +Fleur.XPathFunctions_fn["doc#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:doc", Fleur.Context.prototype.fn_doc_1, + [Fleur.SequenceType_string_01], Fleur.SequenceType_document_01, {dynonly: true, isasync: true}); + +Fleur.XPathFunctions_fn["doc#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:doc", Fleur.Context.prototype.fn_doc_2, + [Fleur.SequenceType_string_01, Fleur.SequenceType_item_01], Fleur.SequenceType_document_01, {dynonly: true, isasync: true}); + +Fleur.XPathFunctions_fn["doc#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:doc", Fleur.Context.prototype.fn_doc_3, + [Fleur.SequenceType_string_01, Fleur.SequenceType_item_01, Fleur.SequenceType_item_01], Fleur.SequenceType_document_01, {dynonly: true, isasync: true}); +/* function(docname, ctx, callback) { return Fleur.XPathFunctions_fn["doc#3"].jsfunc(docname, null, null, ctx, callback); }, null, [{type: Fleur.Type_string}], true, true, {type: Fleur.Node}); - -Fleur.XPathFunctions_fn["doc#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:doc", +*/ +/* function(docname, serialization, ctx, callback) { return Fleur.XPathFunctions_fn["doc#3"].jsfunc(docname, serialization, null, ctx, callback); }, null, [{type: Fleur.Type_string}, {type: Fleur.Node, occurence: "?"}], true, true, {type: Fleur.Node}); - -Fleur.XPathFunctions_fn["doc#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:doc", +*/ +/* function(docname, serialization, data, ctx, callback) { var contentType; var encoding; @@ -363,4 +323,5 @@ Fleur.XPathFunctions_fn["doc#3"] = new Fleur.Function("http://www.w3.org/2005/xp }); } }, - null, [{type: Fleur.Type_string}, {type: Fleur.Node, occurence: "?"}, {type: Fleur.Node, occurence: "?"}], true, true, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Type_string}, {type: Fleur.Node, occurence: "?"}, {type: Fleur.Node, occurence: "?"}], true, true, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/document-uri.js b/src/js/fleur.js/XPath/XPathFunctions/fn/document-uri.js index e5b4952..201258f 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/document-uri.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/document-uri.js @@ -1,28 +1,37 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_document$_uri_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyURI, - occurrence: "?" - }, - params_type: [null] +Fleur.Context.prototype.fn_document$_uri_0 = function() { + this.itemstack.push(this.item); + const item = new Fleur.Text(); + item.appendData("urn:from-string"); + item.schemaTypeInfo = Fleur.Type_anyURI; + this.item = item; + return this; +}; +Fleur.Context.prototype.fn_document$_uri_1 = function() { + const item = new Fleur.Text(); + item.appendData("urn:from-string"); + item.schemaTypeInfo = Fleur.Type_anyURI; + this.item = item; + return this; }; -Fleur.XPathFunctions_fn["document-uri#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:document-uri", - function(ctx) { +Fleur.XPathFunctions_fn["document-uri#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:document-uri", Fleur.Context.prototype.fn_document$_uri_0, + [], Fleur.SequenceType_anyURI_01, {dynonly: true}); + +Fleur.XPathFunctions_fn["document-uri#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:document-uri", Fleur.Context.prototype.fn_document$_uri_1, + [Fleur.SequenceType_item_01], Fleur.SequenceType_anyURI_01, {dynonly: true}); +/* function(ctx) { return Fleur.XPathFunctions_fn["document-uri#1"].jsfunc(ctx._curr); }, null, [], true, false, {type: Fleur.Type_anyURI}); - -Fleur.XPathFunctions_fn["document-uri#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:document-uri", +*/ +/* function(node) { if (node === Fleur.EmptySequence) { return null; @@ -34,4 +43,5 @@ Fleur.XPathFunctions_fn["document-uri#1"] = new Fleur.Function("http://www.w3.or } return ""; }, - null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_anyURI}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_anyURI}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/empty.js b/src/js/fleur.js/XPath/XPathFunctions/fn/empty.js index 4233ed3..6f55078 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/empty.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/empty.js @@ -1,20 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_empty_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "1" - }, - params_type: [null] -}; Fleur.Context.prototype.fn_empty_1 = function() { const isempty = this.item.isEmpty(); this.item = new Fleur.Text(); @@ -23,8 +13,11 @@ Fleur.Context.prototype.fn_empty_1 = function() { return this; }; -Fleur.XPathFunctions_fn["empty#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:empty", +Fleur.XPathFunctions_fn["empty#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:empty", Fleur.Context.prototype.fn_empty_1, + [Fleur.SequenceType_item_0n], Fleur.SequenceType_boolean_1); +/* function(arg) { return arg === Fleur.EmptySequence; }, - null, [{type: Fleur.Node, occurence: "*"}], false, false, {type: Fleur.Type_boolean}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "*"}], false, false, {type: Fleur.Type_boolean}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/encode-for-uri.js b/src/js/fleur.js/XPath/XPathFunctions/fn/encode-for-uri.js index bd61dc6..6bae743 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/encode-for-uri.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/encode-for-uri.js @@ -1,29 +1,27 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_encode$_for$_uri_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_encode$_for$_uri_1 = function() { + const res = new Fleur.Text(); + if (this.item.isNotEmpty()) { + res.data = encodeURIComponent(this.item.data).replace(/[!'()*]/g, function(c) {return '%' + c.charCodeAt(0).toString(16).toUpperCase();}); + } else { + res.data = ""; + } + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; + return this; }; -Fleur.XPathFunctions_fn["encode-for-uri#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:encode-for-uri", +Fleur.XPathFunctions_fn["encode-for-uri#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:encode-for-uri", Fleur.Context.prototype.fn_encode$_for$_uri_1, + [Fleur.SequenceType_string_01], Fleur.SequenceType_string_1); +/* function(uripart) { return uripart !== null ? encodeURIComponent(uripart).replace(/[!'()*]/g, function(c) {return '%' + c.charCodeAt(0).toString(16).toUpperCase();}) : ""; }, - null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/ends-with.js b/src/js/fleur.js/XPath/XPathFunctions/fn/ends-with.js index 0f1d971..01f4569 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/ends-with.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/ends-with.js @@ -1,56 +1,59 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ - Fleur.signatures.fn_ends$_with_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.fn_ends$_with_2 = function() { const arg2 = this.item; const arg1 = this.itemstack.pop(); + const res = new Fleur.Text(); + if (arg2.isNotEmpty()) { + if (arg1.isNotEmpty()) { + res.data = String(arg1.data.endsWith(arg2.data)); + } else { + res.data = String(arg2.data.length === 0); + } + } else { + res.data = "true"; + } + res.schemaTypeInfo = Fleur.Type_boolean; + this.item = res; + return this; +}; +Fleur.Context.prototype.fn_ends$_with_3 = function() { + const collation = this.item; + const arg2 = this.itemstack.pop(); + const arg1 = this.itemstack.pop(); + const res = new Fleur.Text(); if (arg2.isNotEmpty()) { if (arg1.isNotEmpty()) { - this.item.data = String(arg1.data.endsWith(arg2.data)); + const c = Fleur.getCollation(collation.data); + res.data = String(c.endsWith(arg1.data, arg2.data)); } else { - this.item = new Fleur.Text(); - this.item.data = String(arg2.data.length === 0); + res.data = String(arg2.data.length === 0); } } else { - this.item = new Fleur.Text(); - this.item.data = "true"; + res.data = "true"; } - this.item.schemaTypeInfo = Fleur.Type_boolean; + res.schemaTypeInfo = Fleur.Type_boolean; + this.item = res; return this; }; -Fleur.XPathFunctions_fn["ends-with#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:ends-with", +Fleur.XPathFunctions_fn["ends-with#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:ends-with", Fleur.Context.prototype.fn_ends$_with_2, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_01], Fleur.SequenceType_boolean_1); + +Fleur.XPathFunctions_fn["ends-with#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:ends-with", Fleur.Context.prototype.fn_ends$_with_3, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_01, Fleur.SequenceType_string_1], Fleur.SequenceType_boolean_1); +/* function(a, b) { return !b ? true : !a ? false : a.endsWith(b); }, null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_boolean}); - -Fleur.XPathFunctions_fn["ends-with#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:ends-with", +*/ +/* function(a, b, collation) { var c = Fleur.getCollation(collation); if (!c) { @@ -60,4 +63,5 @@ Fleur.XPathFunctions_fn["ends-with#3"] = new Fleur.Function("http://www.w3.org/2 } return !b ? true : !a ? false : c.endsWith(a, b); }, - null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_boolean}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_boolean}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/error.js b/src/js/fleur.js/XPath/XPathFunctions/fn/error.js index d036d98..63ac1ed 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/error.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/error.js @@ -1,73 +1,64 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_error_0 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [] +Fleur.Context.prototype.fn_error_0 = function() { + this.emptySequence().emptySequence().emptySequence().fn_error_3(); }; - -Fleur.signatures.fn_error_1 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [null] +Fleur.Context.prototype.fn_error_1 = function() { + this.emptySequence().emptySequence().fn_error_3(); }; - -Fleur.signatures.fn_error_2 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - null, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_error_2 = function() { + this.emptySequence().fn_error_3(); }; - -Fleur.signatures.fn_error_3 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - null, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - null - ] +Fleur.Context.prototype.fn_error_3 = function() { + //const errorObject = this.item; + const description = this.itemstack.pop(); + const code = this.itemstack.pop(); + let namespaceURI = "http://www.w3.org/2005/xqt-errors"; + let localName = "FOER0000"; + let prefix = "err"; + if (code.isNotEmpty()) { + namespaceURI = code.namespaceURI; + localName = code.localName; + prefix = code.prefix; + } + Fleur.XQueryError(namespaceURI, localName, prefix, null, description.data, null, null, null); }; -Fleur.XPathFunctions_fn["error#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:error", +Fleur.XPathFunctions_fn["error#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:error", Fleur.Context.prototype.fn_error_0, + [], null, {dynonly: true}); + +Fleur.XPathFunctions_fn["error#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:error", Fleur.Context.prototype.fn_error_1, + [Fleur.SequenceType_QName_01], null, {dynonly: true}); + +Fleur.XPathFunctions_fn["error#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:error", Fleur.Context.prototype.fn_error_2, + [Fleur.SequenceType_QName_01, Fleur.SequenceType_string_01], null, {dynonly: true}); + +Fleur.XPathFunctions_fn["error#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:error", Fleur.Context.prototype.fn_error_3, + [Fleur.SequenceType_QName_01, Fleur.SequenceType_string_01, Fleur.SequenceType_item_0n], null, {dynonly: true}); +/* function(ctx) { return Fleur.XPathFunctions_fn["error#3"].jsfunc(null, null, null, ctx); }, null, [], true, false, {type: Fleur.Node}); - -Fleur.XPathFunctions_fn["error#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:error", - function(code, ctx) { +*/ +/* +function(code, ctx) { return Fleur.XPathFunctions_fn["error#3"].jsfunc(code, null, null, ctx); }, null, [{type: Fleur.Node, occurence: "?"}], true, false, {type: Fleur.Node}); - -Fleur.XPathFunctions_fn["error#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:error", +*/ +/* function(code, description, ctx) { return Fleur.XPathFunctions_fn["error#3"].jsfunc(code, description, null, ctx); }, null, [{type: Fleur.Node, occurence: "?"}, {type: Fleur.Type_string}], true, false, {type: Fleur.Node}); - -Fleur.XPathFunctions_fn["error#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:error", - function(code, description, errorObject, ctx) { +*/ +/* function(code, description, errorObject, ctx) { var a = new Fleur.Text(); a.schemaTypeInfo = Fleur.Type_error; if (!code || code === Fleur.EmptySequence) { @@ -84,4 +75,5 @@ Fleur.XPathFunctions_fn["error#3"] = new Fleur.Function("http://www.w3.org/2005/ } return a; }, - null, [{type: Fleur.Node, occurence: "?"}, {type: Fleur.Type_string}, {type: Fleur.Node, occurence: "*"}], true, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}, {type: Fleur.Type_string}, {type: Fleur.Node, occurence: "*"}], true, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/escape-html-uri.js b/src/js/fleur.js/XPath/XPathFunctions/fn/escape-html-uri.js index ee899b6..fe112b3 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/escape-html-uri.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/escape-html-uri.js @@ -1,39 +1,27 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_escape$_html$_uri_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.fn_escape$_html$_uri_1 = function() { + const res = new Fleur.Text(); if (this.item.isNotEmpty()) { - this.item.data = this.item.data.replace(/[^ -~]/g, function(c) {return encodeURIComponent(c);}); + res.data = this.item.data.replace(/[^ -~]/g, function(c) {return encodeURIComponent(c);}); } else { - this.item = new Fleur.Text(); - this.item.data = ""; + res.data = ""; } - this.item.schemaTypeInfo = Fleur.Type_string; + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; return this; }; -Fleur.XPathFunctions_fn["escape-html-uri#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:escape-html-uri", +Fleur.XPathFunctions_fn["escape-html-uri#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:escape-html-uri", Fleur.Context.prototype.fn_escape$_html$_uri_1, + [Fleur.SequenceType_string_01], Fleur.SequenceType_string_1); +/* function(s) { return !s ? "" : s.replace(/[^ -~]/g, function(c) {return encodeURIComponent(c);}); }, - null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/evaluate.js b/src/js/fleur.js/XPath/XPathFunctions/fn/evaluate.js index ad92f11..c3eadb7 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/evaluate.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/evaluate.js @@ -1,39 +1,28 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_evaluate_1 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.fn_evaluate_1 = function() { if (this.item.isNotEmpty()) { - const jsret = Fleur.XPathEvaluator._xp2js(this.item.data, "", ""); - let arr; - eval("arr = " + jsret + ";"); + const jsret = Fleur.XQueryParser._xp2js(this.item.data, [], [], 0); try { - const jsresult = (new Fleur.Transpiler("ctx", " ")).funcdef(arr); + const jsresult = (new Fleur.Transpiler("ctx", " ")).funcdef(jsret); try { - this.item = (eval("(" + jsresult + ")(new Fleur.Context())")).item; + this.item = (eval("(" + jsresult.inst + ")(new Fleur.Context())")).item; } catch(e) {} } catch(e) {} } return this; }; -Fleur.XPathFunctions_fn["evaluate#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:evaluate", +Fleur.XPathFunctions_fn["evaluate#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:evaluate", Fleur.Context.prototype.fn_evaluate_1, + [Fleur.SequenceType_string_01], Fleur.SequenceType_item_0n, {dynonly: true}); +/* function(arg) { return arg !== Fleur.EmptySequence; }, - null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Node, occurence: "*"}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Node, occurence: "*"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/exactly-one.js b/src/js/fleur.js/XPath/XPathFunctions/fn/exactly-one.js index c43c32e..a835873 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/exactly-one.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/exactly-one.js @@ -1,29 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_exactly$_one_1 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - { - occurrence: "*" - } - ] -}; Fleur.Context.prototype.fn_exactly$_one_1 = function() { if (this.item.nodeType === Fleur.Node.SEQUENCE_NODE) { - + Fleur.XQueryError_xqt("FORG0005", null, "Wrong argument type for fn:exactly-one#1", "", this.item); } return this; }; -Fleur.XPathFunctions_fn["exactly-one#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:exactly-one", - function(arg, ctx) { +Fleur.XPathFunctions_fn["exactly-one#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:exactly-one", Fleur.Context.prototype.fn_exactly$_one_1, + [Fleur.SequenceType_item_0n], Fleur.SequenceType_item_1, {dynonly: true}); +/* function(arg, ctx) { if (arg.nodeType === Fleur.Node.SEQUENCE_NODE) { var err = Fleur.error(ctx, "FORG0005"); var result = err; @@ -37,4 +28,5 @@ Fleur.XPathFunctions_fn["exactly-one#1"] = new Fleur.Function("http://www.w3.org return arg; } }, - null, [{type: Fleur.Node, occurence: "*"}], true, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "*"}], true, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/exists.js b/src/js/fleur.js/XPath/XPathFunctions/fn/exists.js index 1609291..cdbeb2e 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/exists.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/exists.js @@ -1,34 +1,23 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_exists_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "1" - }, - params_type: [ - { - occurrence: "*" - } - ] -}; Fleur.Context.prototype.fn_exists_1 = function() { const previtem = this.item; this.item = new Fleur.Text(); - this.item.data = String(previtem.isNotEmpty()) + this.item.data = String(previtem.isNotEmpty()); this.item.schemaTypeInfo = Fleur.Type_boolean; return this; }; -Fleur.XPathFunctions_fn["exists#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:exists", +Fleur.XPathFunctions_fn["exists#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:exists", Fleur.Context.prototype.fn_exists_1, + [Fleur.SequenceType_item_0n], Fleur.SequenceType_boolean_1); +/* function(arg) { return arg !== Fleur.EmptySequence; }, - null, [{type: Fleur.Node, occurence: "*"}], false, false, {type: Fleur.Type_boolean}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "*"}], false, false, {type: Fleur.Type_boolean}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/false.js b/src/js/fleur.js/XPath/XPathFunctions/fn/false.js index a5a30d5..ebc7d1a 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/false.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/false.js @@ -1,21 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_false_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "1" - }, - params_type: [] -}; - Fleur.Context.prototype.fn_false_0 = function() { this.itemstack.push(this.item); const item = new Fleur.Text(); @@ -25,8 +14,11 @@ Fleur.Context.prototype.fn_false_0 = function() { return this; }; -Fleur.XPathFunctions_fn["false#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:false", +Fleur.XPathFunctions_fn["false#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:false", Fleur.Context.prototype.fn_false_0, + [], Fleur.SequenceType_boolean_1); +/* function() { return false; }, - null, [], false, false, {type: Fleur.Type_boolean}); \ No newline at end of file + null, [], false, false, {type: Fleur.Type_boolean}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/floor.js b/src/js/fleur.js/XPath/XPathFunctions/fn/floor.js index fa0b393..073602a 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/floor.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/floor.js @@ -1,39 +1,28 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_floor_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.fn_floor_1 = function() { if (this.item.isNotEmpty()) { const op = Fleur.toJSValue(this.item, true, false, false, false, false, false); if (op[0] >= 0) { - this.item.data = String(Math.floor(Number(op[1]))); - this.item.schemaTypeInfo = Fleur.Type_double; + const res = new Fleur.Text(); + res.data = String(Math.floor(Number(op[1]))); + res.schemaTypeInfo = Fleur.Type_double; + this.item = res; } } return this; }; -Fleur.XPathFunctions_fn["floor#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:floor", +Fleur.XPathFunctions_fn["floor#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:floor", Fleur.Context.prototype.fn_floor_1, + [Fleur.SequenceType_numeric_01], Fleur.SequenceType_numeric_01); +/* function(a) { return a ? [typeof a[0] === "bigint" ? a[0] : Math.floor(a[0]), a[1]] : null; }, - null, [{type: Fleur.numericTypes, adaptative: true, occurence: "?"}], false, false, {type: Fleur.numericTypes, adaptative: true, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.numericTypes, adaptative: true, occurence: "?"}], false, false, {type: Fleur.numericTypes, adaptative: true, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/format-date.js b/src/js/fleur.js/XPath/XPathFunctions/fn/format-date.js index 248fa09..201a7d9 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/format-date.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/format-date.js @@ -1,40 +1,31 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_format$_date_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_date, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - } - ] +Fleur.Context.prototype.fn_format$_date_2 = function() { + return this.emptySequence().emptySequence().emptySequence().fn_format$_dateTime_5(false, true); +}; +Fleur.Context.prototype.fn_format$_date_5 = function() { + return this.fn_format$_dateTime_5(false, true); }; -Fleur.XPathFunctions_fn["format-date#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:format-date", +Fleur.XPathFunctions_fn["format-date#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:format-date", Fleur.Context.prototype.fn_format$_date_2, + [Fleur.SequenceType_date_01, Fleur.SequenceType_string_1], Fleur.SequenceType_string_01); + +Fleur.XPathFunctions_fn["format-date#5"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:format-date", Fleur.Context.prototype.fn_format$_date_5, + [Fleur.SequenceType_date_01, Fleur.SequenceType_string_1, Fleur.SequenceType_string_01, Fleur.SequenceType_string_01, Fleur.SequenceType_string_01], Fleur.SequenceType_string_01); +/* function(value, picture, ctx) { return Fleur.XPathFunctions_fn["format-dateTime#5"].jsfunc(value, picture, null, null, null, ctx, true, false); }, null, [{type: Fleur.Type_date, occurence: "?"}, {type: Fleur.Type_string}], true, false, {type: Fleur.Type_string, occurence: "?"}); - -Fleur.XPathFunctions_fn["format-date#5"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:format-date", +*/ +/* function(value, picture, language, calendar, place, ctx) { return Fleur.XPathFunctions_fn["format-dateTime#5"].jsfunc(value, picture, language, calendar, place, ctx, true, false); }, - null, [{type: Fleur.Type_date, occurence: "?"}, {type: Fleur.Type_string}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}], true, false, {type: Fleur.Type_string, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_date, occurence: "?"}, {type: Fleur.Type_string}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}], true, false, {type: Fleur.Type_string, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/format-dateTime.js b/src/js/fleur.js/XPath/XPathFunctions/fn/format-dateTime.js index ee149fe..7eb92a4 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/format-dateTime.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/format-dateTime.js @@ -1,41 +1,187 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_format$_dateTime_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dateTime, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" +Fleur.Context.prototype.fn_format$_dateTime_2 = function() { + return this.emptySequence().emptySequence().emptySequence().fn_format$_dateTime_5(false, false); +}; +Fleur.Context.prototype.fn_format$_dateTime_5 = function(nodate, notime) { + //const place = this.item.data; + //const calendar = + this.itemstack.pop(); + const language = this.itemstack.pop().data || Fleur.defaultLanguage; + const picture = this.itemstack.pop().data; + const valueitem = this.itemstack.pop(); + const value = valueitem.data; + let s = ""; + let i = 0, l = picture.length; + let format = ""; + let pdate = false; + let ptime = false; + let valueDate = notime ? Fleur.toDate(value) : nodate ? Fleur.toTime(value) : Fleur.toDateTime(value); + while (i < l) { + var c = picture.charAt(i); + var prec = ""; + while (c !== "[" && i < l) { + if (c !== "]") { + s += c; + } else if (prec === c) { + s += c; + c = ""; + } + prec = c; + c = picture.charAt(++i); + } + if (c === "[") { + c = picture.charAt(++i); + if (c === "[") { + s += c; + i++; + } else { + format = ""; + while (c !== "]" && i < l) { + format += c; + c = picture.charAt(++i); + } + if (c === "]") { + var intvalue = null, stringvalue = null; + switch(format.charAt(0)) { + case "Y": + pdate = true; + if (format.charAt(1).toLowerCase() === "i") { + stringvalue = Fleur.convertToRoman(parseInt(value.substr(0, 4), 10)); + if (format.charAt(1) === "i") { + stringvalue = stringvalue.toLowerCase(); + } + } else { + intvalue = parseInt(value.substr(0, 4), 10); + } + break; + case "M": + pdate = true; + if (format.charAt(1).toLowerCase() === "i") { + stringvalue = Fleur.convertToRoman(parseInt(value.substr(5, 2), 10)); + if (format.charAt(1) === "i") { + stringvalue = stringvalue.toLowerCase(); + } + } else if (format.charAt(1).toLowerCase() === "n") { + stringvalue = Fleur.getMonthName(language, valueDate.d); + if (format.charAt(1) === "N") { + if (format.charAt(2) === "n") { + stringvalue = stringvalue.charAt(0).toUpperCase() + stringvalue.substr(1).toLowerCase(); + } else { + stringvalue = stringvalue.toUpperCase(); + } + } else { + stringvalue = stringvalue.toLowerCase(); + } + } else { + intvalue = parseInt(value.substr(5, 2), 10); + } + break; + case "D": + pdate = true; + intvalue = parseInt(value.substr(8, 2), 10); + break; + case "d": + break; + case "F": + pdate = true; + stringvalue = Fleur.getDayName(language, valueDate.d); + if (format.charAt(1) === "N") { + if (format.charAt(2) === "n") { + stringvalue = stringvalue.charAt(0).toUpperCase() + stringvalue.substr(1).toLowerCase(); + } else { + stringvalue = stringvalue.toUpperCase(); + } + } else { + stringvalue = stringvalue.toLowerCase(); + } + break; + case "W": + break; + case "w": + break; + case "H": + break; + case "h": + ptime = true; + intvalue = parseInt(value.substr(nodate ? 0 : 11, 2), 10); + break; + case "P": + break; + case "m": + ptime = true; + intvalue = parseInt(value.substr(nodate ? 3 : 14, 2), 10); + break; + case "s": + ptime = true; + intvalue = parseInt(value.substr(nodate ? 6 : 17, 2), 10); + break; + case "f": + break; + case "Z": + break; + case "z": + break; + case "C": + break; + case "E": + break; + } + if ((ptime && notime) || (pdate && nodate)) { + Fleur.XQueryError_xqt("FOFD1350", null, "Wrong argument type for fn:format-dateTime#5", "", valueitem); + } + if (intvalue !== null || stringvalue !== null) { + format = format.split(','); + var maxw, minw; + if (format[1]) { + var ws = format[1].split('-'); + minw = ws[0] === "*" ? 1 : parseInt(ws[0], 10); + maxw = !ws[1] || ws[1] === "*" ? Infinity : parseInt(ws[1], 10); + } else { + minw = Math.max(format[0].length - 1, 1); + maxw = Infinity; + } + if (intvalue !== null) { + stringvalue = String(intvalue); + } + stringvalue = "0".repeat(Math.max(minw - stringvalue.length, 0)) + stringvalue; + if (stringvalue.length > maxw) { + if (format[0].charAt(0) === 'Y') { + stringvalue = stringvalue.substring(stringvalue.length - maxw); + } + } + } + if (stringvalue !== null) { + s += stringvalue; + } + i++; + } + } } - ] + } + this.item = new Fleur.Text(); + this.item.schemaTypeInfo = Fleur.Type_string; + this.item.data = s; + return this; }; -Fleur.XPathFunctions_fn["format-dateTime#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:format-dateTime", +Fleur.XPathFunctions_fn["format-dateTime#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:format-dateTime", Fleur.Context.prototype.fn_format$_dateTime_2, + [Fleur.SequenceType_dateTime_01, Fleur.SequenceType_string_1], Fleur.SequenceType_string_01); + +Fleur.XPathFunctions_fn["format-dateTime#5"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:format-dateTime", Fleur.Context.prototype.fn_format$_dateTime_5, +[Fleur.SequenceType_dateTime_01, Fleur.SequenceType_string_1, Fleur.SequenceType_string_01, Fleur.SequenceType_string_01, Fleur.SequenceType_string_01], Fleur.SequenceType_string_01); +/* function(value, picture, ctx) { return Fleur.XPathFunctions_fn["format-dateTime#5"].jsfunc(value, picture, null, null, null, ctx, false, false); }, null, [{type: Fleur.Type_dateTime, occurence: "?"}, {type: Fleur.Type_string}], true, false, {type: Fleur.Type_string, occurence: "?"}); - -Fleur.XPathFunctions_fn["format-dateTime#5"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:format-dateTime", +*/ +/* function(value, picture, language, calendar, place, ctx, notime, nodate) { var s = ""; var i = 0, l = picture.length; @@ -188,4 +334,5 @@ Fleur.XPathFunctions_fn["format-dateTime#5"] = new Fleur.Function("http://www.w3 } return s; }, - null, [{type: Fleur.Type_dateTime, occurence: "?"}, {type: Fleur.Type_string}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}], true, false, {type: Fleur.Type_string, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_dateTime, occurence: "?"}, {type: Fleur.Type_string}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}], true, false, {type: Fleur.Type_string, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/format-integer.js b/src/js/fleur.js/XPath/XPathFunctions/fn/format-integer.js index cd329f3..65ad66a 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/format-integer.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/format-integer.js @@ -1,32 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_format$_integer_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - } - ] -}; - Fleur.romanValues = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]; Fleur.romanLetters = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"]; Fleur.convertToRoman = function(num, index) { @@ -40,7 +18,230 @@ Fleur.convertToRoman = function(num, index) { } }; -Fleur.XPathFunctions_fn["format-integer#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:format-integer", +Fleur.Context.prototype.fn_format$_integer_2 = function() { + let picture = this.item.data; + const valueitem = this.itemstack.pop(); + if (valueitem.isNotEmpty()) { + const res = new Fleur.Text(); + let value = Fleur.BigInt(valueitem.data); + let sres = ""; + let i, j, l, l2, pictures, dss, ess, ps, pms, ms, msbefore, psafter, pmsafter, signs, esigns, iipgp, ipgp, mips, prefix, fstart, fpgp, minfps, maxfps, mes, suffix, dsspos, evalue, esign, s0, s; + pictures = picture.split(";"); + picture = value < 0 && pictures[1] ? pictures[1] : pictures[0]; + signs = ".,-%\u2030#0123456789"; + esigns = ".,e-%\u2030#0123456789"; + i = 0; + l = picture.length; + while (i < l && signs.indexOf(picture.charAt(i)) === -1) { + i++; + } + prefix = picture.substring(0, i); + dss = ess = ps = pms = false; + mips = 0; + minfps = 0; + maxfps = 0; + mes = 0; + iipgp = []; + ipgp = []; + fpgp = []; + while (i < l && esigns.indexOf(picture.charAt(i)) !== -1) { + switch (picture.charAt(i)) { + case ".": + dss = true; + fstart = i + 1; + j = 0; + l2 = iipgp.length; + while (j < l2) { + ipgp[l2 - j - 1] = i - iipgp[j] - 1; + j++; + } + break; + case ",": + if (dss) { + fpgp.push(i - fstart); + } else { + iipgp.push(i); + } + break; + case "e": + ess = true; + if (!dss) { + j = 0; + l2 = iipgp.length; + while (j < l2) { + ipgp[l2 - j - 1] = i - iipgp[j] - 1; + j++; + } + } + break; + case "-": + ms = true; + msbefore = mips === 0; + break; + case "%": + ps = true; + psafter = mips !== 0; + value *= Fleur.BigInt(100); + if (!dss) { + j = 0; + l2 = iipgp.length; + while (j < l2) { + ipgp[l2 - j - 1] = i - iipgp[j] - 1; + j++; + } + } + break; + case "\u2030": + pms = true; + pmsafter = mips !== 0; + value *= Fleur.BigInt(1000); + if (!dss) { + j = 0; + l2 = iipgp.length; + while (j < l2) { + ipgp[l2 - j - 1] = i - iipgp[j] - 1; + j++; + } + } + break; + case "0": + case "1": + case "2": + case "3": + case "4": + case "5": + case "6": + case "7": + case "8": + case "9": + if (ess) { + mes++; + } else if (dss) { + minfps++; + maxfps++; + } else { + mips++; + } + break; + case "#": + if (dss) { + maxfps++; + } + break; + } + i++; + } + if (!dss) { + if (iipgp.length !== ipgp.length) { + j = 0; + l2 = iipgp.length; + while (j < l2) { + ipgp[l2 - j - 1] = i - iipgp[j] - 1; + j++; + } + } + if (mips === 0) { + mips = 1; + } + } + if (ipgp.length > 1) { + j = 1; + l2 = ipgp.length; + while (j < l2 && ipgp[j] % ipgp[0] === 0) { + j++; + } + if (j === l2) { + ipgp = [ipgp[0]]; + } + } + if (ipgp.length === 1) { + j = 1; + while (j < 30) { + ipgp[j] = ipgp[j - 1] + ipgp[0]; + j++; + } + } + suffix = picture.substring(i); + if (value === Number.POSITIVE_INFINITY) { + sres = prefix + "Infinity" + suffix; + } else if (value === Number.NEGATIVE_INFINITY) { + sres = "-" + prefix + "Infinity" + suffix; + } else { + if (value < 0 && pictures.length === 1) { + prefix = "-" + prefix; + } + if (ess) { + evalue = Math.floor(Math.log(value) / Math.LN10) + 1 - mips; + value /= Math.pow(10, evalue); + esign = evalue < 0 ? "-" : ""; + evalue = String(Math.abs(evalue)); + evalue = esign + ("000000000000000000000000000000").substring(0, Math.max(0, mes - evalue.length)) + evalue; + } + s0 = Math.abs(Number(value)).toFixed(maxfps); + if (maxfps === 0 && dss) { + s0 += "."; + } + dsspos = s0.indexOf(".") === -1 ? s0.length : s0.indexOf("."); + if (dsspos < mips) { + s0 = ("000000000000000000000000000000").substring(0, mips - dsspos) + s0; + dsspos = mips; + } + j = dsspos - 1; + s = ""; + i = 0; + l2 = s0.length; + while (j >= 0) { + s = s0.charAt(j) + s; + if (j !== 0 && ipgp[i] === dsspos - j) { + s = "," + s; + i++; + } + j--; + } + if (dss) { + s += "."; + j = dsspos + 1; + i = 0; + while (j < l2) { + s += s0.charAt(j); + if (j !== l2 - 1 && fpgp[i] === j - dsspos) { + s += ","; + i++; + } + j++; + } + } + if (ps) { + if (psafter) { + s += "%"; + } else { + s = "%" + s; + } + } + if (pms) { + if (pmsafter) { + s += "\u2030"; + } else { + s = "\u2030" + s; + } + } + if (ess) { + s += "e" + evalue; + } + sres = prefix + s + suffix; + } + res.data = sres; + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; + } else { + this.item = valueitem; + } + return this; +}; + +Fleur.XPathFunctions_fn["format-integer#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:format-integer", Fleur.Context.prototype.fn_format$_integer_2, + [Fleur.SequenceType_integer_01, Fleur.SequenceType_string_1], Fleur.SequenceType_string_01); +/* function(value, picture) { var i, j, l, l2, pictures, dss, ess, ps, pms, ms, msbefore, psafter, pmsafter, signs, esigns, iipgp, ipgp, mips, prefix, fstart, fpgp, minfps, maxfps, mes, suffix, dsspos, evalue, esign, s0, s; pictures = picture.split(";"); @@ -247,4 +448,5 @@ Fleur.XPathFunctions_fn["format-integer#2"] = new Fleur.Function("http://www.w3. } return prefix + s + suffix; }, - null, [{type: Fleur.Type_integer, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [{type: Fleur.Type_integer, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/format-number.js b/src/js/fleur.js/XPath/XPathFunctions/fn/format-number.js index 6177d25..048fd77 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/format-number.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/format-number.js @@ -1,33 +1,234 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_format$_number_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - } - ] +Fleur.Context.prototype.fn_format$_number_2 = function() { + let picture = this.item.data; + const valueitem = this.itemstack.pop(); + if (valueitem.isNotEmpty()) { + const res = new Fleur.Text(); + let value = Number(valueitem.data); + let sres = ""; + let i, j, l, l2, pictures, dss, ess, ps, pms, ms, msbefore, psafter, pmsafter, signs, esigns, iipgp, ipgp, mips, prefix, fstart, fpgp, minfps, maxfps, mes, suffix, dsspos, evalue, esign, s0, s; + pictures = picture.split(";"); + picture = value < 0 && pictures[1] ? pictures[1] : pictures[0]; + signs = ".,-%\u2030#0123456789"; + esigns = ".,e-%\u2030#0123456789"; + i = 0; + l = picture.length; + while (i < l && signs.indexOf(picture.charAt(i)) === -1) { + i++; + } + prefix = picture.substring(0, i); + dss = ess = ps = pms = false; + mips = 0; + minfps = 0; + maxfps = 0; + mes = 0; + iipgp = []; + ipgp = []; + fpgp = []; + while (i < l && esigns.indexOf(picture.charAt(i)) !== -1) { + switch (picture.charAt(i)) { + case ".": + dss = true; + fstart = i + 1; + j = 0; + l2 = iipgp.length; + while (j < l2) { + ipgp[l2 - j - 1] = i - iipgp[j] - 1; + j++; + } + break; + case ",": + if (dss) { + fpgp.push(i - fstart); + } else { + iipgp.push(i); + } + break; + case "e": + ess = true; + if (!dss) { + j = 0; + l2 = iipgp.length; + while (j < l2) { + ipgp[l2 - j - 1] = i - iipgp[j] - 1; + j++; + } + } + break; + case "-": + ms = true; + msbefore = mips === 0; + break; + case "%": + ps = true; + psafter = mips !== 0; + value *= 100; + if (!dss) { + j = 0; + l2 = iipgp.length; + while (j < l2) { + ipgp[l2 - j - 1] = i - iipgp[j] - 1; + j++; + } + } + break; + case "\u2030": + pms = true; + pmsafter = mips !== 0; + value *= 1000; + if (!dss) { + j = 0; + l2 = iipgp.length; + while (j < l2) { + ipgp[l2 - j - 1] = i - iipgp[j] - 1; + j++; + } + } + break; + case "0": + case "1": + case "2": + case "3": + case "4": + case "5": + case "6": + case "7": + case "8": + case "9": + if (ess) { + mes++; + } else if (dss) { + minfps++; + maxfps++; + } else { + mips++; + } + break; + case "#": + if (dss) { + maxfps++; + } + break; + } + i++; + } + if (!dss) { + if (iipgp.length !== ipgp.length) { + j = 0; + l2 = iipgp.length; + while (j < l2) { + ipgp[l2 - j - 1] = i - iipgp[j] - 1; + j++; + } + } + if (mips === 0) { + mips = 1; + } + } + if (ipgp.length > 1) { + j = 1; + l2 = ipgp.length; + while (j < l2 && ipgp[j] % ipgp[0] === 0) { + j++; + } + if (j === l2) { + ipgp = [ipgp[0]]; + } + } + if (ipgp.length === 1) { + j = 1; + while (j < 30) { + ipgp[j] = ipgp[j - 1] + ipgp[0]; + j++; + } + } + suffix = picture.substring(i); + if (Number(value) === Number.POSITIVE_INFINITY) { + sres = prefix + "Infinity" + suffix; + } else if (Number(value) === Number.NEGATIVE_INFINITY) { + sres = "-" + prefix + "Infinity" + suffix; + } else { + if (value < 0 && pictures.length === 1) { + prefix = "-" + prefix; + } + if (ess) { + evalue = Math.floor(Math.log(Number(value)) / Math.LN10) + 1 - mips; + value = Number(value) / Math.pow(10, evalue); + esign = evalue < 0 ? "-" : ""; + evalue = String(Math.abs(evalue)); + evalue = esign + ("000000000000000000000000000000").substr(0, Math.max(0, mes - evalue.length)) + evalue; + } + s0 = Math.abs(Number(value)).toFixed(maxfps); + if (maxfps === 0 && dss) { + s0 += "."; + } + dsspos = s0.indexOf(".") === -1 ? s0.length : s0.indexOf("."); + if (dsspos < mips) { + s0 = ("000000000000000000000000000000").substring(0, mips - dsspos) + s0; + dsspos = mips; + } + j = dsspos - 1; + s = ""; + i = 0; + l2 = s0.length; + while (j >= 0) { + s = s0.charAt(j) + s; + if (j !== 0 && ipgp[i] === dsspos - j) { + s = "," + s; + i++; + } + j--; + } + if (dss) { + s += "."; + j = dsspos + 1; + i = 0; + while (j < l2) { + s += s0.charAt(j); + if (j !== l2 - 1 && fpgp[i] === j - dsspos) { + s += ","; + i++; + } + j++; + } + } + if (ps) { + if (psafter) { + s += "%"; + } else { + s = "%" + s; + } + } + if (pms) { + if (pmsafter) { + s += "\u2030"; + } else { + s = "\u2030" + s; + } + } + if (ess) { + s += "e" + evalue; + } + sres = prefix + s + suffix; + } + res.data = sres; + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; + } else { + this.item = valueitem; + } +return this; }; -Fleur.XPathFunctions_fn["format-number#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:format-number", +Fleur.XPathFunctions_fn["format-number#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:format-number", Fleur.Context.prototype.fn_format$_number_2, + [Fleur.SequenceType_numeric_01, Fleur.SequenceType_string_1], Fleur.SequenceType_string_01); +/* function(value, picture) { var i, j, l, l2, pictures, dss, ess, ps, pms, ms, msbefore, psafter, pmsafter, signs, esigns, iipgp, ipgp, mips, prefix, fstart, fpgp, minfps, maxfps, mes, suffix, dsspos, evalue, esign, s0, s; pictures = picture.split(";"); @@ -234,4 +435,5 @@ Fleur.XPathFunctions_fn["format-number#2"] = new Fleur.Function("http://www.w3.o } return prefix + s + suffix; }, - null, [{type: Fleur.numericTypes, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [{type: Fleur.numericTypes, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/format-time.js b/src/js/fleur.js/XPath/XPathFunctions/fn/format-time.js index 8f85e1d..60c4a5f 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/format-time.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/format-time.js @@ -1,40 +1,31 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_format$_time_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_time, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - } - ] +Fleur.Context.prototype.fn_format$_time_2 = function() { + return this.emptySequence().emptySequence().emptySequence().fn_format$_dateTime_5(true, false); +}; +Fleur.Context.prototype.fn_format$_time_5 = function() { + return this.fn_format$_dateTime_5(true, false); }; -Fleur.XPathFunctions_fn["format-time#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:format-time", - function(value, picture, ctx) { +Fleur.XPathFunctions_fn["format-time#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:format-time", Fleur.Context.prototype.fn_format$_time_2, + [Fleur.SequenceType_time_01, Fleur.SequenceType_string_1], Fleur.SequenceType_string_01); +/* +function(value, picture, ctx) { return Fleur.XPathFunctions_fn["format-dateTime#5"].jsfunc(value, picture, null, null, null, ctx, false, true); }, null, [{type: Fleur.Type_time, occurence: "?"}, {type: Fleur.Type_string}], true, false, {type: Fleur.Type_string, occurence: "?"}); +*/ -Fleur.XPathFunctions_fn["format-time#5"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:format-time", - function(value, picture, language, calendar, place, ctx) { +Fleur.XPathFunctions_fn["format-time#5"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:format-time", Fleur.Context.prototype.fn_format$_time_5, +[Fleur.SequenceType_time_01, Fleur.SequenceType_string_1, Fleur.SequenceType_string_01, Fleur.SequenceType_string_01, Fleur.SequenceType_string_01], Fleur.SequenceType_string_01); +/* +function(value, picture, language, calendar, place, ctx) { return Fleur.XPathFunctions_fn["format-dateTime#5"].jsfunc(value, picture, language, calendar, place, ctx, false, true); }, - null, [{type: Fleur.Type_time, occurence: "?"}, {type: Fleur.Type_string}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}], true, false, {type: Fleur.Type_string, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_time, occurence: "?"}, {type: Fleur.Type_string}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}], true, false, {type: Fleur.Type_string, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/function-arity.js b/src/js/fleur.js/XPath/XPathFunctions/fn/function-arity.js index 2311cdc..3195b94 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/function-arity.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/function-arity.js @@ -1,28 +1,23 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_function$_arity_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.FUNCTION_NODE, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_function$_arity_1 = function() { + const newitem = new Fleur.Text(); + newitem.data = String(this.item.argtypes.length); + newitem.schemaTypeInfo = Fleur.Type_integer; + this.item = newitem; + return this; }; -Fleur.XPathFunctions_fn["function-arity#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:function-arity", +Fleur.XPathFunctions_fn["function-arity#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:function-arity", Fleur.Context.prototype.fn_function$_arity_1, + [Fleur.SequenceType_function_1], Fleur.SequenceType_integer_1); +/* function(f) { return f.argtypes.length; }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Type_integer}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Type_integer}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/function-lookup.js b/src/js/fleur.js/XPath/XPathFunctions/fn/function-lookup.js index 118e928..2b3d79e 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/function-lookup.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/function-lookup.js @@ -1,11 +1,25 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.XPathFunctions_fn["function-lookup#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:function-lookup", +Fleur.Context.prototype.fn_function$_lookup_2 = function() { + const arity = this.item; + const fqname = this.itemstack.pop(); + if (fqname.isNotEmpty()) { + const func = Fleur.XPathFunctions[fqname.namespaceURI] ? Fleur.XPathFunctions[fqname.namespaceURI][fqname.localName + "#" + arity.data] || null : null; + this.item = func ? func : new Fleur.Sequence(); + } else { + this.item = fqname; + } + return this; +}; + +Fleur.XPathFunctions_fn["function-lookup#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:function-lookup", Fleur.Context.prototype.fn_function$_lookup_2, + [Fleur.SequenceType_QName_1, Fleur.SequenceType_integer_1], Fleur.SequenceType_function_01); +/* function(fqname, arity) { if (fqname.namespaceURI === "http://www.w3.org/2005/xpath-functions" && fqname.localName === "concat" && arity > 1 && !Fleur.XPathFunctions[fqname.namespaceURI][fqname.localName + "#" + arity]) { var cparam = []; @@ -16,4 +30,5 @@ Fleur.XPathFunctions_fn["function-lookup#2"] = new Fleur.Function("http://www.w3 } return Fleur.XPathFunctions[fqname.namespaceURI] ? Fleur.XPathFunctions[fqname.namespaceURI][fqname.localName + "#" + arity] || null : null; }, - null, [{type: Fleur.Type_QName}, {type: Fleur.Type_integer}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Type_QName}, {type: Fleur.Type_integer}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/function-name.js b/src/js/fleur.js/XPath/XPathFunctions/fn/function-name.js index a7e1c6a..cd8dd01 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/function-name.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/function-name.js @@ -1,15 +1,26 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.XPathFunctions_fn["function-name#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:function-name", +Fleur.Context.prototype.fn_function$_name_1 = function() { + var newitem = new Fleur.Text(); + newitem.schemaTypeInfo = Fleur.Type_QName; + newitem._setNodeNameLocalNamePrefix(this.item.namespaceURI, this.item.nodeName); + this.item = newitem; + return this; +}; + +Fleur.XPathFunctions_fn["function-name#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:function-name", Fleur.Context.prototype.fn_function$_name_1, + [Fleur.SequenceType_function_1], Fleur.SequenceType_QName_01); +/* function(f) { var a = new Fleur.Text(); a.schemaTypeInfo = Fleur.Type_QName; a._setNodeNameLocalNamePrefix(f.namespaceURI, f.nodeName); return a; }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Type_QName}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Type_QName}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/has-children.js b/src/js/fleur.js/XPath/XPathFunctions/fn/has-children.js index ef9519e..50d43e4 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/has-children.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/has-children.js @@ -1,32 +1,40 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_has$_children_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "1" - }, - params_type: [ - { - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_has$_children_0 = function() { + return this.current().fn_has$_children_1(); +}; +Fleur.Context.prototype.fn_has$_children_1 = function() { + const node = this.item; + const newitem = new Fleur.Text(); + newitem.data = "false"; + newitem.schemaTypeInfo = Fleur.Type_boolean; + if ((node.nodeType === Fleur.Node.TEXT_NODE && node.schemaTypeInfo !== Fleur.Type_untypedAtomic) || node.nodeType === Fleur.Node.FUNCTION_NODE) { + Fleur.XQueryError_xqt("XPTY0004", null, "Invalid parameter"); + } + if (node.nodeType !== Fleur.Node.SEQUENCE_NODE && node.nodeType !== Fleur.Node.ATTRIBUTE_NODE) { + newitem.data = String(node.childNodes && node.childNodes.length !== 0); + } + this.item = newitem; + return this; }; -Fleur.XPathFunctions_fn["has-children#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:has-children", +Fleur.XPathFunctions_fn["has-children#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:has-children", Fleur.Context.prototype.fn_has$_children_0, + [], Fleur.SequenceType_boolean_1); + +Fleur.XPathFunctions_fn["has-children#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:has-children", Fleur.Context.prototype.fn_has$_children_1, + [Fleur.SequenceType_item_01], Fleur.SequenceType_boolean_1); +/* function(ctx) { return Fleur.XPathFunctions_fn["has-children#1"].jsfunc(ctx._curr); }, null, [], true, false, {type: Fleur.Type_boolean}); - -Fleur.XPathFunctions_fn["has-children#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:has-children", +*/ +/* function(node) { if (node === null) { return false; @@ -41,4 +49,5 @@ Fleur.XPathFunctions_fn["has-children#1"] = new Fleur.Function("http://www.w3.or } return false; }, - null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_boolean}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_boolean}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/head.js b/src/js/fleur.js/XPath/XPathFunctions/fn/head.js index f1fd11d..b090103 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/head.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/head.js @@ -1,20 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ - Fleur.signatures.fn_head_1 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - { - occurrence: "*" - } - ] -}; Fleur.Context.prototype.fn_head_1 = function() { if (this.item.nodeType === Fleur.Node.SEQUENCE_NODE && this.item.childNodes.length !== 0) { this.item = this.item.childNodes[0]; @@ -22,8 +12,11 @@ Fleur.Context.prototype.fn_head_1 = function() { return this; }; -Fleur.XPathFunctions_fn["head#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:head", - function(arg) { +Fleur.XPathFunctions_fn["head#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:head", Fleur.Context.prototype.fn_head_1, + [Fleur.SequenceType_item_0n], Fleur.SequenceType_item_01); +/* +function(arg) { return arg === Fleur.EmptySequence || arg.nodeType !== Fleur.Node.SEQUENCE_NODE ? arg : arg.childNodes[0]; }, - null, [{type: Fleur.Node, occurence: "*"}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "*"}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/hours-from-dateTime.js b/src/js/fleur.js/XPath/XPathFunctions/fn/hours-from-dateTime.js index 473f2d2..c1cbd51 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/hours-from-dateTime.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/hours-from-dateTime.js @@ -1,29 +1,25 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_hours$_from$_dateTime_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dateTime, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_hours$_from$_dateTime_1 = function() { + if (this.item.isNotEmpty()) { + const res = new Fleur.Text(); + res.data = String(parseInt(this.item.data.match(/^\d{4}-\d{2}-\d{2}T(\d{2}):\d{2}:\d{2}(?:\.\d+)?(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10)); + res.schemaTypeInfo = Fleur.Type_integer; + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["hours-from-dateTime#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:hours-from-dateTime", - function(arg) { +Fleur.XPathFunctions_fn["hours-from-dateTime#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:hours-from-dateTime", Fleur.Context.prototype.fn_hours$_from$_dateTime_1, + [Fleur.SequenceType_dateTime_01], Fleur.SequenceType_integer_01); +/* +function(arg) { return arg !== null ? parseInt(arg.match(/^\d{4}-\d{2}-\d{2}T(\d{2}):\d{2}:\d{2}(?:\.\d+)?(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10) : null; }, - null, [{type: Fleur.Type_dateTime, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_dateTime, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/hours-from-duration.js b/src/js/fleur.js/XPath/XPathFunctions/fn/hours-from-duration.js index f445ba3..9801d5b 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/hours-from-duration.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/hours-from-duration.js @@ -1,28 +1,33 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ - Fleur.signatures.fn_hours$_from$_duration_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_duration, - occurrence: "?" +Fleur.Context.prototype.fn_hours$_from$_duration_1 = function() { + if (this.item.isNotEmpty()) { + const a = this.item; + let signedd = 0; + if (a.schemaTypeInfo === Fleur.Type_dayTimeDuration) { + const d = Fleur.toJSONDayTimeDuration(a.data); + signedd = d.sign * d.hour; + } + if (a.schemaTypeInfo !== Fleur.Type_yearMonthDuration) { + const d = Fleur.toJSONDuration(a.data); + signedd = d.sign * d.hour; } - ] + const res = new Fleur.Text(); + res.schemaTypeInfo = Fleur.Type_integer; + res.data = Number(signedd); + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["hours-from-duration#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:hours-from-duration", +Fleur.XPathFunctions_fn["hours-from-duration#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:hours-from-duration", Fleur.Context.prototype.fn_hours$_from$_duration_1, + [Fleur.SequenceType_duration_01], Fleur.SequenceType_integer_01); +/* function(arg) { var a = Fleur.Atomize(arg); var d; @@ -44,4 +49,5 @@ Fleur.XPathFunctions_fn["hours-from-duration#1"] = new Fleur.Function("http://ww e.name = "XPTY0004"; return e; }, - null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_integer, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_integer, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/hours-from-time.js b/src/js/fleur.js/XPath/XPathFunctions/fn/hours-from-time.js index eae1d53..949c5d2 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/hours-from-time.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/hours-from-time.js @@ -1,29 +1,25 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_hours$_from$_time_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_time, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_hours$_from$_time_1 = function() { + if (this.item.isNotEmpty()) { + const res = new Fleur.Text(); + res.data = String(parseInt(this.item.data.match(/^(\d{2}):\d{2}:\d{2}(?:\.\d+)?(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10)); + res.schemaTypeInfo = Fleur.Type_integer; + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["hours-from-time#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:hours-from-time", - function(arg) { +Fleur.XPathFunctions_fn["hours-from-time#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:hours-from-time", Fleur.Context.prototype.fn_hours$_from$_time_1, + [Fleur.SequenceType_time_01], Fleur.SequenceType_integer_01); +/* +function(arg) { return arg !== null ? parseInt(arg.match(/^(\d{2}):\d{2}:\d{2}(?:\.\d+)?(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10) : null; }, - null, [{type: Fleur.Type_time, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_time, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/id.js b/src/js/fleur.js/XPath/XPathFunctions/fn/id.js index f9017ed..c1b8df4 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/id.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/id.js @@ -1,30 +1,56 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_id_1 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "*" + Fleur.Context.prototype.fn_id_1 = function() { + return this.current().fn_id_2(); +}; +Fleur.Context.prototype.fn_id_2 = function() { + let node = this.item; + const arg = this.itemstack.pop(); + node = node.ownerDocument || node; + let elts; + if (arg.nodeType === Fleur.Node.SEQUENCE_NODE) { + var res = []; + arg.childNodes.forEach(function(id) { + var elt = node.getElementById(id); + if (elt) { + res.push(elt); + } + }); + elts = res.length === 0 ? null : res.length === 1 ? res[0] : node.sortNodes(res); + } else { + elts = node.getElementById(arg); + } + if (elts) { + if (elts instanceof Array) { + this.item = new Fleur.Sequence(); + this.item.childNodes = elts; + } else { + this.item = elts; } - ] + } else { + this.item = new Fleur.Sequence(); + } + return this; }; -Fleur.XPathFunctions_fn["id#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:id", +Fleur.XPathFunctions_fn["id#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:id", Fleur.Context.prototype.fn_id_1, + [Fleur.SequenceType_string_0n], Fleur.SequenceType_element_0n); + +Fleur.XPathFunctions_fn["id#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:id", Fleur.Context.prototype.fn_id_2, + [Fleur.SequenceType_string_0n, Fleur.SequenceType_item_1], Fleur.SequenceType_element_0n); +/* function(arg, ctx) { return Fleur.XPathFunctions_fn["id#2"].jsfunc(arg, ctx._curr); }, null, [{type: Fleur.Type_string, occurence: "*"}], true, false, {type: Fleur.Node, occurence: "*"}); +*/ +/* -Fleur.XPathFunctions_fn["id#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:id", function(arg, node) { if (!arg || !node || (!node.ownerDocument && node.nodeType !== Fleur.Node.DOCUMENT_NODE)) { return null; @@ -42,4 +68,5 @@ Fleur.XPathFunctions_fn["id#2"] = new Fleur.Function("http://www.w3.org/2005/xpa } return node.getElementById(arg); }, - null, [{type: Fleur.Type_string, occurence: "*"}, {type: Fleur.Node}], false, false, {type: Fleur.Node, occurence: "*"}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "*"}, {type: Fleur.Node}], false, false, {type: Fleur.Node, occurence: "*"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/implicit-timezone.js b/src/js/fleur.js/XPath/XPathFunctions/fn/implicit-timezone.js index be0da02..4e17e81 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/implicit-timezone.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/implicit-timezone.js @@ -1,26 +1,27 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_implicit$_timezone_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dayTimeDuration, - occurrence: "?" - }, - params_type: [] +Fleur.Context.prototype.fn_implicit$_timezone_0 = function() { + this.itemstack.push(this.item); + const item = new Fleur.Text(); + item.appendData(this.rs.timezone); + item.schemaTypeInfo = Fleur.Type_dayTimeDuration; + this.item = item; + return this; }; -Fleur.XPathFunctions_fn["implicit-timezone#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:implicit-timezone", +Fleur.XPathFunctions_fn["implicit-timezone#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:implicit-timezone", Fleur.Context.prototype.fn_implicit$_timezone_0, + [], Fleur.SequenceType_dayTimeDuration_01); +/* function(ctx) { var a = new Fleur.Text(); a.schemaTypeInfo = Fleur.Type_dayTimeDuration; a.data = ctx.env.timezone; return a; }, - null, [], true, false, {type: Fleur.Node, occurence: "?"}); \ No newline at end of file + null, [], true, false, {type: Fleur.Node, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/index-of.js b/src/js/fleur.js/XPath/XPathFunctions/fn/index-of.js index b0adf4b..87cce1d 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/index-of.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/index-of.js @@ -1,68 +1,65 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_index$_of_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "*" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "*" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "1" - } - ] +Fleur.Context.prototype.fn_index$_of_2 = function() { + return this.fn_default$_collation_0().fn_index$_of_3(); }; -Fleur.signatures.fn_index$_of_3 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "*" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "*" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "1" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" +Fleur.Context.prototype.fn_index$_of_3 = function() { + const collation = this.item; + const search = this.itemstack.pop(); + const seq = this.itemstack.pop(); + if (seq.isNotEmpty()) { + const c = Fleur.getCollation(collation.data); + const v2 = Fleur.toJSValue(search, true, true, true, true); + if (seq.nodeType !== Fleur.Node.SEQUENCE_NODE) { + const v1 = Fleur.toJSValue(seq, v2[0] < 4, true, true, true); + if (v1[0] === v2[0] && Fleur.eqOp(v1, v2, c)) { + const res = new Fleur.Text(); + res.schemaTypeInfo = Fleur.Type_integer; + res.data = "1"; + this.item = res; + } else { + this.item = new Fleur.Sequence(); + } + } else { + let result = new Fleur.Sequence(); + seq.childNodes.forEach(function(d, i) { + const vd = Fleur.toJSValue(d, v2[0] < 4, true, true, true); + if (vd[0] === v2[0] && Fleur.eqOp(vd, v2, c)) { + const b = new Fleur.Text(); + b.schemaTypeInfo = Fleur.Type_integer; + b.data = String(i + 1); + result.appendChild(b); + } + }); + if (result.childNodes.length === 0) { + result = Fleur.EmptySequence; + } else if (result.childNodes.length === 1) { + result = result.childNodes[0]; + } + this.item = result; } - ] + } + return this; }; -Fleur.XPathFunctions_fn["index-of#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:index-of", +Fleur.XPathFunctions_fn["index-of#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:index-of", Fleur.Context.prototype.fn_index$_of_2, + [Fleur.SequenceType_anyAtomicType_0n, Fleur.SequenceType_anyAtomicType_1], Fleur.SequenceType_integer_0n); + +Fleur.XPathFunctions_fn["index-of#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:index-of", Fleur.Context.prototype.fn_index$_of_3, + [Fleur.SequenceType_anyAtomicType_0n, Fleur.SequenceType_anyAtomicType_1, Fleur.SequenceType_string_1], Fleur.SequenceType_integer_0n); +/* function(seq, search) { return Fleur.XPathFunctions_fn["index-of#3"].jsfunc(seq, search, "http://www.w3.org/2005/xpath-functions/collation/codepoint"); }, null, [{type: Fleur.Node, occurence: "*"}, {type: Fleur.Node}], false, false, {type: Fleur.Type_integer, occurence: "*"}); - -Fleur.XPathFunctions_fn["index-of#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:index-of", - function(seq, search, collation) { +*/ +/* +function(seq, search, collation) { var c = Fleur.getCollation(collation); if (!c) { var e = new Error(""); diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/insert-before.js b/src/js/fleur.js/XPath/XPathFunctions/fn/insert-before.js index 112c0aa..78cc30b 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/insert-before.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/insert-before.js @@ -1,25 +1,17 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_insert$_before_1 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - null, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "1" - }, - null - ] +Fleur.Context.prototype.fn_insert$_before_3 = function() { + this.notyet(); }; +Fleur.XPathFunctions_fn["insert-before#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:insert-before", Fleur.Context.prototype.fn_insert$_before_3, + [Fleur.SequenceType_item_0n, Fleur.SequenceType_integer_1, Fleur.SequenceType_item_0n], Fleur.SequenceType_item_0n); +/* Fleur.XPathFunctions_fn["insert-before"] = function(ctx, children, callback) { if (children.length !== 3) { Fleur.callback(function() {callback(Fleur.error(ctx, "XPST0017"));}); @@ -89,4 +81,5 @@ Fleur.XPathFunctions_fn["insert-before"] = function(ctx, children, callback) { }); }); }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/iri-to-uri.js b/src/js/fleur.js/XPath/XPathFunctions/fn/iri-to-uri.js index 8753dde..84da764 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/iri-to-uri.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/iri-to-uri.js @@ -1,42 +1,29 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_iri$_to$_uri_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] -}; - Fleur.Context.prototype.fn_iri$_to$_uri_1 = function() { + const res = new Fleur.Text(); if (this.item.isNotEmpty()) { - this.item.data = this.item.data.replace(/([^!-~]|[<>"{}|\\\^\`])/g, function(c) { + res.data = this.item.data.replace(/([^!-~]|[<>"{}|\\\^\`])/g, function(c) { return encodeURIComponent(c); }); } else { - this.item = new Fleur.Text(); - this.item.data = ""; + res.data = ""; } - this.item.schemaTypeInfo = Fleur.Type_string; + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; return this; }; -Fleur.XPathFunctions_fn["iri-to-uri#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:iri-to-uri", +Fleur.XPathFunctions_fn["iri-to-uri#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:iri-to-uri", Fleur.Context.prototype.fn_iri$_to$_uri_1, + [Fleur.SequenceType_string_01], Fleur.SequenceType_string_1); +/* function(iri) { return iri !== null ? iri.replace(/([^!-~]|[<>"{}|\\\^\`])/g, function(c) {return encodeURIComponent(c);}) : ""; }, - null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/last.js b/src/js/fleur.js/XPath/XPathFunctions/fn/last.js index dfd2309..596f8cb 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/last.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/last.js @@ -1,21 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_last_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "1" - }, - params_type: [] -}; - Fleur.Context.prototype.fn_last_0 = function() { this.itemstack.push(this.item); const item = new Fleur.Text(); @@ -25,8 +14,11 @@ Fleur.Context.prototype.fn_last_0 = function() { return this; }; -Fleur.XPathFunctions_fn["last#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:last", +Fleur.XPathFunctions_fn["last#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:last", Fleur.Context.prototype.fn_last_0, + [], Fleur.SequenceType_integer_1); +/* function(ctx) { return ctx._last; }, - null, [], true, false, {type: Fleur.Type_integer}); \ No newline at end of file + null, [], true, false, {type: Fleur.Type_integer}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/local-name.js b/src/js/fleur.js/XPath/XPathFunctions/fn/local-name.js index d8979ba..02ff122 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/local-name.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/local-name.js @@ -1,36 +1,32 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ - Fleur.signatures.fn_local$_name_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - params_type: [] +Fleur.Context.prototype.fn_local$_name_0 = function() { + return this.current().fn_local$_name_1(); }; -Fleur.signatures.fn_local$_name_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - params_type: [ - { - occurrence: "?" +Fleur.Context.prototype.fn_local$_name_1 = function() { + const node = this.item; + if (node.isNotEmpty()) { + const newitem = new Fleur.Text(""); + newitem.schemaTypeInfo = Fleur.Type_string; + if (node.nodeType !== Fleur.Node.DOCUMENT_NODE && node.nodeType !== Fleur.Node.COMMENT_NODE && node.nodeType !== Fleur.Node.TEXT_NODE) { + newitem.data = node.localName; } - ] + this.item = newitem; + } + return this; }; -Fleur.XPathFunctions_fn["local-name#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:local-name", +Fleur.XPathFunctions_fn["local-name#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:local-name", Fleur.Context.prototype.fn_local$_name_0, + [], Fleur.SequenceType_string_01); + +Fleur.XPathFunctions_fn["local-name#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:local-name", Fleur.Context.prototype.fn_local$_name_1, + [Fleur.SequenceType_item_01], Fleur.SequenceType_string_01); +/* function(ctx) { if (ctx._curr === Fleur.EmptySequence) { return null; @@ -41,8 +37,8 @@ Fleur.XPathFunctions_fn["local-name#0"] = new Fleur.Function("http://www.w3.org/ return ctx._curr.localName; }, null, [], true, false, {type: Fleur.Type_string}); - -Fleur.XPathFunctions_fn["local-name#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:local-name", +*/ +/* function(node) { if (node === Fleur.EmptySequence) { return null; @@ -52,4 +48,5 @@ Fleur.XPathFunctions_fn["local-name#1"] = new Fleur.Function("http://www.w3.org/ } return node.localName; }, - null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/lower-case.js b/src/js/fleur.js/XPath/XPathFunctions/fn/lower-case.js index c97b575..415051a 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/lower-case.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/lower-case.js @@ -1,40 +1,27 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_lower$_case_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] -}; - Fleur.Context.prototype.fn_lower$_case_1 = function() { + const res = new Fleur.Text(); if (this.item.isNotEmpty()) { - this.item.data = this.item.data.toLowerCase(); + res.data = this.item.data.toLowerCase(); } else { - this.item = new Fleur.Text(); - this.item.data = ""; + res.data = ""; } - this.item.schemaTypeInfo = Fleur.Type_string; + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; return this; }; -Fleur.XPathFunctions_fn["lower-case#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:lower-case", +Fleur.XPathFunctions_fn["lower-case#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:lower-case", Fleur.Context.prototype.fn_lower$_case_1, + [Fleur.SequenceType_string_01], Fleur.SequenceType_string_1); +/* function(arg) { return arg ? arg.toLowerCase() : ""; }, - null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/matches.js b/src/js/fleur.js/XPath/XPathFunctions/fn/matches.js index 97eb940..6e55714 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/matches.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/matches.js @@ -1,44 +1,41 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_matches_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_matches_2 = function() { + return this.emptySequence().fn_matches_3(); +}; +Fleur.Context.prototype.fn_matches_3 = function() { + const flags = this.item; + const pattern = this.itemstack.pop(); + const input = this.itemstack.pop(); + const inputdata = input.data || ""; + const flagsdata = flags.data || ""; + const newitem = new Fleur.Text("false"); + try { + var re = new RegExp(pattern.data, flagsdata); + newitem.data = String(re.test(inputdata)); + } catch (e) {} + newitem.schemaTypeInfo = Fleur.Type_boolean; + this.item = newitem; + return this; }; -Fleur.XPathFunctions_fn["matches#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:matches", +Fleur.XPathFunctions_fn["matches#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:matches", Fleur.Context.prototype.fn_matches_2, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_1], Fleur.SequenceType_boolean_1); + +Fleur.XPathFunctions_fn["matches#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:matches", Fleur.Context.prototype.fn_matches_3, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_1, Fleur.SequenceType_string_1], Fleur.SequenceType_boolean_1); +/* function(input, pattern) { return Fleur.XPathFunctions_fn["matches#3"].jsfunc(input, pattern); }, null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_boolean}); - -Fleur.XPathFunctions_fn["matches#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:matches", +*/ +/* function(input, pattern, flags) { input = input || ""; flags = flags || ""; @@ -49,4 +46,5 @@ Fleur.XPathFunctions_fn["matches#3"] = new Fleur.Function("http://www.w3.org/200 return false; } }, - null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}, {type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_boolean}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}, {type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_boolean}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/max.js b/src/js/fleur.js/XPath/XPathFunctions/fn/max.js index 472628b..dd5028c 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/max.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/max.js @@ -1,48 +1,23 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_max_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "*" - } - ] +Fleur.Context.prototype.fn_max_1 = function() { + this.notyet(); }; -Fleur.signatures.fn_max_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "*" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - } - ] +Fleur.Context.prototype.fn_max_2 = function() { + this.notyet(); }; +Fleur.XPathFunctions_fn["max#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:max", Fleur.Context.prototype.fn_max_1, + [Fleur.SequenceType_anyAtomicType_0n], Fleur.SequenceType_anyAtomicType_01); + +Fleur.XPathFunctions_fn["max#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:max", Fleur.Context.prototype.fn_max_2, + [Fleur.SequenceType_anyAtomicType_0n, Fleur.SequenceType_string_1], Fleur.SequenceType_anyAtomicType_01); +/* Fleur.XPathFunctions_fn["max"] = function(ctx, children, callback) { if (children.length !== 1) { Fleur.callback(function() {callback(Fleur.error(ctx, "XPST0017"));}); @@ -105,4 +80,5 @@ Fleur.XPathFunctions_fn["max"] = function(ctx, children, callback) { a.schemaTypeInfo = comp === Fleur.Type_double ? Fleur.numericTypes[t] : Fleur.Type_string; Fleur.callback(function() {callback(a);}); }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/min.js b/src/js/fleur.js/XPath/XPathFunctions/fn/min.js index 203ead3..2e24f90 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/min.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/min.js @@ -1,48 +1,23 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_min_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "*" - } - ] +Fleur.Context.prototype.fn_min_1 = function() { + this.notyet(); }; -Fleur.signatures.fn_min_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "*" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - } - ] +Fleur.Context.prototype.fn_min_2 = function() { + this.notyet(); }; +Fleur.XPathFunctions_fn["min#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:min", Fleur.Context.prototype.fn_min_1, + [Fleur.SequenceType_anyAtomicType_0n], Fleur.SequenceType_anyAtomicType_01); + +Fleur.XPathFunctions_fn["min#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:min", Fleur.Context.prototype.fn_min_2, + [Fleur.SequenceType_anyAtomicType_0n, Fleur.SequenceType_string_1], Fleur.SequenceType_anyAtomicType_01); +/* Fleur.XPathFunctions_fn["min"] = function(ctx, children, callback) { if (children.length !== 1) { Fleur.callback(function() {callback(Fleur.error(ctx, "XPST0017"));}); @@ -106,4 +81,5 @@ Fleur.XPathFunctions_fn["min"] = function(ctx, children, callback) { a.schemaTypeInfo = comp === Fleur.Type_double ? Fleur.numericTypes[t] : Fleur.Type_string; Fleur.callback(function() {callback(a);}); }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/minutes-from-dateTime.js b/src/js/fleur.js/XPath/XPathFunctions/fn/minutes-from-dateTime.js index d17947b..cff3731 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/minutes-from-dateTime.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/minutes-from-dateTime.js @@ -1,29 +1,25 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_minutes$_from$_dateTime_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dateTime, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_minutes$_from$_dateTime_1 = function() { + if (this.item.isNotEmpty()) { + const res = new Fleur.Text(); + res.data = String(parseInt(this.item.data.match(/^\d{4}-\d{2}-\d{2}T\d{2}:(\d{2}):\d{2}(?:\.\d+)?(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10)); + res.schemaTypeInfo = Fleur.Type_integer; + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["minutes-from-dateTime#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:minutes-from-dateTime", +Fleur.XPathFunctions_fn["minutes-from-dateTime#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:minutes-from-dateTime", Fleur.Context.prototype.fn_minutes$_from$_dateTime_1, + [Fleur.SequenceType_dateTime_01], Fleur.SequenceType_integer_01); +/* function(arg) { return arg !== null ? parseInt(arg.match(/^\d{4}-\d{2}-\d{2}T\d{2}:(\d{2}):\d{2}(?:\.\d+)?(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10) : null; }, - null, [{type: Fleur.Type_dateTime, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_dateTime, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/minutes-from-duration.js b/src/js/fleur.js/XPath/XPathFunctions/fn/minutes-from-duration.js index 1a8feb6..5bc16ff 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/minutes-from-duration.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/minutes-from-duration.js @@ -1,28 +1,33 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_minutes$_from$_duration_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_duration, - occurrence: "?" +Fleur.Context.prototype.fn_minutes$_from$_duration_1 = function() { + if (this.item.isNotEmpty()) { + const a = this.item; + let signedd = 0; + if (a.schemaTypeInfo === Fleur.Type_dayTimeDuration) { + const d = Fleur.toJSONDayTimeDuration(a.data); + signedd = d.sign * d.minute; + } + if (a.schemaTypeInfo !== Fleur.Type_yearMonthDuration) { + const d = Fleur.toJSONDuration(a.data); + signedd = d.sign * d.minute; } - ] + const res = new Fleur.Text(); + res.schemaTypeInfo = Fleur.Type_integer; + res.data = Number(signedd); + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["minutes-from-duration#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:minutes-from-duration", +Fleur.XPathFunctions_fn["minutes-from-duration#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:minutes-from-duration", Fleur.Context.prototype.fn_minutes$_from$_duration_1, + [Fleur.SequenceType_duration_01], Fleur.SequenceType_integer_01); +/* function(arg) { var a = Fleur.Atomize(arg); var d; @@ -44,4 +49,5 @@ Fleur.XPathFunctions_fn["minutes-from-duration#1"] = new Fleur.Function("http:// e.name = "XPTY0004"; return e; }, - null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_integer, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_integer, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/minutes-from-time.js b/src/js/fleur.js/XPath/XPathFunctions/fn/minutes-from-time.js index 25a90af..781de4d 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/minutes-from-time.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/minutes-from-time.js @@ -1,29 +1,25 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_minutes$_from$_time_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_time, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_minutes$_from$_time_1 = function() { + if (this.item.isNotEmpty()) { + const res = new Fleur.Text(); + res.data = String(parseInt(this.item.data.match(/^\d{2}:(\d{2}):\d{2}(?:\.\d+)?(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10)); + res.schemaTypeInfo = Fleur.Type_integer; + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["minutes-from-time#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:minutes-from-time", +Fleur.XPathFunctions_fn["minutes-from-time#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:minutes-from-time", Fleur.Context.prototype.fn_minutes$_from$_time_1, + [Fleur.SequenceType_time_01], Fleur.SequenceType_integer_01); +/* function(arg) { return arg !== null ? parseInt(arg.match(/^\d{2}:(\d{2}):\d{2}(?:\.\d+)?(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10) : null; }, - null, [{type: Fleur.Type_time, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_time, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/month-from-date.js b/src/js/fleur.js/XPath/XPathFunctions/fn/month-from-date.js index 40a824d..51e700b 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/month-from-date.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/month-from-date.js @@ -1,29 +1,25 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_month$_from$_date_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_date, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_month$_from$_date_1 = function() { + if (this.item.isNotEmpty()) { + const res = new Fleur.Text(); + res.data = String(parseInt(this.item.data.match(/^\d{4}-(\d{2})-\d{2}(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10)); + res.schemaTypeInfo = Fleur.Type_integer; + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["month-from-date#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:month-from-date", +Fleur.XPathFunctions_fn["month-from-date#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:month-from-date", Fleur.Context.prototype.fn_month$_from$_date_1, + [Fleur.SequenceType_date_01], Fleur.SequenceType_integer_01); +/* function(arg) { return arg !== null ? parseInt(arg.match(/^\d{4}-(\d{2})-\d{2}(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10) : null; }, - null, [{type: Fleur.Type_date, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_date, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/month-from-dateTime.js b/src/js/fleur.js/XPath/XPathFunctions/fn/month-from-dateTime.js index f147c5e..0ad3ccd 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/month-from-dateTime.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/month-from-dateTime.js @@ -1,29 +1,25 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_month$_from$_dateTime_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dateTime, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_month$_from$_dateTime_1 = function() { + if (this.item.isNotEmpty()) { + const res = new Fleur.Text(); + res.data = String(parseInt(this.item.data.match(/^\d{4}-(\d{2})-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10)); + res.schemaTypeInfo = Fleur.Type_integer; + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["month-from-dateTime#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:month-from-dateTime", +Fleur.XPathFunctions_fn["month-from-dateTime#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:month-from-dateTime", Fleur.Context.prototype.fn_month$_from$_dateTime_1, + [Fleur.SequenceType_dateTime_01], Fleur.SequenceType_integer_01); +/* function(arg) { return arg !== null ? parseInt(arg.match(/^\d{4}-(\d{2})-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10) : null; }, - null, [{type: Fleur.Type_dateTime, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_dateTime, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/months-from-duration.js b/src/js/fleur.js/XPath/XPathFunctions/fn/months-from-duration.js index b616ace..93e1145 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/months-from-duration.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/months-from-duration.js @@ -1,28 +1,33 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_month$_from$_duration_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_duration, - occurrence: "?" +Fleur.Context.prototype.fn_month$_from$_duration_1 = function() { + if (this.item.isNotEmpty()) { + const a = this.item; + let signedd = 0; + if (a.schemaTypeInfo === Fleur.Type_dayTimeDuration) { + const d = Fleur.toJSONDayTimeDuration(a.data); + signedd = d.sign * d.month; + } + if (a.schemaTypeInfo !== Fleur.Type_yearMonthDuration) { + const d = Fleur.toJSONDuration(a.data); + signedd = d.sign * d.month; } - ] + const res = new Fleur.Text(); + res.schemaTypeInfo = Fleur.Type_integer; + res.data = Number(signedd); + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["months-from-duration#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:months-from-duration", +Fleur.XPathFunctions_fn["months-from-duration#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:months-from-duration", Fleur.Context.prototype.fn_month$_from$_duration_1, + [Fleur.SequenceType_duration_01], Fleur.SequenceType_integer_01); +/* function(arg) { var a = Fleur.Atomize(arg); var d; @@ -44,4 +49,5 @@ Fleur.XPathFunctions_fn["months-from-duration#1"] = new Fleur.Function("http://w e.name = "XPTY0004"; return e; }, - null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_integer, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_integer, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/name.js b/src/js/fleur.js/XPath/XPathFunctions/fn/name.js index 335e6c1..bbdaf8b 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/name.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/name.js @@ -5,33 +5,28 @@ * @module * @description */ -Fleur.signatures.fn_name_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - params_type: [] +Fleur.Context.prototype.fn_name_0 = function() { + return this.current().fn_name_1(); }; -Fleur.signatures.fn_name_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - params_type: [ - { - occurrence: "?" +Fleur.Context.prototype.fn_name_1 = function() { + const node = this.item; + if (node.isNotEmpty()) { + const newitem = new Fleur.Text(""); + newitem.schemaTypeInfo = Fleur.Type_string; + if (node.nodeType !== Fleur.Node.DOCUMENT_NODE && node.nodeType !== Fleur.Node.COMMENT_NODE && node.nodeType !== Fleur.Node.TEXT_NODE) { + newitem.data = node.nodeName; } - ] + this.item = newitem; + } + return this; }; -Fleur.XPathFunctions_fn["name#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:name", - function(ctx) { +Fleur.XPathFunctions_fn["name#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:name", Fleur.Context.prototype.fn_name_0, + [], Fleur.SequenceType_string_01); + +Fleur.XPathFunctions_fn["name#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:name", Fleur.Context.prototype.fn_name_1, + [Fleur.SequenceType_item_01], Fleur.SequenceType_string_01); +/* function(ctx) { if (ctx._curr === null) { return null; } @@ -41,8 +36,8 @@ Fleur.XPathFunctions_fn["name#0"] = new Fleur.Function("http://www.w3.org/2005/x return ctx._curr.nodeName; }, null, [], true, false, {type: Fleur.Type_string}); - -Fleur.XPathFunctions_fn["name#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:name", +*/ +/* function(node) { if (node === null) { return null; @@ -52,4 +47,5 @@ Fleur.XPathFunctions_fn["name#1"] = new Fleur.Function("http://www.w3.org/2005/x } return node.nodeName; }, - null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/namespace-uri.js b/src/js/fleur.js/XPath/XPathFunctions/fn/namespace-uri.js index 19c964d..39409e5 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/namespace-uri.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/namespace-uri.js @@ -1,36 +1,32 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_namespace$_uri_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyURI, - occurrence: "?" - }, - params_type: [] +Fleur.Context.prototype.fn_namespace$_uri_0 = function() { + return this.current().fn_namespace$_uri_1(); }; -Fleur.signatures.fn_namespace$_uri_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyURI, - occurrence: "?" - }, - params_type: [ - { - occurrence: "?" +Fleur.Context.prototype.fn_namespace$_uri_1 = function() { + const node = this.item; + if (node.isNotEmpty()) { + const newitem = new Fleur.Text(""); + newitem.schemaTypeInfo = Fleur.Type_string; + if (node.nodeType !== Fleur.Node.DOCUMENT_NODE && node.nodeType !== Fleur.Node.COMMENT_NODE && node.nodeType !== Fleur.Node.TEXT_NODE) { + newitem.data = node.namespaceURI; } - ] + this.item = newitem; + } + return this; }; -Fleur.XPathFunctions_fn["namespace-uri#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:namespace-uri", +Fleur.XPathFunctions_fn["namespace-uri#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:namespace-uri", Fleur.Context.prototype.fn_namespace$_uri_0, + [], Fleur.SequenceType_anyURI_01); + +Fleur.XPathFunctions_fn["namespace-uri#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:namespace-uri", Fleur.Context.prototype.fn_namespace$_uri_1, + [Fleur.SequenceType_item_01], Fleur.SequenceType_anyURI_01); +/* function(ctx) { if (ctx._curr === null) { return null; @@ -41,8 +37,8 @@ Fleur.XPathFunctions_fn["namespace-uri#0"] = new Fleur.Function("http://www.w3.o return ctx._curr.namespaceURI; }, null, [{type: Fleur.Node, occurence: "?"}], true, false, {type: Fleur.Type_anyURI}); - -Fleur.XPathFunctions_fn["namespace-uri#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:namespace-uri", +*/ +/* function(node) { if (node === null) { return null; @@ -52,4 +48,5 @@ Fleur.XPathFunctions_fn["namespace-uri#1"] = new Fleur.Function("http://www.w3.o } return node.namespaceURI; }, - null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_anyURI}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_anyURI}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/nilled.js b/src/js/fleur.js/XPath/XPathFunctions/fn/nilled.js index 7fa031d..8074b4c 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/nilled.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/nilled.js @@ -1,42 +1,29 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_nilled_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "1" - }, - params_type: [] +Fleur.Context.prototype.fn_nilled_0 = function() { + this.notyet(); }; -Fleur.signatures.fn_nilled_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "?" - }, - params_type: [ - { - occurrence: "1" - } - ] +Fleur.Context.prototype.fn_nilled_1 = function() { + this.notyet(); }; -Fleur.XPathFunctions_fn["nilled#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:nilled", +Fleur.XPathFunctions_fn["nilled#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:nilled", Fleur.Context.prototype.fn_nilled_0, + [], Fleur.SequenceType_boolean_01); + +Fleur.XPathFunctions_fn["nilled#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:nilled", Fleur.Context.prototype.fn_nilled_1, + [Fleur.SequenceType_item_01], Fleur.SequenceType_boolean_01); +/* function(ctx) { return Fleur.XPathFunctions_fn["nilled#1"].jsfunc(ctx._curr); }, null, [], true, false, {type: Fleur.Type_boolean}); - -Fleur.XPathFunctions_fn["nilled#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:nilled", +*/ +/* function(node) { if (node === Fleur.EmptySequence) { return null; @@ -48,4 +35,5 @@ Fleur.XPathFunctions_fn["nilled#1"] = new Fleur.Function("http://www.w3.org/2005 } return false; }, - null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_boolean}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_boolean}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/node-name.js b/src/js/fleur.js/XPath/XPathFunctions/fn/node-name.js index 2c2522e..a556eae 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/node-name.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/node-name.js @@ -1,36 +1,31 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_node$_name_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - params_type: [] +Fleur.Context.prototype.fn_node$_name_0 = function() { + return this.current().fn_node$_name_1(); }; -Fleur.signatures.fn_node$_name_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - params_type: [ - { - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_node$_name_1 = function() { + const node = this.item; + if (node.isNotEmpty() && (node.nodeType !== Fleur.Node.DOCUMENT_NODE && node.nodeType !== Fleur.Node.COMMENT_NODE && node.nodeType !== Fleur.Node.TEXT_NODE)) { + const newitem = new Fleur.Text(""); + newitem.data = node.nodeName; + newitem.schemaTypeInfo = Fleur.Type_QName; + newitem._setNodeNameLocalNamePrefix(node.namespaceURI.isNotEmpty() ? node.namespaceURI : "", node.nodeName); + this.item = newitem; + } + return this; }; -Fleur.XPathFunctions_fn["node-name#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:node-name", +Fleur.XPathFunctions_fn["node-name#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:node-name", Fleur.Context.prototype.fn_node$_name_0, + [], Fleur.SequenceType_QName_01); + +Fleur.XPathFunctions_fn["node-name#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:node-name", Fleur.Context.prototype.fn_node$_name_1, + [Fleur.SequenceType_item_01], Fleur.SequenceType_QName_01); +/* function(ctx) { if (ctx._curr === Fleur.EmptySequence) { return null; @@ -41,9 +36,9 @@ Fleur.XPathFunctions_fn["node-name#0"] = new Fleur.Function("http://www.w3.org/2 return ctx._curr.nodeName; }, null, [], true, false, {type: Fleur.Type_string}); - -Fleur.XPathFunctions_fn["node-name#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:node-name", - function(node) { +*/ +/* +function(node) { if (node === Fleur.EmptySequence) { return null; } @@ -52,4 +47,5 @@ Fleur.XPathFunctions_fn["node-name#1"] = new Fleur.Function("http://www.w3.org/2 } return node.nodeName; }, - null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/normalize-empty.js b/src/js/fleur.js/XPath/XPathFunctions/fn/normalize-empty.js index d15ecb9..9cf14ee 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/normalize-empty.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/normalize-empty.js @@ -1,45 +1,34 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_normalize$_empty_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [] +Fleur.Context.prototype.fn_normalize$_empty_0 = function() { + return this.current().fn_normalize$_empty_1(); }; -Fleur.signatures.fn_normalize$_empty_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_normalize$_empty_1 = function() { + if (this.item.isEmpty()) { + this.item = new Fleur.Text(""); + } + return this; }; -Fleur.XPathFunctions_fn["normalize-empty#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:normalize-empty", +Fleur.XPathFunctions_fn["normalize-empty#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:normalize-empty", Fleur.Context.prototype.fn_normalize$_empty_0, + [], Fleur.SequenceType_string_1); + +Fleur.XPathFunctions_fn["normalize-empty#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:normalize-empty", Fleur.Context.prototype.fn_normalize$_empty_1, + [Fleur.SequenceType_string_01], Fleur.SequenceType_string_1); +/* function(ctx) { return ctx._curr && ctx._curr.textContent !== "" ? ctx._curr.textContent : null; }, null, [], true, false, {type: Fleur.Type_string}); - -Fleur.XPathFunctions_fn["normalize-empty#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:normalize-empty", +*/ +/* function(arg) { return arg && arg !== "" ? arg : null; }, - null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/normalize-space.js b/src/js/fleur.js/XPath/XPathFunctions/fn/normalize-space.js index e88ce12..dc5c2fd 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/normalize-space.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/normalize-space.js @@ -1,56 +1,40 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_normalize$_space_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [] -}; -Fleur.signatures.fn_normalize$_space_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_normalize$_space_0 = function() { + return this.current().fn_normalize$_empty_1(); }; Fleur.Context.prototype.fn_normalize$_space_1 = function() { + const res = new Fleur.Text(); if (this.item.isNotEmpty()) { - this.item.data = this.item.data.trim().replace(/\s+/g, " "); + res.data = this.item.data.trim().replace(/\s+/g, " "); } else { - this.item = new Fleur.Text(); - this.item.data = ""; + res.data = ""; } - this.item.schemaTypeInfo = Fleur.Type_string; + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; return this; }; -Fleur.XPathFunctions_fn["normalize-space#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:normalize-space", +Fleur.XPathFunctions_fn["normalize-space#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:normalize-space", Fleur.Context.prototype.fn_normalize$_space_0, + [], Fleur.SequenceType_string_1); + +Fleur.XPathFunctions_fn["normalize-space#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:normalize-space", Fleur.Context.prototype.fn_normalize$_space_1, + [Fleur.SequenceType_string_01], Fleur.SequenceType_string_1); +/* function(ctx) { return ctx._curr ? ctx._curr.textContent.replace(/^\s+|\s+$/g, "").replace(/\s+/g, " ") : ""; }, null, [], true, false, {type: Fleur.Type_string}); - -Fleur.XPathFunctions_fn["normalize-space#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:normalize-space", +*/ +/* function(arg) { return arg ? arg.replace(/^\s+|\s+$/g, "").replace(/\s+/g, " ") : ""; }, - null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/normalize-unicode.js b/src/js/fleur.js/XPath/XPathFunctions/fn/normalize-unicode.js index 4bd4144..48f0552 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/normalize-unicode.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/normalize-unicode.js @@ -1,49 +1,50 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_normalize$_unicode_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_normalize$_unicode_1 = function() { + const res = new Fleur.Text(); + if (this.item.isNotEmpty()) { + res.data = this.item.data.normalize(); + } else { + res.data = ""; + } + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; + return this; }; -Fleur.signatures.fn_normalize$_unicode_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" +Fleur.Context.prototype.fn_normalize$_unicode_2 = function() { + const res = new Fleur.Text(); + const arg = this.itemstack.pop(); + if (arg.isNotEmpty()) { + const normalizationForm = this.item.data.toUpperCase().trim(); + res.data = ""; + if (normalizationForm === "") { + res.data = arg.data; + } else { + try { + res.data = arg.data.normalize(normalizationForm); + } catch(e) { + res.data = arg.data; + } } - ] + } else { + res.data = ""; + } + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; + return this; }; -Fleur.XPathFunctions_fn["normalize-unicode#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:normalize-unicode", +Fleur.XPathFunctions_fn["normalize-unicode#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:normalize-unicode", Fleur.Context.prototype.fn_normalize$_unicode_1, + [Fleur.SequenceType_string_01], Fleur.SequenceType_string_1); + +Fleur.XPathFunctions_fn["normalize-unicode#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:normalize-unicode", Fleur.Context.prototype.fn_normalize$_unicode_2, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_1], Fleur.SequenceType_string_1); +/* function(arg) { if (!arg) { return ""; @@ -51,8 +52,8 @@ Fleur.XPathFunctions_fn["normalize-unicode#1"] = new Fleur.Function("http://www. return arg.normalize(); }, null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string}); - -Fleur.XPathFunctions_fn["normalize-unicode#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:normalize-unicode", +*/ +/* function(arg, normalizationForm) { if (!arg) { return ""; @@ -67,4 +68,5 @@ Fleur.XPathFunctions_fn["normalize-unicode#2"] = new Fleur.Function("http://www. return arg; } }, - null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/not.js b/src/js/fleur.js/XPath/XPathFunctions/fn/not.js index 0220c15..ffb256f 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/not.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/not.js @@ -1,23 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_not_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "1" - }, - params_type: [ - null - ] -}; - Fleur.Context.prototype.fn_not_1 = function() { const newitem = new Fleur.Text(); newitem.schemaTypeInfo = Fleur.Type_boolean; @@ -59,7 +46,9 @@ Fleur.Context.prototype.fn_not_1 = function() { return this; }; -Fleur.XPathFunctions_fn["not#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:not", +Fleur.XPathFunctions_fn["not#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:not", Fleur.Context.prototype.fn_not_1, + [Fleur.SequenceType_item_0n], Fleur.SequenceType_boolean_1); +/* function(arg, ctx) { var e; if (arg === Fleur.EmptySequence) { @@ -101,4 +90,5 @@ Fleur.XPathFunctions_fn["not#1"] = new Fleur.Function("http://www.w3.org/2005/xp e.name = "FORG0006"; return e; }, - null, [{type: Fleur.Node, occurence: "*"}], true, false, {type: Fleur.Type_boolean}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "*"}], true, false, {type: Fleur.Type_boolean}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/number.js b/src/js/fleur.js/XPath/XPathFunctions/fn/number.js index 23b0832..d8e4f93 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/number.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/number.js @@ -1,48 +1,41 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ - Fleur.signatures.fn_number_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_number_0 = function() { + return this.current().fn_number_1(); }; Fleur.Context.prototype.fn_number_1 = function() { + const res = new Fleur.Text(); if (this.item.isNotEmpty()) { try { - this.item.data = Fleur.Type_double.canonicalize(this.item.data); - } catch { - this.item.data = "NaN"; + res.data = Fleur.Type_double.canonicalize(this.item.data); + } catch(e) { + res.data = "NaN"; } } else { - this.item = new Fleur.Text(); - this.item.data = "NaN"; + res.data = "NaN"; } - this.item.schemaTypeInfo = Fleur.Type_double; + res.schemaTypeInfo = Fleur.Type_double; + this.item = res; return this; }; -Fleur.XPathFunctions_fn["number#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:number", +Fleur.XPathFunctions_fn["number#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:number", Fleur.Context.prototype.fn_number_0, + [], Fleur.SequenceType_numeric_1); + +Fleur.XPathFunctions_fn["number#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:number", Fleur.Context.prototype.fn_number_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_numeric_1); +/* function(ctx) { return Fleur.XPathFunctions_fn["number#1"].jsfunc(ctx._curr); }, null, [], true, false, {type: Fleur.Type_double}); - -Fleur.XPathFunctions_fn["number#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:number", +*/ +/* function(arg) { var a = Fleur.Atomize(arg); if (a.schemaTypeInfo === Fleur.Type_error) { @@ -65,4 +58,5 @@ Fleur.XPathFunctions_fn["number#1"] = new Fleur.Function("http://www.w3.org/2005 } return parseFloat(a.data); }, - null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_double}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_double}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/one-or-more.js b/src/js/fleur.js/XPath/XPathFunctions/fn/one-or-more.js index c918899..42c37d2 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/one-or-more.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/one-or-more.js @@ -1,20 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ - Fleur.signatures.fn_one$_or$_more_1 = { - need_ctx: false, - is_async: false, - return_type: { - occurrence: "+" - }, - params_type: [null] +Fleur.Context.prototype.fn_one$_or$_more_1 = function() { + if (this.item.isEmpty()) { + Fleur.XQueryError_xqt("FORG0004", null, "Wrong argument type for fn:one-or-more#1", "", this.item); + } + return this; }; -Fleur.XPathFunctions_fn["one-or-more#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:one-or-more", +Fleur.XPathFunctions_fn["one-or-more#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:one-or-more", Fleur.Context.prototype.fn_one$_or$_more_1, + [Fleur.SequenceType_item_0n], Fleur.SequenceType_item_1n); +/* function(arg, ctx) { if (arg === Fleur.EmptySequence) { return Fleur.error(ctx, "FORG0004"); @@ -31,4 +31,5 @@ Fleur.XPathFunctions_fn["one-or-more#1"] = new Fleur.Function("http://www.w3.org return arg; } }, - null, [{type: Fleur.Node, occurence: "*"}], true, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "*"}], true, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/parse-ietf-date.js b/src/js/fleur.js/XPath/XPathFunctions/fn/parse-ietf-date.js index 5843fdf..e7a8ef7 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/parse-ietf-date.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/parse-ietf-date.js @@ -1,29 +1,30 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_parse$_ietf$_date_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dateTime, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_parse$_ietf$_date_1 = function() { + if (this.item.isNotEmpty()) { + const d = new Date(this.item.data); + const dtz = { + d: d, + tz: d.getTimezoneOffset() + }; + const res = new Fleur.Text(); + res.data = Fleur.dateToDateTime(dtz); + res.schemaTypeInfo = Fleur.Type_dateTime; + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["parse-ietf-date#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:parse-ietf-date", +Fleur.XPathFunctions_fn["parse-ietf-date#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:parse-ietf-date", Fleur.Context.prototype.fn_parse$_ietf$_date_1, + [Fleur.SequenceType_string_01], Fleur.SequenceType_dateTime_01); +/* function(value) { return value ? new Date(value) : null; }, - null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_dateTime}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_dateTime}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/parse-md.js b/src/js/fleur.js/XPath/XPathFunctions/fn/parse-md.js index d80c965..b46828e 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/parse-md.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/parse-md.js @@ -1,28 +1,24 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_parse$_md_1 = { - need_ctx: false, - is_async: false, - return_type: { - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_parse$_md_1 = function() { + if (this.item.isNotEmpty()) { + const parser = new Fleur.DOMParser(); + this.item = parser.parseFromString(this.item.data, "text/markdown"); + } + return this; }; -Fleur.XPathFunctions_fn["parse-md#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:parse-md", +Fleur.XPathFunctions_fn["parse-md#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:parse-md", Fleur.Context.prototype.fn_parse$_md_1, + [Fleur.SequenceType_string_01], Fleur.SequenceType_document_01); +/* function(arg) { var parser = new Fleur.DOMParser(); return arg !== null ? parser.parseFromString(arg, "text/markdown") : null; }, - null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Node, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Node, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/parse-xml-fragment.js b/src/js/fleur.js/XPath/XPathFunctions/fn/parse-xml-fragment.js new file mode 100644 index 0000000..f281a1d --- /dev/null +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/parse-xml-fragment.js @@ -0,0 +1,24 @@ +"use strict"; +/** + * @author Alain Couthures + * @license LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.Context.prototype.fn_parse$_xml$_fragment_1 = function() { + if (this.item.isNotEmpty()) { + const parser = new Fleur.DOMParser(); + this.item = parser.parseFromString(this.item.data, "application/xml"); + } + return this; +}; + +Fleur.XPathFunctions_fn["parse-xml#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:parse-xml", Fleur.Context.prototype.fn_parse$_xml$_fragment_1, + [Fleur.SequenceType_string_01], Fleur.SequenceType_document_01); +/* + function(arg) { + var parser = new Fleur.DOMParser(); + return arg !== null ? parser.parseFromString(arg, "application/xml") : null; + }, + null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Node, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/parse-xml.js b/src/js/fleur.js/XPath/XPathFunctions/fn/parse-xml.js index 99c7ae6..a1a2a0b 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/parse-xml.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/parse-xml.js @@ -1,28 +1,24 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_parse$_xml_1 = { - need_ctx: false, - is_async: false, - return_type: { - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_parse$_xml_1 = function() { + if (this.item.isNotEmpty()) { + const parser = new Fleur.DOMParser(); + this.item = parser.parseFromString(this.item.data, "application/xml"); + } + return this; }; -Fleur.XPathFunctions_fn["parse-xml#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:parse-xml", +Fleur.XPathFunctions_fn["parse-xml#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:parse-xml", Fleur.Context.prototype.fn_parse$_xml_1, + [Fleur.SequenceType_string_01], Fleur.SequenceType_document_01); +/* function(arg) { var parser = new Fleur.DOMParser(); return arg !== null ? parser.parseFromString(arg, "application/xml") : null; }, - null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Node, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Node, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/parse.js b/src/js/fleur.js/XPath/XPathFunctions/fn/parse.js index 0c611b7..2807381 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/parse.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/parse.js @@ -1,29 +1,30 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_parse_2 = { - need_ctx: false, - is_async: false, - return_type: { - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - occurrence: "?" +Fleur.Context.prototype.fn_parse_2 = function() { + const serialization = this.item; + const arg = this.itemstack.pop(); + if (arg.isNotEmpty()) { + let contentType = "application/xml"; + if (serialization.isNotEmpty()) { + const op2 = Fleur.toJSObject(serialization); + contentType = Fleur.toContentType(op2[1]); } - ] + const parser = new Fleur.DOMParser(); + this.item = parser.parseFromString(arg.data, contentType); + } else { + this.item = arg; + } + return this; }; -Fleur.XPathFunctions_fn["parse#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:parse", +Fleur.XPathFunctions_fn["parse#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:parse", Fleur.Context.prototype.fn_parse_2, + [Fleur.SequenceType_string_01, Fleur.SequenceType_item_01], Fleur.SequenceType_document_01); +/* function(arg, serialization) { var contentType; if (serialization) { @@ -41,4 +42,5 @@ Fleur.XPathFunctions_fn["parse#2"] = new Fleur.Function("http://www.w3.org/2005/ var parser = new Fleur.DOMParser(); return arg !== null ? parser.parseFromString(arg, contentType) : null; }, - null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Node, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Node, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/position.js b/src/js/fleur.js/XPath/XPathFunctions/fn/position.js index c355f3e..cfd0098 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/position.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/position.js @@ -1,21 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_position_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, - params_type: [] -}; - Fleur.Context.prototype.fn_position_0 = function() { this.itemstack.push(this.item); const item = new Fleur.Text(); @@ -25,8 +14,11 @@ Fleur.Context.prototype.fn_position_0 = function() { return this; }; -Fleur.XPathFunctions_fn["position#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:position", - function(ctx) { +Fleur.XPathFunctions_fn["position#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:position", Fleur.Context.prototype.fn_position_0, + [], Fleur.SequenceType_integer_1); +/* +function(ctx) { return ctx._pos; }, - null, [], true, false, {type: Fleur.Type_integer}); \ No newline at end of file + null, [], true, false, {type: Fleur.Type_integer}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/project.json b/src/js/fleur.js/XPath/XPathFunctions/fn/project.json index 0e7ba51..0a8b46f 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/project.json +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/project.json @@ -26,6 +26,7 @@ "days-from-duration.js", "deep-equal.js", "default-collation.js", + "default-language.js", "distinct-values.js", "doc.js", "document-uri.js", @@ -83,6 +84,7 @@ "parse-ietf-date.js", "parse-md.js", "parse-xml.js", + "parse-xml-fragment.js", "position.js", "QName.js", "remove.js", diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/remove.js b/src/js/fleur.js/XPath/XPathFunctions/fn/remove.js index 5a50040..274caeb 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/remove.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/remove.js @@ -1,24 +1,17 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_remove_1 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - null, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "1" - } - ] +Fleur.Context.prototype.fn_remove_2 = function() { + this.notyet(); }; +Fleur.XPathFunctions_fn["remove#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:remove", Fleur.Context.prototype.fn_remove_2, + [Fleur.SequenceType_item_0n, Fleur.SequenceType_integer_1], Fleur.SequenceType_item_0n); +/* Fleur.XPathFunctions_fn["remove"] = function(ctx, children, callback) { if (children.length !== 2) { Fleur.callback(function() {callback(Fleur.error(ctx, "XPST0017"));}); @@ -71,4 +64,4 @@ Fleur.XPathFunctions_fn["remove"] = function(ctx, children, callback) { Fleur.callback(function() {callback(result);}); }); }); -}; \ No newline at end of file +};*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/replace.js b/src/js/fleur.js/XPath/XPathFunctions/fn/replace.js index d3ff457..a2a0c7d 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/replace.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/replace.js @@ -1,76 +1,43 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_replace_3 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - } - ] +Fleur.Context.prototype.fn_replace_3 = function() { + return this.emptySequence().fn_replace_4(); }; - -Fleur.signatures.fn_replace_4 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" +Fleur.Context.prototype.fn_replace_4 = function() { + const flags = this.item; + const replacement = this.itemstack.pop(); + const pattern = this.itemstack.pop(); + const input = this.itemstack.pop(); + this.item = new Fleur.Text(""); + this.item.schemaTypeInfo = Fleur.Type_string; + if (input.isNotEmpty()) { + try { + const re = new RegExp(pattern.data, flags.isNotEmpty() ? flags.data + "g" : "g"); + this.item.data = input.data.replace(re, replacement.data); + } catch (e) { + this.item.data = input.data; } - ] + } + return this; }; -Fleur.XPathFunctions_fn["replace#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:replace", +Fleur.XPathFunctions_fn["replace#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:replace", Fleur.Context.prototype.fn_replace_3, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_1, Fleur.SequenceType_string_1], Fleur.SequenceType_string_1); + +Fleur.XPathFunctions_fn["replace#4"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:replace", Fleur.Context.prototype.fn_replace_4, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_1, Fleur.SequenceType_string_1, Fleur.SequenceType_string_01], Fleur.SequenceType_string_1); +/* function(input, pattern, replacement) { return Fleur.XPathFunctions_fn["replace#4"].jsfunc(input, pattern, replacement); }, null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_string}); - -Fleur.XPathFunctions_fn["replace#4"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:replace", +*/ +/* function(input, pattern, replacement, flags) { input = input || ""; flags = (flags || "") + "g"; @@ -81,4 +48,5 @@ Fleur.XPathFunctions_fn["replace#4"] = new Fleur.Function("http://www.w3.org/200 return input; } }, - null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}, {type: Fleur.Type_string}, {type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}, {type: Fleur.Type_string}, {type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/reverse.js b/src/js/fleur.js/XPath/XPathFunctions/fn/reverse.js index ca8f5a1..433b36a 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/reverse.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/reverse.js @@ -1,18 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_reverse_1 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - null - ] -}; Fleur.Context.prototype.fn_reverse_1 = function() { if (this.item.nodeType === Fleur.Node.SEQUENCE_NODE && this.item.childNodes.length !== 0) { const result = new Fleur.Sequence(); @@ -26,7 +18,9 @@ Fleur.Context.prototype.fn_reverse_1 = function() { return this; }; -Fleur.XPathFunctions_fn["reverse#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:reverse", +Fleur.XPathFunctions_fn["reverse#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:reverse", Fleur.Context.prototype.fn_reverse_1, + [Fleur.SequenceType_item_0n], Fleur.SequenceType_item_0n); +/* function(arg) { if (arg === Fleur.EmptySequence) { return Fleur.EmptySequence; @@ -43,4 +37,5 @@ Fleur.XPathFunctions_fn["reverse#1"] = new Fleur.Function("http://www.w3.org/200 } return arg; }, - null, [{type: Fleur.Node, occurence: "*"}], false, false, {type: Fleur.Node, occurence: "*"}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "*"}], false, false, {type: Fleur.Node, occurence: "*"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/round-half-to-even.js b/src/js/fleur.js/XPath/XPathFunctions/fn/round-half-to-even.js index c882551..4d26da4 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/round-half-to-even.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/round-half-to-even.js @@ -1,49 +1,54 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_round$_half$_to$_even_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" +Fleur.Context.prototype.fn_round$_half$_to$_even_1 = function() { + if (this.item.isNotEmpty()) { + let a = Number(this.item.data); + if (a - Math.floor(a) === 0.5 && Math.floor(a) % 2 === 0) { + a -= 1; } - ] + const res = new Fleur.Text(); + res.data = String(Math.round(a)); + res.schemaTypeInfo = this.item.schemaTypeInfo; + this.item = res; + } + return this; }; -Fleur.signatures.fn_round$_half$_to$_even_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "1" +Fleur.Context.prototype.fn_round$_half$_to$_even_2 = function() { + const precision = Number(this.item.data); + const arg = this.itemstack.pop(); + if (arg.isNotEmpty()) { + const res = new Fleur.Text(); + let a = Number(arg.data); + let a2 = a * Math.pow(10, precision) + Math.pow(10, Math.floor(Math.log(Math.abs(a)) * Math.LOG10E) + precision - 15); + if (a2 === Number.POSITIVE_INFINITY) { + res.data = "+INF"; + } else if (a2 === 0) { + res.data = "0"; + } else if (Math.round(a2 * 2) / 2 - Math.floor(a2) === 0.5 && Math.floor(a2) % 2 === 0) { + a2 -= 1; + res.data = String(Math.round(a2) * Math.pow(10, -precision)); + } else { + res.data = String(Math.round(a2) * Math.pow(10, -precision)); } - ] + res.schemaTypeInfo = arg.schemaTypeInfo; + this.item = res; + } else { + this.item = arg; + } + return this; }; -Fleur.XPathFunctions_fn["round-half-to-even#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:round-half-to-even", +Fleur.XPathFunctions_fn["round-half-to-even#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:round-half-to-even", Fleur.Context.prototype.fn_round$_half$_to$_even_1, + [Fleur.SequenceType_numeric_01], Fleur.SequenceType_numeric_01); + +Fleur.XPathFunctions_fn["round-half-to-even#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:round-half-to-even", Fleur.Context.prototype.fn_round$_half$_to$_even_2, + [Fleur.SequenceType_numeric_01, Fleur.SequenceType_integer_1], Fleur.SequenceType_numeric_01); +/* function(arg) { if (arg === null) { return [null, null]; @@ -59,8 +64,8 @@ Fleur.XPathFunctions_fn["round-half-to-even#1"] = new Fleur.Function("http://www return [a2, t2]; }, null, [{type: Fleur.numericTypes, adaptative: true, occurence: "?"}], false, false, {type: Fleur.numericTypes, adaptative: true, occurence: "?"}); - -Fleur.XPathFunctions_fn["round-half-to-even#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:round-half-to-even", +*/ +/* function(arg, precision) { if (arg === null) { return [null, null]; @@ -80,4 +85,5 @@ Fleur.XPathFunctions_fn["round-half-to-even#2"] = new Fleur.Function("http://www } return [Math.round(a2) * Math.pow(10, -precision), t]; }, - null, [{type: Fleur.numericTypes, adaptative: true, occurence: "?"}, {type: Fleur.Type_integer}], false, false, {type: Fleur.numericTypes, adaptative: true, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.numericTypes, adaptative: true, occurence: "?"}, {type: Fleur.Type_integer}], false, false, {type: Fleur.numericTypes, adaptative: true, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/round.js b/src/js/fleur.js/XPath/XPathFunctions/fn/round.js index 1dc7e90..4b9d62e 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/round.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/round.js @@ -1,50 +1,42 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_round_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_round_1 = function() { + if (this.item.isNotEmpty()) { + const a = Number(this.item.data); + const res = new Fleur.Text(); + res.data = String(Math.round(a)); + res.schemaTypeInfo = this.item.schemaTypeInfo; + this.item = res; + } + return this; }; -Fleur.signatures.fn_round_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "1" - } - ] +Fleur.Context.prototype.fn_round_2 = function() { + const arg = this.itemstack.pop(); + if (arg.isNotEmpty()) { + const precision = Number(this.item.data); + const res = new Fleur.Text(); + res.schemaTypeInfo = arg.schemaTypeInfo; + const a = Number(arg.data); + res.data = String(Math.round(a * Math.pow(10, precision) + Math.pow(10, Math.floor(Math.log(Math.abs(a)) * Math.LOG10E) + precision - 15)) / Math.pow(10, precision)); + this.item = res; + } else { + this.item = arg; + } + return this; }; -Fleur.XPathFunctions_fn["round#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:round", - function(arg) { +Fleur.XPathFunctions_fn["round#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:round", Fleur.Context.prototype.fn_round_1, + [Fleur.SequenceType_numeric_01], Fleur.SequenceType_numeric_01); + +Fleur.XPathFunctions_fn["round#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:round", Fleur.Context.prototype.fn_round_2, + [Fleur.SequenceType_numeric_01, Fleur.SequenceType_integer_1], Fleur.SequenceType_numeric_01); +/* +function(arg) { if (arg === null) { return [null, null]; } @@ -56,8 +48,8 @@ Fleur.XPathFunctions_fn["round#1"] = new Fleur.Function("http://www.w3.org/2005/ return [a2, t2]; }, null, [{type: Fleur.numericTypes, adaptative: true, occurence: "?"}], false, false, {type: Fleur.numericTypes, adaptative: true, occurence: "?"}); - -Fleur.XPathFunctions_fn["round#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:round", +*/ +/* function(arg, precision) { if (arg === null) { return [null, null]; @@ -69,4 +61,5 @@ Fleur.XPathFunctions_fn["round#2"] = new Fleur.Function("http://www.w3.org/2005/ t2 = t; return [a2, t2]; }, - null, [{type: Fleur.numericTypes, adaptative: true, occurence: "?"}, {type: Fleur.Type_integer}], false, false, {type: Fleur.numericTypes, adaptative: true, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.numericTypes, adaptative: true, occurence: "?"}, {type: Fleur.Type_integer}], false, false, {type: Fleur.numericTypes, adaptative: true, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/seconds-from-dateTime.js b/src/js/fleur.js/XPath/XPathFunctions/fn/seconds-from-dateTime.js index 0d970d3..eb0a756 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/seconds-from-dateTime.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/seconds-from-dateTime.js @@ -1,29 +1,25 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_seconds$_from$_dateTime_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_decimal, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dateTime, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_seconds$_from$_dateTime_1 = function() { + if (this.item.isNotEmpty()) { + const res = new Fleur.Text(); + res.data = String(parseFloat(this.data.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:(\d{2}(?:\.\d+)?)(?:Z|[+\-]\d{2}:\d{2})?$/)[1])); + res.schemaTypeInfo = Fleur.Type_decimal; + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["seconds-from-dateTime#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:seconds-from-dateTime", +Fleur.XPathFunctions_fn["seconds-from-dateTime#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:seconds-from-dateTime", Fleur.Context.prototype.fn_seconds$_from$_dateTime_1, + [Fleur.SequenceType_dateTime_01], Fleur.SequenceType_decimal_01); +/* function(arg) { return arg !== null ? parseFloat(arg.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:(\d{2}(?:\.\d+)?)(?:Z|[+\-]\d{2}:\d{2})?$/)[1]) : null; }, - null, [{type: Fleur.Type_dateTime, occurence: "?"}], true, false, {type: Fleur.Type_decimal, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_dateTime, occurence: "?"}], true, false, {type: Fleur.Type_decimal, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/seconds-from-duration.js b/src/js/fleur.js/XPath/XPathFunctions/fn/seconds-from-duration.js index 797b131..b3775b4 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/seconds-from-duration.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/seconds-from-duration.js @@ -1,28 +1,33 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ - Fleur.signatures.fn_seconds$_from$_dateTime_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_decimal, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_duration, - occurrence: "?" +Fleur.Context.prototype.fn_seconds$_from$_dateTime_1 = function() { + if (this.item.isNotEmpty()) { + const a = this.item; + let signedd = 0; + if (a.schemaTypeInfo === Fleur.Type_dayTimeDuration) { + const d = Fleur.toJSONDayTimeDuration(a.data); + signedd = d.sign * d.second; + } + if (a.schemaTypeInfo !== Fleur.Type_yearMonthDuration) { + const d = Fleur.toJSONDuration(a.data); + signedd = d.sign * d.second; } - ] + const res = new Fleur.Text(); + res.schemaTypeInfo = Fleur.Type_decimal; + res.data = Number(signedd); + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["seconds-from-duration#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:seconds-from-duration", +Fleur.XPathFunctions_fn["seconds-from-duration#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:seconds-from-duration", Fleur.Context.prototype.fn_seconds$_from$_dateTime_1, + [Fleur.SequenceType_duration_01], Fleur.SequenceType_decimal_01); +/* function(arg) { var a = Fleur.Atomize(arg); if (a === Fleur.EmptySequence) { @@ -39,4 +44,5 @@ Fleur.XPathFunctions_fn["seconds-from-duration#1"] = new Fleur.Function("http:// e.name = "XPTY0004"; return e; }, - null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_decimal, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_decimal, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/seconds-from-time.js b/src/js/fleur.js/XPath/XPathFunctions/fn/seconds-from-time.js index ee0f48f..2bfed37 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/seconds-from-time.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/seconds-from-time.js @@ -1,29 +1,25 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_seconds$_from$_time_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_decimal, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_time, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_seconds$_from$_time_1 = function() { + if (this.item.isNotEmpty()) { + const res = new Fleur.Text(); + res.data = String(parseFloat(this.data.match(/^\d{2}:\d{2}:(\d{2}(?:\.\d+)?)(?:Z|[+\-]\d{2}:\d{2})?$/)[1])); + res.schemaTypeInfo = Fleur.Type_decimal; + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["seconds-from-time#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:seconds-from-time", +Fleur.XPathFunctions_fn["seconds-from-time#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:seconds-from-time", Fleur.Context.prototype.fn_seconds$_from$_time_1, + [Fleur.SequenceType_time_01], Fleur.SequenceType_decimal_01); +/* function(arg) { return arg !== null ? parseFloat(arg.match(/^\d{2}:\d{2}:(\d{2}(?:\.\d+)?)(?:Z|[+\-]\d{2}:\d{2})?$/)[1]) : null; }, - null, [{type: Fleur.Type_time, occurence: "?"}], true, false, {type: Fleur.Type_decimal, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_time, occurence: "?"}], true, false, {type: Fleur.Type_decimal, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/serialize.js b/src/js/fleur.js/XPath/XPathFunctions/fn/serialize.js index a5e9d21..8b60bf6 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/serialize.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/serialize.js @@ -1,17 +1,74 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.XPathFunctions_fn["serialize#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:serialize", +Fleur.Context.prototype.fn_serialize_1 =function() { + return this.emptySequence().fn_serialize_2(); +}; +Fleur.Context.prototype.fn_serialize_2 = function() { + const serialization = this.item; + const node = this.itemstack.pop(); + this.item = new Fleur.Text(""); + this.item.schemaTypeInfo = Fleur.Type_string; + if (node.isNotEmpty()) { + let contentType; + let defContentType = null; + let i, l; + const defDetect = function(n) { + switch(n.nodeType) { + case Fleur.Node.ARRAY_NODE : + case Fleur.Node.MAP_NODE : + defContentType = "application/json"; + break; + case Fleur.Node.TEXT_NODE: + defContentType = "text/plain"; + break; + case Fleur.Node.SEQUENCE_NODE: + defContentType = "text/csv"; + break; + case Fleur.Node.ELEMENT_NODE: + defContentType = "application/xml"; + } + }; + if (node.nodeType === Fleur.Node.DOCUMENT_NODE) { + for (i = 0, l = node.children.length; i < l && !defContentType; i++) { + defDetect(node.children[i]); + } + for (i = 0, l = node.childNodes.length; i < l && !defContentType; i++) { + defDetect(node.childNodes[i]); + } + } else { + defDetect(node); + } + let indent = false; + if (serialization.isNotEmpty()) { + const op2 = Fleur.toJSObject(serialization); + contentType = Fleur.toContentType(op2[1], defContentType); + indent = op2[1].indent === "yes"; + } + if (!contentType) { + contentType = defContentType; + } + const ser = new Fleur.Serializer(); + this.item.data = ser.serializeToString(node, contentType, indent); + } + return this; +}; + +Fleur.XPathFunctions_fn["serialize#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:serialize", Fleur.Context.prototype.fn_serialize_1, + [Fleur.SequenceType_item_01], Fleur.SequenceType_string_1); +Fleur.XPathFunctions_fn["serialize#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:serialize", Fleur.Context.prototype.fn_serialize_2, + [Fleur.SequenceType_item_01, Fleur.SequenceType_item_01], Fleur.SequenceType_string_1); +/* function(node) { return Fleur.XPathFunctions_fn["serialize#2"].jsfunc(node, null); }, null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_string}); - -Fleur.XPathFunctions_fn["serialize#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:serialize", +*/ +/* function(node, serialization) { var contentType; var defContentType = null; @@ -58,4 +115,5 @@ Fleur.XPathFunctions_fn["serialize#2"] = new Fleur.Function("http://www.w3.org/2 var ser = new Fleur.Serializer(); return ser.serializeToString(node, contentType, indent); }, - null, [{type: Fleur.Node, occurence: "?"}, {type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}, {type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/sort.js b/src/js/fleur.js/XPath/XPathFunctions/fn/sort.js index 600d963..d350b7a 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/sort.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/sort.js @@ -1,45 +1,82 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_sort_1 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - null - ] +Fleur.Context.prototype.fn_sort_1 = function() { + return this.emptySequence().emptySequence().fn_sort_3(); }; -Fleur.signatures.fn_sort_2 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - null, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_sort_2 = function() { + return this.emptySequence().fn_sort_3(); +}; +Fleur.Context.prototype.fn_sort_3 = function() { + const collation = this.itemstack.pop(); + const input = this.itemstack.pop(); + if (input.isNotEmpty() && input.nodeType === Fleur.Node.SEQUENCE_NODE) { + const key = this.item; + const seq = new Fleur.Sequence(); + seq.childNodes = input.childNodes.slice(); + const v = function(n) { + if (n.schemaTypeInfo === Fleur.Type_integer) { + return parseInt(n.data, 10); + } else if (n.schemaTypeInfo === Fleur.Type_decimal) { + return parseFloat(n.data); + } else if (n.schemaTypeInfo === Fleur.Type_float) { + return n.data === "INF" ? Number.POSITIVE_INFINITY : n.data === "-INF" ? Number.NEGATIVE_INFINITY : parseFloat(n.data); + } else if (n.schemaTypeInfo === Fleur.Type_double) { + return n.data === "INF" ? Number.POSITIVE_INFINITY : n.data === "-INF" ? Number.NEGATIVE_INFINITY : parseFloat(n.data); + } else if (n.schemaTypeInfo.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "integer", Fleur.TypeInfo.DERIVATION_RESTRICTION)) { + return parseInt(n.data, 10); + } else if (n.schemaTypeInfo.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "decimal", Fleur.TypeInfo.DERIVATION_RESTRICTION)) { + return parseFloat(n.data); + } else if (n.schemaTypeInfo.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "float", Fleur.TypeInfo.DERIVATION_RESTRICTION)) { + return n.data === "INF" ? Number.POSITIVE_INFINITY : n.data === "-INF" ? Number.NEGATIVE_INFINITY : parseFloat(n.data); + } else if (n.schemaTypeInfo.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "double", Fleur.TypeInfo.DERIVATION_RESTRICTION)) { + return n.data === "INF" ? Number.POSITIVE_INFINITY : n.data === "-INF" ? Number.NEGATIVE_INFINITY : parseFloat(n.data); + } else if (n.schemaTypeInfo === Fleur.Type_string || n.schemaTypeInfo === Fleur.Type_anyURI || n.schemaTypeInfo === Fleur.Type_untypedAtomic) { + return n.data; + } else if (n.schemaTypeInfo.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "string", Fleur.TypeInfo.DERIVATION_RESTRICTION) || n.schemaTypeInfo.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "anyURI", Fleur.TypeInfo.DERIVATION_RESTRICTION) || n.schemaTypeInfo.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "untypedAtomic", Fleur.TypeInfo.DERIVATION_RESTRICTION)) { + return n.data; + } + }; + seq.childNodes.sort(function(a, b) { + if (a.data === b.data) { + return 0; + } + if (v(a) < v(b)) { + return -1; + } + return 1; + }); + this.item = seq; + } else { + this.item = input; + } }; -Fleur.XPathFunctions_fn["sort#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:sort", +Fleur.XPathFunctions_fn["sort#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:sort", Fleur.Context.prototype.fn_sort_1, + [Fleur.SequenceType_item_0n], Fleur.SequenceType_item_0n); + +Fleur.XPathFunctions_fn["sort#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:sort", Fleur.Context.prototype.fn_sort_2, + [Fleur.SequenceType_item_0n, Fleur.SequenceType_collation_01], Fleur.SequenceType_item_0n); + +Fleur.XPathFunctions_fn["sort#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:sort", Fleur.Context.prototype.fn_sort_3, + [Fleur.SequenceType_item_0n, Fleur.SequenceType_collation_01, Fleur.SequenceType_function_1], Fleur.SequenceType_item_0n); +/* function(input) { return Fleur.XPathFunctions_fn["sort#3"].jsfunc(input, null, null); }, null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Node, occurence: "*"}); - -Fleur.XPathFunctions_fn["sort#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:sort", +*/ +/* function(input, collation) { return Fleur.XPathFunctions_fn["sort#3"].jsfunc(input, collation, null); }, null, [{type: Fleur.Node, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Node, occurence: "*"}); - -Fleur.XPathFunctions_fn["sort#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:sort", +*/ +/* function(input, collation, key) { if (input.nodeType !== Fleur.Node.SEQUENCE_NODE) { return Fleur.Atomize(input); @@ -90,4 +127,5 @@ Fleur.XPathFunctions_fn["sort#3"] = new Fleur.Function("http://www.w3.org/2005/x }); return seq; }, - null, [{type: Fleur.Node, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Node}], false, false, {type: Fleur.Node, occurence: "*"}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Node}], false, false, {type: Fleur.Node, occurence: "*"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/starts-with.js b/src/js/fleur.js/XPath/XPathFunctions/fn/starts-with.js index f160625..683e7e6 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/starts-with.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/starts-with.js @@ -1,56 +1,43 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ - Fleur.signatures.fn_starts$_with_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.fn_starts$_with_2 = function() { const arg2 = this.item; const arg1 = this.itemstack.pop(); + const res = new Fleur.Text(); if (arg2.isNotEmpty()) { if (arg1.isNotEmpty()) { - this.item.data = String(arg1.data.startsWith(arg2.data)); + res.data = String(arg1.data.startsWith(arg2.data)); } else { - this.item = new Fleur.Text(); - this.item.data = String(arg2.data.length === 0); + res.data = String(arg2.data.length === 0); } } else { - this.item = new Fleur.Text(); - this.item.data = "true"; + res.data = "true"; } - this.item.schemaTypeInfo = Fleur.Type_boolean; + res.schemaTypeInfo = Fleur.Type_boolean; + this.item = res; return this; }; +Fleur.Context.prototype.fn_starts$_with_3 = function() { + this.notyet(); +}; Fleur.XPathFunctions_fn["starts-with#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:starts-with", + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_01], Fleur.SequenceType_boolean_1); + +Fleur.XPathFunctions_fn["starts-with#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:starts-with", + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_01, Fleur.SequenceType_string_1], Fleur.SequenceType_boolean_1); +/* function(a, b) { return !b ? true : !a ? false : a.startsWith(b); }, null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_boolean}); - -Fleur.XPathFunctions_fn["starts-with#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:starts-with", +*/ +/* function(a, b, collation) { var c = Fleur.getCollation(collation); if (!c) { @@ -60,4 +47,5 @@ Fleur.XPathFunctions_fn["starts-with#3"] = new Fleur.Function("http://www.w3.org } return !b ? true : !a ? false : c.startsWith(a, b); }, - null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_boolean}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_boolean}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/string-join.js b/src/js/fleur.js/XPath/XPathFunctions/fn/string-join.js index d00f156..d7798fb 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/string-join.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/string-join.js @@ -1,56 +1,47 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_string$_join_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "*" - } - ] +Fleur.Context.prototype.fn_string$_join_1 = function() { + return this.xqx_stringConstantExpr("").fn_string$_join_2(); }; -Fleur.signatures.fn_string$_join_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "*" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" +Fleur.Context.prototype.fn_string$_join_2 = function() { + const arg2 = this.item; + const arg1 = this.itemstack.pop(); + this.item = new Fleur.Text(""); + this.item.schemaTypeInfo = Fleur.Type_string; + if (arg1.isNotEmpty()) { + if (arg1.nodeType !== Fleur.Node.SEQUENCE_NODE) { + this.item.data = arg1.data; + } else { + const l = arg1.childNodes.length; + const sep = arg2.isEmpty() ? "" : arg2.data; + this.item.data = arg1.childNodes[0].data; + for (let i = 1; i < l; i++) { + this.item.data += sep + arg1.childNodes[i].data; + } } - ] + } + return this; }; -Fleur.XPathFunctions_fn["string-join#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:string-join", +Fleur.XPathFunctions_fn["string-join#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:string-join", Fleur.Context.prototype.fn_string$_join_1, + [Fleur.SequenceType_string_0n], Fleur.SequenceType_string_1); + +Fleur.XPathFunctions_fn["string-join#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:string-join", Fleur.Context.prototype.fn_string$_join_2, + [Fleur.SequenceType_string_0n, Fleur.SequenceType_string_01], Fleur.SequenceType_string_1); +/* function(arg1) { return Fleur.XPathFunctions_fn["string-join#2"].jsfunc(arg1, ""); }, null, [{type: Fleur.Type_string, occurence: "*"}], false, false, {type: Fleur.Type_string}); - -Fleur.XPathFunctions_fn["string-join#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:string-join", +*/ +/* function(arg1, arg2) { return arg1 instanceof Array ? arg1.join(arg2 || "") : arg1; }, - null, [{type: Fleur.Type_string, occurence: "*"}, {type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "*"}, {type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/string-length.js b/src/js/fleur.js/XPath/XPathFunctions/fn/string-length.js index 24c1764..6b5892c 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/string-length.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/string-length.js @@ -1,39 +1,31 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_string$_length_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_string$_length_0 = function() { + return this.current().fn_string$_length_1(); }; - Fleur.Context.prototype.fn_string$_length_1 = function() { + const res = new Fleur.Text(); if (this.item.isNotEmpty()) { - this.item.data = Fleur.Type_integer.canonicalize(String(this.item.data.length)); + res.data = Fleur.Type_integer.canonicalize(String(this.item.data.length)); } else { - this.item = new Fleur.Text(); - this.item.data = "0"; + res.data = "0"; } - this.item.schemaTypeInfo = Fleur.Type_integer; + res.schemaTypeInfo = Fleur.Type_integer; + this.item = res; return this; }; -Fleur.XPathFunctions_fn["string-length#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:string-length", +Fleur.XPathFunctions_fn["string-length#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:string-length", Fleur.Context.prototype.fn_string$_length_0, + [], Fleur.SequenceType_integer_1); + +Fleur.XPathFunctions_fn["string-length#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:string-length", Fleur.Context.prototype.fn_string$_length_1, + [Fleur.SequenceType_string_01], Fleur.SequenceType_integer_1); +/* function(ctx) { if (!ctx._curr) { return 0; @@ -42,9 +34,8 @@ Fleur.XPathFunctions_fn["string-length#0"] = new Fleur.Function("http://www.w3.o return a.data.length; }, null, [], true, false, {type: Fleur.Type_integer}); - -Fleur.XPathFunctions_fn["string-length#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:string-length", function(arg) { return !arg ? 0 : arg.length; }, - null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_integer}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_integer}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/string-to-codepoints.js b/src/js/fleur.js/XPath/XPathFunctions/fn/string-to-codepoints.js index 9384a12..3616a93 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/string-to-codepoints.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/string-to-codepoints.js @@ -1,28 +1,34 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_string$_to$_codepoints_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "*" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" +Fleur.Context.prototype.fn_string$_to$_codepoints_1 = function() { + if (this.item.isNotEmpty() && this.item.data !== "") { + const arg = this.item.data; + if (arg.length === 1) { + const res = new Fleur.Text(); + res.data = arg.codePointAt(0); + res.schemaTypeInfo = Fleur.Type_integer; + this.item = res; + } else { + this.item = new Fleur.Sequence(); + const l = arg.length; + for (let i = 0; i < l; i++) { + const cp = new Fleur.Text(String(arg.codePointAt(i))); + cp.schemaTypeInfo = Fleur.Type_integer; + this.item.appendChild(cp); + } } - ] + } + return this; }; -Fleur.XPathFunctions_fn["string-to-codepoints#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:string-to-codepoints", +Fleur.XPathFunctions_fn["string-to-codepoints#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:string-to-codepoints", Fleur.Context.prototype.fn_string$_to$_codepoints_1, + [Fleur.SequenceType_string_01], Fleur.SequenceType_integer_0n, {dynonly: true}); +/* function(arg) { if (!arg || arg === "") { return null; @@ -37,4 +43,5 @@ Fleur.XPathFunctions_fn["string-to-codepoints#1"] = new Fleur.Function("http://w } return ret; }, - null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_integer, occurence: "*"}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_integer, occurence: "*"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/string.js b/src/js/fleur.js/XPath/XPathFunctions/fn/string.js index 05c7391..332ed67 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/string.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/string.js @@ -1,33 +1,12 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_string_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [] -}; -Fleur.signatures.fn_string_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_string_0 = function() { + return this.current().fn_string_1(); }; Fleur.Context.prototype.fn_string_1 = function() { const newitem = new Fleur.Text(this.item.data); @@ -36,13 +15,18 @@ Fleur.Context.prototype.fn_string_1 = function() { return this; }; -Fleur.XPathFunctions_fn["string#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:string", +Fleur.XPathFunctions_fn["string#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:string", Fleur.Context.prototype.fn_string_0, + [], Fleur.SequenceType_string_1); + +Fleur.XPathFunctions_fn["string#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:string", Fleur.Context.prototype.fn_string_1, + [Fleur.SequenceType_item_01], Fleur.SequenceType_string_1); +/* function(ctx) { return Fleur.XPathFunctions_fn["string#1"].jsfunc(ctx._curr); }, null, [], true, false, {type: Fleur.Type_string}); - -Fleur.XPathFunctions_fn["string#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:string", +*/ +/* function(arg) { if (arg === Fleur.EmptySequence) { return ""; @@ -50,4 +34,5 @@ Fleur.XPathFunctions_fn["string#1"] = new Fleur.Function("http://www.w3.org/2005 var a = Fleur.Atomize(arg); return a.data; }, - null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/subsequence.js b/src/js/fleur.js/XPath/XPathFunctions/fn/subsequence.js index 1db0206..bf032f3 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/subsequence.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/subsequence.js @@ -1,49 +1,62 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_subsequence_2 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - null, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "1" - } - ] +Fleur.Context.prototype.fn_subsequence_2 = function() { + return this.xqx_constantExpr(Fleur.Type_float, 'INF').fn_subsequence_3(); }; -Fleur.signatures.fn_subsequence_3 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - null, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "1" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "1" +Fleur.Context.prototype.fn_subsequence_3 = function() { + const length = this.item; + const startingLoc = this.itemstack.pop(); + const sourceSeq = this.itemstack.pop(); + if (startingLoc.data === "-INF" && length.data === "INF" ) { + this.item = new Fleur.Sequence(); + } else { + const lengthval = Math.round(Number(Fleur.toJSNumber(length)[1])); + const startingLocval = Math.round(Number(Fleur.toJSNumber(startingLoc)[1])); + if (lengthval <= 0) { + this.item = new Fleur.Sequence(); + } + if (lengthval === 1 || (sourceSeq.nodeType === Fleur.Node.SEQUENCE_NODE && startingLocval === sourceSeq.childNodes.length && lengthval > 1)) { + if (sourceSeq.nodeType !== Fleur.Node.SEQUENCE_NODE) { + this.item = startingLocval === 1 ? sourceSeq : new Fleur.Sequence(); + } else { + if (startingLoc <= sourceSeq.childNodes.length) { + this.item = sourceSeq.childNodes[startingLocval - 1]; + } else { + this.item = new Fleur.Sequence(); + } + } + } else { + if (sourceSeq.nodeType !== Fleur.Node.SEQUENCE_NODE) { + this.item = startingLocval === 1 ? sourceSeq : Fleur.EmptySequence; + } else { + var seq = new Fleur.Sequence(); + for (let i = startingLocval - 1, l = Math.min(i + lengthval, sourceSeq.childNodes.length); i < l; i++) { + seq.appendChild(sourceSeq.childNodes[i]); + } + this.item = seq; + } } - ] + } + return this; }; -Fleur.XPathFunctions_fn["subsequence#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:subsequence", +Fleur.XPathFunctions_fn["subsequence#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:subsequence", Fleur.Context.prototype.fn_subsequence_2, + [Fleur.SequenceType_item_0n, Fleur.SequenceType_numeric_1], Fleur.SequenceType_item_0n); + +Fleur.XPathFunctions_fn["subsequence#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:subsequence", Fleur.Context.prototype.fn_subsequence_3, + [Fleur.SequenceType_item_0n, Fleur.SequenceType_numeric_1, Fleur.SequenceType_numeric_1], Fleur.SequenceType_item_0n); +/* function(sourceSeq, startingLoc) { return Fleur.XPathFunctions_fn["subsequence#3"].jsfunc(sourceSeq, startingLoc, Number.POSITIVE_INFINITY); }, null, [{type: Fleur.Node, occurence: "*"}, {type: Fleur.numericTypes}], false, false, {type: Fleur.Node}); - -Fleur.XPathFunctions_fn["subsequence#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:subsequence", +*/ +/* function(sourceSeq, startingLoc, length) { if (startingLoc === Number.NEGATIVE_INFINITY && length === Number.POSITIVE_INFINITY) { return Fleur.EmptySequence; @@ -75,4 +88,5 @@ Fleur.XPathFunctions_fn["subsequence#3"] = new Fleur.Function("http://www.w3.org } return seq; }, - null, [{type: Fleur.Node, occurence: "*"}, {type: Fleur.numericTypes}, {type: Fleur.numericTypes}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "*"}, {type: Fleur.numericTypes}, {type: Fleur.numericTypes}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/substring-after.js b/src/js/fleur.js/XPath/XPathFunctions/fn/substring-after.js index b3a16ed..78b3f29 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/substring-after.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/substring-after.js @@ -1,78 +1,54 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_substring$_after_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] -}; -Fleur.signatures.fn_substring$_after_3 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - } - ] -}; - Fleur.Context.prototype.fn_substring$_after_2 = function() { const arg2 = this.item; const arg1 = this.itemstack.pop(); + const res = new Fleur.Text(); if (arg1.isNotEmpty()) { if (arg2.isNotEmpty() || arg2.data === "") { const index = arg1.data.indexOf(arg2.data); - this.item.data = index === -1 ? "" : arg1.data.substring(index + arg2.data.length); + res.data = index === -1 ? "" : arg1.data.substring(index + arg2.data.length); + } else { + res.data = arg1.data; + } + } else { + res.data = ""; + } + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; + return this; +}; +Fleur.Context.prototype.fn_substring$_after_3 = function() { + const collation = this.item; + const arg2 = this.itemstack.pop(); + const arg1 = this.itemstack.pop(); + const res = new Fleur.Text(); + if (arg1.isNotEmpty()) { + if (arg2.isNotEmpty() || arg2.data === "") { + const c = Fleur.getCollation(collation.data); + res.data = c.substringAfter(arg1.data, arg2.data); } else { - this.item = new Fleur.Text(); - this.item.data = arg1.data; + res.data = arg1.data; } } else { - this.item = new Fleur.Text(); - this.item.data = ""; + res.data = ""; } - this.item.schemaTypeInfo = Fleur.Type_string; + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; return this; }; -Fleur.XPathFunctions_fn["substring-after#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:substring-after", +Fleur.XPathFunctions_fn["substring-after#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:substring-after", Fleur.Context.prototype.fn_substring$_after_2, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_01], Fleur.SequenceType_string_1); + +Fleur.XPathFunctions_fn["substring-after#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:substring-after", Fleur.Context.prototype.fn_substring$_after_3, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_01, Fleur.SequenceType_string_1], Fleur.SequenceType_string_1); +/* function(a, b) { if (!a) { return ""; @@ -84,8 +60,8 @@ Fleur.XPathFunctions_fn["substring-after#2"] = new Fleur.Function("http://www.w3 return index === -1 ? "" : a.substring(index + b.length); }, null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string, occurence: "?"}); - -Fleur.XPathFunctions_fn["substring-after#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:substring-after", +*/ +/* function(a, b, collation) { var c = Fleur.getCollation(collation); if (!c) { @@ -101,4 +77,5 @@ Fleur.XPathFunctions_fn["substring-after#3"] = new Fleur.Function("http://www.w3 } return c.substringAfter(a, b); }, - null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_string, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_string, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/substring-before.js b/src/js/fleur.js/XPath/XPathFunctions/fn/substring-before.js index 206a11f..19be572 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/substring-before.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/substring-before.js @@ -1,78 +1,55 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ - Fleur.signatures.fn_substring$_before_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] -}; -Fleur.signatures.fn_substring$_before_3 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - } - ] -}; - Fleur.Context.prototype.fn_substring$_before_2 = function() { const arg1 = this.itemstack.pop(); const arg2 = this.item; + const res = new Fleur.Text(); if (arg1.isNotEmpty() && arg2.isNotEmpty()) { - this.item.data = arg1.data.substring(0, arg1.data.indexOf(arg2.data)); + res.data = arg1.data.substring(0, arg1.data.indexOf(arg2.data)); } else { - this.item = new Fleur.Text(); - this.item.data = ""; + res.data = ""; } - this.item.schemaTypeInfo = Fleur.Type_string; + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; return this; }; +Fleur.Context.prototype.fn_substring$_before_3 = function() { + const collation = this.item; + const arg2 = this.itemstack.pop(); + const arg1 = this.itemstack.pop(); + const res = new Fleur.Text(); + if (arg1.isNotEmpty()) { + if (arg2.isNotEmpty() || arg2.data === "") { + const c = Fleur.getCollation(collation.data); + res.data = c.substringBefore(arg1.data, arg2.data); + } else { + res.data = arg1.data; + } + } else { + res.data = ""; + } + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; + return this; +}; + +Fleur.XPathFunctions_fn["substring-before#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:substring-before", Fleur.Context.prototype.fn_substring$_before_2, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_01], Fleur.SequenceType_string_1); -Fleur.XPathFunctions_fn["substring-before#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:substring-before", +Fleur.XPathFunctions_fn["substring-before#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:substring-before", Fleur.Context.prototype.fn_substring$_before_3, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_01, Fleur.SequenceType_string_1], Fleur.SequenceType_string_1); +/* function(a, b) { return !a || !b ? "" : a.substring(0, a.indexOf(b)); }, null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string, occurence: "?"}); - -Fleur.XPathFunctions_fn["substring-before#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:substring-before", +*/ +/* function(a, b, collation) { var c = Fleur.getCollation(collation); if (!c) { @@ -82,4 +59,5 @@ Fleur.XPathFunctions_fn["substring-before#3"] = new Fleur.Function("http://www.w } return !a || !b ? "" : c.substringBefore(a, b); }, - null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_string, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_string, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/substring.js b/src/js/fleur.js/XPath/XPathFunctions/fn/substring.js index 9411986..9d3311a 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/substring.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/substring.js @@ -1,93 +1,52 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ - Fleur.signatures.fn_substring_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "1" - } - ] -}; -Fleur.signatures.fn_substring_3 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "1" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "1" - } - ] -}; - Fleur.Context.prototype.fn_substring_2 = function() { const arg2 = this.item; const arg1 = this.itemstack.pop(); + const res = new Fleur.Text(); if (arg1.isNotEmpty()) { - this.item.data = arg1.data.substr(Number(arg2.data) - 1); + res.data = arg1.data.substr(Number(arg2.data) - 1); } else { - this.item = new Fleur.Text(); - this.item.data = ""; + res.data = ""; } - this.item.schemaTypeInfo = Fleur.Type_string; + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; return this; }; Fleur.Context.prototype.fn_substring_3 = function() { const arg3 = this.item; const arg2 = this.itemstack.pop(); const arg1 = this.itemstack.pop(); + const res = new Fleur.Text(); if (arg1.isNotEmpty()) { - this.item.data = arg1.data.substr(Number(arg2.data) - 1, Number(arg3.data)); + res.data = arg1.data.substr(Number(arg2.data) - 1, Number(arg3.data)); } else { - this.item = new Fleur.Text(); - this.item.data = ""; + res.data = ""; } - this.item.schemaTypeInfo = Fleur.Type_string; + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; return this; }; -Fleur.XPathFunctions_fn["substring#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:substring", +Fleur.XPathFunctions_fn["substring#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:substring", Fleur.Context.prototype.fn_substring_2, + [Fleur.SequenceType_string_01, Fleur.SequenceType_numeric_1], Fleur.SequenceType_string_1); + +Fleur.XPathFunctions_fn["substring#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:substring", Fleur.Context.prototype.fn_substring_3, + [Fleur.SequenceType_string_01, Fleur.SequenceType_numeric_1, Fleur.SequenceType_numeric_1], Fleur.SequenceType_string_1); +/* function(source, start) { return source ? source.substr(Number(start) - 1) : ""; }, null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_integer}], false, false, {type: Fleur.Type_string, occurence: "?"}); - - -Fleur.XPathFunctions_fn["substring#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:substring", +*/ +/* function(source, start, end) { return source ? source.substr(Number(start) - 1, Number(end)) : ""; }, - null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_integer}, {type: Fleur.Type_integer}], false, false, {type: Fleur.Type_string, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_integer}, {type: Fleur.Type_integer}], false, false, {type: Fleur.Type_string, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/sum.js b/src/js/fleur.js/XPath/XPathFunctions/fn/sum.js index d3b6bfa..e164ce1 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/sum.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/sum.js @@ -1,52 +1,17 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_sum_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "*" - } - ] -}; -Fleur.signatures.fn_sum_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "*" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyAtomicType, - occurrence: "?" - } - ] -}; - Fleur.Context.prototype.fn_sum_1 = function() { if (this.item.nodeType === Fleur.Node.SEQUENCE_NODE) { if (this.item.childNodes.length !== 0) { - this.item.data = Fleur.Type_integer.canonicalize(String(this.item.data.length)); + const res = new Fleur.Text(); + res.data = Fleur.Type_integer.canonicalize(String(this.item.data.length)); + res.schemaTypeInfo = Fleur.Type_integer; + this.item = res; } else { this.item = new Fleur.Text(); this.item.data = "0"; @@ -55,8 +20,16 @@ Fleur.Context.prototype.fn_sum_1 = function() { } return this; }; +Fleur.Context.prototype.fn_sum_2 = function() { + this.notyet(); +}; + +Fleur.XPathFunctions_fn["sum#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:sum", Fleur.Context.prototype.fn_sum_1, + [Fleur.SequenceType_anyAtomicType_0n], Fleur.SequenceType_anyAtomicType_1); -Fleur.XPathFunctions_fn["sum#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:sum", +Fleur.XPathFunctions_fn["sum#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:sum", Fleur.Context.prototype.fn_sum_2, + [Fleur.SequenceType_anyAtomicType_0n, Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_anyAtomicType_1); +/* function(arg) { if (arg === null) { return [null, null]; @@ -91,7 +64,7 @@ Fleur.XPathFunctions_fn["sum#1"] = new Fleur.Function("http://www.w3.org/2005/xp return [val, rt, precision]; }, [0, null, 0]); return r; - /* + / var v = r[0]; var t = r[1]; var p = r[2]; @@ -101,11 +74,12 @@ Fleur.XPathFunctions_fn["sum#1"] = new Fleur.Function("http://www.w3.org/2005/xp } } return [v, t, p]; - */ + / } if (arg[1] === Fleur.Type_untypedAtomic) { arg[1] = Fleur.Type_double; } return arg; }, - null, [{type: Fleur.numericTypes, adaptative: true, occurence: "*"}], false, false, {type: Fleur.numericTypes, adaptative: true, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.numericTypes, adaptative: true, occurence: "*"}], false, false, {type: Fleur.numericTypes, adaptative: true, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/tail.js b/src/js/fleur.js/XPath/XPathFunctions/fn/tail.js index 7205b8a..be5f3d3 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/tail.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/tail.js @@ -1,19 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ - Fleur.signatures.fn_tail_1 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - null - ] -}; - Fleur.Context.prototype.fn_tail_1 = function() { if (this.item.nodeType === Fleur.Node.SEQUENCE_NODE && this.item.childNodes.length !== 0) { if (this.item.childNodes.length > 2) { @@ -31,7 +22,9 @@ Fleur.Context.prototype.fn_tail_1 = function() { return this; }; -Fleur.XPathFunctions_fn["tail#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:tail", +Fleur.XPathFunctions_fn["tail#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:tail", Fleur.Context.prototype.fn_tail_1, + [Fleur.SequenceType_item_0n], Fleur.SequenceType_item_0n); +/* function(arg) { if (arg === Fleur.EmptySequence || arg.nodeType !== Fleur.Node.SEQUENCE_NODE) { return Fleur.EmptySequence; @@ -45,4 +38,5 @@ Fleur.XPathFunctions_fn["tail#1"] = new Fleur.Function("http://www.w3.org/2005/x } return arg.childNodes[1]; }, - null, [{type: Fleur.Node, occurence: "*"}], false, false, {type: Fleur.Node, occurence: "*"}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "*"}], false, false, {type: Fleur.Node, occurence: "*"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/timezone-from-date.js b/src/js/fleur.js/XPath/XPathFunctions/fn/timezone-from-date.js index e0f5418..4071237 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/timezone-from-date.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/timezone-from-date.js @@ -1,29 +1,19 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_timezone$_from$_date_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dayTimeDuration, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_date, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_timezone$_from$_date_1 = function() { + return this.fn_timezone$_from$_date_1(true, false); }; -Fleur.XPathFunctions_fn["timezone-from-date#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:timezone-from-date", +Fleur.XPathFunctions_fn["timezone-from-date#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:timezone-from-date", Fleur.Context.prototype.fn_timezone$_from$_date_1, + [Fleur.SequenceType_date_01], Fleur.SequenceType_dayTimeDuration_01); +/* function(arg) { return Fleur.XPathFunctions_fn["timezone-from-dateTime#1"].jsfunc(arg, true, false); }, - null, [{type: Fleur.Type_date, occurence: "?"}], false, false, {type: Fleur.Node, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_date, occurence: "?"}], false, false, {type: Fleur.Node, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/timezone-from-dateTime.js b/src/js/fleur.js/XPath/XPathFunctions/fn/timezone-from-dateTime.js index 93bf0ad..41105d1 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/timezone-from-dateTime.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/timezone-from-dateTime.js @@ -1,28 +1,35 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_timezone$_from$_dateTime_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dayTimeDuration, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dateTime, - occurrence: "?" +Fleur.Context.prototype.fn_timezone$_from$_dateTime_1 = function(nodate, notime) { + if (this.item.isNotEmpty()) { + let dt; + if (notime) { + dt = Fleur.toDate(this.item); + } else if (nodate) { + dt = Fleur.toTime(this.item); + } else { + dt = Fleur.toDateTime(this.item); + } + if (dt.tz === null) { + this.item = new Fleur.Sequence(); + } else { + const res = new Fleur.Text(); + res.schemaTypeInfo = Fleur.Type_dayTimeDuration; + res.data = Fleur.msToDayTimeDuration(dt.tz * 60 * 1000); + this.item = res; } - ] + } + return this; }; -Fleur.XPathFunctions_fn["timezone-from-dateTime#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:timezone-from-datTime", +Fleur.XPathFunctions_fn["timezone-from-dateTime#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:timezone-from-datTime", Fleur.Context.prototype.fn_timezone$_from$_dateTime_1, + [Fleur.SequenceType_dateTime_01], Fleur.SequenceType_dayTimeDuration_01); +/* function(arg, nodate, notime) { var dt; if (arg === null) { @@ -43,4 +50,5 @@ Fleur.XPathFunctions_fn["timezone-from-dateTime#1"] = new Fleur.Function("http:/ a.data = Fleur.msToDayTimeDuration(dt.tz * 60 * 1000); return a; }, - null, [{type: Fleur.Type_time, occurence: "?"}], false, false, {type: Fleur.Node, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_time, occurence: "?"}], false, false, {type: Fleur.Node, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/timezone-from-time.js b/src/js/fleur.js/XPath/XPathFunctions/fn/timezone-from-time.js index 1279982..3a123b2 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/timezone-from-time.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/timezone-from-time.js @@ -1,29 +1,19 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_timezone$_from$_time_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dayTimeDuration, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_time, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_timezone$_from$_time_1 = function() { + return this.fn_timezone$_from$_date_1(false, true); }; -Fleur.XPathFunctions_fn["timezone-from-time#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:timezone-from-time", +Fleur.XPathFunctions_fn["timezone-from-time#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:timezone-from-time", Fleur.Context.prototype.fn_timezone$_from$_time_1, + [Fleur.SequenceType_time_01], Fleur.SequenceType_dayTimeDuration_1); +/* function(arg) { return Fleur.XPathFunctions_fn["timezone-from-dateTime#1"].jsfunc(arg, false, true); }, - null, [{type: Fleur.Type_time, occurence: "?"}], false, false, {type: Fleur.Node, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_time, occurence: "?"}], false, false, {type: Fleur.Node, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/tokenize.js b/src/js/fleur.js/XPath/XPathFunctions/fn/tokenize.js index e300e48..9d6a496 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/tokenize.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/tokenize.js @@ -1,74 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_tokenize_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "*" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] -}; -Fleur.signatures.fn_tokenize_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "*" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - } - ] -}; -Fleur.signatures.fn_tokenize_3 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "*" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - } - ] -}; - Fleur.Context.prototype.fn_tokenize_1 = function() { const seq = new Fleur.Sequence(); if (this.item.isNotEmpty() && this.item.data !== "") { @@ -108,7 +44,15 @@ Fleur.Context.prototype.fn_tokenize_3 = function() { return this; }; -Fleur.XPathFunctions_fn["tokenize#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:tokenize", +Fleur.XPathFunctions_fn["tokenize#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:tokenize", Fleur.Context.prototype.fn_tokenize_1, + [Fleur.SequenceType_string_01], Fleur.SequenceType_string_0n); + +Fleur.XPathFunctions_fn["tokenize#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:tokenize", Fleur.Context.prototype.fn_tokenize_2, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_1], Fleur.SequenceType_string_0n); + +Fleur.XPathFunctions_fn["tokenize#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:tokenize", Fleur.Context.prototype.fn_tokenize_3, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_1, Fleur.SequenceType_string_1], Fleur.SequenceType_string_0n); +/* function(input) { if (!input || input === "") { return null; @@ -123,14 +67,14 @@ Fleur.XPathFunctions_fn["tokenize#1"] = new Fleur.Function("http://www.w3.org/20 return input.length === 1 ? input[0] : input; }, null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string, occurence: "*"}); - -Fleur.XPathFunctions_fn["tokenize#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:tokenize", +*/ +/* function(input, pattern) { return Fleur.XPathFunctions_fn["tokenize#3"].jsfunc(input, pattern, ""); }, null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_string, occurence: "*"}); - -Fleur.XPathFunctions_fn["tokenize#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:tokenize", +*/ +/* function(input, pattern, flags) { pattern = new RegExp(pattern, flags); if (!input || input === "") { @@ -145,4 +89,5 @@ Fleur.XPathFunctions_fn["tokenize#3"] = new Fleur.Function("http://www.w3.org/20 }); return result.length === 0 ? "" : result.length === 1 ? result[0] : result; }, - null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_string, occurence: "*"}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_string, occurence: "*"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/trace.js b/src/js/fleur.js/XPath/XPathFunctions/fn/trace.js index 95239b5..a3d650d 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/trace.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/trace.js @@ -1,63 +1,66 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_trace_1 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - null - ] +Fleur.Context.prototype.fn_trace_1 = function() { + console.log(Fleur.Serializer._serializeNodeToXQuery(this.item, false, "")); + return this; }; -Fleur.signatures.fn_trace_2 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - null, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - } - ] +Fleur.Context.prototype.fn_trace_2 = function() { + const label = this.item; + const n = this.itemstack.pop(); + const labelval = label.isNotEmpty() ? label.data : ""; + console.log(labelval + Fleur.Serializer._serializeNodeToXQuery(n, false, "")); + this.item = n; + return this; }; -Fleur.signatures.fn_trace_3 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - null, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - { - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_trace_3 = function() { + const serialization = this.item; + const label = this.itemstack.pop(); + const n = this.itemstack.pop(); + const labelval = label.isNotEmpty() ? label.data : ""; + let contentType; + let indent = false; + if (serialization.isNotEmpty()) { + const op2 = Fleur.toJSObject(serialization); + contentType = Fleur.toContentType(op2[1], "application/xquery"); + indent = op2[1].indent === "yes"; + } + if (!contentType) { + contentType = "application/xquery"; + } + const ser = new Fleur.Serializer(); + console.log(labelval + ser.serializeToString(n, contentType, indent)); + this.item = n; + return this; }; -Fleur.XPathFunctions_fn["trace#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:trace", +Fleur.XPathFunctions_fn["trace#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:trace", Fleur.Context.prototype.fn_trace_1, + [Fleur.SequenceType_item_0n], Fleur.SequenceType_item_0n); + +Fleur.XPathFunctions_fn["trace#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:trace", Fleur.Context.prototype.fn_trace_2, + [Fleur.SequenceType_item_0n, Fleur.SequenceType_string_1], Fleur.SequenceType_item_0n); + +Fleur.XPathFunctions_fn["trace#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:trace", Fleur.Context.prototype.fn_trace_3, + [Fleur.SequenceType_item_0n, Fleur.SequenceType_string_1, Fleur.SequenceType_item_01], Fleur.SequenceType_item_0n); +/* function(n) { console.log(Fleur.Serializer._serializeNodeToXQuery(n, false, "")); return n; }, null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Node}); - -Fleur.XPathFunctions_fn["trace#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:trace", +*/ +/* function(n, label) { console.log((label || "") + Fleur.Serializer._serializeNodeToXQuery(n, false, "")); return n; }, null, [{type: Fleur.Node, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Node}); - -Fleur.XPathFunctions_fn["trace#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:trace", +*/ +/* function(n, label, serialization) { var contentType; var indent = false; @@ -77,4 +80,5 @@ Fleur.XPathFunctions_fn["trace#3"] = new Fleur.Function("http://www.w3.org/2005/ console.log((label || "") + ser.serializeToString(n, contentType, indent)); return n; }, - null, [{type: Fleur.Node, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}, {type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/translate.js b/src/js/fleur.js/XPath/XPathFunctions/fn/translate.js index 4d590e9..597fca4 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/translate.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/translate.js @@ -1,64 +1,40 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ - Fleur.signatures.fn_translate_3 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - } - ] -}; - Fleur.Context.prototype.fn_translate_3 = function() { const arg3 = this.item; const arg2 = this.itemstack.pop(); const arg1 = this.itemstack.pop(); + const res = new Fleur.Text(); if (arg1.isNotEmpty()) { const tl = arg3.data.length; - let res = ""; + let sres = ""; for (let i = 0, l = arg1.data.length; i < l; i++) { const j = arg2.data.indexOf(arg1.data.charAt(i)); if (j !== -1) { if (j < tl) { - res += arg3.data.charAt(j); + sres += arg3.data.charAt(j); } } else { - res += arg1.data.charAt(i); + sres += arg1.data.charAt(i); } } - this.item.data = res; + res.data = sres; } else { - this.item = new Fleur.Text(); - this.item.data = ""; + res.data = ""; } - this.item.schemaTypeInfo = Fleur.Type_string; + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; return this; }; -Fleur.XPathFunctions_fn["translate#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:translate", +Fleur.XPathFunctions_fn["translate#3"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:translate", Fleur.Context.prototype.fn_translate_3, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_1, Fleur.SequenceType_string_1], Fleur.SequenceType_string_01); +/* function(arg, mapString, transString) { var res = "", i, j, l, tl = transString.length; if (arg === null) { @@ -76,4 +52,5 @@ Fleur.XPathFunctions_fn["translate#3"] = new Fleur.Function("http://www.w3.org/2 } return res; }, - null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}, {type: Fleur.Type_string}, {type: Fleur.Type_string}], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/true.js b/src/js/fleur.js/XPath/XPathFunctions/fn/true.js index 5681ea9..bfd2973 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/true.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/true.js @@ -1,20 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_true_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "1" - }, - params_type: [] -}; Fleur.Context.prototype.fn_true_0 = function() { this.itemstack.push(this.item); const item = new Fleur.Text(); @@ -24,8 +14,11 @@ Fleur.Context.prototype.fn_true_0 = function() { return this; }; -Fleur.XPathFunctions_fn["true#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:true", +Fleur.XPathFunctions_fn["true#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:true", Fleur.Context.prototype.fn_true_0, + [], Fleur.SequenceType_boolean_1); +/* function() { return true; }, - null, [], false, false, {type: Fleur.Type_boolean}); \ No newline at end of file + null, [], false, false, {type: Fleur.Type_boolean}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/type-QName.js b/src/js/fleur.js/XPath/XPathFunctions/fn/type-QName.js index 416f0ae..b7450d3 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/type-QName.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/type-QName.js @@ -1,30 +1,28 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_type$_QName_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_QName, - occurrence: "?" - }, - params_type: [ - { - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_type$_QName_1 = function() { + if (this.item.isNotEmpty()) { + const n = this.item; + this.item = new Fleur.Text(); + this.item.schemaTypeInfo = Fleur.Type_QName; + this.item._setNodeNameLocalNamePrefix(n.schemaTypeInfo ? n.schemaTypeInfo.typeNamespace : "http://www.w3.org/2001/XMLSchema", n.schemaTypeInfo ? n.schemaTypeInfo.typeName : "untypedAtomic"); + } + return this; }; -Fleur.XPathFunctions_fn["type-QName#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:type-QName", +Fleur.XPathFunctions_fn["type-QName#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:type-QName", Fleur.Context.prototype.fn_type$_QName_1, + [Fleur.SequenceType_item_01], Fleur.SequenceType_QName_01); +/* function(n) { - var a = new Fleur.Text(); + var a = new Fleur.Text(); a.schemaTypeInfo = Fleur.Type_QName; a._setNodeNameLocalNamePrefix(n.schemaTypeInfo ? n.schemaTypeInfo.typeNamespace : "http://www.w3.org/2001/XMLSchema", n.schemaTypeInfo ? n.schemaTypeInfo.typeName : "untypedAtomic"); return a; }, - null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_QName}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_QName}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/unordered.js b/src/js/fleur.js/XPath/XPathFunctions/fn/unordered.js index ff41c0b..b0d284d 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/unordered.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/unordered.js @@ -1,21 +1,19 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ - Fleur.signatures.fn_unordered_1 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - null - ] +Fleur.Context.prototype.fn_unordered_1 = function() { + return this; }; -Fleur.XPathFunctions_fn["unordered#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:unordered", +Fleur.XPathFunctions_fn["unordered#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:unordered", Fleur.Context.prototype.fn_unordered_1, + [Fleur.SequenceType_item_0n], Fleur.SequenceType_item_0n); +/* function(sourceSeq) { return sourceSeq; }, - null, [{type: Fleur.Node, occurence: "*"}], false, false, {type: Fleur.Node, occurence: "*"}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "*"}], false, false, {type: Fleur.Node, occurence: "*"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/unparsed-text.js b/src/js/fleur.js/XPath/XPathFunctions/fn/unparsed-text.js index dfb9e83..2558a4a 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/unparsed-text.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/unparsed-text.js @@ -1,48 +1,23 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_unparsed$_text_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_unparsed$_text_1 = function() { + this.notyet(); }; -Fleur.signatures.fn_unparsed$_text_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - } - ] +Fleur.Context.prototype.fn_unparsed$_text_2 = function() { + this.notyet(); }; +Fleur.XPathFunctions_fn["unparsed-text#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:unparsed-text", Fleur.Context.prototype.fn_unparsed$_text_1, + [Fleur.SequenceType_string_01], Fleur.SequenceType_string_01); + +Fleur.XPathFunctions_fn["unparsed-text#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:unparsed-text", Fleur.Context.prototype.fn_unparsed$_text_2, + [Fleur.SequenceType_string_01, Fleur.SequenceType_string_1], Fleur.SequenceType_string_01); +/* Fleur.XPathFunctions_fn["unparsed-text"] = function(ctx, children, callback) { var mediatype = "text/plain"; if (children.length !== 1) { @@ -106,4 +81,5 @@ Fleur.XPathFunctions_fn["unparsed-text"] = function(ctx, children, callback) { } }; Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], cb); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/upper-case.js b/src/js/fleur.js/XPath/XPathFunctions/fn/upper-case.js index af81dd6..adba666 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/upper-case.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/upper-case.js @@ -1,39 +1,27 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_upper$_case_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.fn_upper$_case_1 = function() { + const res = new Fleur.Text(); if (this.item.isNotEmpty()) { - this.item.data = this.item.data.toUpperCase(); + res.data = this.item.data.toUpperCase(); } else { - this.item = new Fleur.Text(); - this.item.data = ""; + res.data = ""; } - this.item.schemaTypeInfo = Fleur.Type_string; + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; return this; }; -Fleur.XPathFunctions_fn["upper-case#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:upper-case", +Fleur.XPathFunctions_fn["upper-case#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:upper-case", Fleur.Context.prototype.fn_upper$_case_1, + [Fleur.SequenceType_string_01], Fleur.SequenceType_string_1); +/* function(arg) { return arg ? arg.toUpperCase() : ""; }, - null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string}); \ No newline at end of file + null, [{type: Fleur.Type_string, occurence: "?"}], false, false, {type: Fleur.Type_string}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/xsi-type.js b/src/js/fleur.js/XPath/XPathFunctions/fn/xsi-type.js index d384d0d..4c02155 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/xsi-type.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/xsi-type.js @@ -1,25 +1,32 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_xsi$_type_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.ATTRIBUTE_NODE, - occurrence: "?" - }, - params_type: [ - { - occurrence: "?" +Fleur.Context.prototype.fn_xsi$_type_1 = function() { + if (this.item.isNotEmpty()) { + const n = this.item; + if (!n.schemaTypeInfo || (n.schemaTypeInfo.typeNamespace === "http://www.w3.org/2001/XMLSchema" && (n.schemaTypeInfo.typeName === "untypedAtomic" || n.schemaTypeInfo.typeName === "string"))) { + this.item = new Fleur.Sequence(); + } else { + const a = new Fleur.Attr(); + a.nodeName = "xsi:type"; + a.localName = "type"; + a.namespaceURI = "http://www.w3.org/2001/XMLSchema-instance"; + const t = new Fleur.Text(); + t.data = this.rs.nsresolver.lookupPrefix(n.schemaTypeInfo.typeNamespace) + ":" + n.schemaTypeInfo.typeName; + a.appendChild(t); + this.item = a; } - ] + } + return this; }; -Fleur.XPathFunctions_fn["xsi-type#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:xsi-type", +Fleur.XPathFunctions_fn["xsi-type#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:xsi-type", Fleur.Context.prototype.fn_xsi$_type_1, + [Fleur.SequenceType_item_01], Fleur.SequenceType_attribute_01); +/* function(n, ctx) { if (!n.schemaTypeInfo || (n.schemaTypeInfo.typeNamespace === "http://www.w3.org/2001/XMLSchema" && (n.schemaTypeInfo.typeName === "untypedAtomic" || n.schemaTypeInfo.typeName === "string"))) { return null; @@ -33,4 +40,5 @@ Fleur.XPathFunctions_fn["xsi-type#1"] = new Fleur.Function("http://www.w3.org/20 a.appendChild(t); return a; }, - null, [{type: Fleur.Node, occurence: "?"}], true, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}], true, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/year-from-date.js b/src/js/fleur.js/XPath/XPathFunctions/fn/year-from-date.js index 1fa0306..a374699 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/year-from-date.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/year-from-date.js @@ -1,29 +1,25 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_year$_from$_date_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_date, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_year$_from$_date_1 = function() { + if (this.item.isNotEmpty()) { + const res = new Fleur.Text(); + res.data = String(parseInt(this.item.data.match(/^(\d{4})-\d{2}-\d{2}(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10)); + res.schemaTypeInfo = Fleur.Type_integer; + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["year-from-date#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:year-from-date", +Fleur.XPathFunctions_fn["year-from-date#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:year-from-date", Fleur.Context.prototype.fn_year$_from$_date_1, + [Fleur.SequenceType_date_01], Fleur.SequenceType_integer_01); +/* function(arg) { return arg !== null ? parseInt(arg.match(/^(\d{4})-\d{2}-\d{2}(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10) : null; }, - null, [{type: Fleur.Type_date, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_date, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/year-from-dateTime.js b/src/js/fleur.js/XPath/XPathFunctions/fn/year-from-dateTime.js index aa9ff36..d91056a 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/year-from-dateTime.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/year-from-dateTime.js @@ -1,29 +1,25 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_year$_from$_dateTime_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dateTime, - occurrence: "?" - } - ] +Fleur.Context.prototype.fn_year$_from$_dateTime_1 = function() { + if (this.item.isNotEmpty()) { + const res = new Fleur.Text(); + res.data = String(parseInt(this.item.data.match(/^(\d{4})-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10)); + res.schemaTypeInfo = Fleur.Type_integer; + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["year-from-dateTime#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:year-from-dateTime", +Fleur.XPathFunctions_fn["year-from-dateTime#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:year-from-dateTime", Fleur.Context.prototype.fn_year$_from$_dateTime_1, + [Fleur.SequenceType_dateTime_01], Fleur.SequenceType_integer_01); +/* function(arg) { return arg !== null ? parseInt(arg.match(/^(\d{4})-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+\-]\d{2}:\d{2})?$/)[1], 10) : null; }, - null, [{type: Fleur.Type_dateTime, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Type_dateTime, occurence: "?"}], true, false, {type: Fleur.Type_integer, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/years-from-duration.js b/src/js/fleur.js/XPath/XPathFunctions/fn/years-from-duration.js index 7e5dffb..9f20ddd 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/years-from-duration.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/years-from-duration.js @@ -1,28 +1,33 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_year$_from$_duration_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_duration, - occurrence: "?" +Fleur.Context.prototype.fn_year$_from$_duration_1 = function() { + if (this.item.isNotEmpty()) { + const a = this.item; + let signedd = 0; + if (a.schemaTypeInfo === Fleur.Type_dayTimeDuration) { + const d = Fleur.toJSONDayTimeDuration(a.data); + signedd = d.sign * d.year; + } + if (a.schemaTypeInfo !== Fleur.Type_yearMonthDuration) { + const d = Fleur.toJSONDuration(a.data); + signedd = d.sign * d.year; } - ] + const res = new Fleur.Text(); + res.schemaTypeInfo = Fleur.Type_integer; + res.data = Number(signedd); + this.item = res; + } + return this; }; -Fleur.XPathFunctions_fn["years-from-duration#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:years-from-duration", +Fleur.XPathFunctions_fn["years-from-duration#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:years-from-duration", Fleur.Context.prototype.fn_year$_from$_duration_1, + [Fleur.SequenceType_duration_01], Fleur.SequenceType_integer_01); +/* function(arg) { var a = Fleur.Atomize(arg); var d; @@ -44,4 +49,5 @@ Fleur.XPathFunctions_fn["years-from-duration#1"] = new Fleur.Function("http://ww e.name = "XPTY0004"; return e; }, - null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_integer, occurence: "?"}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "?"}], false, false, {type: Fleur.Type_integer, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/fn/zero-or-one.js b/src/js/fleur.js/XPath/XPathFunctions/fn/zero-or-one.js index 7715de5..9a9b50c 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/fn/zero-or-one.js +++ b/src/js/fleur.js/XPath/XPathFunctions/fn/zero-or-one.js @@ -1,26 +1,25 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.fn_zero$_or$_one_1 = { - need_ctx: false, - is_async: false, - return_type: { - occurrence: "?" - }, - params_type: [ - null - ] +Fleur.signatures.fn_zero$_or$_one_1 = function() { + if (this.item.isNotEmpty() && this.item.nodeType === Fleur.Node.SEQUENCE_NODE) { + Fleur.XQueryError_xqt("FORG0004", null, "Wrong argument type for fn:zero-or-one#1", "", this.item); + } + return this; }; -Fleur.XPathFunctions_fn["zero-or-one#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:zero-or-one", +Fleur.XPathFunctions_fn["zero-or-one#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:zero-or-one", Fleur.signatures.fn_zero$_or$_one_1, + [Fleur.SequenceType_item_0n], Fleur.SequenceType_item_01); +/* function(arg, ctx) { if (arg.nodeType === Fleur.Node.SEQUENCE_NODE && arg.childNodes && arg.childNodes.length > 1) { return Fleur.error(ctx, "FORG0003"); } return arg; }, - null, [{type: Fleur.Node, occurence: "*"}], true, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node, occurence: "*"}], true, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/main.js b/src/js/fleur.js/XPath/XPathFunctions/main.js index 3c8a00a..7bd7da5 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/main.js +++ b/src/js/fleur.js/XPath/XPathFunctions/main.js @@ -23,6 +23,8 @@ Fleur.XPathFunctions["http://www.w3.org/2005/xpath-functions/math"] = {}; Fleur.XPathFunctions_math = Fleur.XPathFunctions["http://www.w3.org/2005/xpath-functions/math"]; Fleur.XPathFunctions["http://www.w3.org/2001/XMLSchema"] = {}; Fleur.XPathFunctions_xs = Fleur.XPathFunctions["http://www.w3.org/2001/XMLSchema"]; +Fleur.XPathFunctions["http://www.w3.org/2005/xquery-local-functions"] = {}; +Fleur.XPathFunctions_local = Fleur.XPathFunctions["http://www.w3.org/2005/xquery-local-functions"]; Fleur.XPathFunctions["http://expath.org/ns/binary"] = {}; Fleur.XPathFunctions_bin = Fleur.XPathFunctions["http://expath.org/ns/binary"]; Fleur.XPathFunctions["http://expath.org/ns/file"] = {}; @@ -53,4 +55,6 @@ Fleur.XPathFunctions["http://www.agencexml.com/fleur/unit"] = {}; Fleur.XPathFunctions_unit = Fleur.XPathFunctions["http://www.agencexml.com/fleur/unit"]; Fleur.XPathFunctions["http://www.w3.org/2005/xquery"] = {}; Fleur.XPathFunctions_xquery = Fleur.XPathFunctions["http://www.w3.org/2005/xquery"]; +Fleur.XPathFunctions["http://www.w3.org/2002/xforms"] = {}; +Fleur.XPathFunctions_xf = Fleur.XPathFunctions["http://www.w3.org/2002/xforms"]; Fleur.canonize = {}; \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/math/acos.js b/src/js/fleur.js/XPath/XPathFunctions/math/acos.js index d117825..af0686b 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/math/acos.js +++ b/src/js/fleur.js/XPath/XPathFunctions/math/acos.js @@ -1,26 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.math_acos_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.math_acos_1 = function() { if (this.item.isNotEmpty()) { const op = Fleur.toJSValue(this.item, true, false, false, false, false, false); @@ -32,10 +16,13 @@ Fleur.Context.prototype.math_acos_1 = function() { return this; }; -Fleur.XPathFunctions_math["acos#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:acos", - function(arg) { - if (arg === null) { - return null; - } - return Math.acos(Number(arg));}, - null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); \ No newline at end of file +Fleur.XPathFunctions_math["acos#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:acos", Fleur.Context.prototype.math_acos_1, + [Fleur.SequenceType_numeric_01], Fleur.SequenceType_numeric_01); +/* +function(arg) { + if (arg === null) { + return null; + } + return Math.acos(Number(arg));}, + null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/math/asin.js b/src/js/fleur.js/XPath/XPathFunctions/math/asin.js index b5b6c89..18ed8b8 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/math/asin.js +++ b/src/js/fleur.js/XPath/XPathFunctions/math/asin.js @@ -1,26 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.math_asin_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.math_asin_1 = function() { if (this.item.isNotEmpty()) { const op = Fleur.toJSValue(this.item, true, false, false, false, false, false); @@ -32,10 +16,13 @@ Fleur.Context.prototype.math_asin_1 = function() { return this; }; -Fleur.XPathFunctions_math["asin#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:asin", - function(arg) { - if (arg === null) { - return null; - } - return Math.asin(Number(arg));}, - null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); \ No newline at end of file +Fleur.XPathFunctions_math["asin#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:asin", Fleur.Context.prototype.math_asin_1, + [Fleur.SequenceType_numeric_01], Fleur.SequenceType_numeric_01); +/* +function(arg) { + if (arg === null) { + return null; + } + return Math.asin(Number(arg));}, + null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/math/atan.js b/src/js/fleur.js/XPath/XPathFunctions/math/atan.js index 2a0b836..0ffa1b0 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/math/atan.js +++ b/src/js/fleur.js/XPath/XPathFunctions/math/atan.js @@ -1,26 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.math_atan_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.math_atan_1 = function() { if (this.item.isNotEmpty()) { const op = Fleur.toJSValue(this.item, true, false, false, false, false, false); @@ -32,10 +16,13 @@ Fleur.Context.prototype.math_atan_1 = function() { return this; }; -Fleur.XPathFunctions_math["atan#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:atan", - function(arg) { - if (arg === null) { - return null; - } - return Math.atan(Number(arg));}, - null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); \ No newline at end of file +Fleur.XPathFunctions_math["atan#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:atan", Fleur.Context.prototype.math_atan_1, + [Fleur.SequenceType_numeric_01], Fleur.SequenceType_numeric_01); +/* +function(arg) { + if (arg === null) { + return null; + } + return Math.atan(Number(arg));}, + null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/math/atan2.js b/src/js/fleur.js/XPath/XPathFunctions/math/atan2.js index 186ea0c..4220193 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/math/atan2.js +++ b/src/js/fleur.js/XPath/XPathFunctions/math/atan2.js @@ -1,31 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.math_atan2_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.math_atan2_2 = function() { const arg2 = this.item; const arg1 = this.itemstack.pop(); @@ -38,12 +17,15 @@ Fleur.Context.prototype.math_atan2_2 = function() { if (op2[0] < 0) { return this; } - this.item.data = Fleur.Type_double.canonicalize(String(Math.atan2(Number(op1[1]), Number(op2[1])))); - this.item.schemaTypeInfo = Fleur.Type_double; + this.item.data = Fleur.Type_double.canonicalize(String(Math.atan2(Number(op1[1]), Number(op2[1])))); + this.item.schemaTypeInfo = Fleur.Type_double; return this; }; -Fleur.XPathFunctions_math["atan2#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:atan2", - function(arg1, arg2) { - return Math.atan2(Number(arg1), Number(arg2));}, - null, [{type: Fleur.numericTypes}, {type: Fleur.numericTypes}], false, false, {type: Fleur.Type_double, occurence: "?"}); \ No newline at end of file +Fleur.XPathFunctions_math["atan2#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:atan2", Fleur.Context.prototype.math_atan2_2, + [Fleur.SequenceType_numeric_01, Fleur.SequenceType_numeric_01], Fleur.SequenceType_numeric_01); +/* +function(arg1, arg2) { + return Math.atan2(Number(arg1), Number(arg2));}, + null, [{type: Fleur.numericTypes}, {type: Fleur.numericTypes}], false, false, {type: Fleur.Type_double, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/math/cos.js b/src/js/fleur.js/XPath/XPathFunctions/math/cos.js index c5babf3..594f621 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/math/cos.js +++ b/src/js/fleur.js/XPath/XPathFunctions/math/cos.js @@ -1,26 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.math_cos_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.math_cos_1 = function() { if (this.item.isNotEmpty()) { const op = Fleur.toJSValue(this.item, true, false, false, false, false, false); @@ -32,10 +16,13 @@ Fleur.Context.prototype.math_cos_1 = function() { return this; }; -Fleur.XPathFunctions_math["cos#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:cos", - function(theta) { - if (theta === null) { - return null; - } - return Math.cos(Number(theta));}, - null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); \ No newline at end of file +Fleur.XPathFunctions_math["cos#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:cos", Fleur.Context.prototype.math_cos_1, + [Fleur.SequenceType_numeric_01], Fleur.SequenceType_numeric_01); +/* +function(theta) { + if (theta === null) { + return null; + } + return Math.cos(Number(theta));}, + null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/math/exp.js b/src/js/fleur.js/XPath/XPathFunctions/math/exp.js index d41668f..c59ba77 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/math/exp.js +++ b/src/js/fleur.js/XPath/XPathFunctions/math/exp.js @@ -1,26 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.math_exp_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.math_exp_1 = function() { if (this.item.isNotEmpty()) { const op = Fleur.toJSValue(this.item, true, false, false, false, false, false); @@ -32,10 +16,13 @@ Fleur.Context.prototype.math_exp_1 = function() { return this; }; -Fleur.XPathFunctions_math["exp#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:exp", - function(arg) { - if (arg === null) { - return null; - } - return Math.exp(Number(arg));}, - null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); \ No newline at end of file +Fleur.XPathFunctions_math["exp#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:exp", Fleur.Context.prototype.math_exp_1, + [Fleur.SequenceType_numeric_01], Fleur.SequenceType_numeric_01); +/* +function(arg) { + if (arg === null) { + return null; + } + return Math.exp(Number(arg));}, + null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/math/exp10.js b/src/js/fleur.js/XPath/XPathFunctions/math/exp10.js index f14e8c7..88359d0 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/math/exp10.js +++ b/src/js/fleur.js/XPath/XPathFunctions/math/exp10.js @@ -1,26 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.math_exp10_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.math_exp10_1 = function() { if (this.item.isNotEmpty()) { const op = Fleur.toJSValue(this.item, true, false, false, false, false, false); @@ -32,10 +16,13 @@ Fleur.Context.prototype.math_exp10_1 = function() { return this; }; -Fleur.XPathFunctions_math["exp10#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:exp10", - function(arg) { - if (arg === null) { - return null; - } - return Math.pow(10, Number(arg));}, - null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); \ No newline at end of file +Fleur.XPathFunctions_math["exp10#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:exp10", Fleur.Context.prototype.math_exp10_1, + [Fleur.SequenceType_numeric_01], Fleur.SequenceType_numeric_01); +/* +function(arg) { + if (arg === null) { + return null; + } + return Math.pow(10, Number(arg));}, + null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/math/log.js b/src/js/fleur.js/XPath/XPathFunctions/math/log.js index ad4d06e..1c4b3ac 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/math/log.js +++ b/src/js/fleur.js/XPath/XPathFunctions/math/log.js @@ -1,26 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.math_log_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.math_log_1 = function() { if (this.item.isNotEmpty()) { const op = Fleur.toJSValue(this.item, true, false, false, false, false, false); @@ -32,10 +16,13 @@ Fleur.Context.prototype.math_log_1 = function() { return this; }; -Fleur.XPathFunctions_math["log#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:log", - function(arg) { - if (arg === null) { - return null; - } - return Math.log(Number(arg));}, - null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); \ No newline at end of file +Fleur.XPathFunctions_math["log#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:log", Fleur.Context.prototype.math_log_1, + [Fleur.SequenceType_numeric_01], Fleur.SequenceType_numeric_01); +/* +function(arg) { + if (arg === null) { + return null; + } + return Math.log(Number(arg));}, + null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/math/log10.js b/src/js/fleur.js/XPath/XPathFunctions/math/log10.js index 509d29b..4348dae 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/math/log10.js +++ b/src/js/fleur.js/XPath/XPathFunctions/math/log10.js @@ -1,26 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.math_log10_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.math_log10_1 = function() { if (this.item.isNotEmpty()) { const op = Fleur.toJSValue(this.item, true, false, false, false, false, false); @@ -32,10 +16,13 @@ Fleur.Context.prototype.math_log10_1 = function() { return this; }; -Fleur.XPathFunctions_math["log10#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:log10", - function(arg) { - if (arg === null) { - return null; - } - return Math.log10(Number(arg));}, - null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); \ No newline at end of file +Fleur.XPathFunctions_math["log10#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:log10", Fleur.Context.prototype.math_log10_1, + [Fleur.SequenceType_numeric_01], Fleur.SequenceType_numeric_01); +/* +function(arg) { + if (arg === null) { + return null; + } + return Math.log10(Number(arg));}, + null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/math/pi.js b/src/js/fleur.js/XPath/XPathFunctions/math/pi.js index 2f1da6e..4cd6b37 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/math/pi.js +++ b/src/js/fleur.js/XPath/XPathFunctions/math/pi.js @@ -1,29 +1,22 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.math_pi_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [] -}; Fleur.Context.prototype.math_pi_0 = function() { this.itemstack.push(this.item); - const item = new Fleur.Text(); - item.data = "3.141592653589793"; - item.schemaTypeInfo = Fleur.Type_double; + const item = new Fleur.Text(); + item.data = "3.141592653589793"; + item.schemaTypeInfo = Fleur.Type_double; this.item = item; return this; }; -Fleur.XPathFunctions_math["pi#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:pi", - function() { return 3.141592653589793; }, - null, [], false, false, {type: Fleur.Type_double}); \ No newline at end of file +Fleur.XPathFunctions_math["pi#0"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:pi", Fleur.Context.prototype.math_pi_0, + [], Fleur.SequenceType_numeric_01); +/* +function() { return 3.141592653589793; }, + null, [], false, false, {type: Fleur.Type_double}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/math/pow.js b/src/js/fleur.js/XPath/XPathFunctions/math/pow.js index bb0c50c..10a740e 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/math/pow.js +++ b/src/js/fleur.js/XPath/XPathFunctions/math/pow.js @@ -1,31 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.math_pow_2 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.math_pow_2 = function() { const arg1 = this.itemstack.pop(); const arg2 = this.item; @@ -38,15 +17,18 @@ Fleur.Context.prototype.math_pow_2 = function() { if (op2[0] < 0) { return this; } - this.item.data = Fleur.Type_double.canonicalize(String(Math.pow(Number(op1[1]), Number(op2[1])))); - this.item.schemaTypeInfo = Fleur.Type_double; + this.item.data = Fleur.Type_double.canonicalize(String(Math.pow(Number(op1[1]), Number(op2[1])))); + this.item.schemaTypeInfo = Fleur.Type_double; return this; }; -Fleur.XPathFunctions_math["pow#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:pow", - function(x, y) { - if (x === null) { - return null; - } - return y >= 0 && typeof x === "bigint" && typeof y === "bigint" ? eval("x ** y") : Math.pow(Number(x), Number(y));}, - null, [{type: Fleur.numericTypes, occurence: "?"}, {type: Fleur.numericTypes}], false, false, {type: Fleur.Type_double, occurence: "?"}); \ No newline at end of file +Fleur.XPathFunctions_math["pow#2"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:pow", Fleur.Context.prototype.math_pow_2, + [Fleur.SequenceType_numeric_01, Fleur.SequenceType_numeric_01], Fleur.SequenceType_numeric_01); +/* +function(x, y) { + if (x === null) { + return null; + } + return y >= 0 && typeof x === "bigint" && typeof y === "bigint" ? eval("x ** y") : Math.pow(Number(x), Number(y));}, + null, [{type: Fleur.numericTypes, occurence: "?"}, {type: Fleur.numericTypes}], false, false, {type: Fleur.Type_double, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/math/sin.js b/src/js/fleur.js/XPath/XPathFunctions/math/sin.js index 1b35c4d..c2f953c 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/math/sin.js +++ b/src/js/fleur.js/XPath/XPathFunctions/math/sin.js @@ -1,26 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.math_sin_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.math_sin_1 = function() { if (this.item.isNotEmpty()) { const op = Fleur.toJSValue(this.item, true, false, false, false, false, false); @@ -32,10 +16,13 @@ Fleur.Context.prototype.math_sin_1 = function() { return this; }; -Fleur.XPathFunctions_math["sin#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:sin", - function(arg) { - if (arg === null) { - return null; - } - return Math.sin(Number(arg));}, - null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); \ No newline at end of file +Fleur.XPathFunctions_math["sin#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:sin", Fleur.Context.prototype.math_sin_1, + [Fleur.SequenceType_numeric_01], Fleur.SequenceType_numeric_01); +/* +function(arg) { + if (arg === null) { + return null; + } + return Math.sin(Number(arg));}, + null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/math/sqrt.js b/src/js/fleur.js/XPath/XPathFunctions/math/sqrt.js index c12b7a9..36f61f5 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/math/sqrt.js +++ b/src/js/fleur.js/XPath/XPathFunctions/math/sqrt.js @@ -1,26 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.math_sqrt_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurence: "?" - } - ] -}; Fleur.Context.prototype.math_sqrt_1 = function() { if (this.item.isNotEmpty()) { const op = Fleur.toJSValue(this.item, true, false, false, false, false, false); @@ -32,10 +16,13 @@ Fleur.Context.prototype.math_sqrt_1 = function() { return this; }; -Fleur.XPathFunctions_math["sqrt#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:sqrt", - function(arg) { - if (arg === null) { - return null; - } - return Math.sqrt(Number(arg));}, - null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); \ No newline at end of file +Fleur.XPathFunctions_math["sqrt#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:sqrt", Fleur.Context.prototype.math_sqrt_1, + [Fleur.SequenceType_numeric_01], Fleur.SequenceType_numeric_01); +/* +function(arg) { + if (arg === null) { + return null; + } + return Math.sqrt(Number(arg));}, + null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/math/tan.js b/src/js/fleur.js/XPath/XPathFunctions/math/tan.js index be9f15b..65a8894 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/math/tan.js +++ b/src/js/fleur.js/XPath/XPathFunctions/math/tan.js @@ -1,26 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.math_tan_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.math_tan_1 = function() { if (this.item.isNotEmpty()) { const op = Fleur.toJSValue(this.item, true, false, false, false, false, false); @@ -32,10 +16,13 @@ Fleur.Context.prototype.math_tan_1 = function() { return this; }; -Fleur.XPathFunctions_math["tan#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:tan", - function(arg) { - if (arg === null) { - return null; - } - return Math.tan(Number(arg));}, - null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); \ No newline at end of file +Fleur.XPathFunctions_math["tan#1"] = new Fleur.Function("http://www.w3.org/2005/xpath-functions/math", "math:tan", Fleur.Context.prototype.math_tan_1, + [Fleur.SequenceType_numeric_01], Fleur.SequenceType_numeric_01); +/* +function(arg) { + if (arg === null) { + return null; + } + return Math.tan(Number(arg));}, + null, [{type: Fleur.numericTypes, occurence: "?"}], false, false, {type: Fleur.Type_double, occurence: "?"}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xf/choose.js b/src/js/fleur.js/XPath/XPathFunctions/xf/choose.js index dd0f103..15b1f33 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xf/choose.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xf/choose.js @@ -1,29 +1,17 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xf_choose_3 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "1" - }, - null, - null - ] -}; Fleur.Context.prototype.xf_choose_3 = function() { + let arg3 = this.item; let arg2 = this.itemstack.pop(); - let arg1 = this.itemstack.pop(); - if (arg1.data === "true") { - this.item = arg2; - } + this.item = this.itemstack.pop(); + this.fn_boolean_1(); + this.item = this.item.data === "true" ? arg2 : arg3; return this; -}; \ No newline at end of file +}; +Fleur.XPathFunctions_xf["choose#3"] = new Fleur.Function("http://www.w3.org/2002/xforms", "xf:choose", Fleur.Context.prototype.xf_choose_3, + [Fleur.SequenceType_boolean_1, Fleur.SequenceType_item_0n, Fleur.SequenceType_item_0n], Fleur.SequenceType_item_0n); \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xf/context.js b/src/js/fleur.js/XPath/XPathFunctions/xf/context.js index f1ec6e7..9a84a9a 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xf/context.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xf/context.js @@ -1,18 +1,15 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xf_context_0 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [] -}; Fleur.Context.prototype.xf_context_0 = function() { this.itemstack.push(this.item); this.item = this.initialpath; return this; -}; \ No newline at end of file +}; + +Fleur.XPathFunctions_xf["context#0"] = new Fleur.Function("http://www.w3.org/2002/xforms", "xf:context", Fleur.Context.prototype.xf_context_0, + [], Fleur.SequenceType_item_0n, {dynonly: true}); \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xf/event.js b/src/js/fleur.js/XPath/XPathFunctions/xf/event.js index 214d837..7c5650e 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xf/event.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xf/event.js @@ -1,26 +1,25 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xf_event_1 = { - need_ctx: false, - is_async: false, - return_type: {type: Fleur.Node}, - params_type: [ - {type: Fleur.Type_string} - ] -}; Fleur.Context.prototype.xf_event_1 = function() { + const res = new Fleur.Text(); + res.schemaTypeInfo = Fleur.Type_string; for (let i = XsltForms_xmlevents.EventContexts.length - 1; i >= 0 ; i--) { const evcontext = XsltForms_xmlevents.EventContexts[i]; if (evcontext[this.item.data]) { - this.item.data = evcontext[this.item.data]; + res.data = evcontext[this.item.data]; + this.item = res; return this; } } - this.item.data = ""; + res.data = ""; + this.item = res; return this; -}; \ No newline at end of file +}; + +Fleur.XPathFunctions_xf["event#1"] = new Fleur.Function("http://www.w3.org/2002/xforms", "xf:event", Fleur.Context.prototype.xf_event_1, + [Fleur.SequenceType_string_1], Fleur.SequenceType_string_1, {dynonly: true}); \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xf/if.js b/src/js/fleur.js/XPath/XPathFunctions/xf/if.js index fb2590f..de63603 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xf/if.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xf/if.js @@ -1,29 +1,17 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xf_if_3 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "1" - }, - null, - null - ] -}; Fleur.Context.prototype.xf_if_3 = function() { let arg3 = this.item; let arg2 = this.itemstack.pop(); - this.item = this.itemstack.pop() + this.item = this.itemstack.pop(); this.fn_boolean_1(); this.item = this.item.data === "true" ? arg2 : arg3; return this; -}; \ No newline at end of file +}; +Fleur.XPathFunctions_xf["if#3"] = new Fleur.Function("http://www.w3.org/2002/xforms", "xf:if", Fleur.Context.prototype.xf_if_3, + [Fleur.SequenceType_boolean_1, Fleur.SequenceType_item_0n, Fleur.SequenceType_item_0n], Fleur.SequenceType_item_0n); \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xf/instance-ids.js b/src/js/fleur.js/XPath/XPathFunctions/xf/instance-ids.js index aa4ec44..5d91440 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xf/instance-ids.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xf/instance-ids.js @@ -1,20 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xf_instance$_ids_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "*" - }, - params_type: [] -}; Fleur.Context.prototype.xf_instance$_ids_0 = function() { this.itemstack.push(this.item); const seq = new Fleur.Sequence(); @@ -27,4 +17,7 @@ Fleur.Context.prototype.xf_instance$_ids_0 = function() { }); this.item = seq.singleton(); return this; -}; \ No newline at end of file +}; + +Fleur.XPathFunctions_xf["instance-ids#0"] = new Fleur.Function("http://www.w3.org/2002/xforms", "xf:instance-ids", Fleur.Context.prototype.xf_instance$_ids_0, + [], Fleur.SequenceType_string_0n, {dynonly: true}); \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xf/instance.js b/src/js/fleur.js/XPath/XPathFunctions/xf/instance.js index cb36716..7ff2e93 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xf/instance.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xf/instance.js @@ -1,28 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xf_instance_0 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [] -}; -Fleur.signatures.xf_instance_1 = { - need_ctx: false, - is_async: false, - return_type: null, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - } - ] -}; Fleur.Context.prototype.xf_instance_0 = function() { this.itemstack.push(this.item); this.item = this.path.ownerDocument ? this.path.ownerDocument.documentElement : this.path.documentElement; @@ -34,4 +16,9 @@ Fleur.Context.prototype.xf_instance_1 = function() { this.item = instance.xfElement.doc.documentElement; this.addnodedep(this.item); return this; -}; \ No newline at end of file +}; + +Fleur.XPathFunctions_xf["instance#0"] = new Fleur.Function("http://www.w3.org/2002/xforms", "xf:instance", Fleur.Context.prototype.xf_instance_0, + [], Fleur.SequenceType_item_0n, {dynonly: true}); +Fleur.XPathFunctions_xf["instance#1"] = new Fleur.Function("http://www.w3.org/2002/xforms", "xf:instance", Fleur.Context.prototype.xf_instance_1, + [Fleur.SequenceType_string_1], Fleur.SequenceType_item_0n, {dynonly: true}); \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xf/js-eval.js b/src/js/fleur.js/XPath/XPathFunctions/xf/js-eval.js index d457000..05c765a 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xf/js-eval.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xf/js-eval.js @@ -1,27 +1,17 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xf_js$_eval_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "1" - } - ] -}; Fleur.Context.prototype.xf_js$_eval_1 = function() { - this.item.data = String((0, eval)(this.item.data)); + const res = new Fleur.Text(); + res.data = String((0, eval)(this.item.data)); + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; return this; -}; \ No newline at end of file +}; + +Fleur.XPathFunctions_xf["js-eval#1"] = new Fleur.Function("http://www.w3.org/2002/xforms", "xf:js-eval", Fleur.Context.prototype.xf_js$_eval_1, + [Fleur.SequenceType_string_01], Fleur.SequenceType_string_0n, {dynonly: true}); \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xf/now.js b/src/js/fleur.js/XPath/XPathFunctions/xf/now.js index 4a7bd11..f67d965 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xf/now.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xf/now.js @@ -1,20 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xf_now_0 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dateTime, - occurrence: "1" - }, - params_type: [] -}; Fleur.Context.prototype.xf_now_0 = function() { this.itemstack.push(this.item); const now = new Date(); @@ -23,4 +13,7 @@ Fleur.Context.prototype.xf_now_0 = function() { this.item.data = Fleur.dateToDateTime({d: now, tz: -jstz}); this.item.schemaTypeInfo = Fleur.Type_dateTime; return this; -}; \ No newline at end of file +}; + +Fleur.XPathFunctions_xf["now#0"] = new Fleur.Function("http://www.w3.org/2002/xforms", "xf:now", Fleur.Context.prototype.xf_now_0, + [], Fleur.SequenceType_dateTime_1, {dynonly: true}); \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/ENTITIES.js b/src/js/fleur.js/XPath/XPathFunctions/xs/ENTITIES.js index 62ce3b6..02fe843 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/ENTITIES.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/ENTITIES.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_ENTITIES_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_ENTITIES, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_ENTITIES_1 = function() { this.typeConstructor(Fleur.Type_ENTITIES); return this; }; -Fleur.XPathFunctions_xs["ENTITIES#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:ENTITIES", +Fleur.XPathFunctions_xs["ENTITIES#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:ENTITIES", Fleur.Context.prototype.xs_ENTITIES_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_ENTITY_0n); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_ENTITIES, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/ENTITY.js b/src/js/fleur.js/XPath/XPathFunctions/xs/ENTITY.js index 45c8048..5c04c67 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/ENTITY.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/ENTITY.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_ENTITY_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_ENTITY, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; -Fleur.Context.prototype.xs__1 = function() { +Fleur.Context.prototype.xs_ENTITY_1 = function() { this.typeConstructor(Fleur.Type_ENTITY); return this; }; -Fleur.XPathFunctions_xs["ENTITY#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:ENTITY", +Fleur.XPathFunctions_xs["ENTITY#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:ENTITY", Fleur.Context.prototype.xs_ENTITY_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_ENTITY_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_ENTITY, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/ID.js b/src/js/fleur.js/XPath/XPathFunctions/xs/ID.js index ad09324..8186cf3 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/ID.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/ID.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_ID_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_ID, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_ID_1 = function() { this.typeConstructor(Fleur.Type_ID); return this; }; -Fleur.XPathFunctions_xs["ID#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:ID", +Fleur.XPathFunctions_xs["ID#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:ID", Fleur.Context.prototype.xs_ID_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_ID_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_ID, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/IDREF.js b/src/js/fleur.js/XPath/XPathFunctions/xs/IDREF.js index 60258c8..6fa8855 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/IDREF.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/IDREF.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_IDREF_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_IDREF, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_IDREF_1 = function() { this.typeConstructor(Fleur.Type_IDREF); return this; }; -Fleur.XPathFunctions_xs["IDREF#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:IDREF", +Fleur.XPathFunctions_xs["IDREF#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:IDREF", Fleur.Context.prototype.xs_IDREF_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_IDREF_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_IDREF, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/IDREFS.js b/src/js/fleur.js/XPath/XPathFunctions/xs/IDREFS.js index 9c6185f..a08ca31 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/IDREFS.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/IDREFS.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_IDREFS_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_IDREFS, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_IDREFS_1 = function() { this.typeConstructor(Fleur.Type_IDREFS); return this; }; -Fleur.XPathFunctions_xs["IDREFS#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:IDREFS", +Fleur.XPathFunctions_xs["IDREFS#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:IDREFS", Fleur.Context.prototype.xs_IDREFS_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_IDREF_0n); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_IDREFS, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/NCName.js b/src/js/fleur.js/XPath/XPathFunctions/xs/NCName.js index e2a93f3..d20cf02 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/NCName.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/NCName.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_NCName_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_NCName, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_NCName_1 = function() { this.typeConstructor(Fleur.Type_NCName); return this; }; -Fleur.XPathFunctions_xs["NCName#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:NCName", +Fleur.XPathFunctions_xs["NCName#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:NCName", Fleur.Context.prototype.xs_NCName_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_NCName_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_NCName, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/NMTOKEN.js b/src/js/fleur.js/XPath/XPathFunctions/xs/NMTOKEN.js index 5ef6ead..d4c1b64 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/NMTOKEN.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/NMTOKEN.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_NMTOKEN_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_NMTOKEN, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_NMTOKEN_1 = function() { this.typeConstructor(Fleur.Type_NMTOKEN); return this; }; -Fleur.XPathFunctions_xs["NMTOKEN#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:NMTOKEN", +Fleur.XPathFunctions_xs["NMTOKEN#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:NMTOKEN", Fleur.Context.prototype.xs_NMTOKEN_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_NMTOKEN_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_NMTOKEN, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/NMTOKENS.js b/src/js/fleur.js/XPath/XPathFunctions/xs/NMTOKENS.js index 681bbd9..2c8a1ee 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/NMTOKENS.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/NMTOKENS.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_NMTOKENS_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_NMTOKENS, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_NMTOKENS_1 = function() { this.typeConstructor(Fleur.Type_NMTOKENS); return this; }; -Fleur.XPathFunctions_xs["NMTOKENS#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:NMTOKENS", +Fleur.XPathFunctions_xs["NMTOKENS#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:NMTOKENS", Fleur.Context.prototype.xs_NMTOKENS_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_NMTOKEN_0n); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_NMTOKENS, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/Name.js b/src/js/fleur.js/XPath/XPathFunctions/xs/Name.js index 3c411b1..8da6c3b 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/Name.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/Name.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_Name_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_Name, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_Name_1 = function() { this.typeConstructor(Fleur.Type_Name); return this; }; -Fleur.XPathFunctions_xs["Name#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:Name", +Fleur.XPathFunctions_xs["Name#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:Name", Fleur.Context.prototype.xs_Name_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_Name_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_Name, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/QName.js b/src/js/fleur.js/XPath/XPathFunctions/xs/QName.js index 50b7f7c..a4ad042 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/QName.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/QName.js @@ -1,32 +1,32 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_QName_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_QName, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_QName_1 = function() { this.typeConstructor(Fleur.Type_QName); + let prefix = ""; + let localName = ""; + if (this.item.data.indexOf(":") !== -1) { + const nparts = this.item.data.split(":"); + prefix = nparts[0]; + localName = nparts[1]; + } else { + localName = this.item.data; + } + this.item.namespaceURI = this.rs.nsresolver.lookupNamespaceURI(prefix); + this.item.nodeName = this.item.data; + this.item.prefix = prefix; + this.item.localName = localName; + this.item.data = null; return this; }; -Fleur.XPathFunctions_xs["QName#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:QName", +Fleur.XPathFunctions_xs["QName#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:QName", Fleur.Context.prototype.xs_QName_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_QName_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_QName, function() {}); }, @@ -57,4 +57,5 @@ Fleur.XPathFunctions_xs.QName = function(ctx, children, callback) { } else { Fleur.callback(function() {callback(Fleur.error(ctx, "XPST0017"));}); } -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/anyURI.js b/src/js/fleur.js/XPath/XPathFunctions/xs/anyURI.js index 1a64583..2b68115 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/anyURI.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/anyURI.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_anyURI_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anyURI, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_anyURI_1 = function() { - this.typeConstructor(Fleur.Type_anyURI); - return this; + this.typeConstructor(Fleur.Type_anyURI); + return this; }; -Fleur.XPathFunctions_xs["anyURI#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:anyURI", - function(arg) { - return Fleur.XPathConstructor(arg, Fleur.Type_anyURI, function() {}); - }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file +Fleur.XPathFunctions_xs["anyURI#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:anyURI", Fleur.Context.prototype.xs_anyURI_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_anyURI_01); +/* + function(arg) { + return Fleur.XPathConstructor(arg, Fleur.Type_anyURI, function() {}); + }, + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/base64Binary.js b/src/js/fleur.js/XPath/XPathFunctions/xs/base64Binary.js index 756d6b8..0d1bfb2 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/base64Binary.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/base64Binary.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_base64Binary_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_base64Binary, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_base64Binary_1 = function() { this.typeConstructor(Fleur.Type_base64Binary); return this; }; -Fleur.XPathFunctions_xs["base64Binary#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:base64Binary", +Fleur.XPathFunctions_xs["base64Binary#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:base64Binary", Fleur.Context.prototype.xs_base64Binary_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_base64Binary_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_base64Binary, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/boolean.js b/src/js/fleur.js/XPath/XPathFunctions/xs/boolean.js index e54c18a..3def57e 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/boolean.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/boolean.js @@ -1,26 +1,10 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_boolean_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_boolean_1 = function() { if (this.item.isNotEmpty()) { const schematype = this.item.schemaTypeInfo; @@ -39,7 +23,9 @@ Fleur.Context.prototype.xs_boolean_1 = function() { return this; }; -Fleur.XPathFunctions_xs["boolean#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:boolean", +Fleur.XPathFunctions_xs["boolean#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:boolean", Fleur.Context.prototype.xs_boolean_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_boolean_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_boolean, function(node) { if (node.schemaTypeInfo === Fleur.Type_integer || node.schemaTypeInfo === Fleur.Type_decimal || node.schemaTypeInfo === Fleur.Type_float || node.schemaTypeInfo === Fleur.Type_double) { @@ -50,3 +36,4 @@ Fleur.XPathFunctions_xs["boolean#1"] = new Fleur.Function("http://www.w3.org/200 }); }, null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/byte.js b/src/js/fleur.js/XPath/XPathFunctions/xs/byte.js index af1ee17..13e3b24 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/byte.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/byte.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_byte_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_byte, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_byte_1 = function() { this.typeConstructor(Fleur.Type_byte); return this; }; -Fleur.XPathFunctions_xs["byte#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:byte", +Fleur.XPathFunctions_xs["byte#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:byte", Fleur.Context.prototype.xs_byte_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_byte_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_byte, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/codepoint.js b/src/js/fleur.js/XPath/XPathFunctions/xs/codepoint.js new file mode 100644 index 0000000..26bff4c --- /dev/null +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/codepoint.js @@ -0,0 +1,14 @@ +"use strict"; +/** + * @author Alain Couthures + * @license LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.Context.prototype.xs_codepoint_1 = function() { + this.typeConstructor(Fleur.Type_codepoint); + return this; +}; + +Fleur.XPathFunctions_xs["codepoint#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:codepoint", Fleur.Context.prototype.xs_codepoint_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_codepoint_01); \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/collation.js b/src/js/fleur.js/XPath/XPathFunctions/xs/collation.js new file mode 100644 index 0000000..2de5858 --- /dev/null +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/collation.js @@ -0,0 +1,14 @@ +"use strict"; +/** + * @author Alain Couthures + * @license LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.Context.prototype.xs_collation_1 = function() { + this.typeConstructor(Fleur.Type_collation); + return this; +}; + +Fleur.XPathFunctions_xs["collation#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:collation", Fleur.Context.prototype.xs_collation_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_collation_01); \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/date.js b/src/js/fleur.js/XPath/XPathFunctions/xs/date.js index 0fd3d27..f9e50d5 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/date.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/date.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_date_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_date, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_date_1 = function() { this.typeConstructor(Fleur.Type_date); return this; }; -Fleur.XPathFunctions_xs["date#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:date", +Fleur.XPathFunctions_xs["date#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:date", Fleur.Context.prototype.xs_date_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_date_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_date, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/dateTime.js b/src/js/fleur.js/XPath/XPathFunctions/xs/dateTime.js index c2828dd..c015cd1 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/dateTime.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/dateTime.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_dateTime_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dateTime, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_dateTime_1 = function() { this.typeConstructor(Fleur.Type_dateTime); return this; }; -Fleur.XPathFunctions_xs["dateTime#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:dateTime", +Fleur.XPathFunctions_xs["dateTime#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:dateTime", Fleur.Context.prototype.xs_dateTime_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_dateTime_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_dateTime, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/dateTimeStamp.js b/src/js/fleur.js/XPath/XPathFunctions/xs/dateTimeStamp.js index 6815f05..d373c61 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/dateTimeStamp.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/dateTimeStamp.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_dateTimeStamp_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dateTimeStamp, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_dateTimeStamp_1 = function() { this.typeConstructor(Fleur.Type_dateTimeStamp); return this; }; Fleur.XPathFunctions_xs["dateTimeStamp#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:dateTimeStamp", + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_dateTimeStamp_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_dateTimeStamp, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/dayTimeDuration.js b/src/js/fleur.js/XPath/XPathFunctions/xs/dayTimeDuration.js index b4f2aea..a89424f 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/dayTimeDuration.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/dayTimeDuration.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_dayTimeDuration_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_dayTimeDuration, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_dayTimeDuration_1 = function() { this.typeConstructor(Fleur.Type_dayTimeDuration); return this; }; -Fleur.XPathFunctions_xs["dayTimeDuration#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:dayTimeDuration", +Fleur.XPathFunctions_xs["dayTimeDuration#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:dayTimeDuration", Fleur.Context.prototype.xs_dayTimeDuration_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_dayTimeDuration_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_dayTimeDuration, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/decimal.js b/src/js/fleur.js/XPath/XPathFunctions/xs/decimal.js index db8a39b..d0c3d47 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/decimal.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/decimal.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_decimal_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_decimal, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_decimal_1 = function() { this.typeConstructor(Fleur.Type_decimal); return this; }; -Fleur.XPathFunctions_xs["decimal#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:decimal", +Fleur.XPathFunctions_xs["decimal#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:decimal", Fleur.Context.prototype.xs_decimal_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_decimal_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_decimal, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/double.js b/src/js/fleur.js/XPath/XPathFunctions/xs/double.js index 16e3100..8703e52 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/double.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/double.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_double_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_double, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_double_1 = function() { this.typeConstructor(Fleur.Type_double); return this; }; -Fleur.XPathFunctions_xs["double#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:double", +Fleur.XPathFunctions_xs["double#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:double", Fleur.Context.prototype.xs_double_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_double_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_double, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/duration.js b/src/js/fleur.js/XPath/XPathFunctions/xs/duration.js index 013bf9c..d81fea7 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/duration.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/duration.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_duration_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_duration, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_duration_1 = function() { this.typeConstructor(Fleur.Type_duration); return this; }; -Fleur.XPathFunctions_xs["duration#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:duration", +Fleur.XPathFunctions_xs["duration#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:duration", Fleur.Context.prototype.xs_duration_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_duration_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_duration, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/float.js b/src/js/fleur.js/XPath/XPathFunctions/xs/float.js index a7142e8..8603642 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/float.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/float.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_float_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_float, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_float_1 = function() { this.typeConstructor(Fleur.Type_float); return this; }; -Fleur.XPathFunctions_xs["float#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:float", +Fleur.XPathFunctions_xs["float#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:float", Fleur.Context.prototype.xs_float_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_float_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_float, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/gDay.js b/src/js/fleur.js/XPath/XPathFunctions/xs/gDay.js index 20588e3..ece4c11 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/gDay.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/gDay.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_gDay_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_gDay, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_gDay_1 = function() { this.typeConstructor(Fleur.Type_gDay); return this; }; -Fleur.XPathFunctions_xs["gDay#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:gDay", +Fleur.XPathFunctions_xs["gDay#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:gDay", Fleur.Context.prototype.xs_gDay_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_gDay_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_gDay, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/gMonth.js b/src/js/fleur.js/XPath/XPathFunctions/xs/gMonth.js index ff3d621..40e87cf 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/gMonth.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/gMonth.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_gMonth_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_gMonth, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_gMonth_1 = function() { this.typeConstructor(Fleur.Type_gMonth); return this; }; -Fleur.XPathFunctions_xs["gMonth#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:gMonth", +Fleur.XPathFunctions_xs["gMonth#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:gMonth", Fleur.Context.prototype.xs_gMonth_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_gMonth_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_gMonth, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/gMonthDay.js b/src/js/fleur.js/XPath/XPathFunctions/xs/gMonthDay.js index 2cbba3f..9729505 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/gMonthDay.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/gMonthDay.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_gMonthDay_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_gMonthDay, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_gMonthDay_1 = function() { this.typeConstructor(Fleur.Type_gMonthDay); return this; }; -Fleur.XPathFunctions_xs["gMonthDay#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:gMonthDay", +Fleur.XPathFunctions_xs["gMonthDay#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:gMonthDay", Fleur.Context.prototype.xs_gMonthDay_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_gMonthDay_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_gMonthDay, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/gYear.js b/src/js/fleur.js/XPath/XPathFunctions/xs/gYear.js index 0c30785..30f7403 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/gYear.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/gYear.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_gYear_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_gYear, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_gYear_1 = function() { this.typeConstructor(Fleur.Type_gYear); return this; }; -Fleur.XPathFunctions_xs["gYear#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:gYear", +Fleur.XPathFunctions_xs["gYear#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:gYear", Fleur.Context.prototype.xs_gYear_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_gYear_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_gYear, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/gYearMonth.js b/src/js/fleur.js/XPath/XPathFunctions/xs/gYearMonth.js index 78c2969..9f0c745 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/gYearMonth.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/gYearMonth.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_gYearMonth_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_gYearMonth, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_gYearMonth_1 = function() { this.typeConstructor(Fleur.Type_gYearMonth); return this; }; -Fleur.XPathFunctions_xs["gYearMonth#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:gYearMonth", +Fleur.XPathFunctions_xs["gYearMonth#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:gYearMonth", Fleur.Context.prototype.xs_gYearMonth_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_gYearMonth_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_gYearMonth, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/hexBinary.js b/src/js/fleur.js/XPath/XPathFunctions/xs/hexBinary.js index 10178da..ddbc473 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/hexBinary.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/hexBinary.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_hexBinary_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_hexBinary, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_hexBinary_1 = function() { this.typeConstructor(Fleur.Type_hexBinary); return this; }; -Fleur.XPathFunctions_xs["hexBinary#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:hexBinary", +Fleur.XPathFunctions_xs["hexBinary#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:hexBinary", Fleur.Context.prototype.xs_hexBinary_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_hexBinary_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_hexBinary, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/int.js b/src/js/fleur.js/XPath/XPathFunctions/xs/int.js index 1f2ca1c..58adf0f 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/int.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/int.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_int_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_int, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_int_1 = function() { this.typeConstructor(Fleur.Type_int); return this; }; -Fleur.XPathFunctions_xs["int#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:int", +Fleur.XPathFunctions_xs["int#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:int", Fleur.Context.prototype.xs_int_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_int_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_int, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/integer.js b/src/js/fleur.js/XPath/XPathFunctions/xs/integer.js index e392029..cad44aa 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/integer.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/integer.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_integer_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_integer_1 = function() { this.typeConstructor(Fleur.Type_integer); return this; }; -Fleur.XPathFunctions_xs["integer#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:integer", +Fleur.XPathFunctions_xs["integer#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:integer", Fleur.Context.prototype.xs_integer_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_integer_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_integer, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/language.js b/src/js/fleur.js/XPath/XPathFunctions/xs/language.js index 7c2667c..0e96cbc 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/language.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/language.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_language_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_language, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_language_1 = function() { this.typeConstructor(Fleur.Type_language); return this; }; -Fleur.XPathFunctions_xs["language#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:language", +Fleur.XPathFunctions_xs["language#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:language", Fleur.Context.prototype.xs_language_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_language_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_language, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/long.js b/src/js/fleur.js/XPath/XPathFunctions/xs/long.js index 03cb611..f0323e4 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/long.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/long.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_long_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_long, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_long_1 = function() { this.typeConstructor(Fleur.Type_long); return this; }; -Fleur.XPathFunctions_xs["long#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:long", +Fleur.XPathFunctions_xs["long#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:long", Fleur.Context.prototype.xs_long_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_long_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_long, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/negativeInteger.js b/src/js/fleur.js/XPath/XPathFunctions/xs/negativeInteger.js index 022047c..e84cf8a 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/negativeInteger.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/negativeInteger.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_negativeInteger_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_negativeInteger, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_negativeInteger_1 = function() { this.typeConstructor(Fleur.Type_negativeInteger); return this; }; -Fleur.XPathFunctions_xs["negativeInteger#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:negativeInteger", +Fleur.XPathFunctions_xs["negativeInteger#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:negativeInteger", Fleur.Context.prototype.xs_negativeInteger_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_negativeInteger_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_negativeInteger, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/nonNegativeInteger.js b/src/js/fleur.js/XPath/XPathFunctions/xs/nonNegativeInteger.js index ba6f03b..d663c08 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/nonNegativeInteger.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/nonNegativeInteger.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_nonNegativeInteger_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_nonNegativeInteger, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_nonNegativeInteger_1 = function() { this.typeConstructor(Fleur.Type_nonNegativeInteger); return this; }; -Fleur.XPathFunctions_xs["nonNegativeInteger#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:nonNegativeInteger", +Fleur.XPathFunctions_xs["nonNegativeInteger#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:nonNegativeInteger", Fleur.Context.prototype.xs_nonNegativeInteger_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_nonNegativeInteger_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_nonNegativeInteger, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/nonPositiveInteger.js b/src/js/fleur.js/XPath/XPathFunctions/xs/nonPositiveInteger.js index 464085d..684e6e4 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/nonPositiveInteger.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/nonPositiveInteger.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_nonPositiveInteger_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_nonPositiveInteger, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_nonPositiveInteger_1 = function() { this.typeConstructor(Fleur.Type_nonPositiveInteger); return this; }; -Fleur.XPathFunctions_xs["nonPositiveInteger#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:nonPositiveInteger", +Fleur.XPathFunctions_xs["nonPositiveInteger#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:nonPositiveInteger", Fleur.Context.prototype.xs_nonPositiveInteger_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_nonPositiveInteger_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_nonPositiveInteger, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/normalizedString.js b/src/js/fleur.js/XPath/XPathFunctions/xs/normalizedString.js index 2015c73..6469275 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/normalizedString.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/normalizedString.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_normalizedString_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_normalizedString, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_normalizedString_1 = function() { this.typeConstructor(Fleur.Type_normalizedString); return this; }; -Fleur.XPathFunctions_xs["normalizedString#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:normalizedString", +Fleur.XPathFunctions_xs["normalizedString#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:normalizedString", Fleur.Context.prototype.xs_normalizedString_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_normalizedString_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_normalizedString, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/numeric.js b/src/js/fleur.js/XPath/XPathFunctions/xs/numeric.js index 69f848c..174a866 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/numeric.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/numeric.js @@ -1,27 +1,14 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_numeric_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_numeric_1 = function() { this.typeConstructor(Fleur.Type_numeric); return this; }; + +Fleur.XPathFunctions_xs["numeric#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:numeric", Fleur.Context.prototype.xs_numeric_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_numeric_01); \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/positiveInteger.js b/src/js/fleur.js/XPath/XPathFunctions/xs/positiveInteger.js index c36569c..b737cbd 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/positiveInteger.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/positiveInteger.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_positiveInteger_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_positiveInteger, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_positiveInteger_1 = function() { this.typeConstructor(Fleur.Type_positiveInteger); return this; }; -Fleur.XPathFunctions_xs["positiveInteger#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:positiveInteger", +Fleur.XPathFunctions_xs["positiveInteger#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:positiveInteger", Fleur.Context.prototype.xs_positiveInteger_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_positiveInteger_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_positiveInteger, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/project.json b/src/js/fleur.js/XPath/XPathFunctions/xs/project.json index 14e7794..f30c9b4 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/project.json +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/project.json @@ -1,52 +1,54 @@ { - "Components":[ - "anyURI.js", - "base64Binary.js", - "boolean.js", - "byte.js", - "date.js", - "dateTime.js", - "dateTimeStamp.js", - "dayTimeDuration.js", - "decimal.js", - "double.js", - "duration.js", - "ENTITIES.js", - "ENTITY.js", - "float.js", - "gDay.js", - "gMonth.js", - "gMonthDay.js", - "gYear.js", - "gYearMonth.js", - "hexBinary.js", - "ID.js", - "IDREF.js", - "IDREFS.js", - "int.js", - "integer.js", - "language.js", - "long.js", - "Name.js", - "NCName.js", - "negativeInteger.js", - "NMTOKEN.js", - "NMTOKENS.js", - "nonNegativeInteger.js", - "nonPositiveInteger.js", - "normalizedString.js", + "Components":[ + "anyURI.js", + "base64Binary.js", + "boolean.js", + "byte.js", + "codepoint.js", + "collation.js", + "date.js", + "dateTime.js", + "dateTimeStamp.js", + "dayTimeDuration.js", + "decimal.js", + "double.js", + "duration.js", + "ENTITIES.js", + "ENTITY.js", + "float.js", + "gDay.js", + "gMonth.js", + "gMonthDay.js", + "gYear.js", + "gYearMonth.js", + "hexBinary.js", + "ID.js", + "IDREF.js", + "IDREFS.js", + "int.js", + "integer.js", + "language.js", + "long.js", + "Name.js", + "NCName.js", + "negativeInteger.js", + "NMTOKEN.js", + "NMTOKENS.js", + "nonNegativeInteger.js", + "nonPositiveInteger.js", + "normalizedString.js", "numeric.js", - "positiveInteger.js", - "QName.js", - "short.js", - "string.js", - "time.js", - "token.js", - "unsignedByte.js", - "unsignedInt.js", - "unsignedLong.js", - "unsignedShort.js", - "untypedAtomic.js", - "yearMonthDuration.js" - ] + "positiveInteger.js", + "QName.js", + "short.js", + "string.js", + "time.js", + "token.js", + "unsignedByte.js", + "unsignedInt.js", + "unsignedLong.js", + "unsignedShort.js", + "untypedAtomic.js", + "yearMonthDuration.js" + ] } \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/short.js b/src/js/fleur.js/XPath/XPathFunctions/xs/short.js index 93ecdd5..eec455c 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/short.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/short.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @licenSe LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_short_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_short, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_short_1 = function() { this.typeConstructor(Fleur.Type_short); return this; }; -Fleur.XPathFunctions_xs["short#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:short", +Fleur.XPathFunctions_xs["short#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:short", Fleur.Context.prototype.xs_short_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_short_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_short, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/string.js b/src/js/fleur.js/XPath/XPathFunctions/xs/string.js index 4be5a85..2c031d2 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/string.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/string.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_string_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_string_1 = function() { this.typeConstructor(Fleur.Type_string); return this; }; -Fleur.XPathFunctions_xs["string#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:string", +Fleur.XPathFunctions_xs["string#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:string", Fleur.Context.prototype.xs_string_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_string_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_string, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/time.js b/src/js/fleur.js/XPath/XPathFunctions/xs/time.js index 230be4f..f19d473 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/time.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/time.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_time_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_time, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_time_1 = function() { this.typeConstructor(Fleur.Type_time); return this; }; -Fleur.XPathFunctions_xs["time#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:time", +Fleur.XPathFunctions_xs["time#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:time", Fleur.Context.prototype.xs_time_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_time_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_time, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/token.js b/src/js/fleur.js/XPath/XPathFunctions/xs/token.js index 5176260..32c0ded 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/token.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/token.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_token_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_token, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_token_1 = function() { this.typeConstructor(Fleur.Type_token); return this; }; -Fleur.XPathFunctions_xs["token#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:token", +Fleur.XPathFunctions_xs["token#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:token", Fleur.Context.prototype.xs_token_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_token_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_token, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/unsignedByte.js b/src/js/fleur.js/XPath/XPathFunctions/xs/unsignedByte.js index c831cff..e41a0d6 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/unsignedByte.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/unsignedByte.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_unsignedByte_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_unsignedByte, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_unsignedByte_1 = function() { this.typeConstructor(Fleur.Type_unsignedByte); return this; }; -Fleur.XPathFunctions_xs["unsignedByte#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:unsignedByte", +Fleur.XPathFunctions_xs["unsignedByte#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:unsignedByte", Fleur.Context.prototype.xs_unsignedByte_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_unsignedByte_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_unsignedByte, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/unsignedInt.js b/src/js/fleur.js/XPath/XPathFunctions/xs/unsignedInt.js index aa373a4..c6dba1f 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/unsignedInt.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/unsignedInt.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_unsignedInt_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_unsignedInt, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_unsignedInt_1 = function() { this.typeConstructor(Fleur.Type_unsignedInt); return this; }; -Fleur.XPathFunctions_xs["unsignedInt#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:unsignedInt", +Fleur.XPathFunctions_xs["unsignedInt#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:unsignedInt", Fleur.Context.prototype.xs_unsignedInt_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_unsignedInt_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_unsignedInt, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/unsignedLong.js b/src/js/fleur.js/XPath/XPathFunctions/xs/unsignedLong.js index 9c78e73..572654d 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/unsignedLong.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/unsignedLong.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_unsignedLong_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_unsignedLong, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_unsignedLong_1 = function() { this.typeConstructor(Fleur.Type_unsignedLong); return this; }; -Fleur.XPathFunctions_xs["unsignedLong#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:unsignedLong", +Fleur.XPathFunctions_xs["unsignedLong#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:unsignedLong", Fleur.Context.prototype.xs_unsignedLong_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_unsignedLong_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_unsignedLong, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/unsignedShort.js b/src/js/fleur.js/XPath/XPathFunctions/xs/unsignedShort.js index 46eebd7..0ced5c2 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/unsignedShort.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/unsignedShort.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_unsignedShort_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_unsignedShort, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_unsignedShort_1 = function() { this.typeConstructor(Fleur.Type_unsignedShort); return this; }; -Fleur.XPathFunctions_xs["unsignedShort#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:unsignedShort", +Fleur.XPathFunctions_xs["unsignedShort#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:unsignedShort", Fleur.Context.prototype.xs_unsignedShort_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_unsignedShort_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_unsignedShort, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/untypedAtomic.js b/src/js/fleur.js/XPath/XPathFunctions/xs/untypedAtomic.js index 4b13418..0440476 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/untypedAtomic.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/untypedAtomic.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_untypedAtomic_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_untypedAtomic, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_untypedAtomic_1 = function() { this.typeConstructor(Fleur.Type_untypedAtomic); return this; }; -Fleur.XPathFunctions_xs["untypedAtomic#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:untypedAtomic", +Fleur.XPathFunctions_xs["untypedAtomic#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:untypedAtomic", Fleur.Context.prototype.xs_untypedAtomic_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_untypedAtomic_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_untypedAtomic, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathFunctions/xs/yearMonthDuration.js b/src/js/fleur.js/XPath/XPathFunctions/xs/yearMonthDuration.js index 3511436..d418016 100644 --- a/src/js/fleur.js/XPath/XPathFunctions/xs/yearMonthDuration.js +++ b/src/js/fleur.js/XPath/XPathFunctions/xs/yearMonthDuration.js @@ -1,33 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.signatures.xs_yearMonthDuration_1 = { - need_ctx: false, - is_async: false, - return_type: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_yearMonthDuration, - occurrence: "?" - }, - params_type: [ - { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_anySimpleType, - occurrence: "?" - } - ] -}; Fleur.Context.prototype.xs_yearMonthDuration_1 = function() { this.typeConstructor(Fleur.Type_yearMonthDuration); return this; }; -Fleur.XPathFunctions_xs["yearMonthDuration#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:yearMonthDuration", +Fleur.XPathFunctions_xs["yearMonthDuration#1"] = new Fleur.Function("http://www.w3.org/2001/XMLSchema", "xs:yearMonthDuration", Fleur.Context.prototype.xs_yearMonthDuration_1, + [Fleur.SequenceType_anyAtomicType_01], Fleur.SequenceType_yearMonthDuration_01); +/* function(arg) { return Fleur.XPathConstructor(arg, Fleur.Type_yearMonthDuration, function() {}); }, - null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); \ No newline at end of file + null, [{type: Fleur.Node}], false, false, {type: Fleur.Node}); +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XPath/XPathNSResolver.js b/src/js/fleur.js/XPath/XPathNSResolver.js index 8f49b21..60eafec 100644 --- a/src/js/fleur.js/XPath/XPathNSResolver.js +++ b/src/js/fleur.js/XPath/XPathNSResolver.js @@ -1,77 +1,81 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ +Fleur.defaultNS = {}; +Fleur.defaultNS.pf = [ + "xml", + "xmlns", + "xs", + "xsi", + "xf", + " function", + "fn", + "local", + "math", + "map", + "array", + "err", + "b", + "bin", + "file", + "http", + "request", + "prof", + "proc", + "js", + "fleur", + "dgram", + "base64", + "internal", + "unit", + "ietf", + "excel", + "zip", + "matrix", + "xpath", + "xquery" +]; +Fleur.defaultNS.uri = [ + "http://www.w3.org/XML/1998/namespace", + "http://www.w3.org/2000/xmlns/", + "http://www.w3.org/2001/XMLSchema", + "http://www.w3.org/2001/XMLSchema-instance", + "http://www.w3.org/2002/xforms", + "http://www.w3.org/2005/xpath-functions", + "http://www.w3.org/2005/xpath-functions", + "http://www.w3.org/2005/xquery-local-functions", + "http://www.w3.org/2005/xpath-functions/math", + "http://www.w3.org/2005/xpath-functions/map", + "http://www.w3.org/2005/xpath-functions/array", + "http://www.w3.org/2005/xqt-errors", + "http://xqib.org", + "http://expath.org/ns/binary", + "http://expath.org/ns/file", + "http://expath.org/ns/http-client", + "http://exquery.org/ns/request", + "http://basex.org/modules/prof", + "http://basex.org/modules/proc", + "http://www.w3.org/standards/webdesign/script", + "http://www.agencexml.com/fleur", + "http://www.agencexml.com/fleur/dgram", + "http://www.agencexml.com/fleur/base64", + "http://www.agencexml.com/fleur/internal", + "http://www.agencexml.com/fleur/unit", + "https://tools.ietf.org/rfc/index", + "http://schemas.openxmlformats.org/spreadsheetml/2006/main", + "http://expath.org/ns/zip", + "http://www.mathunion.org/matrix", + "http://www.w3.org/2005/xpath", + "http://www.w3.org/2005/xquery" +]; + Fleur.XPathNSResolver = function(node) { - this.pf = [ - "xml", - "xmlns", - "xs", - "xsi", - "xf", - " function", - "fn", - "local", - "math", - "map", - "array", - "err", - "b", - "bin", - "file", - "http", - "request", - "prof", - "proc", - "js", - "fleur", - "dgram", - "base64", - "internal", - "unit", - "ietf", - "excel", - "zip", - "matrix", - "xpath", - "xquery" - ]; - this.uri = [ - "http://www.w3.org/XML/1998/namespace", - "http://www.w3.org/2000/xmlns/", - "http://www.w3.org/2001/XMLSchema", - "http://www.w3.org/2001/XMLSchema-instance", - "http://www.w3.org/2002/xforms", - "http://www.w3.org/2005/xpath-functions", - "http://www.w3.org/2005/xpath-functions", - "http://www.w3.org/2005/xpath", - "http://www.w3.org/2005/xpath-functions/math", - "http://www.w3.org/2005/xpath-functions/map", - "http://www.w3.org/2005/xpath-functions/array", - "http://www.w3.org/2005/xqt-errors", - "http://xqib.org", - "http://expath.org/ns/binary", - "http://expath.org/ns/file", - "http://expath.org/ns/http-client", - "http://exquery.org/ns/request", - "http://basex.org/modules/prof", - "http://basex.org/modules/proc", - "http://www.w3.org/standards/webdesign/script", - "http://www.agencexml.com/fleur", - "http://www.agencexml.com/fleur/dgram", - "http://www.agencexml.com/fleur/base64", - "http://www.agencexml.com/fleur/internal", - "http://www.agencexml.com/fleur/unit", - "https://tools.ietf.org/rfc/index", - "http://schemas.openxmlformats.org/spreadsheetml/2006/main", - "http://expath.org/ns/zip", - "http://www.mathunion.org/matrix", - "http://www.w3.org/2005/xpath", - "http://www.w3.org/2005/xquery" - ]; + this.pf = Fleur.defaultNS.pf; + this.uri = Fleur.defaultNS.uri; this.node = node; }; Fleur.XPathNSResolver.prototype.lookupNamespaceURI = function(prefix) { diff --git a/src/js/fleur.js/XPath/project.json b/src/js/fleur.js/XPath/project.json index 1bc465c..447e0c7 100644 --- a/src/js/fleur.js/XPath/project.json +++ b/src/js/fleur.js/XPath/project.json @@ -1,17 +1,17 @@ { - "Components":[ - "Transpiler.js", - "Context.js", - "XPathFunctions/project.json", - "Atomize.js", - "Collations.js", - "XPathConstructor.js", - "XPathEvaluator.js", - "XPathException.js", - "XPathExpression.js", - "XPathNSResolver.js", - "XPathResult.js", - "varMgr.js", - "encchars.js" - ] + "Components":[ + "Transpiler.js", + "Context.js", + "XPathFunctions/project.json", + "Atomize.js", + "Collations.js", + "XPathConstructor.js", + "XPathEvaluator.js", + "XPathException.js", + "XPathExpression.js", + "XPathNSResolver.js", + "XPathResult.js", + "varMgr.js", + "encchars.js" + ] } \ No newline at end of file diff --git a/src/js/fleur.js/XPath/varMgr.js b/src/js/fleur.js/XPath/varMgr.js index 39f0c49..49ff5c9 100644 --- a/src/js/fleur.js/XPath/varMgr.js +++ b/src/js/fleur.js/XPath/varMgr.js @@ -1,7 +1,7 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ @@ -35,10 +35,11 @@ Fleur.varMgr.prototype.get = function(ctx, vuri, vname) { } r = r.previous; } while (r); - return Fleur.error(ctx, "XPST0008", "$" + (vuri && vuri !== '' ? "Q{" + vuri + "}" + vname : vname) + " is undefined"); + Fleur.XQueryError_xqt("XPST0008", null, "$" + (vuri && vuri !== '' ? "Q{" + vuri + "}" + vname : vname) + " is undefined"); }; Fleur.varMgr.prototype.set = function(ctx, vuri, vname, value) { //console.log(vname + " := " + Fleur.Serializer._serializeNodeToXQuery(value, false, "")); +/* var i; var r = this; do { @@ -52,6 +53,7 @@ Fleur.varMgr.prototype.set = function(ctx, vuri, vname, value) { } r = r.previous; } while (r); +*/ this.vars.push({vuri: vuri, vname: vname, value: value}); return value; }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/Wildcard.js b/src/js/fleur.js/XQuery/Instructions/Wildcard.js index 9c48419..bf1962c 100644 --- a/src/js/fleur.js/XQuery/Instructions/Wildcard.js +++ b/src/js/fleur.js/XQuery/Instructions/Wildcard.js @@ -1,7 +1,7 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ diff --git a/src/js/fleur.js/XQuery/Instructions/anyKindTest.js b/src/js/fleur.js/XQuery/Instructions/anyKindTest-BROKEN.js similarity index 96% rename from src/js/fleur.js/XQuery/Instructions/anyKindTest.js rename to src/js/fleur.js/XQuery/Instructions/anyKindTest-BROKEN.js index 404f0bd..2fb38cc 100644 --- a/src/js/fleur.js/XQuery/Instructions/anyKindTest.js +++ b/src/js/fleur.js/XQuery/Instructions/anyKindTest-BROKEN.js @@ -1,194 +1,195 @@ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.Transpiler.prototype.xqx_anyKindTest = function() { - return this.inst("xqx_anyKindTest()"); -}; - -Fleur.Context.nodeTest_ = []; - -Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_ANCESTOR] = (item, nodeType, namespaceURI, localName) => { - let newitem = new Fleur.Sequence(); - if (item.ownerElement) { - item = item.ownerElement; - if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { - newitem.appendChild(item); - } - } - while (item.parentNode) { - item = item.parentNode; - if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { - newitem.appendChild(item); - } - } - return newitem.singleton(); -}; - -Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_ANCESTOR_OR_SELF] = (item, nodeType, namespaceURI, localName) => { - let newitem = new Fleur.Sequence(); - if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { - newitem.appendChild(item); - } - if (item.ownerElement) { - item = item.ownerElement; - if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { - newitem.appendChild(item); - } - } - while (item.parentNode) { - item = item.parentNode; - if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { - newitem.appendChild(item); - } - } - return newitem.singleton(); -}; - -Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_ATTRIBUTE] = (item, nodeType, namespaceURI, localName) => { - let newitem = new Fleur.Sequence(); - if (item.attributes) { - item.attributes.forEach( - it => { - if ((namespaceURI === null || it.namespaceURI === namespaceURI) && (!localName || it.localName === localName)) { - newitem.appendChild(it); - } - } - ); - } - return newitem.singleton(); -}; - -Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_CHILD] = (item, nodeType, namespaceURI, localName) => { - let newitem = new Fleur.Sequence(); - if (item.childNodes) { - item.childNodes.forEach( - it => { - if ((!nodeType || it.nodeType === nodeType) && (namespaceURI === null || it.namespaceURI === namespaceURI) && (!localName || it.localName === localName)) { - newitem.appendChild(it); - } - } - ); - } - return newitem.singleton(); -}; - -Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_DESCENDANT] = (item, nodeType, namespaceURI, localName) => { - let newitem = new Fleur.Sequence(); - if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { - newitem.appendDescendants(item); - } - return newitem.singleton(); -}; - -Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_DESCENDANT_OR_SELF] = (item, nodeType, namespaceURI, localName) => { - let newitem = new Fleur.Sequence(); - if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { - newitem.appendChild(item); - newitem.appendDescendants(item); - } - return newitem.singleton(); -}; - -Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_FOLLOWING] = (item, nodeType, namespaceURI, localName) => { - let newitem = new Fleur.Sequence(); - if (item.ownerElement) { - item = item.ownerElement; - } - while (item.parentNode) { - while (item.nextSibling) { - item = item.nextSibling; - if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { - newitem.appendChild(item); - newitem.appendDescendants(item); - } - } - item = item.parentNode; - } - return newitem.singleton(); -}; - -Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_FOLLOWING_SIBLING] = (item, nodeType, namespaceURI, localName) => { - let newitem = new Fleur.Sequence(); - while (item.nextSibling) { - item = item.nextSibling; - if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { - newitem.appendChild(item); - } - } - return newitem.singleton(); -}; - -Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_PARENT] = (item, nodeType, namespaceURI, localName) => { - if (item.parentNode && (!nodeType || item.parentNode.nodeType === nodeType) && (namespaceURI === null || item.parentNode.namespaceURI === namespaceURI) && (!localName || item.parentNode.localName === localName)) { - return item.parentNode; - } - if (item.ownerElement && (!nodeType || item.ownerElement.nodeType === nodeType) && (namespaceURI === null || item.ownerElement.namespaceURI === namespaceURI) && (!localName || item.ownerElement.localName === localName)) { - return item.ownerElement; - } - return new Fleur.Sequence(); -}; - -Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_PRECEDING] = (item, nodeType, namespaceURI, localName) => { - let newitem = new Fleur.Sequence(); - if (item.ownerElement) { - item = item.ownerElement; - } - while (item.parentNode) { - while (item.previousSibling) { - item = item.previousSibling; - if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { - newitem.appendDescendantsRev(item); - newitem.appendChild(item); - } - } - item = item.parentNode; - } - return newitem.singleton(); -}; - -Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_PRECEDING_SIBLING] = (item, nodeType, namespaceURI, localName) => { - let newitem = new Fleur.Sequence(); - while (item.previousSibling) { - item = item.previousSibling; - if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { - newitem.appendChild(item); - } - } - return newitem.singleton(); -}; - -Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_SELF] = (item, nodeType, namespaceURI, localName) => { - if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { - return item; - } - return new Fleur.Sequence(); -}; - -Fleur.Context.prototype.nodeTest = function(nodeType, namespaceURI, localName) { - if (this.item.isSingle()) { - this.item = Fleur.Context.nodeTest_[this.xpathAxis](this.item, nodeType, namespaceURI, localName); - return this; - } - const seq = new Fleur.Sequence(); - seq.internals = new Set(); - const l = this.item.childNodes.length; - const children = this.item.childNodes; - for (let i = 0; i < l; i++) { - const item = Fleur.Context.nodeTest_[this.xpathAxis](children[i], nodeType, namespaceURI, localName); - seq.merge(item); - } - this.item = seq.singleton(); -}; - -Fleur.Context.prototype.xqx_anyKindTest = function() { - return this.nodeTest(null, null, null); -}; - -Fleur.XQueryEngine[Fleur.XQueryX.anyKindTest] = function(ctx, children, callback) { - //console.log("anyKindTest - " + Fleur.Serializer._serializeNodeToXQuery(ctx._curr, false, "")); - Fleur.callback(function() {callback(ctx._curr);}); -}; \ No newline at end of file +"use strict"; +/** + * @author Alain Couthures + * @license LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.Transpiler.prototype.xqx_anyKindTest = function() { + return this.inst("xqx_anyKindTest()"); +}; + +Fleur.Context.nodeTest_ = []; + +Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_ANCESTOR] = (item, nodeType, namespaceURI, localName) => { + let newitem = new Fleur.Sequence(); + if (item.ownerElement) { + item = item.ownerElement; + if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { + newitem.appendChild(item); + } + } + while (item.parentNode) { + item = item.parentNode; + if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { + newitem.appendChild(item); + } + } + return newitem.singleton(); +}; + +Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_ANCESTOR_OR_SELF] = (item, nodeType, namespaceURI, localName) => { + let newitem = new Fleur.Sequence(); + if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { + newitem.appendChild(item); + } + if (item.ownerElement) { + item = item.ownerElement; + if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { + newitem.appendChild(item); + } + } + while (item.parentNode) { + item = item.parentNode; + if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { + newitem.appendChild(item); + } + } + return newitem.singleton(); +}; + +Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_ATTRIBUTE] = (item, nodeType, namespaceURI, localName) => { + let newitem = new Fleur.Sequence(); + if (item.attributes) { + item.attributes.forEach( + it => { + if ((namespaceURI === null || it.namespaceURI === namespaceURI) && (!localName || it.localName === localName)) { + newitem.appendChild(it); + } + } + ); + } + return newitem.singleton(); +}; + +Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_CHILD] = (item, nodeType, namespaceURI, localName) => { + let newitem = new Fleur.Sequence(); + if (item.childNodes) { + item.childNodes.forEach( + it => { + if ((!nodeType || it.nodeType === nodeType) && (namespaceURI === null || it.namespaceURI === namespaceURI) && (!localName || it.localName === localName)) { + newitem.appendChild(it); + } + } + ); + } + return newitem.singleton(); +}; + +Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_DESCENDANT] = (item, nodeType, namespaceURI, localName) => { + let newitem = new Fleur.Sequence(); + if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { + newitem.appendDescendants(item); + } + return newitem.singleton(); +}; + +Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_DESCENDANT_OR_SELF] = (item, nodeType, namespaceURI, localName) => { + let newitem = new Fleur.Sequence(); + if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { + newitem.appendChild(item); + newitem.appendDescendants(item); + } + return newitem.singleton(); +}; + +Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_FOLLOWING] = (item, nodeType, namespaceURI, localName) => { + let newitem = new Fleur.Sequence(); + if (item.ownerElement) { + item = item.ownerElement; + } + while (item.parentNode) { + while (item.nextSibling) { + item = item.nextSibling; + if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { + newitem.appendChild(item); + newitem.appendDescendants(item); + } + } + item = item.parentNode; + } + return newitem.singleton(); +}; + +Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_FOLLOWING_SIBLING] = (item, nodeType, namespaceURI, localName) => { + let newitem = new Fleur.Sequence(); + while (item.nextSibling) { + item = item.nextSibling; + if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { + newitem.appendChild(item); + } + } + return newitem.singleton(); +}; + +Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_PARENT] = (item, nodeType, namespaceURI, localName) => { + if (item.parentNode && (!nodeType || item.parentNode.nodeType === nodeType) && (namespaceURI === null || item.parentNode.namespaceURI === namespaceURI) && (!localName || item.parentNode.localName === localName)) { + return item.parentNode; + } + if (item.ownerElement && (!nodeType || item.ownerElement.nodeType === nodeType) && (namespaceURI === null || item.ownerElement.namespaceURI === namespaceURI) && (!localName || item.ownerElement.localName === localName)) { + return item.ownerElement; + } + return new Fleur.Sequence(); +}; + +Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_PRECEDING] = (item, nodeType, namespaceURI, localName) => { + let newitem = new Fleur.Sequence(); + if (item.ownerElement) { + item = item.ownerElement; + } + while (item.parentNode) { + while (item.previousSibling) { + item = item.previousSibling; + if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { + newitem.appendDescendantsRev(item); + newitem.appendChild(item); + } + } + item = item.parentNode; + } + return newitem.singleton(); +}; + +Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_PRECEDING_SIBLING] = (item, nodeType, namespaceURI, localName) => { + let newitem = new Fleur.Sequence(); + while (item.previousSibling) { + item = item.previousSibling; + if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { + newitem.appendChild(item); + } + } + return newitem.singleton(); +}; + +Fleur.Context.nodeTest_[Fleur.Context.XPATHAXIS_SELF] = (item, nodeType, namespaceURI, localName) => { + if ((!nodeType || item.nodeType === nodeType) && (namespaceURI === null || item.namespaceURI === namespaceURI) && (!localName || item.localName === localName)) { + return item; + } + return new Fleur.Sequence(); +}; + +Fleur.Context.prototype.nodeTest = function(nodeType, namespaceURI, localName) { + if (this.item.isSingle()) { + this.item = Fleur.Context.nodeTest_[this.xpathAxis](this.item, nodeType, namespaceURI, localName); + return this; + } + const seq = new Fleur.Sequence(); + seq.internals = new Set(); + const l = this.item.childNodes.length; + const children = this.item.childNodes; + for (let i = 0; i < l; i++) { + const item = Fleur.Context.nodeTest_[this.xpathAxis](children[i], nodeType, namespaceURI, localName); + seq.merge(item); + } + this.item = seq.singleton(); +}; + +Fleur.Context.prototype.xqx_anyKindTest = function() { + return this.nodeTest(null, null, null); +}; +/* +Fleur.XQueryEngine[Fleur.XQueryX.anyKindTest] = function(ctx, children, callback) { + //console.log("anyKindTest - " + Fleur.Serializer._serializeNodeToXQuery(ctx._curr, false, "")); + Fleur.callback(function() {callback(ctx._curr);}); +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/arrayConstructor.js b/src/js/fleur.js/XQuery/Instructions/arrayConstructor-BROKEN.js similarity index 96% rename from src/js/fleur.js/XQuery/Instructions/arrayConstructor.js rename to src/js/fleur.js/XQuery/Instructions/arrayConstructor-BROKEN.js index 7c29b28..3cf50a6 100644 --- a/src/js/fleur.js/XQuery/Instructions/arrayConstructor.js +++ b/src/js/fleur.js/XQuery/Instructions/arrayConstructor-BROKEN.js @@ -1,33 +1,33 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.arrayConstructor] = function(ctx, children, callback) { - var arr = new Fleur.Array(); - var i = 0; - var cb = function(n) { - if (n.schemaTypeInfo === Fleur.Type_error) { - Fleur.callback(function() {callback(n);}); - return; - } - if (n !== Fleur.EmptySequence) { - arr.appendChild(n); - } - i++; - if (i === children.length) { - Fleur.callback(function() {callback(arr);}); - return; - } - Fleur.XQueryEngine[children[i][0]](ctx, children[i][1], cb); - }; - if (children.length !== 0) { - Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], cb); - } else { - Fleur.callback(function() {callback(arr);}); - } +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.arrayConstructor] = function(ctx, children, callback) { + var arr = new Fleur.Array(); + var i = 0; + var cb = function(n) { + if (n.schemaTypeInfo === Fleur.Type_error) { + Fleur.callback(function() {callback(n);}); + return; + } + if (n !== Fleur.EmptySequence) { + arr.appendChild(n); + } + i++; + if (i === children.length) { + Fleur.callback(function() {callback(arr);}); + return; + } + Fleur.XQueryEngine[children[i][0]](ctx, children[i][1], cb); + }; + if (children.length !== 0) { + Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], cb); + } else { + Fleur.callback(function() {callback(arr);}); + } }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/arrayTest.js b/src/js/fleur.js/XQuery/Instructions/arrayTest-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/arrayTest.js rename to src/js/fleur.js/XQuery/Instructions/arrayTest-BROKEN.js index f8c2a80..cd7edcf 100644 --- a/src/js/fleur.js/XQuery/Instructions/arrayTest.js +++ b/src/js/fleur.js/XQuery/Instructions/arrayTest-BROKEN.js @@ -1,15 +1,15 @@ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.Transpiler.prototype.xqx_arrayTest = function() { - return this.inst("xqx_arrayTest()"); -}; - -Fleur.XQueryEngine[Fleur.XQueryX.arrayTest] = function(ctx, children, callback) { - Fleur.callback(function() {callback(ctx._curr.nodeType !== Fleur.Node.ARRAY_NODE ? Fleur.EmptySequence : ctx._curr);}); +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.Transpiler.prototype.xqx_arrayTest = function() { + return this.inst("xqx_arrayTest()"); +}; + +Fleur.XQueryEngine[Fleur.XQueryX.arrayTest] = function(ctx, children, callback) { + Fleur.callback(function() {callback(ctx._curr.nodeType !== Fleur.Node.ARRAY_NODE ? Fleur.EmptySequence : ctx._curr);}); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/atomicType.js b/src/js/fleur.js/XQuery/Instructions/atomicType-BROKEN.js similarity index 92% rename from src/js/fleur.js/XQuery/Instructions/atomicType.js rename to src/js/fleur.js/XQuery/Instructions/atomicType-BROKEN.js index df831f0..02e4583 100644 --- a/src/js/fleur.js/XQuery/Instructions/atomicType.js +++ b/src/js/fleur.js/XQuery/Instructions/atomicType-BROKEN.js @@ -1,24 +1,22 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.atomicType] = function(ctx, children, callback) { - if (!ctx._curr.schemaTypeInfo) { - Fleur.callback(function() {callback(Fleur.EmptySequence);}); - return; - } - var localname = children[0]; - var prefix = children[1][1][0]; - var namespace = ctx.env.nsresolver.lookupNamespaceURI(prefix); - if ((localname === ctx._curr.schemaTypeInfo.typeName && namespace === ctx._curr.schemaTypeInfo.typeNamespace) || - ctx._curr.schemaTypeInfo.isDerivedFrom(namespace, localname, Fleur.TypeInfo.DERIVATION_RESTRICTION)) { - Fleur.callback(function() {callback(ctx._curr);}); - return; - } - Fleur.callback(function() {callback(Fleur.EmptySequence);}); +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.atomicType] = function(ctx, children, callback) { + if (!ctx._curr.schemaTypeInfo) { + Fleur.callback(function() {callback(Fleur.EmptySequence);}); + return; + } + var localname = children[0]; + var prefix = children[1][1][0]; + var namespace = ctx.env.nsresolver.lookupNamespaceURI(prefix); + if ((localname === ctx._curr.schemaTypeInfo.typeName && namespace === ctx._curr.schemaTypeInfo.typeNamespace) || + ctx._curr.schemaTypeInfo.isDerivedFrom(namespace, localname, Fleur.TypeInfo.DERIVATION_RESTRICTION)) { + Fleur.callback(function() {callback(ctx._curr);}); + return; + } + Fleur.callback(function() {callback(Fleur.EmptySequence);}); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/attributeConstructor.js b/src/js/fleur.js/XQuery/Instructions/attributeConstructor.js index 929d288..6e43cf2 100644 --- a/src/js/fleur.js/XQuery/Instructions/attributeConstructor.js +++ b/src/js/fleur.js/XQuery/Instructions/attributeConstructor.js @@ -1,7 +1,7 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ @@ -16,7 +16,8 @@ Fleur.Transpiler.prototype.xqx_attributeConstructor = function(children) { } r += this.inst("xqx_attributeConstructor" + (value ? "_value" : "") + "('" + prefix + "', '" + children[0][1][0] + "'" + (value ? ", '" + value + "'" : "") + ")").inst; return { - inst : r + inst: r, + sequenceType: Fleur.SequenceType_attribute_1 }; }; @@ -45,7 +46,7 @@ Fleur.Context.prototype.xqx_attributeConstructor_value = function(prefix, localN this.item = attr; return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.attributeConstructor] = function(ctx, children, callback, elt) { var attr = new Fleur.Attr(); var t; @@ -72,4 +73,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.attributeConstructor] = function(ctx, children, Fleur.callback(function() {callback(n);}); }, attr); } -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/attributeList.js b/src/js/fleur.js/XQuery/Instructions/attributeList-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/attributeList.js rename to src/js/fleur.js/XQuery/Instructions/attributeList-BROKEN.js index 4478944..a37a5b5 100644 --- a/src/js/fleur.js/XQuery/Instructions/attributeList.js +++ b/src/js/fleur.js/XQuery/Instructions/attributeList-BROKEN.js @@ -1,27 +1,27 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.attributeList] = function(ctx, children, callback, elt) { - Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], function(n) { - if (n === Fleur.EmptySequence) { - Fleur.callback(function() {callback(elt);}); - } else if (n.nodeType === Fleur.Node.ATTRIBUTE_NODE) { - elt.setAttributeNode(n); - if (children.length > 1) { - Fleur.XQueryEngine[Fleur.XQueryX.attributeList](ctx, children.slice(1), function(n) { - Fleur.callback(function() {callback(n);}); - }, elt); - } else { - Fleur.callback(function() {callback(elt);}); - } - } else { - Fleur.callback(function() {callback(n);}); - } - }, elt); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.attributeList] = function(ctx, children, callback, elt) { + Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], function(n) { + if (n === Fleur.EmptySequence) { + Fleur.callback(function() {callback(elt);}); + } else if (n.nodeType === Fleur.Node.ATTRIBUTE_NODE) { + elt.setAttributeNode(n); + if (children.length > 1) { + Fleur.XQueryEngine[Fleur.XQueryX.attributeList](ctx, children.slice(1), function(n) { + Fleur.callback(function() {callback(n);}); + }, elt); + } else { + Fleur.callback(function() {callback(elt);}); + } + } else { + Fleur.callback(function() {callback(n);}); + } + }, elt); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/attributeTest.js b/src/js/fleur.js/XQuery/Instructions/attributeTest-BROKEN.js similarity index 98% rename from src/js/fleur.js/XQuery/Instructions/attributeTest.js rename to src/js/fleur.js/XQuery/Instructions/attributeTest-BROKEN.js index 24f0dc4..afb7248 100644 --- a/src/js/fleur.js/XQuery/Instructions/attributeTest.js +++ b/src/js/fleur.js/XQuery/Instructions/attributeTest-BROKEN.js @@ -1,13 +1,13 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.attributeTest] = function(ctx, children, callback) { - //console.log("attributeTest - " + Fleur.Serializer._serializeNodeToXQuery(ctx._curr, false, "")); - Fleur.callback(function() {callback(ctx._curr.nodeType !== Fleur.Node.ATTRIBUTE_NODE || ctx._curr.nodeName === "xmlns" || ctx._curr.prefix === "xmlns" ? Fleur.EmptySequence : ctx._curr);}); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.attributeTest] = function(ctx, children, callback) { + //console.log("attributeTest - " + Fleur.Serializer._serializeNodeToXQuery(ctx._curr, false, "")); + Fleur.callback(function() {callback(ctx._curr.nodeType !== Fleur.Node.ATTRIBUTE_NODE || ctx._curr.nodeName === "xmlns" || ctx._curr.prefix === "xmlns" ? Fleur.EmptySequence : ctx._curr);}); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/attributeValueExpr.js b/src/js/fleur.js/XQuery/Instructions/attributeValueExpr-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/attributeValueExpr.js rename to src/js/fleur.js/XQuery/Instructions/attributeValueExpr-BROKEN.js index f97cc40..4d34564 100644 --- a/src/js/fleur.js/XQuery/Instructions/attributeValueExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/attributeValueExpr-BROKEN.js @@ -1,28 +1,28 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.attributeValueExpr] = function(ctx, children, callback, attr) { - Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], function(n) { - var a = Fleur.Atomize(n); - if (a !== Fleur.EmptySequence && a.nodeType !== Fleur.Node.TEXT_NODE) { - Fleur.callback(function() {callback(a);}); - } else { - if (a !== Fleur.EmptySequence) { - attr.firstChild.data += a.data; - } - if (children.length > 1) { - Fleur.XQueryEngine[Fleur.XQueryX.attributeValueExpr](ctx, children.slice(1), function(n) { - Fleur.callback(function() {callback(n);}); - }, attr); - } else { - Fleur.callback(function() {callback(attr);}); - } - } - }); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.attributeValueExpr] = function(ctx, children, callback, attr) { + Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], function(n) { + var a = Fleur.Atomize(n); + if (a !== Fleur.EmptySequence && a.nodeType !== Fleur.Node.TEXT_NODE) { + Fleur.callback(function() {callback(a);}); + } else { + if (a !== Fleur.EmptySequence) { + attr.firstChild.data += a.data; + } + if (children.length > 1) { + Fleur.XQueryEngine[Fleur.XQueryX.attributeValueExpr](ctx, children.slice(1), function(n) { + Fleur.callback(function() {callback(n);}); + }, attr); + } else { + Fleur.callback(function() {callback(attr);}); + } + } + }); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/castExpr.js b/src/js/fleur.js/XQuery/Instructions/castExpr-BROKEN.js similarity index 96% rename from src/js/fleur.js/XQuery/Instructions/castExpr.js rename to src/js/fleur.js/XQuery/Instructions/castExpr-BROKEN.js index c14545b..981fe21 100644 --- a/src/js/fleur.js/XQuery/Instructions/castExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/castExpr-BROKEN.js @@ -1,39 +1,39 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.castExpr] = function(ctx, children, callback) { - var typename = children[1][1][0][1][0]; - var typeprefix = children[1][1][0][1][1][1][0]; - var typeuri = ctx.env.nsresolver.lookupNamespaceURI(typeprefix); - var optional = children[1][1].length === 2; - Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { - var err = Fleur.error(ctx, "FORG0001"); - var a; - if (n === Fleur.EmptySequence) { - if (optional) { - a = new Fleur.Text(); - a.data = "true"; - a.schemaTypeInfo = Fleur.Type_boolean; - } else { - a = err; - } - } else if (n.nodeType === Fleur.Node.SEQUENCE_NODE) { - a = err; - } else { - a = Fleur.Atomize(n); - try { - a.data = Fleur.Types[typeuri][typename].canonicalize(a.data); - a.schemaTypeInfo = Fleur.Types[typeuri][typename]; - } catch(e) { - a = err; - } - } - Fleur.callback(function() {callback(a);}); - }); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.castExpr] = function(ctx, children, callback) { + var typename = children[1][1][0][1][0]; + var typeprefix = children[1][1][0][1][1][1][0]; + var typeuri = ctx.env.nsresolver.lookupNamespaceURI(typeprefix); + var optional = children[1][1].length === 2; + Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { + var err = Fleur.error(ctx, "FORG0001"); + var a; + if (n === Fleur.EmptySequence) { + if (optional) { + a = new Fleur.Text(); + a.data = "true"; + a.schemaTypeInfo = Fleur.Type_boolean; + } else { + a = err; + } + } else if (n.nodeType === Fleur.Node.SEQUENCE_NODE) { + a = err; + } else { + a = Fleur.Atomize(n); + try { + a.data = Fleur.Types[typeuri][typename].canonicalize(a.data); + a.schemaTypeInfo = Fleur.Types[typeuri][typename]; + } catch(e) { + a = err; + } + } + Fleur.callback(function() {callback(a);}); + }); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/castableExpr.js b/src/js/fleur.js/XQuery/Instructions/castableExpr-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/castableExpr.js rename to src/js/fleur.js/XQuery/Instructions/castableExpr-BROKEN.js index d862bad..c3a51d6 100644 --- a/src/js/fleur.js/XQuery/Instructions/castableExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/castableExpr-BROKEN.js @@ -1,35 +1,35 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.castableExpr] = function(ctx, children, callback) { - var typename = children[1][1][0][1][0]; - var typeprefix = children[1][1][0][1][1][1][0]; - var typeuri = ctx.env.nsresolver.lookupNamespaceURI(typeprefix); - var optional = children[1][1].length === 2; - Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { - var a; - if (n === Fleur.EmptySequence) { - a = new Fleur.Text(); - a.data = String(optional); - } else if (n.nodeType === Fleur.Node.SEQUENCE_NODE) { - a = new Fleur.Text(); - a.data = "false"; - } else { - a = Fleur.Atomize(n); - try { - Fleur.Types[typeuri][typename].canonicalize(a.data); - a.data = "true"; - } catch(e) { - a.data = "false"; - } - } - a.schemaTypeInfo = Fleur.Type_boolean; - Fleur.callback(function() {callback(a);}); - }); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.castableExpr] = function(ctx, children, callback) { + var typename = children[1][1][0][1][0]; + var typeprefix = children[1][1][0][1][1][1][0]; + var typeuri = ctx.env.nsresolver.lookupNamespaceURI(typeprefix); + var optional = children[1][1].length === 2; + Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { + var a; + if (n === Fleur.EmptySequence) { + a = new Fleur.Text(); + a.data = String(optional); + } else if (n.nodeType === Fleur.Node.SEQUENCE_NODE) { + a = new Fleur.Text(); + a.data = "false"; + } else { + a = Fleur.Atomize(n); + try { + Fleur.Types[typeuri][typename].canonicalize(a.data); + a.data = "true"; + } catch(e) { + a.data = "false"; + } + } + a.schemaTypeInfo = Fleur.Type_boolean; + Fleur.callback(function() {callback(a);}); + }); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/commentTest.js b/src/js/fleur.js/XQuery/Instructions/commentTest-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/commentTest.js rename to src/js/fleur.js/XQuery/Instructions/commentTest-BROKEN.js index 81e03fb..a46460f 100644 --- a/src/js/fleur.js/XQuery/Instructions/commentTest.js +++ b/src/js/fleur.js/XQuery/Instructions/commentTest-BROKEN.js @@ -1,15 +1,15 @@ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.Transpiler.prototype.xqx_commentTest = function() { - return this.inst("xqx_commentTest()"); -}; - -Fleur.XQueryEngine[Fleur.XQueryX.commentTest] = function(ctx, children, callback) { - Fleur.callback(function() {callback(ctx._curr.nodeType !== Fleur.Node.COMMENT_NODE ? Fleur.EmptySequence : ctx._curr);}); +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.Transpiler.prototype.xqx_commentTest = function() { + return this.inst("xqx_commentTest()"); +}; + +Fleur.XQueryEngine[Fleur.XQueryX.commentTest] = function(ctx, children, callback) { + Fleur.callback(function() {callback(ctx._curr.nodeType !== Fleur.Node.COMMENT_NODE ? Fleur.EmptySequence : ctx._curr);}); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/computedAttributeConstructor.js b/src/js/fleur.js/XQuery/Instructions/computedAttributeConstructor.js index 477a5c7..d2a5dc4 100644 --- a/src/js/fleur.js/XQuery/Instructions/computedAttributeConstructor.js +++ b/src/js/fleur.js/XQuery/Instructions/computedAttributeConstructor.js @@ -1,7 +1,7 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ @@ -13,12 +13,13 @@ Fleur.Transpiler.prototype.xqx_computedAttributeConstructor = function(children) if (children[0][0] === Fleur.XQueryX.tagName) { tagName = children[0][1][0]; } else { - r = this.gen(children[0][1][0], Fleur.atomicTypes).inst; + r = this.gen(children[0][1][0], Fleur.SequenceType_anyAtomicType_1).inst; } - r += this.gen(children[1][1][0], Fleur.atomicTypes).inst; + r += this.gen(children[1][1][0], Fleur.SequenceType_anyAtomicType_1).inst; r += this.inst("xqx_computedAttributeConstructor" + (tagName ? (URI ? "_URI" : "") + "('" + (URI ? URI : prefix) + "', '" + tagName + "')" : "_expr()")).inst; return { - inst: r + inst: r, + sequenceType: Fleur.SequenceType_attribute_1 }; }; @@ -60,7 +61,7 @@ Fleur.Context.prototype.xqx_computedAttributeConstructor_URI = function(URI, loc this.item = attr; return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.computedAttributeConstructor] = function(ctx, children, callback) { var attr = new Fleur.Attr(); if (children[0][0] === Fleur.XQueryX.tagName) { @@ -97,4 +98,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.computedAttributeConstructor] = function(ctx, c } }); } -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/computedCommentConstructor.js b/src/js/fleur.js/XQuery/Instructions/computedCommentConstructor.js index 49de203..8788bd9 100644 --- a/src/js/fleur.js/XQuery/Instructions/computedCommentConstructor.js +++ b/src/js/fleur.js/XQuery/Instructions/computedCommentConstructor.js @@ -1,14 +1,15 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_computedCommentConstructor = function(children) { - let r = (children.length === 1 ? this.gen(children[0][1][0], Fleur.atomicTypes).inst : this.inst("emptySequence()").inst) + this.inst("xqx_computedCommentConstructor()").inst; + let r = children.length === 1 ? this.gen(children[0][1][0], Fleur.SequenceType_anyAtomicType_1).inst + this.inst("xqx_computedCommentConstructor()").inst: this.inst("emptySequence()").inst; return { - inst: r + inst: r, + sequenceType: children.length === 1 ? Fleur.SequenceType_comment_01 : Fleur.SequenceType_empty_sequence }; }; @@ -18,7 +19,7 @@ Fleur.Context.prototype.xqx_computedCommentConstructor = function() { this.item = cmt; return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.computedCommentConstructor] = function(ctx, children, callback) { var cmt = new Fleur.Comment(); cmt.data = ""; @@ -26,4 +27,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.computedCommentConstructor] = function(ctx, chi cmt.data = n.data; Fleur.callback(function() {callback(cmt);}); }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/computedDocumentConstructor.js b/src/js/fleur.js/XQuery/Instructions/computedDocumentConstructor.js index f804279..5182d1a 100644 --- a/src/js/fleur.js/XQuery/Instructions/computedDocumentConstructor.js +++ b/src/js/fleur.js/XQuery/Instructions/computedDocumentConstructor.js @@ -1,14 +1,15 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_computedDocumentConstructor = function(children) { let r = (children.length === 1 ? this.gen(children[0][1][0]).inst : this.inst("emptySequence()").inst) + this.inst("xqx_computedDocumentConstructor()").inst; return { - inst: r + inst: r, + sequenceType: Fleur.SequenceType_document_1 }; }; @@ -18,7 +19,7 @@ Fleur.Context.prototype.xqx_computedDocumentConstructor = function() { this.item = doc; return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.computedDocumentConstructor] = function(ctx, children, callback) { var doc = new Fleur.Document(); Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { @@ -31,4 +32,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.computedDocumentConstructor] = function(ctx, ch } Fleur.callback(function() {callback(doc);}); }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/computedElementConstructor.js b/src/js/fleur.js/XQuery/Instructions/computedElementConstructor.js index 96b1349..f304bf9 100644 --- a/src/js/fleur.js/XQuery/Instructions/computedElementConstructor.js +++ b/src/js/fleur.js/XQuery/Instructions/computedElementConstructor.js @@ -1,7 +1,7 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ @@ -18,7 +18,8 @@ Fleur.Transpiler.prototype.xqx_computedElementConstructor = function(children) { r += children.length === 2 ? this.gen(children[1][1][0]).inst : this.inst("emptySequence()").inst; r += this.inst("xqx_computedElementConstructor" + (tagName ? (URI ? "_URI" : "") + "('" + (URI ? URI : prefix) + "', '" + tagName + "')" : "_expr()")).inst; return { - inst: r + inst: r, + sequenceType: Fleur.SequenceType_element_1 }; }; diff --git a/src/js/fleur.js/XQuery/Instructions/computedEntryConstructor.js b/src/js/fleur.js/XQuery/Instructions/computedEntryConstructor.js index ef3e01f..28ea3d1 100644 --- a/src/js/fleur.js/XQuery/Instructions/computedEntryConstructor.js +++ b/src/js/fleur.js/XQuery/Instructions/computedEntryConstructor.js @@ -1,12 +1,67 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ +Fleur.Transpiler.prototype.xqx_computedEntryConstructor = function(children) { + let r = ""; + const prefix = children[0][1].length === 2 && children[0][1][1][0] === Fleur.XQueryX.prefix ? children[0][1][1][1][0] : ""; + const URI = children[0][1].length === 2 && children[0][1][1][0] === Fleur.XQueryX.URI ? children[0][1][1][1][0] : null; + let tagName; + if (children[0][0] === Fleur.XQueryX.tagName) { + tagName = children[0][1][0]; + } else { + r = this.gen(children[0][1][0], Fleur.SequenceType_anyAtomicType_1).inst; + } + r += this.gen(children[1][1][0], Fleur.SequenceType_anyAtomicType_1).inst; + r += this.inst("xqx_computedEntryConstructor" + (tagName ? (URI ? "_URI" : "") + "('" + (URI ? URI : prefix) + "', '" + tagName + "')" : "_expr()")).inst; + return { + inst: r, + sequenceType: Fleur.SequenceType_entry_1 + }; +}; + +Fleur.Context.prototype.xqx_computedEntryConstructor = function(prefix, localName) { + const entry = new Fleur.Entry(); + entry.nodeName = prefix === "" ? localName : prefix + ":" + localName; + entry.localName = localName; + entry.prefix = prefix === "" ? null : prefix; + entry.namespaceURI = this.rs.nsresolver.lookupNamespaceURI(prefix); + this.item.schemaTypeInfo = Fleur.Type_untypedAtomic; + entry.appendChild(this.item); + this.item = entry; + return this; +}; + +Fleur.Context.prototype.xqx_computedEntryConstructor_expr = function() { + const arg2 = this.item; + const arg1 = this.itemstack.pop(); + const entry = new Fleur.Entry(); + const prefix = arg1.data.includes(":") ? arg1.data.split(":")[0] : ""; + entry.nodeName = arg1.data; + entry.localName = prefix === "" ? arg1.data : arg1.data.split(":")[1]; + entry.prefix = prefix === "" ? null : prefix; + entry.namespaceURI = this.rs.nsresolver.lookupNamespaceURI(prefix); + arg2.schemaTypeInfo = Fleur.Type_untypedAtomic; + entry.appendChild(arg2); + this.item = entry; + return this; +}; + +Fleur.Context.prototype.xqx_computedEntryConstructor_URI = function(URI, localName) { + const entry = new Fleur.Entry(); + entry.nodeName = localName; + entry.localName = localName; + entry.prefix = null; + entry.namespaceURI = URI; + this.item.schemaTypeInfo = Fleur.Type_untypedAtomic; + entry.appendChild(this.item); + this.item = entry; + return this; +}; +/* Fleur.XQueryEngine[Fleur.XQueryX.computedEntryConstructor] = function(ctx, children, callback) { var entry = new Fleur.Entry(); if (children[0][0] === Fleur.XQueryX.tagName) { @@ -33,4 +88,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.computedEntryConstructor] = function(ctx, child } }); } -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/computedPIConstructor.js b/src/js/fleur.js/XQuery/Instructions/computedPIConstructor.js index 2910da7..6a78ba3 100644 --- a/src/js/fleur.js/XQuery/Instructions/computedPIConstructor.js +++ b/src/js/fleur.js/XQuery/Instructions/computedPIConstructor.js @@ -1,14 +1,15 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_computedPIConstructor = function(children) { - let r = (children.length === 2 ? this.gen(children[1][1][0], Fleur.atomicTypes).inst : this.inst("emptySequence()").inst) + this.inst("xqx_computedPIConstructor('" + children[0][1][0] + "')").inst; + let r = (children.length === 2 ? this.gen(children[1][1][0], Fleur.SequenceType_anyAtomicType_1).inst : this.inst("emptySequence()").inst) + this.inst("xqx_computedPIConstructor('" + children[0][1][0] + "')").inst; return { - inst: r + inst: r, + sequenceType: Fleur.SequenceType_processing_instruction_1 }; }; @@ -19,7 +20,7 @@ Fleur.Context.prototype.xqx_computedPIConstructor = function(name) { this.item = prins; return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.computedPIConstructor] = function(ctx, children, callback) { var aval, prins = new Fleur.ProcessingInstruction(); if (children[0][0] === Fleur.XQueryX.piTarget) { @@ -52,4 +53,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.computedPIConstructor] = function(ctx, children } }); } -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/computedTextConstructor.js b/src/js/fleur.js/XQuery/Instructions/computedTextConstructor.js index cd4cfb3..21924e9 100644 --- a/src/js/fleur.js/XQuery/Instructions/computedTextConstructor.js +++ b/src/js/fleur.js/XQuery/Instructions/computedTextConstructor.js @@ -1,14 +1,15 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_computedTextConstructor = function(children) { - let r = (children.length === 1 ? this.gen(children[0][1][0], Fleur.atomicTypes).inst : this.inst("emptySequence()").inst) + this.inst("xqx_computedTextConstructor()").inst; + let r = children.length === 1 ? this.gen(children[0][1][0], Fleur.SequenceType_anyAtomicType_1).inst + this.inst("xqx_computedTextConstructor()").inst : this.inst("emptySequence()").inst; return { - inst: r + inst: r, + sequenceType: children.length === 1 ? Fleur.SequenceType_untypedAtomic_01 : Fleur.SequenceType_empty_sequence }; }; diff --git a/src/js/fleur.js/XQuery/Instructions/constantExpr.js b/src/js/fleur.js/XQuery/Instructions/constantExpr.js new file mode 100644 index 0000000..126a00c --- /dev/null +++ b/src/js/fleur.js/XQuery/Instructions/constantExpr.js @@ -0,0 +1,15 @@ +"use strict"; +/** + * @author Alain Couthures + * @license LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.Context.prototype.xqx_constantExpr = function(argType, arg) { + this.itemstack.push(this.item); + const item = new Fleur.Text(); + item.appendData(arg); + item.schemaTypeInfo = argType; + this.item = item; + return this; +}; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/contextItemExpr.js b/src/js/fleur.js/XQuery/Instructions/contextItemExpr.js index c672a2d..587ce64 100644 --- a/src/js/fleur.js/XQuery/Instructions/contextItemExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/contextItemExpr.js @@ -1,20 +1,19 @@ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.Transpiler.prototype.xqx_contextItemExpr = function(children, atomicType) { - return this.inst("xqx_contextItemExpr()", false, atomicType); +Fleur.Transpiler.prototype.xqx_contextItemExpr = function(children, expectedSequenceType) { + return this.inst("xqx_contextItemExpr()", false, expectedSequenceType, "", expectedSequenceType); }; Fleur.Context.prototype.xqx_contextItemExpr = function() { this.itemstack.push(this.item); this.item = this.path; return this; -} +}; Fleur.XQueryEngine[Fleur.XQueryX.contextItemExpr] = function(ctx, children, callback) { Fleur.callback(function() {callback(ctx._curr);}); diff --git a/src/js/fleur.js/XQuery/Instructions/countClause.js b/src/js/fleur.js/XQuery/Instructions/countClause-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/countClause.js rename to src/js/fleur.js/XQuery/Instructions/countClause-BROKEN.js index 4a97383..56b709d 100644 --- a/src/js/fleur.js/XQuery/Instructions/countClause.js +++ b/src/js/fleur.js/XQuery/Instructions/countClause-BROKEN.js @@ -1,20 +1,20 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.countClause] = function(ctx, children, callback, resarr) { - //console.log("countClause "); - var countname = children[0][1][0][1][0]; - resarr.forEach(function addcount(vmgr, i) { - var countvalue = new Fleur.Text(); - countvalue.data = String(i + 1); - countvalue.schemaTypeInfo = Fleur.Type_integer; - vmgr.set(ctx, "", countname, countvalue); - }); - Fleur.callback(function() {callback(Fleur.EmptySequence);}); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.countClause] = function(ctx, children, callback, resarr) { + //console.log("countClause "); + var countname = children[0][1][0][1][0]; + resarr.forEach(function addcount(vmgr, i) { + var countvalue = new Fleur.Text(); + countvalue.data = String(i + 1); + countvalue.schemaTypeInfo = Fleur.Type_integer; + vmgr.set(ctx, "", countname, countvalue); + }); + Fleur.callback(function() {callback(Fleur.EmptySequence);}); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/decimalConstantExpr.js b/src/js/fleur.js/XQuery/Instructions/decimalConstantExpr.js index 295f448..895059b 100644 --- a/src/js/fleur.js/XQuery/Instructions/decimalConstantExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/decimalConstantExpr.js @@ -1,20 +1,27 @@ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.Transpiler.prototype.xqx_decimalConstantExpr = function(children) { - return { - inst: this.inst("xqx_decimalConstantExpr('" + children[0][1][0] + "')", false).inst, - sequenceType: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_decimal, - occurrence: 1 - } - }; +Fleur.Transpiler.prototype.xqx_decimalConstantExpr = function(children, expectedSequenceType) { + const issubtype = expectedSequenceType && expectedSequenceType.schemaTypeInfo !== Fleur.Type_double && expectedSequenceType.schemaTypeInfo.as(Fleur.Type_double); + const subtype = issubtype ? expectedSequenceType.schemaTypeInfo : Fleur.Type_double; + const item = new Fleur.Text(); + item.schemaTypeInfo = subtype; + try { + const canon = subtype.canonicalize(children[0][1][0]); + item.appendData(canon); + return { + inst: this.inst((issubtype ? "xqx_constantExpr(Fleur.Type_" + expectedSequenceType.schemaTypeInfo.typeName + ", '" : "xqx_decimalConstantExpr('") + canon + "')", false).inst, + sequenceType: new Fleur.SequenceType(Fleur.Node.TEXT_NODE, subtype, "1"), + value: item + }; + } catch (e) { + item.appendData(children[0][1][0]); + Fleur.XQueryError_xqt(e.code === Fleur.DOMException.VALIDATION_ERR ? "FORG0001" : "FODT0001", null, "Wrong argument for implicit xs:" + expectedSequenceType.schemaTypeInfo.typeName + "#1", "", item); + } }; Fleur.Context.prototype.xqx_decimalConstantExpr = function(arg) { @@ -25,10 +32,11 @@ Fleur.Context.prototype.xqx_decimalConstantExpr = function(arg) { this.item = item; return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.decimalConstantExpr] = function(ctx, children, callback) { var a = new Fleur.Text(); a.appendData(Fleur.Type_decimal.canonicalize(children[0][1][0])); a.schemaTypeInfo = Fleur.Type_decimal; Fleur.callback(function() {callback(a);}); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/defaultNamespaceCategory.js b/src/js/fleur.js/XQuery/Instructions/defaultNamespaceCategory-BROKEN.js similarity index 96% rename from src/js/fleur.js/XQuery/Instructions/defaultNamespaceCategory.js rename to src/js/fleur.js/XQuery/Instructions/defaultNamespaceCategory-BROKEN.js index 924468e..7ae60e7 100644 --- a/src/js/fleur.js/XQuery/Instructions/defaultNamespaceCategory.js +++ b/src/js/fleur.js/XQuery/Instructions/defaultNamespaceCategory-BROKEN.js @@ -1,11 +1,11 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.defaultNamespaceCategory] = function(ctx, children) { +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.defaultNamespaceCategory] = function(ctx, children) { }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/defaultNamespaceDecl.js b/src/js/fleur.js/XQuery/Instructions/defaultNamespaceDecl-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/defaultNamespaceDecl.js rename to src/js/fleur.js/XQuery/Instructions/defaultNamespaceDecl-BROKEN.js index 36a5751..fcfb4c5 100644 --- a/src/js/fleur.js/XQuery/Instructions/defaultNamespaceDecl.js +++ b/src/js/fleur.js/XQuery/Instructions/defaultNamespaceDecl-BROKEN.js @@ -1,13 +1,13 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.defaultNamespaceDecl] = function(ctx, children, callback) { - ctx.env.nsresolver.declareNamespace(" " + children[0][1][0], children[1][1][0]); - Fleur.callback(function() {callback();}); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.defaultNamespaceDecl] = function(ctx, children, callback) { + ctx.env.nsresolver.declareNamespace(" " + children[0][1][0], children[1][1][0]); + Fleur.callback(function() {callback();}); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/deleteExpr.js b/src/js/fleur.js/XQuery/Instructions/deleteExpr-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/deleteExpr.js rename to src/js/fleur.js/XQuery/Instructions/deleteExpr-BROKEN.js index 21b9d33..7d616bc 100644 --- a/src/js/fleur.js/XQuery/Instructions/deleteExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/deleteExpr-BROKEN.js @@ -1,34 +1,34 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.deleteExpr] = function(ctx, children, callback) { - Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { - var i, l; - if (n !== Fleur.EmptySequence) { - if (n.nodeType === Fleur.Node.SEQUENCE_NODE) { - for (i = 0, l = n.childNodes.length; i < l; i++) { - if (n.childNodes[i].parentElement) { - if (n.childNodes[i].nodeType === Fleur.Node.ATTRIBUTE_NODE) { - n.childNodes[i].parentElement.removeAttributeNode(n.childNodes[i]); - } else { - n.childNodes[i].parentElement.removeChild(n.childNodes[i]); - } - } - } - } else if (n.parentElement) { - if (n.nodeType === Fleur.Node.ATTRIBUTE_NODE) { - n.parentElement.removeAttributeNode(n); - } else { - n.parentElement.removeChild(n); - } - } - } - Fleur.callback(function() {callback(Fleur.EmptySequence);}); - }); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.deleteExpr] = function(ctx, children, callback) { + Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { + var i, l; + if (n !== Fleur.EmptySequence) { + if (n.nodeType === Fleur.Node.SEQUENCE_NODE) { + for (i = 0, l = n.childNodes.length; i < l; i++) { + if (n.childNodes[i].parentElement) { + if (n.childNodes[i].nodeType === Fleur.Node.ATTRIBUTE_NODE) { + n.childNodes[i].parentElement.removeAttributeNode(n.childNodes[i]); + } else { + n.childNodes[i].parentElement.removeChild(n.childNodes[i]); + } + } + } + } else if (n.parentElement) { + if (n.nodeType === Fleur.Node.ATTRIBUTE_NODE) { + n.parentElement.removeAttributeNode(n); + } else { + n.parentElement.removeChild(n); + } + } + } + Fleur.callback(function() {callback(Fleur.EmptySequence);}); + }); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/documentTest.js b/src/js/fleur.js/XQuery/Instructions/documentTest-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/documentTest.js rename to src/js/fleur.js/XQuery/Instructions/documentTest-BROKEN.js index 212a0e1..e7e8bb4 100644 --- a/src/js/fleur.js/XQuery/Instructions/documentTest.js +++ b/src/js/fleur.js/XQuery/Instructions/documentTest-BROKEN.js @@ -1,12 +1,12 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.documentTest] = function(ctx, children, callback) { - Fleur.callback(function() {callback(ctx._curr.nodeType !== Fleur.Node.DOCUMENT_NODE ? Fleur.EmptySequence : ctx._curr);}); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.documentTest] = function(ctx, children, callback) { + Fleur.callback(function() {callback(ctx._curr.nodeType !== Fleur.Node.DOCUMENT_NODE ? Fleur.EmptySequence : ctx._curr);}); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/doubleConstantExpr.js b/src/js/fleur.js/XQuery/Instructions/doubleConstantExpr.js index b56d3d3..9d920d8 100644 --- a/src/js/fleur.js/XQuery/Instructions/doubleConstantExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/doubleConstantExpr.js @@ -1,20 +1,27 @@ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.Transpiler.prototype.xqx_doubleConstantExpr = function(children) { - return { - inst: this.inst("xqx_doubleConstantExpr('" + children[0][1][0] + "')", false).inst, - sequenceType: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_double, - occurrence: 1 - } - }; +Fleur.Transpiler.prototype.xqx_doubleConstantExpr = function(children, expectedSequenceType) { + const issubtype = expectedSequenceType && expectedSequenceType.schemaTypeInfo !== Fleur.Type_double && expectedSequenceType.schemaTypeInfo.as(Fleur.Type_double); + const subtype = issubtype ? expectedSequenceType.schemaTypeInfo : Fleur.Type_double; + const item = new Fleur.Text(); + item.schemaTypeInfo = subtype; + try { + const canon = subtype.canonicalize(children[0][1][0]); + item.appendData(canon); + return { + inst: this.inst((issubtype ? "xqx_constantExpr(Fleur.Type_" + expectedSequenceType.schemaTypeInfo.typeName + ", '" : "xqx_doubleConstantExpr('") + canon + "')", false).inst, + sequenceType: new Fleur.SequenceType(Fleur.Node.TEXT_NODE, subtype, "1"), + value: item + }; + } catch (e) { + item.appendData(children[0][1][0]); + Fleur.XQueryError_xqt(e.code === Fleur.DOMException.VALIDATION_ERR ? "FORG0001" : "FODT0001", null, "Wrong argument for implicit xs:" + expectedSequenceType.schemaTypeInfo.typeName + "#1", "", item); + } }; Fleur.Context.prototype.xqx_doubleConstantExpr = function(arg) { @@ -25,10 +32,11 @@ Fleur.Context.prototype.xqx_doubleConstantExpr = function(arg) { this.item = item; return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.doubleConstantExpr] = function(ctx, children, callback) { var a = new Fleur.Text(); a.appendData(Fleur.Type_double.canonicalize(children[0][1][0])); a.schemaTypeInfo = Fleur.Type_double; Fleur.callback(function() {callback(a);}); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/doubleMapExpr.js b/src/js/fleur.js/XQuery/Instructions/doubleMapExpr-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/doubleMapExpr.js rename to src/js/fleur.js/XQuery/Instructions/doubleMapExpr-BROKEN.js index f564565..889252e 100644 --- a/src/js/fleur.js/XQuery/Instructions/doubleMapExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/doubleMapExpr-BROKEN.js @@ -1,118 +1,118 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.doubleMapExpr] = function(ctx, children, callback) { - Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], function(n) { - //console.log("doubleMapExpr - " + Fleur.Serializer._serializeNodeToXQuery(n, false, "")); - var seq, md, subcurr, next, last, pos = 1, result = Fleur.EmptySequence; - if (n === Fleur.EmptySequence || n.schemaTypeInfo === Fleur.Type_error) { - Fleur.callback(function() {callback(n);}); - return; - } - if (n.nodeType === Fleur.Node.SEQUENCE_NODE && n.childNodes[0].nodeType === Fleur.Node.MULTIDIM_NODE) { - next = new Fleur.Sequence(); - for (var i = 0, l = n.childNodes.length; i < l; i++) { - next.appendChild(n.childNodes[i]); - } - next.rowlabels = n.rowlabels; - next.collabels = n.collabels; - last = next.childNodes.length; - subcurr = next.childNodes.shift(); - seq = new Fleur.Sequence(); - seq.childNodes = subcurr.childNodes; - subcurr = seq; - subcurr.collabels = next.collabels; - if (next.childNodes.length === 0) { - next = Fleur.EmptySequence; - } - } else { - subcurr = n; - next = Fleur.EmptySequence; - last = 1; - } - var cb = function(n) { - //console.log("doubleMapExpr - cb - " + Fleur.Serializer._serializeNodeToXQuery(n, false, "")); - if (n !== Fleur.EmptySequence) { - if (result === Fleur.EmptySequence) { - result = n; - } else { - if (result.nodeType !== Fleur.Node.SEQUENCE_NODE) { - seq = new Fleur.Sequence(); - md = new Fleur.Multidim(); - seq.appendChild(md); - md.appendChild(result); - result = seq; - } else if (result.childNodes[0].nodeType !== Fleur.Node.MULTIDIM_NODE) { - seq = new Fleur.Sequence(); - md = new Fleur.Multidim(); - seq.appendChild(md); - result.childNodes.forEach(function(node) { - md.appendChild(node); - }); - result = seq; - } - if (n.nodeType !== Fleur.Node.SEQUENCE_NODE || n.childNodes[0].nodeType !== Fleur.Node.MULTIDIM_NODE) { - md = new Fleur.Multidim(); - result.appendChild(md); - if (n.nodeType !== Fleur.Node.SEQUENCE_NODE) { - md.appendChild(n); - } else { - n.childNodes.forEach(function(node) { - md.appendChild(node); - }); - } - } else { - n.childNodes.forEach(function(node) { - result.appendChild(node); - }); - } - } - } - if (next === Fleur.EmptySequence) { - Fleur.callback(function() {callback(result, Fleur.XQueryX.doubleMapExpr);}); - return; - } - if (next.nodeType === Fleur.Node.SEQUENCE_NODE) { - subcurr = next.childNodes.shift(); - if (subcurr.nodeType === Fleur.Node.MULTIDIM_NODE) { - seq = new Fleur.Sequence(); - seq.childNodes = subcurr.childNodes; - subcurr = seq; - subcurr.collabels = next.collabels; - if (next.childNodes.length === 0) { - next = Fleur.EmptySequence; - } - } else { - subcurr.collabels = next.collabels; - if (next.childNodes.length === 1) { - next = next.childNodes[0]; - } - } - } else { - subcurr = next; - next = Fleur.EmptySequence; - } - pos++; - Fleur.XQueryEngine[children[1][0]]({ - _curr: subcurr, - _next: next, - _last: last, - _pos: pos, - env: ctx.env - }, children[1][1], cb); - }; - Fleur.XQueryEngine[children[1][0]]({ - _curr: subcurr, - _next: next, - _last: last, - _pos: pos, - env: ctx.env - }, children[1][1], cb); - }); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.doubleMapExpr] = function(ctx, children, callback) { + Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], function(n) { + //console.log("doubleMapExpr - " + Fleur.Serializer._serializeNodeToXQuery(n, false, "")); + var seq, md, subcurr, next, last, pos = 1, result = Fleur.EmptySequence; + if (n === Fleur.EmptySequence || n.schemaTypeInfo === Fleur.Type_error) { + Fleur.callback(function() {callback(n);}); + return; + } + if (n.nodeType === Fleur.Node.SEQUENCE_NODE && n.childNodes[0].nodeType === Fleur.Node.MULTIDIM_NODE) { + next = new Fleur.Sequence(); + for (var i = 0, l = n.childNodes.length; i < l; i++) { + next.appendChild(n.childNodes[i]); + } + next.rowlabels = n.rowlabels; + next.collabels = n.collabels; + last = next.childNodes.length; + subcurr = next.childNodes.shift(); + seq = new Fleur.Sequence(); + seq.childNodes = subcurr.childNodes; + subcurr = seq; + subcurr.collabels = next.collabels; + if (next.childNodes.length === 0) { + next = Fleur.EmptySequence; + } + } else { + subcurr = n; + next = Fleur.EmptySequence; + last = 1; + } + var cb = function(n) { + //console.log("doubleMapExpr - cb - " + Fleur.Serializer._serializeNodeToXQuery(n, false, "")); + if (n !== Fleur.EmptySequence) { + if (result === Fleur.EmptySequence) { + result = n; + } else { + if (result.nodeType !== Fleur.Node.SEQUENCE_NODE) { + seq = new Fleur.Sequence(); + md = new Fleur.Multidim(); + seq.appendChild(md); + md.appendChild(result); + result = seq; + } else if (result.childNodes[0].nodeType !== Fleur.Node.MULTIDIM_NODE) { + seq = new Fleur.Sequence(); + md = new Fleur.Multidim(); + seq.appendChild(md); + result.childNodes.forEach(function(node) { + md.appendChild(node); + }); + result = seq; + } + if (n.nodeType !== Fleur.Node.SEQUENCE_NODE || n.childNodes[0].nodeType !== Fleur.Node.MULTIDIM_NODE) { + md = new Fleur.Multidim(); + result.appendChild(md); + if (n.nodeType !== Fleur.Node.SEQUENCE_NODE) { + md.appendChild(n); + } else { + n.childNodes.forEach(function(node) { + md.appendChild(node); + }); + } + } else { + n.childNodes.forEach(function(node) { + result.appendChild(node); + }); + } + } + } + if (next === Fleur.EmptySequence) { + Fleur.callback(function() {callback(result, Fleur.XQueryX.doubleMapExpr);}); + return; + } + if (next.nodeType === Fleur.Node.SEQUENCE_NODE) { + subcurr = next.childNodes.shift(); + if (subcurr.nodeType === Fleur.Node.MULTIDIM_NODE) { + seq = new Fleur.Sequence(); + seq.childNodes = subcurr.childNodes; + subcurr = seq; + subcurr.collabels = next.collabels; + if (next.childNodes.length === 0) { + next = Fleur.EmptySequence; + } + } else { + subcurr.collabels = next.collabels; + if (next.childNodes.length === 1) { + next = next.childNodes[0]; + } + } + } else { + subcurr = next; + next = Fleur.EmptySequence; + } + pos++; + Fleur.XQueryEngine[children[1][0]]({ + _curr: subcurr, + _next: next, + _last: last, + _pos: pos, + env: ctx.env + }, children[1][1], cb); + }; + Fleur.XQueryEngine[children[1][0]]({ + _curr: subcurr, + _next: next, + _last: last, + _pos: pos, + env: ctx.env + }, children[1][1], cb); + }); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/dynamicFunctionInvocationExpr.js b/src/js/fleur.js/XQuery/Instructions/dynamicFunctionInvocationExpr-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/dynamicFunctionInvocationExpr.js rename to src/js/fleur.js/XQuery/Instructions/dynamicFunctionInvocationExpr-BROKEN.js index 95ea13e..c0e3501 100644 --- a/src/js/fleur.js/XQuery/Instructions/dynamicFunctionInvocationExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/dynamicFunctionInvocationExpr-BROKEN.js @@ -1,301 +1,301 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.dynamicFunctionInvocationExpr] = function(ctx, children, callback) { - Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { - if (n && n.schemaTypeInfo === Fleur.Type_error) { - Fleur.callback(function() {callback(n);}); - return; - } - if (n && n.nodeType === Fleur.Node.ENTRY_NODE) { - n = n.firstChild; - } - var args = children[children.length - 1][0] === Fleur.XQueryX.arguments ? children[children.length - 1][1] : []; - var preds = []; - children.forEach(function(child) { - if (child[0] === Fleur.XQueryX.predicates) { - child[1].forEach(function(subchild) {preds.push(subchild);}); - } else if (child[0] === Fleur.XQueryX.predicate) { - preds.push(child[1][0]); - } else if (child[0] === Fleur.XQueryX.lookup) { - preds.push(child); - } - }); - if (preds.length === 0) { - if (!n || n.nodeType !== Fleur.Node.FUNCTION_NODE) { - Fleur.callback(function() {callback(Fleur.error(ctx, "XPTY0004"));}); - return; - } - Fleur.functionCall(ctx, children, n, args, callback); - } else { - var next; - if (n.nodeType === Fleur.Node.SEQUENCE_NODE) { - next = new Fleur.Sequence(); - next.childNodes = new Fleur.NodeList(); - n.childNodes.forEach(function(node) { - next.appendChild(node); - }); - } else { - next = n; - } - Fleur.XQueryEngine[Fleur.XQueryX.predicates]({ - _next: next, - _item: ctx._item, - env: ctx.env - }, preds, function(n) { - if (n && n.nodeType === Fleur.Node.ENTRY_NODE) { - n = n.firstChild; - } - if (!n || n.nodeType !== Fleur.Node.FUNCTION_NODE) { - Fleur.callback(function() {callback(Fleur.error(ctx, "XPTY0004"));}); - return; - } - Fleur.functionCall(ctx, children, n, args, callback); - }); - } - }); -}; -/* - var mainUpdater = false; - var xf = n; - if (xf.updating && !ctx.updater) { - if (Fleur.XQueryEngine.updating) { - Fleur.XQueryEngine.updateQueue.push(function() { - Fleur.XQueryEngine[Fleur.XQueryX.functionCallExpr](ctx, children, callback); - }); - return; - } - Fleur.XQueryEngine.updating = true; - mainUpdater = true; - ctx.updater = true; - } - if (xf.jsfunc || xf.xqxfunc) { - var argscalc = function(xqxargs, effargs, f) { - if (xqxargs.length === 0) { - f(effargs); - } else { - var xqxarg = xqxargs.shift(); - Fleur.XQueryEngine[xqxarg[0]](ctx, xqxarg[1], function(n) { - if ((xf.argtypes && xf.argtypes[effargs.length].type === Fleur.Node) || (n && n.nodeType === Fleur.Node.SEQUENCE_NODE)) { - effargs.push(n); - } else if (xf.argtypes && xf.argtypes[effargs.length].type === Fleur.Type_handler) { - effargs.push(n.data); - } else { - var a = Fleur.Atomize(n); - effargs.push(a); - } - argscalc(xqxargs, effargs, f); - }); - } - }; - argscalc(args.slice(), [], function(effargs) { - var a = new Fleur.Text(); - a.schemaTypeInfo = xf.restype ? xf.restype.type : null; - a.data = ""; - if (xf.jsfunc) { - var jsargs = []; - try { - effargs.forEach(function(effarg, iarg) { - var op; - var carg = xf.argtypes ? xf.argtypes[iarg] : null; - if (carg.type === Fleur.Node) { - jsargs.push(effarg); - } else if (effarg === Fleur.EmptySequence) { - if (carg && (!carg.occurence || (carg.occurence !== "?" && carg.occurence !== "*"))) { - a.nodeType = Fleur.Node.TEXT_NODE; - a.schemaTypeInfo = Fleur.Type_error; - a._setNodeNameLocalNamePrefix("http://www.w3.org/2005/xqt-errors", "err:XPTY0004"); - throw new Error("error"); - } - jsargs.push(null); - } else if (effarg.nodeType === Fleur.Node.SEQUENCE_NODE) { - if (carg && (!carg.occurence || carg.occurence === "?")) { - a.nodeType = Fleur.Node.TEXT_NODE; - a.schemaTypeInfo = Fleur.Type_error; - a._setNodeNameLocalNamePrefix("http://www.w3.org/2005/xqt-errors", "err:XPTY0004"); - throw new Error("error"); - } - var subarr = []; - for (var iseq = 0, lseq = effarg.childNodes.length; iseq < lseq; iseq++) { - var effchild = effarg.childNodes[iseq]; - if ((!carg && Fleur.numericTypes.indexOf(effchild.schemaTypeInfo) !== -1) || (carg && (carg.type === Fleur.numericTypes || Fleur.numericTypes.indexOf(carg.type) !== -1))) { - op = Fleur.toJSNumber(effchild); - if (op[0] < 0) { - a = effchild; - throw new Error("error"); - } - subarr.push(op[1]); - } else if ((!carg && effchild.schemaTypeInfo === Fleur.Type_string) || (carg && carg.type === Fleur.Type_string)) { - op = Fleur.toJSString(effchild); - if (op[0] < 0) { - a = effchild; - throw new Error("error"); - } - subarr.push(op[1]); - } else if ((!carg && effchild.schemaTypeInfo === Fleur.Type_boolean) || (carg && carg.type === Fleur.Type_boolean)) { - op = Fleur.toJSBoolean(effchild); - if (op[0] < 0) { - a = effchild; - throw new Error("error"); - } - subarr.push(op[1]); - } else if (carg.type === Fleur.Type_dateTime) { - } else { - subarr.push(effchild); - } - } - jsargs.push(subarr); - } else if ((!carg && Fleur.numericTypes.indexOf(effarg.schemaTypeInfo) !== -1) || (carg && (carg.type === Fleur.numericTypes || Fleur.numericTypes.indexOf(carg.type) !== -1 || carg.type.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "integer", Fleur.TypeInfo.DERIVATION_RESTRICTION) || carg.type.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "decimal", Fleur.TypeInfo.DERIVATION_RESTRICTION) || carg.type.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "float", Fleur.TypeInfo.DERIVATION_RESTRICTION) || carg.type.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "double", Fleur.TypeInfo.DERIVATION_RESTRICTION)))) { - op = Fleur.toJSNumber(effarg); - if (op[0] < 0) { - a = effarg; - throw new Error("error"); - } - jsargs.push(op[1]); - } else if ((!carg && effarg.schemaTypeInfo === Fleur.Type_string) || (carg && (carg.type === Fleur.Type_string || carg.type.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "string", Fleur.TypeInfo.DERIVATION_RESTRICTION)))) { - op = Fleur.toJSString(effarg); - if (op[0] < 0) { - a = effarg; - throw new Error("error"); - } - jsargs.push(op[1]); - } else if ((!carg && effarg.schemaTypeInfo === Fleur.Type_boolean) || (carg && carg.type === Fleur.Type_boolean)) { - op = Fleur.toJSBoolean(effarg); - if (op[0] < 0) { - a = effarg; - throw new Error("error"); - } - jsargs.push(op[1]); - } else if ((!carg && effarg.schemaTypeInfo === Fleur.Type_dateTime) || (carg.type === Fleur.Type_dateTime)) { - op = Fleur.toJSDate(effarg); - if (op[0] < 0) { - a = effarg; - throw new Error("error"); - } - jsargs.push(op[1]); - } else { - jsargs.push(effarg); - } - }); - } catch (e) { - Fleur.callback(function() {callback(a);}); - return; - } - if (xf.needctx) { - jsargs.push(ctx); - } - var convback = function(vret) { - if (mainUpdater) { - Fleur.XQueryEngine.updating = false; - ctx.updater = false; - if (Fleur.XQueryEngine.updateQueue.length !== 0) { - setImmediate(Fleur.XQueryEngine.updateQueue.pop()); - } - } - var convret = function(v) { - if (v === undefined || v === null) { - a = Fleur.EmptySequence; - } else if (v === Number.POSITIVE_INFINITY) { - a.data = "INF"; - if (!a.schemaTypeInfo) { - a.schemaTypeInfo = Fleur.Type_double; - } - } else if (v === Number.NEGATIVE_INFINITY) { - a.data = "-INF"; - if (!a.schemaTypeInfo) { - a.schemaTypeInfo = Fleur.Type_double; - } - } else if (typeof v === "number" || typeof v === "boolean") { - a.data = String(v); - if (!a.schemaTypeInfo) { - a.schemaTypeInfo = typeof v === "number" ? Fleur.Type_double : Fleur.Type_boolean; - } - } else if (typeof v === "string") { - a.data = v; - if (!a.schemaTypeInfo) { - a.schemaTypeInfo = Fleur.Type_string; - } - } else if (typeof v.getMonth === "function") { - var o = vret.getTimezoneOffset(); - if (!a.schemaTypeInfo) { - a.schemaTypeInfo = Fleur.Type_datetime; - } - if (a.schemaTypeInfo === Fleur.Type_date) { - a.data = ("000" + v.getFullYear()).slice(-4) + "-" + ("0" + (v.getMonth() + 1)).slice(-2) + "-" + ("0" + v.getDate()).slice(-2) + (o < 0 ? "+" : "-") + ("0" + Math.floor(Math.abs(o)/60)).slice(-2) + ":" + ("0" + Math.floor(Math.abs(o) % 60)).slice(-2); - } else if (a.schemaTypeInfo === Fleur.Type_time) { - a.data = ("0" + v.getHours()).slice(-2) + ":" + ("0" + v.getMinutes()).slice(-2) + ":" + ("0" + v.getSeconds()).slice(-2) + "." + ("00" + v.getMilliseconds()).slice(-3) + (o < 0 ? "+" : "-") + ("0" + Math.floor(Math.abs(o)/60)).slice(-2) + ":" + ("0" + Math.floor(Math.abs(o) % 60)).slice(-2); - } else { - a.data = ("000" + v.getFullYear()).slice(-4) + "-" + ("0" + (v.getMonth() + 1)).slice(-2) + "-" + ("0" + v.getDate()).slice(-2) + "T" + ("0" + v.getHours()).slice(-2) + ":" + ("0" + v.getMinutes()).slice(-2) + ":" + ("0" + v.getSeconds()).slice(-2) + "." + ("00" + v.getMilliseconds()).slice(-3) + (o < 0 ? "+" : "-") + ("0" + Math.floor(Math.abs(o)/60)).slice(-2) + ":" + ("0" + Math.floor(Math.abs(o) % 60)).slice(-2); - } - } else if (v instanceof Error) { - a.nodeType = Fleur.Node.TEXT_NODE; - a.schemaTypeInfo = Fleur.Type_error; - a._setNodeNameLocalNamePrefix("http://www.w3.org/2005/xqt-errors", "err:XPTY"); - } else if (v instanceof Fleur.Node || (Node && v instanceof Node)) { - a = v; - } else { - a.data = v; - if (!a.schemaTypeInfo) { - a.schemaTypeInfo = Fleur.Type_handler; - } - } - }; - if (vret instanceof Array) { - var seq = new Fleur.Sequence(); - vret.forEach(function(v) { - a = new Fleur.Text(); - a.schemaTypeInfo = xf.restype ? xf.restype.type : null; - a.data = ""; - convret(v); - seq.appendChild(a); - }); - Fleur.callback(function() {callback(seq);}); - } else { - convret(vret); - Fleur.callback(function() {callback(a);}); - } - }; - if (xf.needcallback) { - jsargs.push(convback); - xf.jsfunc.apply(null, jsargs); - return; - } - convback(xf.jsfunc.apply(null, jsargs)); - } else { - var currvarres = ctx.env.varresolver; - ctx.env.varresolver = new Fleur.varMgr([], xf.closurevarresolver || ctx.env.globalvarresolver); - effargs.forEach(function(effarg, iarg) { - ctx.env.varresolver.set(ctx, "", xf.argtypes[iarg].name, effarg); - }); - Fleur.XQueryEngine[xf.xqxfunc[0]](ctx, xf.xqxfunc[1], function(n) { - if (mainUpdater) { - Fleur.XQueryEngine.updating = false; - ctx.updater = false; - if (Fleur.XQueryEngine.updateQueue.length !== 0) { - setImmediate(Fleur.XQueryEngine.updateQueue.pop()); - } - } - ctx.env.varresolver = currvarres; - Fleur.callback(function() {callback(n);}); - }); - } - }); - } else { - xf(ctx, args, function(n) { - if (mainUpdater) { - Fleur.XQueryEngine.updating = false; - ctx.updater = false; - if (Fleur.XQueryEngine.updateQueue.length !== 0) { - setImmediate(Fleur.XQueryEngine.updateQueue.pop()); - } - } - Fleur.callback(function() {callback(n);}); - }); - } +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.dynamicFunctionInvocationExpr] = function(ctx, children, callback) { + Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { + if (n && n.schemaTypeInfo === Fleur.Type_error) { + Fleur.callback(function() {callback(n);}); + return; + } + if (n && n.nodeType === Fleur.Node.ENTRY_NODE) { + n = n.firstChild; + } + var args = children[children.length - 1][0] === Fleur.XQueryX.arguments ? children[children.length - 1][1] : []; + var preds = []; + children.forEach(function(child) { + if (child[0] === Fleur.XQueryX.predicates) { + child[1].forEach(function(subchild) {preds.push(subchild);}); + } else if (child[0] === Fleur.XQueryX.predicate) { + preds.push(child[1][0]); + } else if (child[0] === Fleur.XQueryX.lookup) { + preds.push(child); + } + }); + if (preds.length === 0) { + if (!n || n.nodeType !== Fleur.Node.FUNCTION_NODE) { + Fleur.callback(function() {callback(Fleur.error(ctx, "XPTY0004"));}); + return; + } + Fleur.functionCall(ctx, children, n, args, callback); + } else { + var next; + if (n.nodeType === Fleur.Node.SEQUENCE_NODE) { + next = new Fleur.Sequence(); + next.childNodes = new Fleur.NodeList(); + n.childNodes.forEach(function(node) { + next.appendChild(node); + }); + } else { + next = n; + } + Fleur.XQueryEngine[Fleur.XQueryX.predicates]({ + _next: next, + _item: ctx._item, + env: ctx.env + }, preds, function(n) { + if (n && n.nodeType === Fleur.Node.ENTRY_NODE) { + n = n.firstChild; + } + if (!n || n.nodeType !== Fleur.Node.FUNCTION_NODE) { + Fleur.callback(function() {callback(Fleur.error(ctx, "XPTY0004"));}); + return; + } + Fleur.functionCall(ctx, children, n, args, callback); + }); + } + }); +}; +/* + var mainUpdater = false; + var xf = n; + if (xf.updating && !ctx.updater) { + if (Fleur.XQueryEngine.updating) { + Fleur.XQueryEngine.updateQueue.push(function() { + Fleur.XQueryEngine[Fleur.XQueryX.functionCallExpr](ctx, children, callback); + }); + return; + } + Fleur.XQueryEngine.updating = true; + mainUpdater = true; + ctx.updater = true; + } + if (xf.jsfunc || xf.xqxfunc) { + var argscalc = function(xqxargs, effargs, f) { + if (xqxargs.length === 0) { + f(effargs); + } else { + var xqxarg = xqxargs.shift(); + Fleur.XQueryEngine[xqxarg[0]](ctx, xqxarg[1], function(n) { + if ((xf.argtypes && xf.argtypes[effargs.length].type === Fleur.Node) || (n && n.nodeType === Fleur.Node.SEQUENCE_NODE)) { + effargs.push(n); + } else if (xf.argtypes && xf.argtypes[effargs.length].type === Fleur.Type_handler) { + effargs.push(n.data); + } else { + var a = Fleur.Atomize(n); + effargs.push(a); + } + argscalc(xqxargs, effargs, f); + }); + } + }; + argscalc(args.slice(), [], function(effargs) { + var a = new Fleur.Text(); + a.schemaTypeInfo = xf.restype ? xf.restype.type : null; + a.data = ""; + if (xf.jsfunc) { + var jsargs = []; + try { + effargs.forEach(function(effarg, iarg) { + var op; + var carg = xf.argtypes ? xf.argtypes[iarg] : null; + if (carg.type === Fleur.Node) { + jsargs.push(effarg); + } else if (effarg === Fleur.EmptySequence) { + if (carg && (!carg.occurence || (carg.occurence !== "?" && carg.occurence !== "*"))) { + a.nodeType = Fleur.Node.TEXT_NODE; + a.schemaTypeInfo = Fleur.Type_error; + a._setNodeNameLocalNamePrefix("http://www.w3.org/2005/xqt-errors", "err:XPTY0004"); + throw new Error("error"); + } + jsargs.push(null); + } else if (effarg.nodeType === Fleur.Node.SEQUENCE_NODE) { + if (carg && (!carg.occurence || carg.occurence === "?")) { + a.nodeType = Fleur.Node.TEXT_NODE; + a.schemaTypeInfo = Fleur.Type_error; + a._setNodeNameLocalNamePrefix("http://www.w3.org/2005/xqt-errors", "err:XPTY0004"); + throw new Error("error"); + } + var subarr = []; + for (var iseq = 0, lseq = effarg.childNodes.length; iseq < lseq; iseq++) { + var effchild = effarg.childNodes[iseq]; + if ((!carg && Fleur.numericTypes.indexOf(effchild.schemaTypeInfo) !== -1) || (carg && (carg.type === Fleur.numericTypes || Fleur.numericTypes.indexOf(carg.type) !== -1))) { + op = Fleur.toJSNumber(effchild); + if (op[0] < 0) { + a = effchild; + throw new Error("error"); + } + subarr.push(op[1]); + } else if ((!carg && effchild.schemaTypeInfo === Fleur.Type_string) || (carg && carg.type === Fleur.Type_string)) { + op = Fleur.toJSString(effchild); + if (op[0] < 0) { + a = effchild; + throw new Error("error"); + } + subarr.push(op[1]); + } else if ((!carg && effchild.schemaTypeInfo === Fleur.Type_boolean) || (carg && carg.type === Fleur.Type_boolean)) { + op = Fleur.toJSBoolean(effchild); + if (op[0] < 0) { + a = effchild; + throw new Error("error"); + } + subarr.push(op[1]); + } else if (carg.type === Fleur.Type_dateTime) { + } else { + subarr.push(effchild); + } + } + jsargs.push(subarr); + } else if ((!carg && Fleur.numericTypes.indexOf(effarg.schemaTypeInfo) !== -1) || (carg && (carg.type === Fleur.numericTypes || Fleur.numericTypes.indexOf(carg.type) !== -1 || carg.type.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "integer", Fleur.TypeInfo.DERIVATION_RESTRICTION) || carg.type.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "decimal", Fleur.TypeInfo.DERIVATION_RESTRICTION) || carg.type.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "float", Fleur.TypeInfo.DERIVATION_RESTRICTION) || carg.type.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "double", Fleur.TypeInfo.DERIVATION_RESTRICTION)))) { + op = Fleur.toJSNumber(effarg); + if (op[0] < 0) { + a = effarg; + throw new Error("error"); + } + jsargs.push(op[1]); + } else if ((!carg && effarg.schemaTypeInfo === Fleur.Type_string) || (carg && (carg.type === Fleur.Type_string || carg.type.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "string", Fleur.TypeInfo.DERIVATION_RESTRICTION)))) { + op = Fleur.toJSString(effarg); + if (op[0] < 0) { + a = effarg; + throw new Error("error"); + } + jsargs.push(op[1]); + } else if ((!carg && effarg.schemaTypeInfo === Fleur.Type_boolean) || (carg && carg.type === Fleur.Type_boolean)) { + op = Fleur.toJSBoolean(effarg); + if (op[0] < 0) { + a = effarg; + throw new Error("error"); + } + jsargs.push(op[1]); + } else if ((!carg && effarg.schemaTypeInfo === Fleur.Type_dateTime) || (carg.type === Fleur.Type_dateTime)) { + op = Fleur.toJSDate(effarg); + if (op[0] < 0) { + a = effarg; + throw new Error("error"); + } + jsargs.push(op[1]); + } else { + jsargs.push(effarg); + } + }); + } catch (e) { + Fleur.callback(function() {callback(a);}); + return; + } + if (xf.needctx) { + jsargs.push(ctx); + } + var convback = function(vret) { + if (mainUpdater) { + Fleur.XQueryEngine.updating = false; + ctx.updater = false; + if (Fleur.XQueryEngine.updateQueue.length !== 0) { + setImmediate(Fleur.XQueryEngine.updateQueue.pop()); + } + } + var convret = function(v) { + if (v === undefined || v === null) { + a = Fleur.EmptySequence; + } else if (v === Number.POSITIVE_INFINITY) { + a.data = "INF"; + if (!a.schemaTypeInfo) { + a.schemaTypeInfo = Fleur.Type_double; + } + } else if (v === Number.NEGATIVE_INFINITY) { + a.data = "-INF"; + if (!a.schemaTypeInfo) { + a.schemaTypeInfo = Fleur.Type_double; + } + } else if (typeof v === "number" || typeof v === "boolean") { + a.data = String(v); + if (!a.schemaTypeInfo) { + a.schemaTypeInfo = typeof v === "number" ? Fleur.Type_double : Fleur.Type_boolean; + } + } else if (typeof v === "string") { + a.data = v; + if (!a.schemaTypeInfo) { + a.schemaTypeInfo = Fleur.Type_string; + } + } else if (typeof v.getMonth === "function") { + var o = vret.getTimezoneOffset(); + if (!a.schemaTypeInfo) { + a.schemaTypeInfo = Fleur.Type_datetime; + } + if (a.schemaTypeInfo === Fleur.Type_date) { + a.data = ("000" + v.getFullYear()).slice(-4) + "-" + ("0" + (v.getMonth() + 1)).slice(-2) + "-" + ("0" + v.getDate()).slice(-2) + (o < 0 ? "+" : "-") + ("0" + Math.floor(Math.abs(o)/60)).slice(-2) + ":" + ("0" + Math.floor(Math.abs(o) % 60)).slice(-2); + } else if (a.schemaTypeInfo === Fleur.Type_time) { + a.data = ("0" + v.getHours()).slice(-2) + ":" + ("0" + v.getMinutes()).slice(-2) + ":" + ("0" + v.getSeconds()).slice(-2) + "." + ("00" + v.getMilliseconds()).slice(-3) + (o < 0 ? "+" : "-") + ("0" + Math.floor(Math.abs(o)/60)).slice(-2) + ":" + ("0" + Math.floor(Math.abs(o) % 60)).slice(-2); + } else { + a.data = ("000" + v.getFullYear()).slice(-4) + "-" + ("0" + (v.getMonth() + 1)).slice(-2) + "-" + ("0" + v.getDate()).slice(-2) + "T" + ("0" + v.getHours()).slice(-2) + ":" + ("0" + v.getMinutes()).slice(-2) + ":" + ("0" + v.getSeconds()).slice(-2) + "." + ("00" + v.getMilliseconds()).slice(-3) + (o < 0 ? "+" : "-") + ("0" + Math.floor(Math.abs(o)/60)).slice(-2) + ":" + ("0" + Math.floor(Math.abs(o) % 60)).slice(-2); + } + } else if (v instanceof Error) { + a.nodeType = Fleur.Node.TEXT_NODE; + a.schemaTypeInfo = Fleur.Type_error; + a._setNodeNameLocalNamePrefix("http://www.w3.org/2005/xqt-errors", "err:XPTY"); + } else if (v instanceof Fleur.Node || (Node && v instanceof Node)) { + a = v; + } else { + a.data = v; + if (!a.schemaTypeInfo) { + a.schemaTypeInfo = Fleur.Type_handler; + } + } + }; + if (vret instanceof Array) { + var seq = new Fleur.Sequence(); + vret.forEach(function(v) { + a = new Fleur.Text(); + a.schemaTypeInfo = xf.restype ? xf.restype.type : null; + a.data = ""; + convret(v); + seq.appendChild(a); + }); + Fleur.callback(function() {callback(seq);}); + } else { + convret(vret); + Fleur.callback(function() {callback(a);}); + } + }; + if (xf.needcallback) { + jsargs.push(convback); + xf.jsfunc.apply(null, jsargs); + return; + } + convback(xf.jsfunc.apply(null, jsargs)); + } else { + var currvarres = ctx.env.varresolver; + ctx.env.varresolver = new Fleur.varMgr([], xf.closurevarresolver || ctx.env.globalvarresolver); + effargs.forEach(function(effarg, iarg) { + ctx.env.varresolver.set(ctx, "", xf.argtypes[iarg].name, effarg); + }); + Fleur.XQueryEngine[xf.xqxfunc[0]](ctx, xf.xqxfunc[1], function(n) { + if (mainUpdater) { + Fleur.XQueryEngine.updating = false; + ctx.updater = false; + if (Fleur.XQueryEngine.updateQueue.length !== 0) { + setImmediate(Fleur.XQueryEngine.updateQueue.pop()); + } + } + ctx.env.varresolver = currvarres; + Fleur.callback(function() {callback(n);}); + }); + } + }); + } else { + xf(ctx, args, function(n) { + if (mainUpdater) { + Fleur.XQueryEngine.updating = false; + ctx.updater = false; + if (Fleur.XQueryEngine.updateQueue.length !== 0) { + setImmediate(Fleur.XQueryEngine.updateQueue.pop()); + } + } + Fleur.callback(function() {callback(n);}); + }); + } */ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/elementConstructor.js b/src/js/fleur.js/XQuery/Instructions/elementConstructor.js index e9b795d..5114ff1 100644 --- a/src/js/fleur.js/XQuery/Instructions/elementConstructor.js +++ b/src/js/fleur.js/XQuery/Instructions/elementConstructor.js @@ -1,11 +1,11 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.Transpiler.prototype.xqx_elementConstructor = function(children) { +Fleur.Transpiler.prototype.xqx_elementConstructor = function(children, expectedSequenceType) { let r = ""; const prefix = children[0][1].length === 2 ? children[0][1][1][1][0] : ""; let l = 0; @@ -18,13 +18,14 @@ Fleur.Transpiler.prototype.xqx_elementConstructor = function(children) { l += children[2][1].length; } } - r += this.inst("xqx_elementConstructor('" + prefix + "', '" + children[0][1][0] + "', " + String(l) + ")").inst; + r += this.inst("xqx_elementConstructor('" + prefix + "', '" + children[0][1][0] + "', " + String(l) + ")", false, expectedSequenceType, "", expectedSequenceType).inst; if (children.length > 1) { const transp = this; r += children[1][1].reduce((inst, child) => inst + (child[0] === Fleur.XQueryX.namespaceDeclaration ? transp.inst("xqx_namespaceRemoval('" + (child[1].length === 2 ? child[1][0][1][0] : "") + "')").inst : ""), ""); } return { - inst: r + inst: r, + sequenceType: expectedSequenceType || Fleur.SequenceType_element_1 }; }; @@ -51,7 +52,7 @@ Fleur.Context.prototype.xqx_elementConstructor = function(prefix, localName, cou this.item = elt; return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.elementConstructor] = function(ctx, children, callback) { var elt = new Fleur.Element(); elt.internal_id = String(Fleur.Document_index++); @@ -85,4 +86,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.elementConstructor] = function(ctx, children, c elt.namespaceURI = ctx.env.nsresolver.lookupNamespaceURI(elt.prefix); Fleur.callback(function() {callback(elt);}); } -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/elementContent.js b/src/js/fleur.js/XQuery/Instructions/elementContent-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/elementContent.js rename to src/js/fleur.js/XQuery/Instructions/elementContent-BROKEN.js index f938352..b7663a0 100644 --- a/src/js/fleur.js/XQuery/Instructions/elementContent.js +++ b/src/js/fleur.js/XQuery/Instructions/elementContent-BROKEN.js @@ -1,28 +1,28 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.elementContent] = function(ctx, children, callback, elt) { - Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], function(n) { - if (n.schemaTypeInfo === Fleur.Type_error) { - Fleur.callback(function() {callback(n);}); - } else { - if (!n.namespaceURI) { - n.namespaceURI = ctx.env.nsresolver.lookupNamespaceURI(n.prefix); - } - elt.appendContent(n, ""); - if (children.length > 1) { - Fleur.XQueryEngine[Fleur.XQueryX.elementContent](ctx, children.slice(1), function(n) { - Fleur.callback(function() {callback(n);}); - }, elt); - } else { - Fleur.callback(function() {callback(elt);}); - } - } - }); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.elementContent] = function(ctx, children, callback, elt) { + Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], function(n) { + if (n.schemaTypeInfo === Fleur.Type_error) { + Fleur.callback(function() {callback(n);}); + } else { + if (!n.namespaceURI) { + n.namespaceURI = ctx.env.nsresolver.lookupNamespaceURI(n.prefix); + } + elt.appendContent(n, ""); + if (children.length > 1) { + Fleur.XQueryEngine[Fleur.XQueryX.elementContent](ctx, children.slice(1), function(n) { + Fleur.callback(function() {callback(n);}); + }, elt); + } else { + Fleur.callback(function() {callback(elt);}); + } + } + }); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/elementTest.js b/src/js/fleur.js/XQuery/Instructions/elementTest-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/elementTest.js rename to src/js/fleur.js/XQuery/Instructions/elementTest-BROKEN.js index 6dea4ab..ba0737a 100644 --- a/src/js/fleur.js/XQuery/Instructions/elementTest.js +++ b/src/js/fleur.js/XQuery/Instructions/elementTest-BROKEN.js @@ -1,12 +1,12 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.elementTest] = function(ctx, children, callback) { - Fleur.callback(function() {callback(ctx._curr.nodeType !== Fleur.Node.ELEMENT_NODE ? Fleur.EmptySequence : ctx._curr);}); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.elementTest] = function(ctx, children, callback) { + Fleur.callback(function() {callback(ctx._curr.nodeType !== Fleur.Node.ELEMENT_NODE ? Fleur.EmptySequence : ctx._curr);}); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/encoding.js b/src/js/fleur.js/XQuery/Instructions/encoding.js index 2a095d3..170fca2 100644 --- a/src/js/fleur.js/XQuery/Instructions/encoding.js +++ b/src/js/fleur.js/XQuery/Instructions/encoding.js @@ -1,11 +1,17 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ +Fleur.Transpiler.prototype.xqx_encoding = function() { + return { + inst: "", + sequenceType: Fleur.SequenceType_empty_sequence + }; +}; +/* Fleur.XQueryEngine[Fleur.XQueryX.encoding] = function(ctx, children) { -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/entryTest.js b/src/js/fleur.js/XQuery/Instructions/entryTest.js index 8dae47c..6688f11 100644 --- a/src/js/fleur.js/XQuery/Instructions/entryTest.js +++ b/src/js/fleur.js/XQuery/Instructions/entryTest.js @@ -1,8 +1,7 @@ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ diff --git a/src/js/fleur.js/XQuery/Instructions/filterExpr.js b/src/js/fleur.js/XQuery/Instructions/filterExpr.js index 64d6ff0..20b52e3 100644 --- a/src/js/fleur.js/XQuery/Instructions/filterExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/filterExpr.js @@ -1,8 +1,7 @@ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ diff --git a/src/js/fleur.js/XQuery/Instructions/flworExpr.js b/src/js/fleur.js/XQuery/Instructions/flworExpr.js index 7453b43..a583a2e 100644 --- a/src/js/fleur.js/XQuery/Instructions/flworExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/flworExpr.js @@ -1,7 +1,7 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ @@ -35,6 +35,11 @@ Fleur.Transpiler.prototype.xqx_flworExpr = function(children, expectedType) { }; }; +Fleur.Context.prototype.xqx_flworExpr = function() { + this.tuplestack.push(this.tuple); + this.tuple = [new Fleur.varMgr([], this.rs.varresolver)]; + return this; +}; /* Fleur.Transpiler.prototype.xqx_flworExpr_old = function(children, expectedType) { const previndent = this.indent; @@ -66,13 +71,6 @@ Fleur.Transpiler.prototype.xqx_flworExpr_old = function(children, expectedType) sequenceType: returnSequenceType }; }; -*/ - -Fleur.Context.prototype.xqx_flworExpr = function() { - this.tuplestack.push(this.tuple); - this.tuple = [new Fleur.varMgr([], this.rs.varresolver)]; - return this; -}; Fleur.XQueryEngine[Fleur.XQueryX.flworExpr] = function(ctx, children, callback) { //console.log("flworExpr"); diff --git a/src/js/fleur.js/XQuery/Instructions/forClause.js b/src/js/fleur.js/XQuery/Instructions/forClause.js index bc45a48..179c607 100644 --- a/src/js/fleur.js/XQuery/Instructions/forClause.js +++ b/src/js/fleur.js/XQuery/Instructions/forClause.js @@ -1,7 +1,7 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ diff --git a/src/js/fleur.js/XQuery/Instructions/forClauseItem.js b/src/js/fleur.js/XQuery/Instructions/forClauseItem.js index a62557c..fa3cb7d 100644 --- a/src/js/fleur.js/XQuery/Instructions/forClauseItem.js +++ b/src/js/fleur.js/XQuery/Instructions/forClauseItem.js @@ -1,7 +1,7 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ @@ -10,14 +10,42 @@ Fleur.Transpiler.prototype.xqx_forClauseItem = function(children) { this.indent += this.step; const gen = this.funcdef(children[1][1][0]); this.indent = previndent; - let result = "\n" + previndent + (this.async ? "await " : "") + this.ctxvarname + ".xqx_forClauseItem" + (this.async ? "_async" : "") + "('" + (children[0][1][0][1][0][1].length === 2 ? children[0][1][0][1][0][1][1][1][0] : "") + "', '" + children[0][1][0][1][0][1][0] + "',"; + const vname = children[0][1][0][1][0][1][0]; + const namespaceURI = this.rs.nsresolver.lookupNamespaceURI((children[0][1][0][1][0][1].length === 2 ? children[0][1][0][1][0][1][1][1][0] : "")) || ""; + const allowingEmpty = children[1][0] === Fleur.XQueryX.allowingEmpty ? 1 : 0; + const positionalVariableBinding = children[1 + allowingEmpty][0] === Fleur.XQueryX.positionalVariableBinding ? 1 : 0; + const pvname = positionalVariableBinding !== 0 ? children[1 + allowingEmpty][1][0] : null; + const pnamespaceURI = pvname ? this.rs.nsresolver.lookupNamespaceURI((children[1 + allowingEmpty][1].length === 2 ? children[1 + allowingEmpty][1][1][1][0] : "")) || "" : null; + let result = "\n" + previndent + (this.async ? "await " : "") + this.ctxvarname + ".xqx_forClauseItem" + (this.async ? "_async" : "") + "('" + namespaceURI + "', '" + vname + "', " + String(allowingEmpty === 1) + ", " + (pnamespaceURI ? "'" + pnamespaceURI + "'" : "null") + ", " + (pvname ? "'" + pvname + "'" : "null") + ","; result += gen.inst; result += "\n" + previndent + ");"; + this.rs.varresolver.set(null, namespaceURI, vname, new Fleur.SequenceType(gen.sequenceType.nodeType, gen.sequenceType.schemaTypeInfo, allowingEmpty ? "?" : "1")); return { inst: result }; }; +Fleur.Context.prototype.xqx_forClauseItem = function(namespaceURI, vname, allowingEmpty, pnamespaceURI, pvname, fn) { + const newtuple = []; + this.tuple.forEach(vr => { + this.rs.varresolver = vr; + fn(this); + if (this.item.isSingle() || (allowingEmpty && this.item.isEmpty())) { + vr.set(null, namespaceURI, vname, this.item); + newtuple.push(vr); + } else { + this.item.childNodes.forEach(foritem => { + const forvr = vr.clone(); + forvr.set(null, namespaceURI, vname, foritem); + newtuple.push(forvr); + }); + } + }); + this.tuple = newtuple; + return this; +}; + +/* Fleur.XQueryEngine[Fleur.XQueryX.forClauseItem] = function(ctx, children, callback, resarr) { //console.log("forClauseItem"); var i = 0; diff --git a/src/js/fleur.js/XQuery/Instructions/functionCallExpr.js b/src/js/fleur.js/XQuery/Instructions/functionCallExpr.js index 31e740d..639f4d1 100644 --- a/src/js/fleur.js/XQuery/Instructions/functionCallExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/functionCallExpr.js @@ -1,14 +1,14 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.XQueryEngine.updating = false; Fleur.XQueryEngine.updateQueue = []; -Fleur.Transpiler.prototype.xqx_functionCallExpr = function(children, expectedType) { +Fleur.Transpiler.prototype.xqx_functionCallExpr = function(children, expectedSequenceType) { var pf2 = "fn"; var args = children[1][1]; if (children[0][1][1] && children[0][1][1][0] === Fleur.XQueryX.prefix) { @@ -20,55 +20,56 @@ Fleur.Transpiler.prototype.xqx_functionCallExpr = function(children, expectedTyp } else { pf2 = pf; } - } else if (" boolean-from-string is-card-number count-non-empty index power random if choose property digest hmac local-date local-dateTime now days-from-date days-to-date seconds-from-dateTime seconds-to-dateTime adjust-dateTime-to-timezone seconds months instance instance-ids current context event nodeindex is-valid serialize transform js-eval ".indexOf(" " + children[0][1][0] + " ") !== -1) { + } else if (" boolean-from-string is-card-number count-non-empty index power random if choose property digest hmac local-date local-dateTime now days-from-date days-to-date seconds-from-dateTime seconds-to-dateTime adjust-dateTime-to-timezone seconds months instance instance-ids current context event nodeindex is-valid transform js-eval ".indexOf(" " + children[0][1][0] + " ") !== -1) { pf2 = "xf"; } - const shortname = children[0][1][0].replace(/-/g, "$_"); + const xname = children[0][1][0]; + const shortname = xname.replace(/-/g, "$_"); let fname = pf2 + "_" + shortname; if (fname !== "fn_concat") { fname += "_" + String(args.length); } - const libfunc = Fleur.signatures[fname]; - const fasync = libfunc ? libfunc.is_async : false; + const ns = Fleur.defaultNS.uri[Fleur.defaultNS.pf.lastIndexOf(pf2)]; + const libfunc = Fleur.XPathFunctions[ns][xname + "#" + (fname !== "fn_concat" ? String(args.length) : "")]; + const fasync = libfunc ? libfunc.isasync : false; if (!this.async) { this.async = fasync; } - const returnType = libfunc ? libfunc.return_type : { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }; - const untyped = returnType && returnType.schemaTypeInfo === Fleur.Type_untypedAtomic; + const returnSequenceType = libfunc ? libfunc.rettype : Fleur.SequenceType_string_01; + const untyped = returnSequenceType && returnSequenceType.schemaTypeInfo === Fleur.Type_untypedAtomic; if (untyped) { - returnType.schemaTypeInfo = expectedType.schemaTypeInfo; + returnSequenceType.schemaTypeInfo = expectedSequenceType.schemaTypeInfo; } let params = ""; - const paramstype = libfunc ? libfunc.params_type : null; + const paramstype = libfunc ? libfunc.argtypes : null; + let staticvalues = true; + let paramgens = []; for (let i = 0, l = args.length; i < l; i++) { - const expectedParamType = libfunc && fname !== "fn_concat" ? paramstype[i] : { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }; + const expectedParamType = libfunc && fname !== "fn_concat" ? paramstype[i] : Fleur.SequenceType_anyAtomicType_01; const paramgen = this.gen(args[i], expectedParamType); - if (libfunc && expectedParamType) { -// if (paramgen.sequenceType.schemaTypeInfo === Fleur.Type_untypedAtomic) { -// paramgen.inst += this.inst(expectedParamType.schemaTypeInfo.constructorName + "()").inst; -// paramgen.sequenceType.schemaTypeInfo = expectedParamType.schemaTypeInfo; + staticvalues = staticvalues && paramgen.value; + paramgens.push(paramgen); +// if (libfunc && expectedParamType) { +//// if (paramgen.sequenceType.schemaTypeInfo === Fleur.Type_untypedAtomic) { +//// paramgen.inst += this.inst(expectedParamType.schemaTypeInfo.constructorName + "()").inst; +//// paramgen.sequenceType.schemaTypeInfo = expectedParamType.schemaTypeInfo; +//// } +// if ((paramgen.sequenceType.occurrence === "0" && (expectedParamType.occurrence === "1" || expectedParamType.occurrence === "+")) || (paramgen.sequenceType.schemaTypeInfo && expectedParamType.schemaTypeInfo && !paramgen.sequenceType.schemaTypeInfo.as(expectedParamType.schemaTypeInfo))) { +// Fleur.XQueryError_xqt("XPST0017", null, "Invalid type"); // } - if ((paramgen.sequenceType.occurrence === "0" && (expectedParamType.occurrence === "1" || expectedParamType.occurrence === "+")) || (paramgen.sequenceType.schemaTypeInfo && expectedParamType.schemaTypeInfo && !paramgen.sequenceType.schemaTypeInfo.as(expectedParamType.schemaTypeInfo))) { - Fleur.XQueryError_xqt("XPST0017", null, "Invalid type"); - } - } +// } params += paramgen.inst; } + if (staticvalues && libfunc && !libfunc.dynonly) { + return this.staticargs(paramgens)[fname](fname === "fn_concat" || !libfunc ? args.length : null).staticinst(this); + } if (!libfunc && typeof window[shortname] !== "function") { Fleur.XQueryError_xqt("XPST0017", null, "Unknown Javascript function", "", new Fleur.Text(shortname)); } return { - inst: params + this.inst((libfunc ? fname : "xqx_functionCallExpr") + (fasync ? "_async" : "") + "(" + (libfunc ? "" : shortname + ", ") + (fname === "fn_concat" || !libfunc ? String(args.length) : "") + ")", fasync, libfunc ? expectedType : null).inst + (untyped ? this.inst(returnType.schemaTypeInfo.constructorName + "()").inst : ""), - sequenceType: returnType + inst: params + this.inst((libfunc ? fname : "xqx_functionCallExpr") + "(" + (libfunc ? "" : shortname + ", ") + (fname === "fn_concat" || !libfunc ? String(args.length) : "") + ")", fasync, expectedSequenceType).inst + (returnSequenceType.nodeType === Fleur.Node.ANY_NODE && expectedSequenceType.nodeType !== Fleur.Node.ANY_NODE ? this.inst("fn_data_1()").inst: "") + (untyped ? this.inst(returnSequenceType.schemaTypeInfo.constructorName + "()").inst : ""), + sequenceType: expectedSequenceType || returnSequenceType }; }; @@ -87,7 +88,7 @@ Fleur.Context.prototype.xqx_functionCallExpr = function(shortname, arglen) { this.item.data = String(shortname.apply(null, args)); return this; }; - +/* Fleur.functionCall = function(ctx, children, xf, args, callback) { var mainUpdater = false; if (xf.updating && !ctx.updater) { @@ -408,4 +409,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.functionCallExpr] = function(ctx, children, cal } } Fleur.functionCall(ctx, children, xf, args, callback); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/functionDecl.js b/src/js/fleur.js/XQuery/Instructions/functionDecl.js index c1f3a88..e641e56 100644 --- a/src/js/fleur.js/XQuery/Instructions/functionDecl.js +++ b/src/js/fleur.js/XQuery/Instructions/functionDecl.js @@ -1,12 +1,127 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ +Fleur.Transpiler.prototype.xqx_functionDecl = function(children) { + let r = ""; + let fstype = Fleur.SequenceType_item_0n; + let sfstype = "SequenceType_item_0n"; + const updating = children[0][0] === Fleur.XQueryX.updatingFunction; + const init = updating ? 1 : 0; + const fname = children[init][1][0]; + let uri = this.rs.nsresolver.lookupNamespaceURI(" function"); + let prefix = null; + if (children[init][1][1]) { + if (children[init][1][1][0] === Fleur.XQueryX.URI) { + uri = children[init][1][1][1][0]; + } else if (children[init][1][1][0] === Fleur.XQueryX.prefix) { + prefix = children[init][1][1][1][0]; + uri = this.rs.nsresolver.lookupNamespaceURI(prefix); + } + } + const nsr = this.rs.nsresolver; + const args = children[init + 1][1].map(function(arg) { + const o = {name: arg[1][0][1][0]}; + if (arg[1][0][1].length === 1) { + o.uri = ""; + } else { + //o.uri = nsr.lookupNamespaceURI(tprefix); + } + if (arg[1].length === 1) { + o.sequenceType = "SequenceType_item_0n"; + } else { + let tprefix = null, turi; + const atype = arg[1][1][1][0][1]; + const tname = atype[0]; + if (atype[1]) { + if (atype[1][0] === Fleur.XQueryX.URI) { + turi = atype[1][1][0]; + } else if (atype[1][0] === Fleur.XQueryX.prefix) { + tprefix = atype[1][1][0]; + turi = nsr.lookupNamespaceURI(tprefix); + } + } + const occ = arg[1][1][1].length === 2 ? arg[1][1][1][1][1][0] : ""; + o.sequenceType = "SequenceType_" + tname + "_" + ( + occ === "" ? "1" : + occ === "?" ? "01" : + occ === "+" ? "1n" : "0n" + ); + } + return o; + }); + let fbody; + if (children[init + 2][0] === Fleur.XQueryX.typeDeclaration) { + const fret = children[init + 2]; + const atype = fret[1][0][1]; + const tname = atype[0]; + let turi = ""; + let tprefix = ""; + if (atype[1]) { + if (atype[1][0] === Fleur.XQueryX.URI) { + turi = atype[1][1][0]; + } else if (atype[1][0] === Fleur.XQueryX.prefix) { + tprefix = atype[1][1][0]; + turi = nsr.lookupNamespaceURI(tprefix); + } + } + const occ = fret[1].length === 2 ? fret[1][1][1][0] : ""; + sfstype = "SequenceType_" + tname + "_" + ( + occ === "" ? "1" : + occ === "?" ? "01" : + occ === "+" ? "1n" : "0n" + ); + fbody = children[init + 3][0] === Fleur.XQueryX.functionBody ? children[init + 3][1][0] : null; + } else { + fbody = children[init + 2][0] === Fleur.XQueryX.functionBody ? children[init + 2][1][0] : null; + } + if (!Fleur.XPathFunctions[uri]) { + Fleur.XPathFunctions[uri] = {}; + } + Fleur.XPathFunctions[uri][fname + "#" + String(args.length)] = new Fleur.Function(uri, prefix ? prefix + ":" + fname : fname, null, [], Fleur[sfstype], {dynonly: true}); + r += "\n" + this.indent + this.ctxvarname + ".xqx_functionDecl('" + uri + "', '" + fname + "', [" + args.reduce((s, a) => s + (s === "" ? "" : ", ") + this.ctxvarname + ".engine." + a.sequenceType, "") + "], " + this.ctxvarname + ".engine." + sfstype + ", function() {"; + const previndent = this.indent; + const prevctxvarname = this.ctxvarname; + this.indent += this.step; + this.ctxvarname = "this"; + if (args.length !== 0) { + this.rs.varresolver = new Fleur.varMgr([], this.rs.varresolver); + const vr = this.rs.varresolver; + args.forEach(a => vr.set(null, a.uri, a.name, Fleur[a.sequenceType])); + r += this.inst("xqx_paramList()").inst; + const sol = "\n" + this.indent + this.ctxvarname + ".xqx_param('"; + r += args.reverse().reduce((s, a) => s + sol + a.uri + "', '" + a.name + "');", ""); + } + if (fbody) { + r += this.gen(fbody).inst; + } + if (args.length !== 0) { + this.rs.varresolver = this.rs.varresolver.previous; + r += this.inst("xqx_paramList_drop()").inst; + } + r += "\n" + this.indent + "return " + this.ctxvarname + ";"; + this.indent = previndent; + this.ctxvarname = prevctxvarname; + r += "\n" + this.indent + "});"; + return { + inst: r, + sequenceType: Fleur.SequenceType_empty_sequence + }; +}; + +Fleur.Context.prototype.xqx_functionDecl = function(namespaceURI, fname, args, typedecl, f) { + const prefix = this.rs.nsresolver.lookupPrefix(namespaceURI); + if (!Fleur.XPathFunctions[namespaceURI]) { + Fleur.XPathFunctions[namespaceURI] = {}; + } + Fleur.XPathFunctions[namespaceURI][fname + "#" + String(args.length)] = new Fleur.Function(namespaceURI, prefix ? prefix + ":" + fname : fname, f, args, typedecl, {dynonly: true}); + Fleur.Context.prototype[(prefix ? prefix + "_" : "") + fname.replace(/-/g, "$_") + "_" + String(args.length)] = f; + return this; +}; +/* Fleur.XQueryEngine[Fleur.XQueryX.functionDecl] = function(ctx, children, callback) { var updating = children[0][0] === Fleur.XQueryX.updatingFunction; var init = updating ? 1 : 0; @@ -58,4 +173,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.functionDecl] = function(ctx, children, callbac } Fleur.XPathFunctions[uri][fname + "#" + String(args.length)] = new Fleur.Function(uri, prefix ? prefix + ":" + fname : fname, null, fbody, args, false, false, fret, updating); Fleur.callback(function() {callback();}); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/groupByClause.js b/src/js/fleur.js/XQuery/Instructions/groupByClause-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/groupByClause.js rename to src/js/fleur.js/XQuery/Instructions/groupByClause-BROKEN.js index 4a9db98..09cf4ed 100644 --- a/src/js/fleur.js/XQuery/Instructions/groupByClause.js +++ b/src/js/fleur.js/XQuery/Instructions/groupByClause-BROKEN.js @@ -1,74 +1,74 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.groupByClause] = function(ctx, children, callback, resarr, groupkeynames) { - //console.log("groupByClause "); - groupkeynames = groupkeynames || []; - Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], function(n) { - if (n && n.schemaTypeInfo === Fleur.Type_error) { - Fleur.callback(function() {callback(n);}); - return; - } - if (children.length <= 1) { - var aggregnames = []; - resarr[0].vars.forEach(function(v) {if (groupkeynames.indexOf(v.vname) === -1) aggregnames.push(v.vname);}); - var kgroups = []; - var ogroups = resarr.reduce(function(o, vmgr) { - var okey = groupkeynames.reduce(function(k, gkname) { - var v = vmgr.get(ctx, "", gkname); - var jsv = Fleur.toJSValue(v, v.schemaTypeInfo !== Fleur.Type_untypedAtomic, true, true, true); - if (jsv[0] < 3) { - jsv[0] = 3; - } - if (jsv[0] === 6 || jsv[0] === 7) { - jsv[0] = 8; - } - jsv[1] = String(jsv[1]); - return k + String(jsv[0]) + "." + String(jsv[1].length) + "." + jsv[1] + "|"; - }, ""); - if (o[okey]) { - aggregnames.forEach(function(aname) { - var avalue = vmgr.get(ctx, "", aname); - if (avalue !== Fleur.EmptySequence) { - var ovalue = o[okey].get(ctx, "", aname); - if (ovalue === Fleur.EmptySequence) { - o[okey].set(ctx, "", aname, avalue); - } else { - if (ovalue.nodeType !== Fleur.Node.SEQUENCE_NODE) { - var seq = new Fleur.Sequence(); - seq.appendChild(ovalue); - ovalue = seq; - } - if (avalue.nodeType !== Fleur.Node.SEQUENCE_NODE) { - ovalue.appendChild(avalue); - } else { - avalue.childNodes.forEach(function(av) { - ovalue.appendChild(av); - }); - } - o[okey].set(ctx, "", aname, ovalue); - } - } - }); - } else { - kgroups.push(okey); - o[okey] = vmgr; - } - return o; - }, {}); - kgroups.forEach(function(k, i) { - resarr[i] = ogroups[k]; - }); - resarr.splice(kgroups.length); - Fleur.callback(function() {callback(n);}); - return; - } - Fleur.XQueryEngine[Fleur.XQueryX.groupByClause](ctx, children.slice(1), callback, resarr, groupkeynames); - }, resarr, groupkeynames); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.groupByClause] = function(ctx, children, callback, resarr, groupkeynames) { + //console.log("groupByClause "); + groupkeynames = groupkeynames || []; + Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], function(n) { + if (n && n.schemaTypeInfo === Fleur.Type_error) { + Fleur.callback(function() {callback(n);}); + return; + } + if (children.length <= 1) { + var aggregnames = []; + resarr[0].vars.forEach(function(v) {if (groupkeynames.indexOf(v.vname) === -1) aggregnames.push(v.vname);}); + var kgroups = []; + var ogroups = resarr.reduce(function(o, vmgr) { + var okey = groupkeynames.reduce(function(k, gkname) { + var v = vmgr.get(ctx, "", gkname); + var jsv = Fleur.toJSValue(v, v.schemaTypeInfo !== Fleur.Type_untypedAtomic, true, true, true); + if (jsv[0] < 3) { + jsv[0] = 3; + } + if (jsv[0] === 6 || jsv[0] === 7) { + jsv[0] = 8; + } + jsv[1] = String(jsv[1]); + return k + String(jsv[0]) + "." + String(jsv[1].length) + "." + jsv[1] + "|"; + }, ""); + if (o[okey]) { + aggregnames.forEach(function(aname) { + var avalue = vmgr.get(ctx, "", aname); + if (avalue !== Fleur.EmptySequence) { + var ovalue = o[okey].get(ctx, "", aname); + if (ovalue === Fleur.EmptySequence) { + o[okey].set(ctx, "", aname, avalue); + } else { + if (ovalue.nodeType !== Fleur.Node.SEQUENCE_NODE) { + var seq = new Fleur.Sequence(); + seq.appendChild(ovalue); + ovalue = seq; + } + if (avalue.nodeType !== Fleur.Node.SEQUENCE_NODE) { + ovalue.appendChild(avalue); + } else { + avalue.childNodes.forEach(function(av) { + ovalue.appendChild(av); + }); + } + o[okey].set(ctx, "", aname, ovalue); + } + } + }); + } else { + kgroups.push(okey); + o[okey] = vmgr; + } + return o; + }, {}); + kgroups.forEach(function(k, i) { + resarr[i] = ogroups[k]; + }); + resarr.splice(kgroups.length); + Fleur.callback(function() {callback(n);}); + return; + } + Fleur.XQueryEngine[Fleur.XQueryX.groupByClause](ctx, children.slice(1), callback, resarr, groupkeynames); + }, resarr, groupkeynames); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/groupingSpec.js b/src/js/fleur.js/XQuery/Instructions/groupingSpec-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/groupingSpec.js rename to src/js/fleur.js/XQuery/Instructions/groupingSpec-BROKEN.js index b464ad2..a6d0e4e 100644 --- a/src/js/fleur.js/XQuery/Instructions/groupingSpec.js +++ b/src/js/fleur.js/XQuery/Instructions/groupingSpec-BROKEN.js @@ -1,39 +1,39 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.groupingSpec] = function(ctx, children, callback, resarr, groupkeynames) { - //console.log("groupingSpec"); - var varname = children[0][1][0]; - groupkeynames.push(varname); - var i = 0; - var cb = function(n) { - if (n.nodeType === Fleur.Node.SEQUENCE_NODE && n !== Fleur.EmptySequence) { - Fleur.callback(function() {callback(Fleur.error(ctx, "XPTY0004"));}); - } - var a = Fleur.Atomize(n); - resarr[i].set(ctx, "", varname, a); - i++; - if (i !== resarr.length) { - if (children.length === 1) { - cb(resarr[i].get(ctx, "", varname)); - } else { - ctx.env.varresolver = resarr[i]; - Fleur.XQueryEngine[children[1][1][0][1][0][0]](ctx, children[1][1][0][1][0][1], cb); - } - } else { - Fleur.callback(function() {callback(Fleur.EmptySequence);}); - } - }; - if (children.length === 1) { - cb(resarr[i].get(ctx, "", varname)); - } else { - ctx.env.varresolver = resarr[0]; - Fleur.XQueryEngine[children[1][1][0][1][0][0]](ctx, children[1][1][0][1][0][1], cb); - } +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.groupingSpec] = function(ctx, children, callback, resarr, groupkeynames) { + //console.log("groupingSpec"); + var varname = children[0][1][0]; + groupkeynames.push(varname); + var i = 0; + var cb = function(n) { + if (n.nodeType === Fleur.Node.SEQUENCE_NODE && n !== Fleur.EmptySequence) { + Fleur.callback(function() {callback(Fleur.error(ctx, "XPTY0004"));}); + } + var a = Fleur.Atomize(n); + resarr[i].set(ctx, "", varname, a); + i++; + if (i !== resarr.length) { + if (children.length === 1) { + cb(resarr[i].get(ctx, "", varname)); + } else { + ctx.env.varresolver = resarr[i]; + Fleur.XQueryEngine[children[1][1][0][1][0][0]](ctx, children[1][1][0][1][0][1], cb); + } + } else { + Fleur.callback(function() {callback(Fleur.EmptySequence);}); + } + }; + if (children.length === 1) { + cb(resarr[i].get(ctx, "", varname)); + } else { + ctx.env.varresolver = resarr[0]; + Fleur.XQueryEngine[children[1][1][0][1][0][0]](ctx, children[1][1][0][1][0][1], cb); + } }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/ifThenElseExpr.js b/src/js/fleur.js/XQuery/Instructions/ifThenElseExpr.js index fac14e2..85229ba 100644 --- a/src/js/fleur.js/XQuery/Instructions/ifThenElseExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/ifThenElseExpr.js @@ -1,34 +1,28 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.Transpiler.prototype.xqx_ifThenElseExpr = function(children, expectedType) { +Fleur.Transpiler.prototype.xqx_ifThenElseExpr = function(children, expectedSequenceType) { let result = this.gen(children[0][1][0]).inst + "\n" + this.indent + "if (" + this.ctxvarname + ".fn_boolean_1().isTrue()) {"; const previndent = this.indent; this.indent += this.step; - const thenexpr = this.gen(children[1][1][0], expectedType); - if ((thenexpr.sequenceType.occurrence === "0" && (expectedType.occurrence === "1" || expectedType.occurrence === "+")) || (thenexpr.sequenceType.schemaTypeInfo && expectedType.schemaTypeInfo && !thenexpr.sequenceType.schemaTypeInfo.as(expectedType.schemaTypeInfo))) { - Fleur.XQueryError_xqt("XPST0017", null, "Invalid type"); - } + const thenexpr = this.gen(children[1][1][0], expectedSequenceType); result += thenexpr.inst; this.indent = previndent; result += "\n" + previndent + "} else {"; this.indent += this.step; - const elseexpr = this.gen(children[2][1][0], expectedType); - if ((elseexpr.sequenceType.occurrence === "0" && (expectedType.occurrence === "1" || expectedType.occurrence === "+")) || (elseexpr.sequenceType.schemaTypeInfo && expectedType.schemaTypeInfo && !elseexpr.sequenceType.schemaTypeInfo.as(expectedType.schemaTypeInfo))) { - Fleur.XQueryError_xqt("XPST0017", null, "Invalid type"); - } + const elseexpr = this.gen(children[2][1][0], expectedSequenceType); result += elseexpr.inst; this.indent = previndent; return { inst: result + "\n" + previndent + "}", - sequenceType: thenexpr.sequenceType + sequenceType: Fleur.SequenceType.or(thenexpr.sequenceType, elseexpr.sequenceType) }; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.ifThenElseExpr] = function(ctx, children, callback) { Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { var boolean; @@ -73,4 +67,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.ifThenElseExpr] = function(ctx, children, callb Fleur.XQueryEngine[children[2][1][0][0]](ctx, children[2][1][0][1], cb); } }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/inlineFunctionExpr.js b/src/js/fleur.js/XQuery/Instructions/inlineFunctionExpr-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/inlineFunctionExpr.js rename to src/js/fleur.js/XQuery/Instructions/inlineFunctionExpr-BROKEN.js index 4219e0b..dcf8911 100644 --- a/src/js/fleur.js/XQuery/Instructions/inlineFunctionExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/inlineFunctionExpr-BROKEN.js @@ -1,48 +1,48 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.inlineFunctionExpr] = function(ctx, children, callback) { - var updating = children[0][0] === Fleur.XQueryX.updatingFunction; - var init = updating ? 1 : 0; - var args = children[init][1].map(function(arg) { - var o = {name: arg[1][0][1][0]}; - if (arg[1].length === 1) { - o.type = Fleur.Node; - o.occurence = "*"; - } else { - var tprefix = null, turi; - var atype = arg[1][1][1][0][1]; - var tname = atype[0]; - if (atype[1]) { - if (atype[1][0] === Fleur.XQueryX.URI) { - turi = atype[1][1][0]; - } else if (atype[1][0] === Fleur.XQueryX.prefix) { - tprefix = atype[1][1][0]; - turi = ctx.env.nsresolver.lookupNamespaceURI(tprefix); - } - } - o.type = Fleur.Types[turi][tname]; - if (arg[1][1][1].length === 2) { - o.occurence = arg[1][1][1][1][1][0]; - } - } - return o; - }); - var fbody, fret; - if (children[init + 1][0] === Fleur.XQueryX.typeDeclaration) { - fret = children[init + 1][1][0]; - fbody = children[init + 2][0] === Fleur.XQueryX.functionBody ? children[init + 2][1][0] : null; - } else { - fret = {type: Fleur.Node, occurence: "*"}; - fbody = children[init + 1][0] === Fleur.XQueryX.functionBody ? children[init + 1][1][0] : null; - } - var f = new Fleur.Function(null, null, null, fbody, args, false, false, fret, updating); - f.closurevarresolver = ctx.env.varresolver; - Fleur.callback(function() {callback(f);}); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.inlineFunctionExpr] = function(ctx, children, callback) { + var updating = children[0][0] === Fleur.XQueryX.updatingFunction; + var init = updating ? 1 : 0; + var args = children[init][1].map(function(arg) { + var o = {name: arg[1][0][1][0]}; + if (arg[1].length === 1) { + o.type = Fleur.Node; + o.occurence = "*"; + } else { + var tprefix = null, turi; + var atype = arg[1][1][1][0][1]; + var tname = atype[0]; + if (atype[1]) { + if (atype[1][0] === Fleur.XQueryX.URI) { + turi = atype[1][1][0]; + } else if (atype[1][0] === Fleur.XQueryX.prefix) { + tprefix = atype[1][1][0]; + turi = ctx.env.nsresolver.lookupNamespaceURI(tprefix); + } + } + o.type = Fleur.Types[turi][tname]; + if (arg[1][1][1].length === 2) { + o.occurence = arg[1][1][1][1][1][0]; + } + } + return o; + }); + var fbody, fret; + if (children[init + 1][0] === Fleur.XQueryX.typeDeclaration) { + fret = children[init + 1][1][0]; + fbody = children[init + 2][0] === Fleur.XQueryX.functionBody ? children[init + 2][1][0] : null; + } else { + fret = {type: Fleur.Node, occurence: "*"}; + fbody = children[init + 1][0] === Fleur.XQueryX.functionBody ? children[init + 1][1][0] : null; + } + var f = new Fleur.Function(null, null, null, fbody, args, false, false, fret, updating); + f.closurevarresolver = ctx.env.varresolver; + Fleur.callback(function() {callback(f);}); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/insertExpr.js b/src/js/fleur.js/XQuery/Instructions/insertExpr-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/insertExpr.js rename to src/js/fleur.js/XQuery/Instructions/insertExpr-BROKEN.js index 41d2bbe..4f05bc1 100644 --- a/src/js/fleur.js/XQuery/Instructions/insertExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/insertExpr-BROKEN.js @@ -1,65 +1,65 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.insertExpr] = function(ctx, children, callback) { - Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(source) { - if (source !== Fleur.EmptySequence) { - Fleur.XQueryEngine[children[2][1][0][0]](ctx, children[2][1][0][1], function(target) { - var targetChoice = children[1][0]; - var intoPos = null; - if (targetChoice === Fleur.XQueryX.insertInto) { - if (children[1][1].length !== 0) { - intoPos = children[1][1][0][0]; - } - } - if (source.nodeType !== Fleur.Node.SEQUENCE_NODE) { - var tnode; - if (target instanceof Fleur.Node) { - tnode = target.ownerDocument ? target.ownerDocument.importNode(source, true) : source; - } else { - tnode = Fleur.Document.docImportNode(target.ownerDocument, source, true); - } - switch (target.nodeType) { - case Fleur.Node.ELEMENT_NODE: - switch (targetChoice) { - case Fleur.XQueryX.insertInto: - if (source.nodeType === Fleur.Node.ATTRIBUTE_NODE) { - target.setAttributeNode(source); - } else { - if (intoPos === Fleur.XQueryX.insertAsFirst) { - target.insertBefore(tnode, target.firstChild); - } else { - target.appendChild(tnode); - } - } - break; - case Fleur.XQueryX.insertBefore: - target.parentNode.insertBefore(tnode, target); - break; - case Fleur.XQueryX.insertAfter: - if (target.nextSibling) { - target.parentNode.insertBefore(tnode, target.nextSibling); - } else { - target.parentNode.appendChild(tnode); - } - break; - } - break; - case Fleur.Node.MAP_NODE: - target.setEntryNode(tnode.copyNode()); - break; - } - } - Fleur.callback(function() {callback(Fleur.EmptySequence);}); - }); - return; - } - Fleur.callback(function() {callback(Fleur.EmptySequence);}); - }); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.insertExpr] = function(ctx, children, callback) { + Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(source) { + if (source !== Fleur.EmptySequence) { + Fleur.XQueryEngine[children[2][1][0][0]](ctx, children[2][1][0][1], function(target) { + var targetChoice = children[1][0]; + var intoPos = null; + if (targetChoice === Fleur.XQueryX.insertInto) { + if (children[1][1].length !== 0) { + intoPos = children[1][1][0][0]; + } + } + if (source.nodeType !== Fleur.Node.SEQUENCE_NODE) { + var tnode; + if (target instanceof Fleur.Node) { + tnode = target.ownerDocument ? target.ownerDocument.importNode(source, true) : source; + } else { + tnode = Fleur.Document.docImportNode(target.ownerDocument, source, true); + } + switch (target.nodeType) { + case Fleur.Node.ELEMENT_NODE: + switch (targetChoice) { + case Fleur.XQueryX.insertInto: + if (source.nodeType === Fleur.Node.ATTRIBUTE_NODE) { + target.setAttributeNode(source); + } else { + if (intoPos === Fleur.XQueryX.insertAsFirst) { + target.insertBefore(tnode, target.firstChild); + } else { + target.appendChild(tnode); + } + } + break; + case Fleur.XQueryX.insertBefore: + target.parentNode.insertBefore(tnode, target); + break; + case Fleur.XQueryX.insertAfter: + if (target.nextSibling) { + target.parentNode.insertBefore(tnode, target.nextSibling); + } else { + target.parentNode.appendChild(tnode); + } + break; + } + break; + case Fleur.Node.MAP_NODE: + target.setEntryNode(tnode.copyNode()); + break; + } + } + Fleur.callback(function() {callback(Fleur.EmptySequence);}); + }); + return; + } + Fleur.callback(function() {callback(Fleur.EmptySequence);}); + }); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/instanceOfExpr.js b/src/js/fleur.js/XQuery/Instructions/instanceOfExpr.js index 21be223..decd112 100644 --- a/src/js/fleur.js/XQuery/Instructions/instanceOfExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/instanceOfExpr.js @@ -1,12 +1,25 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ +Fleur.Transpiler.prototype.xqx_instanceOfExpr = function(children) { + const arg1 = this.gen(children[0][1][0]); + const seqtype = children[1][1]; + const occurrence = seqtype.length === 2 ? seqtype[1][1][0] : "1"; + return this.inst("xqx_instanceOfExpr(new Fleur.SequenceType(Fleur.Node.ATOMIC_NODE, Fleur.Type_" + seqtype[0][1][0] + ", '" + String(occurrence) + "'))", false, Fleur.SequenceType_boolean_1, arg1.inst); +}; + +Fleur.Context.prototype.xqx_instanceOfExpr = function(arg) { + const item = new Fleur.Text(); + item.schemaTypeInfo = Fleur.Type_boolean; + item.data = String(this.item.instanceOf(arg)); + this.item = item; + return this; +}; +/* Fleur.XQueryEngine[Fleur.XQueryX.instanceOfExpr] = function(ctx, children, callback) { Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { var seqtype = children[1][1]; @@ -61,4 +74,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.instanceOfExpr] = function(ctx, children, callb Fleur.callback(function() {callback(a);}); } }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/integerConstantExpr.js b/src/js/fleur.js/XQuery/Instructions/integerConstantExpr.js index c73c145..d7d8876 100644 --- a/src/js/fleur.js/XQuery/Instructions/integerConstantExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/integerConstantExpr.js @@ -1,34 +1,42 @@ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.Transpiler.prototype.xqx_integerConstantExpr = function(children, expectedType) { - return { - inst: this.inst("xqx_integerConstantExpr('" + children[0][1][0] + "')", false).inst, - sequenceType: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: 1 - } - }; +Fleur.Transpiler.prototype.xqx_integerConstantExpr = function(children, expectedSequenceType) { + const issubtype = expectedSequenceType && expectedSequenceType.schemaTypeInfo !== Fleur.Type_integer && expectedSequenceType.schemaTypeInfo.as(Fleur.Type_integer); + const subtype = issubtype ? expectedSequenceType.schemaTypeInfo : Fleur.Type_integer; + const item = new Fleur.Text(); + item.schemaTypeInfo = subtype; + try { + const canon = subtype.canonicalize(children[0][1][0]); + item.appendData(canon); + return { + inst: this.inst((issubtype ? "xqx_constantExpr(Fleur.Type_" + expectedSequenceType.schemaTypeInfo.typeName + ", '" : "xqx_integerConstantExpr('") + canon + "')", false).inst, + sequenceType: new Fleur.SequenceType(Fleur.Node.TEXT_NODE, subtype, "1"), + value: item + }; + } catch (e) { + item.appendData(children[0][1][0]); + Fleur.XQueryError_xqt(e.code === Fleur.DOMException.VALIDATION_ERR ? "FORG0001" : "FODT0001", null, "Wrong argument for implicit xs:" + expectedSequenceType.schemaTypeInfo.typeName + "#1", "", item); + } }; Fleur.Context.prototype.xqx_integerConstantExpr = function(arg) { this.itemstack.push(this.item); const item = new Fleur.Text(); - item.appendData(Fleur.Type_integer.canonicalize(arg)); + item.appendData(arg); item.schemaTypeInfo = Fleur.Type_integer; this.item = item; return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.integerConstantExpr] = function(ctx, children, callback) { var a = new Fleur.Text(); a.appendData(Fleur.Type_integer.canonicalize(children[0][1][0])); a.schemaTypeInfo = Fleur.Type_integer; Fleur.callback(function() {callback(a);}); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/javascriptImport.js b/src/js/fleur.js/XQuery/Instructions/javascriptImport-BROKEN.js similarity index 96% rename from src/js/fleur.js/XQuery/Instructions/javascriptImport.js rename to src/js/fleur.js/XQuery/Instructions/javascriptImport-BROKEN.js index 485254a..d65658f 100644 --- a/src/js/fleur.js/XQuery/Instructions/javascriptImport.js +++ b/src/js/fleur.js/XQuery/Instructions/javascriptImport-BROKEN.js @@ -1,56 +1,56 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.javascriptImport] = function(ctx, children, callback) { - var at = children[0][1][0]; - var httpget = at.startsWith("http://") || Fleur.inBrowser; - var fileread = at.startsWith("file://") || !httpget; - if (httpget) { - if (at.startsWith("http://")) { - at = at.substr(7); - } - var getp = new Promise(function(resolve, reject) { - var req = new XMLHttpRequest(); - req.open('GET', at, true); - req.onload = function() { - if (req.status === 200) { - resolve(req.responseText); - } else { - reject(Fleur.error(ctx, "FODC0002")); - } - }; - req.send(null); - }); - getp.then( - function(s) { - Fleur.callback(function() {callback();}); - }, - function(a) { - Fleur.callback(function() {callback();}); - } - ); - } else if (fileread) { - if (at.startsWith("file://")) { - at = at.substr(7); - } - if (!at.startsWith(global.path.sep)) { - at = global.path.join(Fleur.baseDir, at); - } - global.fs.readFile(at, 'binary', function(err, file){ - if (err) { - process.stdout.write(err); - Fleur.callback(function() {callback();}); - } else { - (0, eval)(file); - Fleur.callback(function() {callback();}); - } - }); - } - +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.javascriptImport] = function(ctx, children, callback) { + var at = children[0][1][0]; + var httpget = at.startsWith("http://") || Fleur.inBrowser; + var fileread = at.startsWith("file://") || !httpget; + if (httpget) { + if (at.startsWith("http://")) { + at = at.substr(7); + } + var getp = new Promise(function(resolve, reject) { + var req = new XMLHttpRequest(); + req.open('GET', at, true); + req.onload = function() { + if (req.status === 200) { + resolve(req.responseText); + } else { + reject(Fleur.error(ctx, "FODC0002")); + } + }; + req.send(null); + }); + getp.then( + function(s) { + Fleur.callback(function() {callback();}); + }, + function(a) { + Fleur.callback(function() {callback();}); + } + ); + } else if (fileread) { + if (at.startsWith("file://")) { + at = at.substr(7); + } + if (!at.startsWith(global.path.sep)) { + at = global.path.join(Fleur.baseDir, at); + } + global.fs.readFile(at, 'binary', function(err, file){ + if (err) { + process.stdout.write(err); + Fleur.callback(function() {callback();}); + } else { + (0, eval)(file); + Fleur.callback(function() {callback();}); + } + }); + } + }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/letClause.js b/src/js/fleur.js/XQuery/Instructions/letClause.js index 07840cb..ba97ece 100644 --- a/src/js/fleur.js/XQuery/Instructions/letClause.js +++ b/src/js/fleur.js/XQuery/Instructions/letClause.js @@ -1,7 +1,7 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ @@ -21,7 +21,7 @@ Fleur.Transpiler.prototype.xqx_letClause = function(children) { inst: result }; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.letClause] = function(ctx, children, callback, resarr) { //console.log("letClause "); Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], function(n) { @@ -35,4 +35,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.letClause] = function(ctx, children, callback, } Fleur.XQueryEngine[Fleur.XQueryX.letClause](ctx, children.slice(1), callback, resarr); }, resarr); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/letClauseItem.js b/src/js/fleur.js/XQuery/Instructions/letClauseItem.js index 7c0363a..35cb49a 100644 --- a/src/js/fleur.js/XQuery/Instructions/letClauseItem.js +++ b/src/js/fleur.js/XQuery/Instructions/letClauseItem.js @@ -1,7 +1,7 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ @@ -10,23 +10,29 @@ Fleur.Transpiler.prototype.xqx_letClauseItem = function(children) { this.indent += this.step; const gen = this.funcdef(children[1][1][0]); this.indent = previndent; - let result = "\n" + previndent + (this.async ? "await " : "") + this.ctxvarname + ".xqx_letClauseItem" + (this.async ? "_async" : "") + "('" + (children[0][1][0][1][0][1].length === 2 ? children[0][1][0][1][0][1][1][1][0] : "") + "', '" + children[0][1][0][1][0][1][0] + "',"; + const vname = children[0][1][0][1][0][1][0]; + const namespaceURI = this.rs.nsresolver.lookupNamespaceURI((children[0][1][0][1][0][1].length === 2 ? children[0][1][0][1][0][1][1][1][0] : "")) || ""; + let result = "\n" + previndent + (this.async ? "await " : "") + this.ctxvarname + ".xqx_letClauseItem" + (this.async ? "_async" : "") + "('" + namespaceURI + "', '" + vname + "',"; result += gen.inst; result += "\n" + previndent + ");"; + this.rs.varresolver.set(null, namespaceURI, vname, gen.sequenceType); return { inst: result }; }; Fleur.Context.prototype.xqx_letClauseItem = function(namespaceURI, vname, fn) { + const thisisit = this; this.tuple.forEach(vr => { this.rs.varresolver = vr; - fn(this); - vr.set(null, namespaceURI, vname, this.item); + fn(thisisit); + vr.set(null, namespaceURI, vname, thisisit.item); + thisisit.item = thisisit.itemstack.pop(); }); return this; }; +/* Fleur.XQueryEngine[Fleur.XQueryX.letClauseItem] = function(ctx, children, callback, resarr) { //console.log("letClauseItem"); var i = 0; @@ -43,4 +49,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.letClauseItem] = function(ctx, children, callba } }; Fleur.XQueryEngine[children[1][1][0][0]](ctx, children[1][1][0][1], cb); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/lookup.js b/src/js/fleur.js/XQuery/Instructions/lookup.js index 52e2288..bc4c51f 100644 --- a/src/js/fleur.js/XQuery/Instructions/lookup.js +++ b/src/js/fleur.js/XQuery/Instructions/lookup.js @@ -1,12 +1,96 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ +Fleur.Transpiler.prototype.xqx_lookup = function(children) { + let r = ""; + const childname = + children[0][0] === Fleur.XQueryX.star ? "star" : + children[0][0] === Fleur.XQueryX.NCName ? "NCName" : + "expr"; + const NCName = childname === "NCName" ? children[0][1][0] : null; + if (childname === "expr") { + r = this.gen(children[0][1][0]).inst; + } + r += this.inst("xqx_lookup_" + childname + "(" + (NCName ? "'" + NCName + "'": "") + ")").inst; + return { + inst: r, + sequenceType: childname === "star" ? Fleur.SequenceType_entry_0n : Fleur.SequenceType_entry_01 + }; +}; + +Fleur.Context.prototype.xqx_lookup_NCName = function(NCName) { + const arg = this.item; + const res = new Fleur.Sequence(); + if (arg.isSingle()) { + if (arg.nodeType === Fleur.Node.MAP_NODE) { + arg.entries.forEach(e => { + if (e.localName === NCName) { + res.appendChild(e.cloneNode()); + } + }); + } + } else { + arg.childNodes.forEach(c => { + if (c.nodeType === Fleur.Node.MAP_NODE) { + c.entries.forEach(e => { + if (e.localName === NCName) { + res.appendChild(e.cloneNode()); + } + }); + } + }); + } + this.item = res.singleton(); + return this; +}; +Fleur.Context.prototype.xqx_lookup_expr = function() { + const arg1 = this.itemstack.pop(); + const NCName = this.item.data; + const res = new Fleur.Sequence(); + if (arg1.isSingle()) { + if (arg1.nodeType === Fleur.Node.MAP_NODE) { + arg1.entries.forEach(e => { + if (e.localName === NCName) { + res.appendChild(e.cloneNode()); + } + }); + } + } else { + arg1.childNodes.forEach(c => { + if (c.nodeType === Fleur.Node.MAP_NODE) { + c.entries.forEach(e => { + if (e.localName === NCName) { + res.appendChild(e.cloneNode()); + } + }); + } + }); + } + this.item = res.singleton(); + return this; +}; +Fleur.Context.prototype.xqx_lookup_star = function() { + const arg = this.item; + const res = new Fleur.Sequence(); + if (arg.isSingle()) { + if (arg.nodeType === Fleur.Node.MAP_NODE) { + arg.entries.forEach(e => res.appendChild(e.cloneNode())); + } + } else { + arg.childNodes.forEach(c => { + if (c.nodeType === Fleur.Node.MAP_NODE) { + c.entries.forEach(e => res.appendChild(e.cloneNode())); + } + }); + } + this.item = res.singleton(); + return this; +}; +/* Fleur.XQueryEngine.lookups = function(ctx, children, callback, functionid) { //console.log(functionid + " - " + pos + " - " + Fleur.Serializer._serializeNodeToXQuery(ctx._curr, false, "")); var ncname, ilabel, seq; @@ -160,3 +244,4 @@ Fleur.XQueryEngine.lookups = function(ctx, children, callback, functionid) { Fleur.XQueryEngine[Fleur.XQueryX.lookup] = function(ctx, children, callback) { Fleur.XQueryEngine.lookups(ctx, children, callback, Fleur.XQueryX.lookup); }; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/mainModule.js b/src/js/fleur.js/XQuery/Instructions/mainModule.js index 516ae01..4dee660 100644 --- a/src/js/fleur.js/XQuery/Instructions/mainModule.js +++ b/src/js/fleur.js/XQuery/Instructions/mainModule.js @@ -1,12 +1,24 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ +Fleur.Transpiler.prototype.xqx_mainModule = function(children) { + const transp = this; + let lastseqtype; + let r = children.reduce((inst, child) => { + const g = transp.gen(child); + lastseqtype = g.sequenceType; + return inst + g.inst; + }, ""); + return { + inst: r, + sequenceType: lastseqtype + }; +}; +/* Fleur.XQueryEngine[Fleur.XQueryX.mainModule] = function(ctx, children, callback) { Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], function(n) { if (children.length > 1) { @@ -15,4 +27,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.mainModule] = function(ctx, children, callback) Fleur.callback(function() {callback(n);}); } }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/mapConstructor.js b/src/js/fleur.js/XQuery/Instructions/mapConstructor.js index 69f3ac0..1359a6b 100644 --- a/src/js/fleur.js/XQuery/Instructions/mapConstructor.js +++ b/src/js/fleur.js/XQuery/Instructions/mapConstructor.js @@ -1,12 +1,36 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ +Fleur.Transpiler.prototype.xqx_mapConstructor = function(children) { + let r = ""; + const transp = this; + r = children.reduce((inst, child) => inst + transp.gen(child).inst, ""); + r += this.inst("xqx_mapConstructor(" + String(children.length) + ")").inst; + return { + inst: r, + sequenceType: Fleur.SequenceType_map_1 + }; +}; + +Fleur.Context.prototype.xqx_mapConstructor = function(count) { + const map = new Fleur.Map(); + map.appendContent(this.item, ""); + const args = count !== 0 ? [this.item] : (this.itemstack.push(this.item), []); + for (let i = 1; i < count; i++) { + args.push(this.itemstack.pop()); + } + args.reverse(); + args.forEach(arg => { + map.setEntryNode(arg); + }); + this.item = map; + return this; +}; +/* Fleur.XQueryEngine[Fleur.XQueryX.mapConstructor] = function(ctx, children, callback) { var map = new Fleur.Map(); var i = 0; @@ -36,4 +60,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.mapConstructor] = function(ctx, children, callb } else { Fleur.callback(function() {callback(map);}); } -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/mapConstructorEntry.js b/src/js/fleur.js/XQuery/Instructions/mapConstructorEntry.js index 77e5a20..f3c8745 100644 --- a/src/js/fleur.js/XQuery/Instructions/mapConstructorEntry.js +++ b/src/js/fleur.js/XQuery/Instructions/mapConstructorEntry.js @@ -1,12 +1,34 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ +Fleur.Transpiler.prototype.xqx_mapConstructorEntry = function(children) { + let r = this.gen(children[1][1][0], Fleur.SequenceType_item_0n).inst; + r += this.gen(children[0][1][0], Fleur.SequenceType_string_1).inst; + r += this.inst("xqx_mapConstructorEntry()").inst; + return { + inst: r, + sequenceType: Fleur.SequenceType_entry_1 + }; +}; + +Fleur.Context.prototype.xqx_mapConstructorEntry = function() { + const evalue = this.itemstack.pop(); + const ekey = this.item; + const entry = new Fleur.Entry(); + const localName = ekey.data; + entry.nodeName = localName; + entry.localName = localName; + entry.prefix = null; + entry.namespaceURI = null; + entry.appendChild(evalue); + this.item = entry; + return this; +}; +/* Fleur.XQueryEngine[Fleur.XQueryX.mapConstructorEntry] = function(ctx, children, callback) { var entry = new Fleur.Entry(); Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { @@ -30,4 +52,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.mapConstructorEntry] = function(ctx, children, }); } }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/mapTest.js b/src/js/fleur.js/XQuery/Instructions/mapTest.js index 4d6b602..cd2e303 100644 --- a/src/js/fleur.js/XQuery/Instructions/mapTest.js +++ b/src/js/fleur.js/XQuery/Instructions/mapTest.js @@ -1,8 +1,7 @@ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ diff --git a/src/js/fleur.js/XQuery/Instructions/module.js b/src/js/fleur.js/XQuery/Instructions/module.js index 60b869d..154ecf9 100644 --- a/src/js/fleur.js/XQuery/Instructions/module.js +++ b/src/js/fleur.js/XQuery/Instructions/module.js @@ -1,12 +1,27 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ +Fleur.Transpiler.prototype.xqx_module = function(children) { + const transp = this; + let lastseqtype; + let r = children.reduce((inst, child) => { + if (Fleur.XQueryXNames[1][child[0]][0] === 2) { + return inst; + } + const g = transp.gen(child); + lastseqtype = g.sequenceType; + return inst + g.inst; + }, ""); + return { + inst: r, + sequenceType: lastseqtype + }; +}; +/* Fleur.XQueryEngine[Fleur.XQueryX.module] = function(ctx, children, callback) { Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], function(n) { ctx._result = n; @@ -16,4 +31,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.module] = function(ctx, children, callback) { Fleur.callback(function() {callback(n);}); } }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/moduleImport.js b/src/js/fleur.js/XQuery/Instructions/moduleImport-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/moduleImport.js rename to src/js/fleur.js/XQuery/Instructions/moduleImport-BROKEN.js index c365403..d13df0a 100644 --- a/src/js/fleur.js/XQuery/Instructions/moduleImport.js +++ b/src/js/fleur.js/XQuery/Instructions/moduleImport-BROKEN.js @@ -1,19 +1,19 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.moduleImport] = function(ctx, children, callback) { - Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], function(n) { - ctx._result = n; - if (children.length > 1) { - Fleur.XQueryEngine[Fleur.XQueryX.moduleImport](ctx, children.slice(1), callback); - } else { - Fleur.callback(function() {callback(n);}); - } - }); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.moduleImport] = function(ctx, children, callback) { + Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], function(n) { + ctx._result = n; + if (children.length > 1) { + Fleur.XQueryEngine[Fleur.XQueryX.moduleImport](ctx, children.slice(1), callback); + } else { + Fleur.callback(function() {callback(n);}); + } + }); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/multidimExpr.js b/src/js/fleur.js/XQuery/Instructions/multidimExpr-BROKEN.js similarity index 96% rename from src/js/fleur.js/XQuery/Instructions/multidimExpr.js rename to src/js/fleur.js/XQuery/Instructions/multidimExpr-BROKEN.js index e0cf6e6..4340c01 100644 --- a/src/js/fleur.js/XQuery/Instructions/multidimExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/multidimExpr-BROKEN.js @@ -1,41 +1,41 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.multidimExpr] = function(ctx, children, callback) { - var seq = new Fleur.Sequence(); - var i = 0; - var cb = function(n) { - if (n.schemaTypeInfo === Fleur.Type_error) { - Fleur.callback(function() {callback(n);}); - return; - } - if (n !== Fleur.EmptySequence) { - var md = new Fleur.Multidim(); - if (n.nodeType !== Fleur.Node.SEQUENCE_NODE) { - md.appendChild(n); - } else { - n.childNodes.forEach(function(n2) { - md.appendChild(n2); - }); - } - seq.appendChild(md); - } - i++; - if (i === children.length) { - Fleur.callback(function() {callback(seq);}); - return; - } - Fleur.XQueryEngine[children[i][0]](ctx, children[i][1], cb); - }; - if (children.length !== 0) { - Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], cb); - } else { - Fleur.callback(function() {callback(seq);}); - } +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.multidimExpr] = function(ctx, children, callback) { + var seq = new Fleur.Sequence(); + var i = 0; + var cb = function(n) { + if (n.schemaTypeInfo === Fleur.Type_error) { + Fleur.callback(function() {callback(n);}); + return; + } + if (n !== Fleur.EmptySequence) { + var md = new Fleur.Multidim(); + if (n.nodeType !== Fleur.Node.SEQUENCE_NODE) { + md.appendChild(n); + } else { + n.childNodes.forEach(function(n2) { + md.appendChild(n2); + }); + } + seq.appendChild(md); + } + i++; + if (i === children.length) { + Fleur.callback(function() {callback(seq);}); + return; + } + Fleur.XQueryEngine[children[i][0]](ctx, children[i][1], cb); + }; + if (children.length !== 0) { + Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], cb); + } else { + Fleur.callback(function() {callback(seq);}); + } }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/nameTest.js b/src/js/fleur.js/XQuery/Instructions/nameTest.js index 21863a4..f8ff8e2 100644 --- a/src/js/fleur.js/XQuery/Instructions/nameTest.js +++ b/src/js/fleur.js/XQuery/Instructions/nameTest.js @@ -1,8 +1,7 @@ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ diff --git a/src/js/fleur.js/XQuery/Instructions/namedFunctionRef.js b/src/js/fleur.js/XQuery/Instructions/namedFunctionRef-BROKEN.js similarity index 98% rename from src/js/fleur.js/XQuery/Instructions/namedFunctionRef.js rename to src/js/fleur.js/XQuery/Instructions/namedFunctionRef-BROKEN.js index 4ca6fc1..8050cec 100644 --- a/src/js/fleur.js/XQuery/Instructions/namedFunctionRef.js +++ b/src/js/fleur.js/XQuery/Instructions/namedFunctionRef-BROKEN.js @@ -1,32 +1,32 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.namedFunctionRef] = function(ctx, children, callback) { - var fname = children[0][1][0]; - var uri = ctx.env.nsresolver.lookupNamespaceURI(" function"); - var nbargs = parseInt(children[1][1][0][1][0], 10); - var a = new Fleur.Text(); - a.schemaTypeInfo = Fleur.Type_error; - a._setNodeNameLocalNamePrefix("http://www.w3.org/2005/xqt-errors", "err:XPST0017"); - if (children[0][1][1]) { - if (children[0][1][1][0] === Fleur.XQueryX.URI) { - uri = children[0][1][1][1][0]; - } else if (children[0][1][1][0] === Fleur.XQueryX.prefix && ctx.env.nsresolver) { - uri = ctx.env.nsresolver.lookupNamespaceURI(children[0][1][1][1][0]); - } - } - if (uri === "http://www.w3.org/2005/xpath-functions" && fname === "concat" && nbargs > 1 && !Fleur.XPathFunctions[uri][fname + "#" + nbargs]) { - var cparam = []; - for (var i = 0; i < nbargs; i++) { - cparam[i] = {type: Fleur.Node}; - } - Fleur.XPathFunctions[uri][fname + "#" + nbargs] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:concat", Fleur.XPathFunctions_fn["concat#"].jsfunc, null, cparam, false, false, {type: Fleur.Type_string}); - } - Fleur.callback(function() {callback(Fleur.XPathFunctions[uri] ? Fleur.XPathFunctions[uri][fname + "#" + nbargs].cloneNode() || a : a);}); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.namedFunctionRef] = function(ctx, children, callback) { + var fname = children[0][1][0]; + var uri = ctx.env.nsresolver.lookupNamespaceURI(" function"); + var nbargs = parseInt(children[1][1][0][1][0], 10); + var a = new Fleur.Text(); + a.schemaTypeInfo = Fleur.Type_error; + a._setNodeNameLocalNamePrefix("http://www.w3.org/2005/xqt-errors", "err:XPST0017"); + if (children[0][1][1]) { + if (children[0][1][1][0] === Fleur.XQueryX.URI) { + uri = children[0][1][1][1][0]; + } else if (children[0][1][1][0] === Fleur.XQueryX.prefix && ctx.env.nsresolver) { + uri = ctx.env.nsresolver.lookupNamespaceURI(children[0][1][1][1][0]); + } + } + if (uri === "http://www.w3.org/2005/xpath-functions" && fname === "concat" && nbargs > 1 && !Fleur.XPathFunctions[uri][fname + "#" + nbargs]) { + var cparam = []; + for (var i = 0; i < nbargs; i++) { + cparam[i] = {type: Fleur.Node}; + } + Fleur.XPathFunctions[uri][fname + "#" + nbargs] = new Fleur.Function("http://www.w3.org/2005/xpath-functions", "fn:concat", Fleur.XPathFunctions_fn["concat#"].jsfunc, null, cparam, false, false, {type: Fleur.Type_string}); + } + Fleur.callback(function() {callback(Fleur.XPathFunctions[uri] ? Fleur.XPathFunctions[uri][fname + "#" + nbargs].cloneNode() || a : a);}); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/namespaceDecl.js b/src/js/fleur.js/XQuery/Instructions/namespaceDecl-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/namespaceDecl.js rename to src/js/fleur.js/XQuery/Instructions/namespaceDecl-BROKEN.js index 2a8135d..5981f69 100644 --- a/src/js/fleur.js/XQuery/Instructions/namespaceDecl.js +++ b/src/js/fleur.js/XQuery/Instructions/namespaceDecl-BROKEN.js @@ -1,13 +1,13 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.namespaceDecl] = function(ctx, children, callback) { - ctx.env.nsresolver.declareNamespace(children[0][1][0], children[1][1][0]); - Fleur.callback(function() {callback();}); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.namespaceDecl] = function(ctx, children, callback) { + ctx.env.nsresolver.declareNamespace(children[0][1][0], children[1][1][0]); + Fleur.callback(function() {callback();}); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/namespaceDeclaration.js b/src/js/fleur.js/XQuery/Instructions/namespaceDeclaration.js index 34b3268..8bd54ec 100644 --- a/src/js/fleur.js/XQuery/Instructions/namespaceDeclaration.js +++ b/src/js/fleur.js/XQuery/Instructions/namespaceDeclaration.js @@ -1,7 +1,7 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ diff --git a/src/js/fleur.js/XQuery/Instructions/optionDecl.js b/src/js/fleur.js/XQuery/Instructions/optionDecl-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/optionDecl.js rename to src/js/fleur.js/XQuery/Instructions/optionDecl-BROKEN.js index 8d28055..15eea17 100644 --- a/src/js/fleur.js/XQuery/Instructions/optionDecl.js +++ b/src/js/fleur.js/XQuery/Instructions/optionDecl-BROKEN.js @@ -1,20 +1,20 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.optionDecl] = function(ctx, children, callback) { - if (!ctx.env.options) { - ctx.env.options = {}; - } - var uri = children[0][1].length > 1 ? ctx.env.nsresolver.lookupNamespaceURI(children[0][1][1][1][0]) : "http://www.w3.org/2012/xquery"; - if (!ctx.env.options[uri]) { - ctx.env.options[uri] = {}; - } - ctx.env.options[uri][children[0][1][0]] = children[1][1][0]; - Fleur.callback(function() {callback();}); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.optionDecl] = function(ctx, children, callback) { + if (!ctx.env.options) { + ctx.env.options = {}; + } + var uri = children[0][1].length > 1 ? ctx.env.nsresolver.lookupNamespaceURI(children[0][1][1][1][0]) : "http://www.w3.org/2012/xquery"; + if (!ctx.env.options[uri]) { + ctx.env.options[uri] = {}; + } + ctx.env.options[uri][children[0][1][0]] = children[1][1][0]; + Fleur.callback(function() {callback();}); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/orderByClause.js b/src/js/fleur.js/XQuery/Instructions/orderByClause-BROKEN.js similarity index 96% rename from src/js/fleur.js/XQuery/Instructions/orderByClause.js rename to src/js/fleur.js/XQuery/Instructions/orderByClause-BROKEN.js index 6f5375c..25e5726 100644 --- a/src/js/fleur.js/XQuery/Instructions/orderByClause.js +++ b/src/js/fleur.js/XQuery/Instructions/orderByClause-BROKEN.js @@ -1,58 +1,58 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.orderByClause] = function(ctx, children, callback, resarr, orderkeys, orderkinds) { - //console.log("orderByClause "); - orderkeys = orderkeys || []; - orderkeys.push([]); - orderkinds = orderkinds || []; - if (children[0][1].length === 2 && children[0][1][1][1][0][1][0] === "descending") { - orderkinds.push(-1); - } else { - orderkinds.push(1); - } - Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], function(n) { - if (n && n.schemaTypeInfo === Fleur.Type_error) { - Fleur.callback(function() {callback(n);}); - return; - } - if (children.length <= 1) { - var kvs = []; - orderkeys.forEach(function(ks, ki) { - ks.forEach(function(k, kj) { - kvs[kj] = kvs[kj] || []; - kvs[kj][ki] = k; - }); - }, []); - resarr.forEach(function(vmgr, i) { - resarr[i] = { - kvs: kvs[i], - resarr: resarr[i] - }; - }); - resarr.sort(function(a, b) { - for (var i = 0, l = a.kvs.length; i < l; i++) { - if (Fleur.ltOp(a.kvs[i], b.kvs[i])) { - return -orderkinds[i]; - } - if (Fleur.gtOp(a.kvs[i], b.kvs[i])) { - return orderkinds[i]; - } - } - return 0; - }); - resarr.forEach(function(o, i) { - resarr[i] = o.resarr; - }); - Fleur.callback(function() {callback(n);}); - return; - } - Fleur.XQueryEngine[Fleur.XQueryX.orderByClause](ctx, children.slice(1), callback, resarr, orderkeys); - }, resarr, orderkeys[orderkeys.length - 1]); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.orderByClause] = function(ctx, children, callback, resarr, orderkeys, orderkinds) { + //console.log("orderByClause "); + orderkeys = orderkeys || []; + orderkeys.push([]); + orderkinds = orderkinds || []; + if (children[0][1].length === 2 && children[0][1][1][1][0][1][0] === "descending") { + orderkinds.push(-1); + } else { + orderkinds.push(1); + } + Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], function(n) { + if (n && n.schemaTypeInfo === Fleur.Type_error) { + Fleur.callback(function() {callback(n);}); + return; + } + if (children.length <= 1) { + var kvs = []; + orderkeys.forEach(function(ks, ki) { + ks.forEach(function(k, kj) { + kvs[kj] = kvs[kj] || []; + kvs[kj][ki] = k; + }); + }, []); + resarr.forEach(function(vmgr, i) { + resarr[i] = { + kvs: kvs[i], + resarr: resarr[i] + }; + }); + resarr.sort(function(a, b) { + for (var i = 0, l = a.kvs.length; i < l; i++) { + if (Fleur.ltOp(a.kvs[i], b.kvs[i])) { + return -orderkinds[i]; + } + if (Fleur.gtOp(a.kvs[i], b.kvs[i])) { + return orderkinds[i]; + } + } + return 0; + }); + resarr.forEach(function(o, i) { + resarr[i] = o.resarr; + }); + Fleur.callback(function() {callback(n);}); + return; + } + Fleur.XQueryEngine[Fleur.XQueryX.orderByClause](ctx, children.slice(1), callback, resarr, orderkeys); + }, resarr, orderkeys[orderkeys.length - 1]); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/orderBySpec.js b/src/js/fleur.js/XQuery/Instructions/orderBySpec-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/orderBySpec.js rename to src/js/fleur.js/XQuery/Instructions/orderBySpec-BROKEN.js index b911d19..54d6c2e 100644 --- a/src/js/fleur.js/XQuery/Instructions/orderBySpec.js +++ b/src/js/fleur.js/XQuery/Instructions/orderBySpec-BROKEN.js @@ -1,27 +1,27 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.orderBySpec] = function(ctx, children, callback, resarr, orderkeyvalues) { - //console.log("orderBySpec"); - var i = 0; - ctx.env.varresolver = resarr[0]; - var cb = function(n) { - var a = Fleur.Atomize(n, true); - var jsv = Fleur.toJSValue(a, true, true, true, true); - orderkeyvalues.push(jsv); - i++; - if (i !== resarr.length) { - ctx.env.varresolver = resarr[i]; - Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], cb); - } else { - Fleur.callback(function() {callback(Fleur.EmptySequence);}); - } - }; - Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], cb); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.orderBySpec] = function(ctx, children, callback, resarr, orderkeyvalues) { + //console.log("orderBySpec"); + var i = 0; + ctx.env.varresolver = resarr[0]; + var cb = function(n) { + var a = Fleur.Atomize(n, true); + var jsv = Fleur.toJSValue(a, true, true, true, true); + orderkeyvalues.push(jsv); + i++; + if (i !== resarr.length) { + ctx.env.varresolver = resarr[i]; + Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], cb); + } else { + Fleur.callback(function() {callback(Fleur.EmptySequence);}); + } + }; + Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], cb); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/param.js b/src/js/fleur.js/XQuery/Instructions/param.js new file mode 100644 index 0000000..66e8cc1 --- /dev/null +++ b/src/js/fleur.js/XQuery/Instructions/param.js @@ -0,0 +1,12 @@ +"use strict"; +/** + * @author Alain Couthures + * @license LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.Context.prototype.xqx_param = function(namespaceURI, vname) { + this.rs.varresolver.set(null, namespaceURI, vname, this.item); + this.item = this.itemstack.pop(); + return this; +}; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/paramList.js b/src/js/fleur.js/XQuery/Instructions/paramList.js new file mode 100644 index 0000000..1c4da45 --- /dev/null +++ b/src/js/fleur.js/XQuery/Instructions/paramList.js @@ -0,0 +1,16 @@ +"use strict"; +/** + * @author Alain Couthures + * @license LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.Context.prototype.xqx_paramList = function() { + this.rs.varresolver = new Fleur.varMgr([], this.rs.varresolver); + return this; +}; + +Fleur.Context.prototype.xqx_paramList_drop = function() { + this.rs.varresolver = this.rs.varresolver.previous; + return this; +}; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/pathExpr.js b/src/js/fleur.js/XQuery/Instructions/pathExpr.js index 519e869..b53dc61 100644 --- a/src/js/fleur.js/XQuery/Instructions/pathExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/pathExpr.js @@ -1,11 +1,11 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.Transpiler.prototype.xqx_pathExpr = function(children, expectedType) { +Fleur.Transpiler.prototype.xqx_pathExpr = function(children, expectedSequenceType) { let result = this.inst("xqx_pathExpr()").inst; const children2 = []; for (let i = 0, l = children.length; i < l; i++) { @@ -48,14 +48,10 @@ Fleur.Transpiler.prototype.xqx_pathExpr = function(children, expectedType) { } } this.indent = previndent; - result += closes + this.inst("restoreContext()").inst; - if (expectedType && expectedType.schemaTypeInfo) { - result += this.inst("atomize()").inst; - result += this.inst(expectedType.schemaTypeInfo.constructorName + "()").inst; - } + result += closes + this.inst("restoreContext()", false, expectedSequenceType, "", expectedSequenceType).inst; return { inst: result, - sequenceType: expectedType + sequenceType: expectedSequenceType || Fleur.SequenceType_item_0n }; }; diff --git a/src/js/fleur.js/XQuery/Instructions/piTest.js b/src/js/fleur.js/XQuery/Instructions/piTest.js index 74ab4b9..c019c04 100644 --- a/src/js/fleur.js/XQuery/Instructions/piTest.js +++ b/src/js/fleur.js/XQuery/Instructions/piTest.js @@ -2,7 +2,7 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ diff --git a/src/js/fleur.js/XQuery/Instructions/predicate.js b/src/js/fleur.js/XQuery/Instructions/predicate-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/predicate.js rename to src/js/fleur.js/XQuery/Instructions/predicate-BROKEN.js index de975e1..c9da2a0 100644 --- a/src/js/fleur.js/XQuery/Instructions/predicate.js +++ b/src/js/fleur.js/XQuery/Instructions/predicate-BROKEN.js @@ -1,107 +1,107 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.predicate] = function(ctx, children, callback) { - var next = ctx._next; - var last; - var pos = 1; -//console.log("predicate - " + pos + " - " + Fleur.Serializer._serializeNodeToXQuery(next, false, "")); - var result = Fleur.EmptySequence; - var subcurr; - if (next.nodeType === Fleur.Node.SEQUENCE_NODE) { - last = next.childNodes.length; - subcurr = next.childNodes.shift(); - if (next.childNodes.length === 1) { - next = next.childNodes[0]; - } - } else { - subcurr = next; - next = Fleur.EmptySequence; - last = 1; - } - var cb = function(n, eob) { - //console.log("predicate - cb - " + Fleur.Serializer._serializeNodeToXQuery(n, false, "") + (eob ? " - " + (eob === Fleur.XQueryX.predicate ? "predicate" : eob) : "")); - if (eob === Fleur.XQueryX.predicate) { - Fleur.callback(function() {callback(n, Fleur.XQueryX.predicate);}); - return; - } - if ((n.nodeType === Fleur.Node.SEQUENCE_NODE && n.childNodes.length !== 0) || - (n.nodeType === Fleur.Node.TEXT_NODE && n.schemaTypeInfo === Fleur.Type_boolean && n.data !== "false") || - (n.nodeType === Fleur.Node.TEXT_NODE && n.schemaTypeInfo === Fleur.Type_integer && parseInt(n.data, 10) === pos) || - (n.nodeType === Fleur.Node.TEXT_NODE && n.schemaTypeInfo === Fleur.Type_string && n.data !== "") || - (n.nodeType !== Fleur.Node.SEQUENCE_NODE && n.nodeType !== Fleur.Node.TEXT_NODE)) { - if (result === Fleur.EmptySequence) { - result = subcurr; - } else { - if (result.nodeType !== Fleur.Node.SEQUENCE_NODE) { - var seq = new Fleur.Sequence(); - seq.childNodes = new Fleur.NodeList(); - seq.children = new Fleur.NodeList(); - seq.textContent = ""; - seq.appendChild(result); - result = seq; - } - result.appendChild(subcurr); - } - } - if (next === Fleur.EmptySequence) { - if (children.length === 1 || result === Fleur.EmptySequence) { - Fleur.callback(function() {callback(result, Fleur.XQueryX.predicate);}); - return; - } - children.shift(); - next = result; - result = Fleur.EmptySequence; - pos = 1; - if (next.nodeType === Fleur.Node.SEQUENCE_NODE) { - last = next.childNodes.length; - subcurr = next.childNodes.shift(); - if (next.childNodes.length === 1) { - next = next.childNodes[0]; - } - } else { - subcurr = next; - next = Fleur.EmptySequence; - last = 1; - } - Fleur.XQueryEngine[children[0][0]]({ - _curr: subcurr, - _next: next, - _last: last, - _pos: pos, - env: ctx.env - }, children[0][1], cb); - return; - } - if (next.nodeType === Fleur.Node.SEQUENCE_NODE) { - subcurr = next.childNodes.shift(); - if (next.childNodes.length === 1) { - next = next.childNodes[0]; - } - } else { - subcurr = next; - next = Fleur.EmptySequence; - } - pos++; - Fleur.XQueryEngine[children[0][0]]({ - _curr: subcurr, - _next: next, - _last: last, - _pos: pos, - env: ctx.env - }, children[0][1], cb); - }; - Fleur.XQueryEngine[children[0][0]]({ - _curr: subcurr, - _next: next, - _last: last, - _pos: pos, - env: ctx.env - }, children[0][1], cb); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.predicate] = function(ctx, children, callback) { + var next = ctx._next; + var last; + var pos = 1; +//console.log("predicate - " + pos + " - " + Fleur.Serializer._serializeNodeToXQuery(next, false, "")); + var result = Fleur.EmptySequence; + var subcurr; + if (next.nodeType === Fleur.Node.SEQUENCE_NODE) { + last = next.childNodes.length; + subcurr = next.childNodes.shift(); + if (next.childNodes.length === 1) { + next = next.childNodes[0]; + } + } else { + subcurr = next; + next = Fleur.EmptySequence; + last = 1; + } + var cb = function(n, eob) { + //console.log("predicate - cb - " + Fleur.Serializer._serializeNodeToXQuery(n, false, "") + (eob ? " - " + (eob === Fleur.XQueryX.predicate ? "predicate" : eob) : "")); + if (eob === Fleur.XQueryX.predicate) { + Fleur.callback(function() {callback(n, Fleur.XQueryX.predicate);}); + return; + } + if ((n.nodeType === Fleur.Node.SEQUENCE_NODE && n.childNodes.length !== 0) || + (n.nodeType === Fleur.Node.TEXT_NODE && n.schemaTypeInfo === Fleur.Type_boolean && n.data !== "false") || + (n.nodeType === Fleur.Node.TEXT_NODE && n.schemaTypeInfo === Fleur.Type_integer && parseInt(n.data, 10) === pos) || + (n.nodeType === Fleur.Node.TEXT_NODE && n.schemaTypeInfo === Fleur.Type_string && n.data !== "") || + (n.nodeType !== Fleur.Node.SEQUENCE_NODE && n.nodeType !== Fleur.Node.TEXT_NODE)) { + if (result === Fleur.EmptySequence) { + result = subcurr; + } else { + if (result.nodeType !== Fleur.Node.SEQUENCE_NODE) { + var seq = new Fleur.Sequence(); + seq.childNodes = new Fleur.NodeList(); + seq.children = new Fleur.NodeList(); + seq.textContent = ""; + seq.appendChild(result); + result = seq; + } + result.appendChild(subcurr); + } + } + if (next === Fleur.EmptySequence) { + if (children.length === 1 || result === Fleur.EmptySequence) { + Fleur.callback(function() {callback(result, Fleur.XQueryX.predicate);}); + return; + } + children.shift(); + next = result; + result = Fleur.EmptySequence; + pos = 1; + if (next.nodeType === Fleur.Node.SEQUENCE_NODE) { + last = next.childNodes.length; + subcurr = next.childNodes.shift(); + if (next.childNodes.length === 1) { + next = next.childNodes[0]; + } + } else { + subcurr = next; + next = Fleur.EmptySequence; + last = 1; + } + Fleur.XQueryEngine[children[0][0]]({ + _curr: subcurr, + _next: next, + _last: last, + _pos: pos, + env: ctx.env + }, children[0][1], cb); + return; + } + if (next.nodeType === Fleur.Node.SEQUENCE_NODE) { + subcurr = next.childNodes.shift(); + if (next.childNodes.length === 1) { + next = next.childNodes[0]; + } + } else { + subcurr = next; + next = Fleur.EmptySequence; + } + pos++; + Fleur.XQueryEngine[children[0][0]]({ + _curr: subcurr, + _next: next, + _last: last, + _pos: pos, + env: ctx.env + }, children[0][1], cb); + }; + Fleur.XQueryEngine[children[0][0]]({ + _curr: subcurr, + _next: next, + _last: last, + _pos: pos, + env: ctx.env + }, children[0][1], cb); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/predicateExpr.js b/src/js/fleur.js/XQuery/Instructions/predicateExpr.js index b5b4610..fcf7d7e 100644 --- a/src/js/fleur.js/XQuery/Instructions/predicateExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/predicateExpr.js @@ -1,7 +1,7 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ diff --git a/src/js/fleur.js/XQuery/Instructions/predicates.js b/src/js/fleur.js/XQuery/Instructions/predicates-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/predicates.js rename to src/js/fleur.js/XQuery/Instructions/predicates-BROKEN.js index 5de9ab1..78682c0 100644 --- a/src/js/fleur.js/XQuery/Instructions/predicates.js +++ b/src/js/fleur.js/XQuery/Instructions/predicates-BROKEN.js @@ -1,218 +1,218 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.predicates] = function(ctx, children, callback) { - var next = ctx._next; - var last; - var pos = 1; - var i, l, label; -//console.log("predicates - " + pos + " - " + Fleur.Serializer._serializeNodeToXQuery(next, false, "")); - var result = Fleur.EmptySequence; - var subcurr; - //var seq; - if (next.collabels) { - label = next.collabels[0]; - } - if (next.nodeType === Fleur.Node.SEQUENCE_NODE) { - var seq = new Fleur.Sequence(); - next.childNodes.forEach(function(child) { - if (child.nodeType === Fleur.Node.MULTIDIM_NODE) { - var md = new Fleur.Multidim(); - child.childNodes.forEach(function(subchild) {md.appendChild(subchild);}); - seq.appendChild(md); - } else { - seq.appendChild(child); - } - }); - seq.collabels = next.collabels; - next = seq; - if (next.childNodes[0].nodeType === Fleur.Node.MULTIDIM_NODE) { - last = next.childNodes[0].childNodes.length; - if (last !== 1) { - subcurr = new Fleur.Sequence(); - for (i = 0, l = next.childNodes.length; i < l; i++) { - var subitem = next.childNodes[i].childNodes.shift(); - var multi = new Fleur.Multidim(); - multi.appendChild(subitem); - subcurr.appendChild(multi); - } - subcurr.rowlabels = next.rowlabels; - } else { - subcurr = next; - next = Fleur.EmptySequence; - } - } else { - last = next.childNodes.length; - subcurr = next.childNodes.shift(); - if (next.childNodes.length === 1) { - if (label) { - next.childNodes[0].collabels = next.collabels; - } - next = next.childNodes[0]; - } - } - } else { - subcurr = next; - next = Fleur.EmptySequence; - last = 1; - } - var cb = function(n, eob) { - //console.log("predicates - cb - " + Fleur.Serializer._serializeNodeToXQuery(n, false, "") + (eob ? " - " + (eob === Fleur.XQueryX.predicates ? "predicates" : eob) : "")); - if (eob === Fleur.XQueryX.predicates) { - Fleur.callback(function() {callback(n, Fleur.XQueryX.predicates);}); - return; - } - if (eob === Fleur.XQueryX.lookup) { - if (n !== Fleur.EmptySequence) { - if (result === Fleur.EmptySequence) { - result = n; - } else { - if (result.nodeType !== Fleur.Node.SEQUENCE_NODE) { - var seq = new Fleur.Sequence(); - seq.childNodes = new Fleur.NodeList(); - seq.children = new Fleur.NodeList(); - seq.textContent = ""; - seq.appendChild(result); - result = seq; - } - if (n.nodeType !== Fleur.Node.SEQUENCE_NODE) { - result.appendChild(n); - } else { - n.childNodes.forEach(function(n2) { - result.appendChild(n2); - }); - } - } - } - } else { - if ((n.nodeType === Fleur.Node.SEQUENCE_NODE && n.childNodes.length !== 0) || - (n.nodeType === Fleur.Node.TEXT_NODE && n.schemaTypeInfo === Fleur.Type_boolean && n.data !== "false") || - (n.nodeType === Fleur.Node.TEXT_NODE && n.schemaTypeInfo === Fleur.Type_integer && parseInt(n.data, 10) === pos) || - (n.nodeType === Fleur.Node.TEXT_NODE && n.schemaTypeInfo === Fleur.Type_string && n.data !== "") || - (n.nodeType !== Fleur.Node.SEQUENCE_NODE && n.nodeType !== Fleur.Node.TEXT_NODE)) { - if (result === Fleur.EmptySequence) { - result = subcurr; - } else { - if (result.nodeType !== Fleur.Node.SEQUENCE_NODE) { - var seq = new Fleur.Sequence(); - seq.childNodes = new Fleur.NodeList(); - seq.children = new Fleur.NodeList(); - seq.textContent = ""; - seq.appendChild(result); - result = seq; - } - result.appendChild(subcurr); - } - } - } - if (next === Fleur.EmptySequence) { - if (children.length === 1 || result === Fleur.EmptySequence) { - Fleur.callback(function() {callback(result, Fleur.XQueryX.predicates);}); - return; - } - children.shift(); - next = result; - result = Fleur.EmptySequence; - pos = 1; - if (next.collabels) { - label = next.collabels[0]; - } - if (next !== Fleur.EmptySequence && next.nodeType === Fleur.Node.SEQUENCE_NODE) { - if (next.childNodes[0].nodeType === Fleur.Node.MULTIDIM_NODE) { - if (next.childNodes[0].childNodes.length !== 1) { - subcurr = new Fleur.Sequence(); - for (i = 0, l = next.childNodes.length; i < l; i++) { - var subitem = next.childNodes[i].childNodes.shift(); - var multi = new Fleur.Multidim(); - multi.appendChild(subitem); - subcurr.appendChild(multi); - } - subcurr.rowlabels = next.rowlabels; - } else { - subcurr = next; - next = Fleur.EmptySequence; - } - } else { - last = next.childNodes.length; - subcurr = next.childNodes.shift(); - if (next.childNodes.length === 1) { - if (label) { - next.childNodes[0].collabels = next.collabels; - } - next = next.childNodes[0]; - } - } - } else { - subcurr = next; - next = Fleur.EmptySequence; - last = 1; - } - Fleur.XQueryEngine[children[0][0]]({ - _curr: subcurr, - _next: next, - _last: last, - _pos: pos, - _label: label, - env: ctx.env - }, children[0][1], cb); - return; - } - if (next.collabels) { - label = next.collabels[pos]; - } - if (next.nodeType === Fleur.Node.SEQUENCE_NODE) { - if (next.childNodes[0].nodeType === Fleur.Node.MULTIDIM_NODE) { - last = next.childNodes[0].childNodes.length; - if (last !== 1) { - subcurr = new Fleur.Sequence(); - for (i = 0, l = next.childNodes.length; i < l; i++) { - var subitem = next.childNodes[i].childNodes.shift(); - var multi = new Fleur.Multidim(); - multi.appendChild(subitem); - subcurr.appendChild(multi); - } - subcurr.rowlabels = next.rowlabels; - } else { - subcurr = next; - next = Fleur.EmptySequence; - } - } else { - subcurr = next.childNodes.shift(); - if (next.childNodes.length === 1) { - if (label) { - next.childNodes[0].collabels = next.collabels; - } - next = next.childNodes[0]; - } - } - } else { - subcurr = next; - next = Fleur.EmptySequence; - } - pos++; - Fleur.XQueryEngine[children[0][0]]({ - _curr: subcurr, - _item: ctx._item, - _next: next, - _last: last, - _pos: pos, - _label: label, - env: ctx.env - }, children[0][1], cb); - }; - Fleur.XQueryEngine[children[0][0]]({ - _curr: subcurr, - _item: ctx._item, - _next: next, - _last: last, - _pos: pos, - _label: label, - env: ctx.env - }, children[0][1], cb); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.predicates] = function(ctx, children, callback) { + var next = ctx._next; + var last; + var pos = 1; + var i, l, label; +//console.log("predicates - " + pos + " - " + Fleur.Serializer._serializeNodeToXQuery(next, false, "")); + var result = Fleur.EmptySequence; + var subcurr; + //var seq; + if (next.collabels) { + label = next.collabels[0]; + } + if (next.nodeType === Fleur.Node.SEQUENCE_NODE) { + var seq = new Fleur.Sequence(); + next.childNodes.forEach(function(child) { + if (child.nodeType === Fleur.Node.MULTIDIM_NODE) { + var md = new Fleur.Multidim(); + child.childNodes.forEach(function(subchild) {md.appendChild(subchild);}); + seq.appendChild(md); + } else { + seq.appendChild(child); + } + }); + seq.collabels = next.collabels; + next = seq; + if (next.childNodes[0].nodeType === Fleur.Node.MULTIDIM_NODE) { + last = next.childNodes[0].childNodes.length; + if (last !== 1) { + subcurr = new Fleur.Sequence(); + for (i = 0, l = next.childNodes.length; i < l; i++) { + var subitem = next.childNodes[i].childNodes.shift(); + var multi = new Fleur.Multidim(); + multi.appendChild(subitem); + subcurr.appendChild(multi); + } + subcurr.rowlabels = next.rowlabels; + } else { + subcurr = next; + next = Fleur.EmptySequence; + } + } else { + last = next.childNodes.length; + subcurr = next.childNodes.shift(); + if (next.childNodes.length === 1) { + if (label) { + next.childNodes[0].collabels = next.collabels; + } + next = next.childNodes[0]; + } + } + } else { + subcurr = next; + next = Fleur.EmptySequence; + last = 1; + } + var cb = function(n, eob) { + //console.log("predicates - cb - " + Fleur.Serializer._serializeNodeToXQuery(n, false, "") + (eob ? " - " + (eob === Fleur.XQueryX.predicates ? "predicates" : eob) : "")); + if (eob === Fleur.XQueryX.predicates) { + Fleur.callback(function() {callback(n, Fleur.XQueryX.predicates);}); + return; + } + if (eob === Fleur.XQueryX.lookup) { + if (n !== Fleur.EmptySequence) { + if (result === Fleur.EmptySequence) { + result = n; + } else { + if (result.nodeType !== Fleur.Node.SEQUENCE_NODE) { + var seq = new Fleur.Sequence(); + seq.childNodes = new Fleur.NodeList(); + seq.children = new Fleur.NodeList(); + seq.textContent = ""; + seq.appendChild(result); + result = seq; + } + if (n.nodeType !== Fleur.Node.SEQUENCE_NODE) { + result.appendChild(n); + } else { + n.childNodes.forEach(function(n2) { + result.appendChild(n2); + }); + } + } + } + } else { + if ((n.nodeType === Fleur.Node.SEQUENCE_NODE && n.childNodes.length !== 0) || + (n.nodeType === Fleur.Node.TEXT_NODE && n.schemaTypeInfo === Fleur.Type_boolean && n.data !== "false") || + (n.nodeType === Fleur.Node.TEXT_NODE && n.schemaTypeInfo === Fleur.Type_integer && parseInt(n.data, 10) === pos) || + (n.nodeType === Fleur.Node.TEXT_NODE && n.schemaTypeInfo === Fleur.Type_string && n.data !== "") || + (n.nodeType !== Fleur.Node.SEQUENCE_NODE && n.nodeType !== Fleur.Node.TEXT_NODE)) { + if (result === Fleur.EmptySequence) { + result = subcurr; + } else { + if (result.nodeType !== Fleur.Node.SEQUENCE_NODE) { + var seq = new Fleur.Sequence(); + seq.childNodes = new Fleur.NodeList(); + seq.children = new Fleur.NodeList(); + seq.textContent = ""; + seq.appendChild(result); + result = seq; + } + result.appendChild(subcurr); + } + } + } + if (next === Fleur.EmptySequence) { + if (children.length === 1 || result === Fleur.EmptySequence) { + Fleur.callback(function() {callback(result, Fleur.XQueryX.predicates);}); + return; + } + children.shift(); + next = result; + result = Fleur.EmptySequence; + pos = 1; + if (next.collabels) { + label = next.collabels[0]; + } + if (next !== Fleur.EmptySequence && next.nodeType === Fleur.Node.SEQUENCE_NODE) { + if (next.childNodes[0].nodeType === Fleur.Node.MULTIDIM_NODE) { + if (next.childNodes[0].childNodes.length !== 1) { + subcurr = new Fleur.Sequence(); + for (i = 0, l = next.childNodes.length; i < l; i++) { + var subitem = next.childNodes[i].childNodes.shift(); + var multi = new Fleur.Multidim(); + multi.appendChild(subitem); + subcurr.appendChild(multi); + } + subcurr.rowlabels = next.rowlabels; + } else { + subcurr = next; + next = Fleur.EmptySequence; + } + } else { + last = next.childNodes.length; + subcurr = next.childNodes.shift(); + if (next.childNodes.length === 1) { + if (label) { + next.childNodes[0].collabels = next.collabels; + } + next = next.childNodes[0]; + } + } + } else { + subcurr = next; + next = Fleur.EmptySequence; + last = 1; + } + Fleur.XQueryEngine[children[0][0]]({ + _curr: subcurr, + _next: next, + _last: last, + _pos: pos, + _label: label, + env: ctx.env + }, children[0][1], cb); + return; + } + if (next.collabels) { + label = next.collabels[pos]; + } + if (next.nodeType === Fleur.Node.SEQUENCE_NODE) { + if (next.childNodes[0].nodeType === Fleur.Node.MULTIDIM_NODE) { + last = next.childNodes[0].childNodes.length; + if (last !== 1) { + subcurr = new Fleur.Sequence(); + for (i = 0, l = next.childNodes.length; i < l; i++) { + var subitem = next.childNodes[i].childNodes.shift(); + var multi = new Fleur.Multidim(); + multi.appendChild(subitem); + subcurr.appendChild(multi); + } + subcurr.rowlabels = next.rowlabels; + } else { + subcurr = next; + next = Fleur.EmptySequence; + } + } else { + subcurr = next.childNodes.shift(); + if (next.childNodes.length === 1) { + if (label) { + next.childNodes[0].collabels = next.collabels; + } + next = next.childNodes[0]; + } + } + } else { + subcurr = next; + next = Fleur.EmptySequence; + } + pos++; + Fleur.XQueryEngine[children[0][0]]({ + _curr: subcurr, + _item: ctx._item, + _next: next, + _last: last, + _pos: pos, + _label: label, + env: ctx.env + }, children[0][1], cb); + }; + Fleur.XQueryEngine[children[0][0]]({ + _curr: subcurr, + _item: ctx._item, + _next: next, + _last: last, + _pos: pos, + _label: label, + env: ctx.env + }, children[0][1], cb); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/project.json b/src/js/fleur.js/XQuery/Instructions/project.json index ca56ca5..c1655ed 100644 --- a/src/js/fleur.js/XQuery/Instructions/project.json +++ b/src/js/fleur.js/XQuery/Instructions/project.json @@ -18,6 +18,7 @@ "computedEntryConstructor.js", "computedPIConstructor.js", "computedTextConstructor.js", + "constantExpr.js", "contextItemExpr.js", "countClause.js", "decimalConstantExpr.js", @@ -64,6 +65,8 @@ "optionDecl.js", "orderByClause.js", "orderBySpec.js", + "param.js", + "paramList.js", "pathExpr.js", "piTest.js", "predicate.js", @@ -90,6 +93,7 @@ "varDecl.js", "varRef.js", "version.js", + "versionDecl.js", "Wildcard.js", "whereClause.js", "xpathAxis.js", diff --git a/src/js/fleur.js/XQuery/Instructions/prolog.js b/src/js/fleur.js/XQuery/Instructions/prolog.js index 6725e80..0b024e8 100644 --- a/src/js/fleur.js/XQuery/Instructions/prolog.js +++ b/src/js/fleur.js/XQuery/Instructions/prolog.js @@ -1,12 +1,24 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ +Fleur.Transpiler.prototype.xqx_prolog = function(children) { + const transp = this; + let lastseqtype; + let r = children.reduce((inst, child) => { + const g = transp.gen(child); + lastseqtype = g.sequenceType; + return inst + g.inst; + }, ""); + return { + inst: r, + sequenceType: lastseqtype + }; +}; +/* Fleur.XQueryEngine[Fleur.XQueryX.prolog] = function(ctx, children, callback) { Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], function(n) { if (children.length > 1) { @@ -16,4 +28,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.prolog] = function(ctx, children, callback) { Fleur.callback(function() {callback(n);}); } }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/quantifiedExpr.js b/src/js/fleur.js/XQuery/Instructions/quantifiedExpr-BROKEN.js similarity index 96% rename from src/js/fleur.js/XQuery/Instructions/quantifiedExpr.js rename to src/js/fleur.js/XQuery/Instructions/quantifiedExpr-BROKEN.js index 6867bc9..d21abc5 100644 --- a/src/js/fleur.js/XQuery/Instructions/quantifiedExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/quantifiedExpr-BROKEN.js @@ -1,39 +1,39 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.quantifiedExpr] = function(ctx, children, callback) { - var i = 1; - var prevvarres; - var resarr; - var checkvalue = children[0][1][0] === "some"; - var cb = function(n, empty) { - if (n.schemaTypeInfo === Fleur.Type_error) { - ctx.env.varresolver = prevvarres; - Fleur.callback(function() {callback(n);}); - return; - } - if (empty) { - var result = new Fleur.Text(); - result.schemaTypeInfo = Fleur.Type_boolean; - result.data = String(!checkvalue); - Fleur.callback(function() {callback(result);}); - return; - } - i++; - if (i === children.length) { - ctx.env.varresolver = prevvarres; - Fleur.callback(function() {callback(n);}); - return; - } - Fleur.XQueryEngine[children[i][0]](ctx, children[i][1], cb, resarr, checkvalue); - }; - prevvarres = ctx.env.varresolver; - resarr = [new Fleur.varMgr([], prevvarres)]; - Fleur.XQueryEngine[children[1][0]](ctx, children[1][1], cb, resarr); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.quantifiedExpr] = function(ctx, children, callback) { + var i = 1; + var prevvarres; + var resarr; + var checkvalue = children[0][1][0] === "some"; + var cb = function(n, empty) { + if (n.schemaTypeInfo === Fleur.Type_error) { + ctx.env.varresolver = prevvarres; + Fleur.callback(function() {callback(n);}); + return; + } + if (empty) { + var result = new Fleur.Text(); + result.schemaTypeInfo = Fleur.Type_boolean; + result.data = String(!checkvalue); + Fleur.callback(function() {callback(result);}); + return; + } + i++; + if (i === children.length) { + ctx.env.varresolver = prevvarres; + Fleur.callback(function() {callback(n);}); + return; + } + Fleur.XQueryEngine[children[i][0]](ctx, children[i][1], cb, resarr, checkvalue); + }; + prevvarres = ctx.env.varresolver; + resarr = [new Fleur.varMgr([], prevvarres)]; + Fleur.XQueryEngine[children[1][0]](ctx, children[1][1], cb, resarr); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/quantifiedExprInClause.js b/src/js/fleur.js/XQuery/Instructions/quantifiedExprInClause-BROKEN.js similarity index 96% rename from src/js/fleur.js/XQuery/Instructions/quantifiedExprInClause.js rename to src/js/fleur.js/XQuery/Instructions/quantifiedExprInClause-BROKEN.js index 2ec49b4..7bdb7b6 100644 --- a/src/js/fleur.js/XQuery/Instructions/quantifiedExprInClause.js +++ b/src/js/fleur.js/XQuery/Instructions/quantifiedExprInClause-BROKEN.js @@ -1,44 +1,44 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.quantifiedExprInClause] = function(ctx, children, callback, resarr) { - var i = 0; - var varname = children[0][1][0][1][0]; - ctx.env.varresolver = resarr[0]; - var cb = function(n) { - if (n === Fleur.EmptySequence) { - resarr.splice(i, 1); - if (resarr.length === 0) { - Fleur.callback(function() {callback(Fleur.EmptySequence, true);}); - return; - } - } else if (n.nodeType !== Fleur.Node.SEQUENCE_NODE) { - resarr[i].set(ctx, "", varname, n); - i++; - } else { - n.childNodes.forEach(function(e, ie) { - if (ie === 0) { - resarr[i].set(ctx, "", varname, e); - } else { - var newres = resarr[i].clone(); - newres.set(ctx, "", varname, e); - resarr.splice(i + ie, 0, newres); - } - }); - i += n.childNodes.length; - } - if (i !== resarr.length) { - ctx.env.varresolver = resarr[i]; - Fleur.XQueryEngine[children[1][1][0][0]](ctx, children[1][1][0][1], cb); - } else { - Fleur.callback(function() {callback(Fleur.EmptySequence);}); - } - }; - Fleur.XQueryEngine[children[1][1][0][0]](ctx, children[1][1][0][1], cb); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.quantifiedExprInClause] = function(ctx, children, callback, resarr) { + var i = 0; + var varname = children[0][1][0][1][0]; + ctx.env.varresolver = resarr[0]; + var cb = function(n) { + if (n === Fleur.EmptySequence) { + resarr.splice(i, 1); + if (resarr.length === 0) { + Fleur.callback(function() {callback(Fleur.EmptySequence, true);}); + return; + } + } else if (n.nodeType !== Fleur.Node.SEQUENCE_NODE) { + resarr[i].set(ctx, "", varname, n); + i++; + } else { + n.childNodes.forEach(function(e, ie) { + if (ie === 0) { + resarr[i].set(ctx, "", varname, e); + } else { + var newres = resarr[i].clone(); + newres.set(ctx, "", varname, e); + resarr.splice(i + ie, 0, newres); + } + }); + i += n.childNodes.length; + } + if (i !== resarr.length) { + ctx.env.varresolver = resarr[i]; + Fleur.XQueryEngine[children[1][1][0][0]](ctx, children[1][1][0][1], cb); + } else { + Fleur.callback(function() {callback(Fleur.EmptySequence);}); + } + }; + Fleur.XQueryEngine[children[1][1][0][0]](ctx, children[1][1][0][1], cb); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/queryBody.js b/src/js/fleur.js/XQuery/Instructions/queryBody.js index 65796e1..25f9e24 100644 --- a/src/js/fleur.js/XQuery/Instructions/queryBody.js +++ b/src/js/fleur.js/XQuery/Instructions/queryBody.js @@ -1,12 +1,14 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ +Fleur.Transpiler.prototype.xqx_queryBody = function(children) { + return this.gen(children[0]); +}; +/* Fleur.XQueryEngine[Fleur.XQueryX.queryBody] = function(ctx, children, callback) { Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], function(n) { if (children.length > 1) { @@ -15,4 +17,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.queryBody] = function(ctx, children, callback) Fleur.callback(function() {callback(n);}); } }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/rangeSequenceExpr.js b/src/js/fleur.js/XQuery/Instructions/rangeSequenceExpr.js index 098b2de..4ef7791 100644 --- a/src/js/fleur.js/XQuery/Instructions/rangeSequenceExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/rangeSequenceExpr.js @@ -1,14 +1,15 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_rangeSequenceExpr = function(children) { - let r = this.gen(children[0][1][0], Fleur.Type_integer).inst + this.gen(children[1][1][0], Fleur.Type_integer).inst + this.inst("xqx_rangeSequenceExpr()").inst; + let r = this.gen(children[0][1][0], Fleur.SequenceType_integer_01).inst + this.gen(children[1][1][0], Fleur.SequenceType_integer_01).inst + this.inst("xqx_rangeSequenceExpr()").inst; return { - inst: r + inst: r, + sequenceType: Fleur.SequenceType_integer_0n }; }; @@ -40,7 +41,7 @@ Fleur.Context.prototype.xqx_rangeSequenceExpr = function() { this.item.appendChild(i); op1[1]++; } -} + } return this; }; diff --git a/src/js/fleur.js/XQuery/Instructions/replaceExpr.js b/src/js/fleur.js/XQuery/Instructions/replaceExpr-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/replaceExpr.js rename to src/js/fleur.js/XQuery/Instructions/replaceExpr-BROKEN.js index 279eb05..5262ca7 100644 --- a/src/js/fleur.js/XQuery/Instructions/replaceExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/replaceExpr-BROKEN.js @@ -1,72 +1,72 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.replaceExpr] = function(ctx, children, callback) { - var replaceValue = children[0][0] === Fleur.XQueryX.replaceValue ? 1 : 0; - Fleur.XQueryEngine[children[replaceValue][1][0][0]](ctx, children[replaceValue][1][0][1], function(target) { - if (target !== Fleur.EmptySequence) { - Fleur.XQueryEngine[children[replaceValue + 1][1][0][0]](ctx, children[replaceValue + 1][1][0][1], function(replacement) { - if (replaceValue === 1) { - var a = Fleur.Atomize(replacement); - target.textContent = a.data; - target.firstChild.schemaTypeInfo = a.schemaTypeInfo; - } else if (replacement === Fleur.EmptySequence) { - if (target.nodeType === Fleur.Node.ATTRIBUTE_NODE) { - target.ownerElement.removeAttributeNode(target); - } else if (target.nodeType === Fleur.Node.ENTRY_NODE) { - target.ownerMap.removeEntryNode(target); - } else { - target.parentElement.removeChild(target); - } - } else { - var parelt = target.nodeType === Fleur.Node.ATTRIBUTE_NODE ? target.ownerElement : target.nodeType === Fleur.Node.ENTRY_NODE ? target.ownerMap : target.nodeType === Fleur.Node.MAP_NODE ? target.parentNode : target.parentElement || target.parentNode; - var n2; - if (target.ownerDocument) { - if (target instanceof Fleur.Node) { - n2 = target.ownerDocument.importNode(replacement.nodeType === Fleur.Node.SEQUENCE_NODE ? replacement.firstChild : replacement, true); - } else { - n2 = Fleur.Document.docImportNode(target.ownerDocument, replacement.nodeType === Fleur.Node.SEQUENCE_NODE ? replacement.firstChild : replacement, true); - } - } else { - n2 = replacement; - } - if (target.nodeType === Fleur.Node.ATTRIBUTE_NODE) { - parelt.removeAttributeNode(target); - parelt.setAttributeNode(n2); - } else if (target.nodeType === Fleur.Node.ENTRY_NODE) { - parelt.removeEntryNode(target); - parelt.setEntryNode(n2); - } else { - parelt.replaceChild(n2, target); - } - if (replacement.nodeType === Fleur.Node.SEQUENCE_NODE) { - var n3; - for (var i = 1, l = replacement.childNodes.length; i < l; i++) { - if (parelt instanceof Fleur.Node) { - n3 = parelt.ownerDocument.importNode(replacement.childNodes[i], true); - } else { - n3 = Fleur.Document.docImportNode(parelt.ownerDocument, replacement.childNodes[i], true); - } - if (n3.nodeType === Fleur.Node.ATTRIBUTE_NODE) { - parelt.setAttributeNode(n3); - } else if (n3.nodeType === Fleur.Node.ENTRY_NODE) { - parelt.setEntryNode(n3); - } else { - parelt.insertBefore(n3, n2.followingSibling); - } - } - } - } - Fleur.callback(function() {callback(Fleur.EmptySequence);}); - }); - return; - } - Fleur.callback(function() {callback(Fleur.EmptySequence);}); - }); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.replaceExpr] = function(ctx, children, callback) { + var replaceValue = children[0][0] === Fleur.XQueryX.replaceValue ? 1 : 0; + Fleur.XQueryEngine[children[replaceValue][1][0][0]](ctx, children[replaceValue][1][0][1], function(target) { + if (target !== Fleur.EmptySequence) { + Fleur.XQueryEngine[children[replaceValue + 1][1][0][0]](ctx, children[replaceValue + 1][1][0][1], function(replacement) { + if (replaceValue === 1) { + var a = Fleur.Atomize(replacement); + target.textContent = a.data; + target.firstChild.schemaTypeInfo = a.schemaTypeInfo; + } else if (replacement === Fleur.EmptySequence) { + if (target.nodeType === Fleur.Node.ATTRIBUTE_NODE) { + target.ownerElement.removeAttributeNode(target); + } else if (target.nodeType === Fleur.Node.ENTRY_NODE) { + target.ownerMap.removeEntryNode(target); + } else { + target.parentElement.removeChild(target); + } + } else { + var parelt = target.nodeType === Fleur.Node.ATTRIBUTE_NODE ? target.ownerElement : target.nodeType === Fleur.Node.ENTRY_NODE ? target.ownerMap : target.nodeType === Fleur.Node.MAP_NODE ? target.parentNode : target.parentElement || target.parentNode; + var n2; + if (target.ownerDocument) { + if (target instanceof Fleur.Node) { + n2 = target.ownerDocument.importNode(replacement.nodeType === Fleur.Node.SEQUENCE_NODE ? replacement.firstChild : replacement, true); + } else { + n2 = Fleur.Document.docImportNode(target.ownerDocument, replacement.nodeType === Fleur.Node.SEQUENCE_NODE ? replacement.firstChild : replacement, true); + } + } else { + n2 = replacement; + } + if (target.nodeType === Fleur.Node.ATTRIBUTE_NODE) { + parelt.removeAttributeNode(target); + parelt.setAttributeNode(n2); + } else if (target.nodeType === Fleur.Node.ENTRY_NODE) { + parelt.removeEntryNode(target); + parelt.setEntryNode(n2); + } else { + parelt.replaceChild(n2, target); + } + if (replacement.nodeType === Fleur.Node.SEQUENCE_NODE) { + var n3; + for (var i = 1, l = replacement.childNodes.length; i < l; i++) { + if (parelt instanceof Fleur.Node) { + n3 = parelt.ownerDocument.importNode(replacement.childNodes[i], true); + } else { + n3 = Fleur.Document.docImportNode(parelt.ownerDocument, replacement.childNodes[i], true); + } + if (n3.nodeType === Fleur.Node.ATTRIBUTE_NODE) { + parelt.setAttributeNode(n3); + } else if (n3.nodeType === Fleur.Node.ENTRY_NODE) { + parelt.setEntryNode(n3); + } else { + parelt.insertBefore(n3, n2.followingSibling); + } + } + } + } + Fleur.callback(function() {callback(Fleur.EmptySequence);}); + }); + return; + } + Fleur.callback(function() {callback(Fleur.EmptySequence);}); + }); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/returnClause.js b/src/js/fleur.js/XQuery/Instructions/returnClause.js index 4ba7d65..54a0da4 100644 --- a/src/js/fleur.js/XQuery/Instructions/returnClause.js +++ b/src/js/fleur.js/XQuery/Instructions/returnClause.js @@ -1,21 +1,23 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Context.prototype.xqx_returnClause = function(fn) { let seq = new Fleur.Sequence(); + const thisisit = this; this.tuple.forEach(vr => { - this.rs.varresolver = vr; - fn(this); - seq.appendChild(this.item); + thisisit.rs.varresolver = vr; + fn(thisisit); + seq.appendChild(thisisit.item); }); this.item = seq.singleton(); + this.rs.varresolver = this.rs.varresolver.previous; return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.returnClause] = function(ctx, children, callback, resarr) { //console.log("returnClause"); var i = 0; @@ -70,4 +72,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.returnClause] = function(ctx, children, callbac } }; Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], cb); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/rootExpr.js b/src/js/fleur.js/XQuery/Instructions/rootExpr.js index d073e6d..7946abe 100644 --- a/src/js/fleur.js/XQuery/Instructions/rootExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/rootExpr.js @@ -1,8 +1,7 @@ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ diff --git a/src/js/fleur.js/XQuery/Instructions/schemaLocation.js b/src/js/fleur.js/XQuery/Instructions/schemaLocation-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/schemaLocation.js rename to src/js/fleur.js/XQuery/Instructions/schemaLocation-BROKEN.js index 0ee3703..42b3134 100644 --- a/src/js/fleur.js/XQuery/Instructions/schemaLocation.js +++ b/src/js/fleur.js/XQuery/Instructions/schemaLocation-BROKEN.js @@ -1,12 +1,12 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.schemaLocation] = function(ctx, children, callback) { - Fleur.callback(function() {callback(ctx._result);}); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.schemaLocation] = function(ctx, children, callback) { + Fleur.callback(function() {callback(ctx._result);}); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/sequenceExpr.js b/src/js/fleur.js/XQuery/Instructions/sequenceExpr.js index cb0349b..191dedc 100644 --- a/src/js/fleur.js/XQuery/Instructions/sequenceExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/sequenceExpr.js @@ -1,19 +1,30 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_sequenceExpr = function(children, expectedType) { + const expectedItemType = expectedType ? new Fleur.SequenceType(expectedType.nodeType, expectedType.schemaTypeInfo, "*") : null; let items = ""; + let resultSeqType = null; for (let i = 0, l = children.length; i < l; i++) { - items += this.gen(children[i], expectedType).inst; + const itemgen = this.gen(children[i], expectedItemType); + items += itemgen.inst; + if (!resultSeqType) { + resultSeqType = new Fleur.SequenceType(itemgen.sequenceType.nodeType, itemgen.sequenceType.schemaTypeInfo, "+"); + } else { + resultSeqType.schemaTypeInfo = resultSeqType.schemaTypeInfo.aggregate(itemgen.sequenceType.schemaTypeInfo); + } } - return this.inst("xqx_sequenceExpr(" + String(children.length) + ")", false, - items !== "" ? expectedType : {occurrence: "0"}, - items); + return { + inst: this.inst("xqx_sequenceExpr(" + String(children.length) + ")", false, items !== "" ? expectedType : {occurrence: "0"}, items).inst, + sequenceType: children.length === 0 ? Fleur.SequenceType_empty_sequence : resultSeqType, + value: children.length === 0 ? new Fleur.Sequence() : null + }; }; + Fleur.Context.prototype.xqx_sequenceExpr = function(itemlen) { const items = []; if (itemlen === 0) { @@ -29,7 +40,7 @@ Fleur.Context.prototype.xqx_sequenceExpr = function(itemlen) { items.forEach(item => this.item.appendChild(item)); return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.sequenceExpr] = function(ctx, children, callback, depth) { if (!depth) { depth = 0; @@ -99,4 +110,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.sequenceExpr] = function(ctx, children, callbac Fleur.XQueryEngine[Fleur.XQueryX.sequenceExpr](ctx, children.slice(1), cb, depth); }; Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], cb, children[0][0] === Fleur.XQueryX.sequenceExpr ? depth + 1 : depth); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/simpleMapExpr.js b/src/js/fleur.js/XQuery/Instructions/simpleMapExpr.js index b9dbb31..bc146c6 100644 --- a/src/js/fleur.js/XQuery/Instructions/simpleMapExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/simpleMapExpr.js @@ -1,7 +1,7 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ @@ -12,11 +12,12 @@ Fleur.Transpiler.prototype.xqx_simpleMapExpr = function(children) { this.async = false; let result = this.funcdef(children[1][1].length === 1 && children[1][1][0][1][0][0] === Fleur.XQueryX.filterExpr ? children[1][1][0][1][0][1][0] : children[1]); this.indent = previndent; - result = "\n" + this.indent + (this.async ? "await " : "") + this.ctxvarname + ".xqx_simpleMapExpr" + (this.async ? "_async" : "") + "(" + result; + result = "\n" + this.indent + (this.async ? "await " : "") + this.ctxvarname + ".xqx_simpleMapExpr" + (this.async ? "_async" : "") + "(" + result.inst; this.async = this.async || prevasync; let r = this.gen(children[0][1].length === 1 && children[0][1][0][1][0][0] === Fleur.XQueryX.filterExpr ? children[0][1][0][1][0][1][0] : children[0]).inst + result + "\n" + this.indent + ");"; return { - inst: r + inst: r, + sequenceType: Fleur.SequenceType_item_0n }; }; diff --git a/src/js/fleur.js/XQuery/Instructions/stepExpr.js b/src/js/fleur.js/XQuery/Instructions/stepExpr.js index 5b9c623..aa319f9 100644 --- a/src/js/fleur.js/XQuery/Instructions/stepExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/stepExpr.js @@ -1,8 +1,7 @@ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ diff --git a/src/js/fleur.js/XQuery/Instructions/stringConstantExpr.js b/src/js/fleur.js/XQuery/Instructions/stringConstantExpr.js index 9a9a9ec..fccb037 100644 --- a/src/js/fleur.js/XQuery/Instructions/stringConstantExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/stringConstantExpr.js @@ -1,22 +1,26 @@ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.Transpiler.prototype.xqx_stringConstantExpr = function(children, expectedType) { - if (expectedType && Fleur.numericTypes.indexOf(expectedType.schemaTypeInfo) !== -1) { - Fleur.XQueryError_xqt("FORG00001", null, "Wrong argument type"); - } - return { - inst: this.inst("xqx_stringConstantExpr('" + (children[0][1][0] || "").replace(/\'/g, "\\'") + "')").inst, - sequenceType: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: 1 - } +Fleur.Transpiler.prototype.xqx_stringConstantExpr = function(children, expectedSequenceType) { + const issubtype = expectedSequenceType && expectedSequenceType.schemaTypeInfo !== Fleur.Type_string && expectedSequenceType.schemaTypeInfo.as(Fleur.Type_string); + const subtype = issubtype ? expectedSequenceType.schemaTypeInfo : Fleur.Type_string; + const item = new Fleur.Text(); + item.schemaTypeInfo = subtype; + try { + const canon = subtype.canonicalize(children[0][1][0] || ""); + item.appendData(canon); + return { + inst: this.inst((issubtype ? "xqx_constantExpr(Fleur.Type_" + expectedSequenceType.schemaTypeInfo.typeName + ", '" : "xqx_stringConstantExpr('") + canon.replace(/\'/g, "\\'") .replace(/\n/g, "\\n") + "')", false).inst, + sequenceType: new Fleur.SequenceType(Fleur.Node.TEXT_NODE, subtype, "1"), + value: item + }; + } catch (e) { + item.appendData(children[0][1][0] || ""); + Fleur.XQueryError_xqt(e.code === Fleur.DOMException.VALIDATION_ERR ? "FORG0001" : "FODT0001", null, "Wrong argument for implicit xs:" + expectedSequenceType.schemaTypeInfo.typeName + "#1", "", item); } }; @@ -28,10 +32,11 @@ Fleur.Context.prototype.xqx_stringConstantExpr = function(arg) { this.item = item; return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.stringConstantExpr] = function(ctx, children, callback) { var n = new Fleur.Text(); n.appendData(children[0][1][0] || ""); n.schemaTypeInfo = Fleur.Type_string; Fleur.callback(function() {callback(n);}); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/textTest.js b/src/js/fleur.js/XQuery/Instructions/textTest.js index abf1dd3..441f7b5 100644 --- a/src/js/fleur.js/XQuery/Instructions/textTest.js +++ b/src/js/fleur.js/XQuery/Instructions/textTest.js @@ -1,8 +1,7 @@ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ diff --git a/src/js/fleur.js/XQuery/Instructions/treatExpr.js b/src/js/fleur.js/XQuery/Instructions/treatExpr-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/treatExpr.js rename to src/js/fleur.js/XQuery/Instructions/treatExpr-BROKEN.js index 2862cf1..78bce16 100644 --- a/src/js/fleur.js/XQuery/Instructions/treatExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/treatExpr-BROKEN.js @@ -1,57 +1,57 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.treatExpr] = function(ctx, children, callback) { - Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { - var seqtype = children[1][1]; - var occurrence = "1"; - var e = Fleur.error(ctx, "XPDY0050"); - if (seqtype.length === 2) { - occurrence = seqtype[1][1][0]; - } - if (n !== Fleur.EmptySequence) { - if (n.nodeType === Fleur.Node.SEQUENCE_NODE) { - if (occurrence === "1" || occurrence === "?") { - Fleur.callback(function() {callback(e);}); - } else { - var i = 0; - var l = n.childNodes.length; - var cb = function(n2) { - if (n2 === Fleur.EmptySequence) { - Fleur.callback(function() {callback(e);}); - return; - } - i++; - if (i === l) { - Fleur.callback(function() {callback(n);}); - return; - } - Fleur.XQueryEngine[seqtype[0][0]]({ - _curr: n.childNodes[i], - env: ctx.env - }, seqtype[0][1], cb); - }; - Fleur.XQueryEngine[seqtype[0][0]]({ - _curr: n.childNodes[i], - env: ctx.env - }, seqtype[0][1], cb); - } - } else { - Fleur.XQueryEngine[seqtype[0][0]]({ - _curr: n, - env: ctx.env - }, seqtype[0][1], function(n2) { - Fleur.callback(function() {callback(n2 !== Fleur.EmptySequence ? n : e);}); - }); - } - } else if (occurrence === "1" || occurrence === "+") { - Fleur.callback(function() {callback(e);}); - } - }); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.treatExpr] = function(ctx, children, callback) { + Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { + var seqtype = children[1][1]; + var occurrence = "1"; + var e = Fleur.error(ctx, "XPDY0050"); + if (seqtype.length === 2) { + occurrence = seqtype[1][1][0]; + } + if (n !== Fleur.EmptySequence) { + if (n.nodeType === Fleur.Node.SEQUENCE_NODE) { + if (occurrence === "1" || occurrence === "?") { + Fleur.callback(function() {callback(e);}); + } else { + var i = 0; + var l = n.childNodes.length; + var cb = function(n2) { + if (n2 === Fleur.EmptySequence) { + Fleur.callback(function() {callback(e);}); + return; + } + i++; + if (i === l) { + Fleur.callback(function() {callback(n);}); + return; + } + Fleur.XQueryEngine[seqtype[0][0]]({ + _curr: n.childNodes[i], + env: ctx.env + }, seqtype[0][1], cb); + }; + Fleur.XQueryEngine[seqtype[0][0]]({ + _curr: n.childNodes[i], + env: ctx.env + }, seqtype[0][1], cb); + } + } else { + Fleur.XQueryEngine[seqtype[0][0]]({ + _curr: n, + env: ctx.env + }, seqtype[0][1], function(n2) { + Fleur.callback(function() {callback(n2 !== Fleur.EmptySequence ? n : e);}); + }); + } + } else if (occurrence === "1" || occurrence === "+") { + Fleur.callback(function() {callback(e);}); + } + }); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/tryCatchExpr.js b/src/js/fleur.js/XQuery/Instructions/tryCatchExpr-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/tryCatchExpr.js rename to src/js/fleur.js/XQuery/Instructions/tryCatchExpr-BROKEN.js index be6a636..42029dc 100644 --- a/src/js/fleur.js/XQuery/Instructions/tryCatchExpr.js +++ b/src/js/fleur.js/XQuery/Instructions/tryCatchExpr-BROKEN.js @@ -1,59 +1,59 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.tryCatchExpr] = function(ctx, children, callback) { - Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { - if (n && n.schemaTypeInfo === Fleur.Type_error) { - for (var i = 1, l = children.length; i < l ; i++) { - for (var j = 0, l2 = children[i][1][0][1].length; j < l2 ; j++) { - var ctest = children[i][1][0][1][j]; - var cok = false; - if (ctest[0] === Fleur.XQueryX.Wildcard) { - cok = true; - if (ctest[1][0]) { - if (ctest[1][0][0] === Fleur.XQueryX.star && ctest[1][1][0] === Fleur.XQueryX.NCName) { - cok = n.localName === ctest[1][1][1][0]; - } - } - } else { - cok = ctest[1][0] === n.localName; - var nsURI; - if (ctest[1][1].length === 1) { - nsURI = ""; - } else { - nsURI = ctest[1][1][1][0]; - } - var currURI = n.namespaceURI || null; - var lookupURI = ctx.env.nsresolver.lookupNamespaceURI(nsURI) || null; - if (currURI !== lookupURI && currURI !== "http://www.w3.org/1999/xhtml") { - cok = false; - } - } - if (cok) { - var errcode = new Fleur.Text(); - errcode.data = n.localName; - errcode.schemaTypeInfo = Fleur.Type_string; - ctx.env.varresolver.set(ctx, "http://www.w3.org/2005/xqt-errors", "code", errcode); - var errdescription = new Fleur.Text(); - errdescription.data = n.data; - errdescription.schemaTypeInfo = Fleur.Type_string; - ctx.env.varresolver.set(ctx, "http://www.w3.org/2005/xqt-errors", "description", errdescription); - Fleur.XQueryEngine[children[i][1][1][1][0][0]](ctx, children[i][1][1][1][0][1], function(n) { - Fleur.callback(function() {callback(n);}); - }); - return; - } - } - } - Fleur.callback(function() {callback(n);}); - return; - } - Fleur.callback(function() {callback(n);}); - }); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.tryCatchExpr] = function(ctx, children, callback) { + Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { + if (n && n.schemaTypeInfo === Fleur.Type_error) { + for (var i = 1, l = children.length; i < l ; i++) { + for (var j = 0, l2 = children[i][1][0][1].length; j < l2 ; j++) { + var ctest = children[i][1][0][1][j]; + var cok = false; + if (ctest[0] === Fleur.XQueryX.Wildcard) { + cok = true; + if (ctest[1][0]) { + if (ctest[1][0][0] === Fleur.XQueryX.star && ctest[1][1][0] === Fleur.XQueryX.NCName) { + cok = n.localName === ctest[1][1][1][0]; + } + } + } else { + cok = ctest[1][0] === n.localName; + var nsURI; + if (ctest[1][1].length === 1) { + nsURI = ""; + } else { + nsURI = ctest[1][1][1][0]; + } + var currURI = n.namespaceURI || null; + var lookupURI = ctx.env.nsresolver.lookupNamespaceURI(nsURI) || null; + if (currURI !== lookupURI && currURI !== "http://www.w3.org/1999/xhtml") { + cok = false; + } + } + if (cok) { + var errcode = new Fleur.Text(); + errcode.data = n.localName; + errcode.schemaTypeInfo = Fleur.Type_string; + ctx.env.varresolver.set(ctx, "http://www.w3.org/2005/xqt-errors", "code", errcode); + var errdescription = new Fleur.Text(); + errdescription.data = n.data; + errdescription.schemaTypeInfo = Fleur.Type_string; + ctx.env.varresolver.set(ctx, "http://www.w3.org/2005/xqt-errors", "description", errdescription); + Fleur.XQueryEngine[children[i][1][1][1][0][0]](ctx, children[i][1][1][1][0][1], function(n) { + Fleur.callback(function() {callback(n);}); + }); + return; + } + } + } + Fleur.callback(function() {callback(n);}); + return; + } + Fleur.callback(function() {callback(n);}); + }); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/unaryLookup.js b/src/js/fleur.js/XQuery/Instructions/unaryLookup-BROKEN.js similarity index 97% rename from src/js/fleur.js/XQuery/Instructions/unaryLookup.js rename to src/js/fleur.js/XQuery/Instructions/unaryLookup-BROKEN.js index 894b43b..e3e1029 100644 --- a/src/js/fleur.js/XQuery/Instructions/unaryLookup.js +++ b/src/js/fleur.js/XQuery/Instructions/unaryLookup-BROKEN.js @@ -1,12 +1,12 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.unaryLookup] = function(ctx, children, callback) { - Fleur.XQueryEngine.lookups(ctx, children, callback, Fleur.XQueryX.unaryLookup); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.unaryLookup] = function(ctx, children, callback) { + Fleur.XQueryEngine.lookups(ctx, children, callback, Fleur.XQueryX.unaryLookup); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/uri.js b/src/js/fleur.js/XQuery/Instructions/uri-BROKEN.js similarity index 96% rename from src/js/fleur.js/XQuery/Instructions/uri.js rename to src/js/fleur.js/XQuery/Instructions/uri-BROKEN.js index fe0c9b0..7f9e20f 100644 --- a/src/js/fleur.js/XQuery/Instructions/uri.js +++ b/src/js/fleur.js/XQuery/Instructions/uri-BROKEN.js @@ -1,11 +1,11 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.uri] = function(ctx, children) { +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.uri] = function(ctx, children) { }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/varDecl.js b/src/js/fleur.js/XQuery/Instructions/varDecl.js index 84fc881..8d34872 100644 --- a/src/js/fleur.js/XQuery/Instructions/varDecl.js +++ b/src/js/fleur.js/XQuery/Instructions/varDecl.js @@ -1,12 +1,34 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ +Fleur.Transpiler.prototype.xqx_varDecl = function(children) { + let r = ""; + let vstype = Fleur.SequenceType_string_01; + const vname = children[0][1][0]; + const namespaceURI = this.rs.nsresolver.lookupNamespaceURI((children[0][1].length === 2 ? children[0][1][1][1][0] : "")) || ""; + if (children[1][0] !== Fleur.XQueryX.external) { + const vvalue = this.gen(children[1][1][0]); + r = vvalue.inst; + vstype = vvalue.sequenceType; + r += this.inst("xqx_varDecl('" + namespaceURI + "', '" + vname + "')").inst; + } + this.rs.varresolver.set(null, namespaceURI, vname, vstype); + return { + inst: r, + sequenceType: Fleur.SequenceType_empty_sequence + }; +}; + +Fleur.Context.prototype.xqx_varDecl = function(namespaceURI, vname) { + this.rs.varresolver.set(null, namespaceURI, vname, this.item); + this.item = this.itemstack.pop(); + return this; +}; +/* Fleur.XQueryEngine[Fleur.XQueryX.varDecl] = function(ctx, children, callback) { var vname = children[0][1][0]; var uri = ""; @@ -40,4 +62,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.varDecl] = function(ctx, children, callback) { Fleur.callback(function() {callback();}); }); } -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/varRef.js b/src/js/fleur.js/XQuery/Instructions/varRef.js index 4797afb..d1a8e48 100644 --- a/src/js/fleur.js/XQuery/Instructions/varRef.js +++ b/src/js/fleur.js/XQuery/Instructions/varRef.js @@ -1,26 +1,22 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.Transpiler.prototype.xqx_varRef = function(children) { - var nsURI; - if (children[0][1].length === 1) { - nsURI = ""; - } else { - nsURI = children[0][1][1][1][0] + ":"; - } - return this.inst("xqx_varRef('" + children[0][1][0] + "')"); +Fleur.Transpiler.prototype.xqx_varRef = function(children, expectedSequenceType) { + const nsURI = this.rs.nsresolver.lookupNamespaceURI(children[0][1].length === 1 ? "" : children[0][1][1][1][0]) || ""; + const vname = children[0][1][0]; + return this.inst("xqx_varRef('" + nsURI + "', '" + vname + "')", false, expectedSequenceType, null, this.rs.varresolver.get(null, nsURI, vname)); }; -Fleur.Context.prototype.xqx_varRef = function(vname) { +Fleur.Context.prototype.xqx_varRef = function(nsURI, vname) { this.itemstack.push(this.item); - this.item = this.rs.varresolver.get(null, "", vname); + this.item = this.rs.varresolver.get(null, nsURI, vname); return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.varRef] = function(ctx, children, callback) { var nsURI; if (children[0][1].length === 1) { @@ -32,4 +28,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.varRef] = function(ctx, children, callback) { var n = ctx.env.varresolver.get(ctx, lookupURI, children[0][1][0]); //alert(children[0][1][0] + " -> " + n.data); Fleur.callback(function() {callback(n);}); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/version.js b/src/js/fleur.js/XQuery/Instructions/version.js index a93e359..620366c 100644 --- a/src/js/fleur.js/XQuery/Instructions/version.js +++ b/src/js/fleur.js/XQuery/Instructions/version.js @@ -1,11 +1,17 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ +Fleur.Transpiler.prototype.xqx_version = function() { + return { + inst: "", + sequenceType: Fleur.SequenceType_empty_sequence + }; +}; +/* Fleur.XQueryEngine[Fleur.XQueryX.version] = function(ctx, children) { -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/versionDecl.js b/src/js/fleur.js/XQuery/Instructions/versionDecl.js index e35b8d3..0afc09d 100644 --- a/src/js/fleur.js/XQuery/Instructions/versionDecl.js +++ b/src/js/fleur.js/XQuery/Instructions/versionDecl.js @@ -1,11 +1,19 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ +Fleur.Transpiler.prototype.xqx_versionDecl = function(children) { + const transp = this; + const r = children.reduce((inst, child) => inst + transp.gen(child).inst, ""); + return { + inst: r, + sequenceType: Fleur.SequenceType_empty_sequence + }; +}; +/* Fleur.XQueryEngine[Fleur.XQueryX.versionDecl] = function(ctx, children) { -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/whereClause.js b/src/js/fleur.js/XQuery/Instructions/whereClause-BROKEN.js similarity index 96% rename from src/js/fleur.js/XQuery/Instructions/whereClause.js rename to src/js/fleur.js/XQuery/Instructions/whereClause-BROKEN.js index 6442aa0..8d63b58 100644 --- a/src/js/fleur.js/XQuery/Instructions/whereClause.js +++ b/src/js/fleur.js/XQuery/Instructions/whereClause-BROKEN.js @@ -1,28 +1,28 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.whereClause] = function(ctx, children, callback, resarr) { - //console.log("whereClause "); - var i = 0; - ctx.env.varresolver = resarr[0]; - var cb = function(n) { - if (Fleur.XPathFunctions_fn["boolean#1"].jsfunc(n)) { - i++; - } else { - resarr.splice(i, 1); - } - if (i !== resarr.length) { - ctx.env.varresolver = resarr[i]; - Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], cb); - } else { - Fleur.callback(function() {callback(Fleur.EmptySequence);}); - } - }; - Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], cb); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.whereClause] = function(ctx, children, callback, resarr) { + //console.log("whereClause "); + var i = 0; + ctx.env.varresolver = resarr[0]; + var cb = function(n) { + if (Fleur.XPathFunctions_fn["boolean#1"].jsfunc(n)) { + i++; + } else { + resarr.splice(i, 1); + } + if (i !== resarr.length) { + ctx.env.varresolver = resarr[i]; + Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], cb); + } else { + Fleur.callback(function() {callback(Fleur.EmptySequence);}); + } + }; + Fleur.XQueryEngine[children[0][0]](ctx, children[0][1], cb); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/xpathAxis.js b/src/js/fleur.js/XQuery/Instructions/xpathAxis.js index b1eb239..c34ded3 100644 --- a/src/js/fleur.js/XQuery/Instructions/xpathAxis.js +++ b/src/js/fleur.js/XQuery/Instructions/xpathAxis.js @@ -1,7 +1,7 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ diff --git a/src/js/fleur.js/XQuery/Instructions/xqx.js b/src/js/fleur.js/XQuery/Instructions/xqx-BROKEN.js similarity index 96% rename from src/js/fleur.js/XQuery/Instructions/xqx.js rename to src/js/fleur.js/XQuery/Instructions/xqx-BROKEN.js index 3af7210..a4d20aa 100644 --- a/src/js/fleur.js/XQuery/Instructions/xqx.js +++ b/src/js/fleur.js/XQuery/Instructions/xqx-BROKEN.js @@ -1,12 +1,12 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.xqx] = function(ctx, children, callback) { - Fleur.callback(function() {callback(ctx._result);}); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.xqx] = function(ctx, children, callback) { + Fleur.callback(function() {callback(ctx._result);}); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/xqxuf.js b/src/js/fleur.js/XQuery/Instructions/xqxuf-BROKEN.js similarity index 96% rename from src/js/fleur.js/XQuery/Instructions/xqxuf.js rename to src/js/fleur.js/XQuery/Instructions/xqxuf-BROKEN.js index 0ab90dd..a88d386 100644 --- a/src/js/fleur.js/XQuery/Instructions/xqxuf.js +++ b/src/js/fleur.js/XQuery/Instructions/xqxuf-BROKEN.js @@ -1,12 +1,12 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.xqxuf] = function(ctx, children, callback) { - Fleur.callback(function() {callback(ctx._result);}); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.xqxuf] = function(ctx, children, callback) { + Fleur.callback(function() {callback(ctx._result);}); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Instructions/xsi.js b/src/js/fleur.js/XQuery/Instructions/xsi-BROKEN.js similarity index 96% rename from src/js/fleur.js/XQuery/Instructions/xsi.js rename to src/js/fleur.js/XQuery/Instructions/xsi-BROKEN.js index 9f7c70f..11b00bd 100644 --- a/src/js/fleur.js/XQuery/Instructions/xsi.js +++ b/src/js/fleur.js/XQuery/Instructions/xsi-BROKEN.js @@ -1,12 +1,12 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module - * @description - */ -Fleur.XQueryEngine[Fleur.XQueryX.xsi] = function(ctx, children, callback) { - Fleur.callback(function() {callback(ctx._result);}); +/*eslint-env browser, node*/ +/*globals Fleur */ +"use strict"; +/** + * @author Alain Couthures + * @licence LGPL - See file 'LICENSE.md' in this project. + * @module + * @description + */ +Fleur.XQueryEngine[Fleur.XQueryX.xsi] = function(ctx, children, callback) { + Fleur.callback(function() {callback(ctx._result);}); }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/addOp.js b/src/js/fleur.js/XQuery/Operators/addOp.js index 0add9ae..944de6f 100644 --- a/src/js/fleur.js/XQuery/Operators/addOp.js +++ b/src/js/fleur.js/XQuery/Operators/addOp.js @@ -1,7 +1,7 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ @@ -21,27 +21,12 @@ Fleur.addOpTypes = [ ]; Fleur.Transpiler.prototype.xqx_addOp = function(children) { - const arg1 = this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }); - if (!arg1.sequenceType.schemaTypeInfo.as(Fleur.Type_numeric)) { - Fleur.XQueryError_xqt("XPST0017", null, "Not a number"); - } - const arg2 = this.gen(children[1][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }); - if (!arg2.sequenceType.schemaTypeInfo.as(Fleur.Type_numeric)) { - Fleur.XQueryError_xqt("XPST0017", null, "Not a number"); + const arg1 = this.gen(children[0][1][0], Fleur.SequenceType_numeric_1); + const arg2 = this.gen(children[1][1][0], Fleur.SequenceType_numeric_1); + if (arg1.value && arg2.value) { + return this.staticargs([arg1, arg2]).xqx_addOp().staticinst(this); } - return this.inst("xqx_addOp()", false, { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, arg1.inst + arg2.inst); + return this.inst("xqx_addOp()", false, Fleur.SequenceType_numeric_1, arg1.inst + arg2.inst); }; Fleur.Context.prototype.xqx_addOp = function() { @@ -63,20 +48,21 @@ Fleur.Context.prototype.xqx_addOp = function() { if (op2[0] < 0) { return this; } + const res = new Fleur.Text(); const restype = Fleur.addOpTypes[op1[0]][op2[0]]; if (restype !== -1) { - let d, res, resvalue, prevm; + let d, dres, dresvalue, prevm; if (op1[0] < 4 && op2[0] < 4) { const val = typeof op1[1] === typeof op2[1] ? op1[1] + op2[1] : Number(op1[1]) + Number(op2[1]); if (restype > 1) { - this.item.data = Fleur.Type_double.canonicalize(String(val)); + res.data = Fleur.Type_double.canonicalize(String(val)); } else { const precision1 = arg1.data.indexOf(".") !== -1 ? arg1.data.length - arg1.data.indexOf(".") - 1 : 0; const precision2 = arg2.data.indexOf(".") !== -1 ? arg2.data.length - arg2.data.indexOf(".") - 1 : 0; - this.item.data = Fleur.NumberToDecimalString(val, Math.max(precision1, precision2)); + res.data = Fleur.NumberToDecimalString(val, Math.max(precision1, precision2)); } } else if (op1[0] === 4 && op2[0] === 4) { - this.item.data = op1[1] + op2[1]; + res.data = op1[1] + op2[1]; } else if (op1[0] > 5 && op1[0] < 9 && op2[0] > 8) { d = op1[1].d; if (op2[0] === 9) { @@ -104,7 +90,7 @@ Fleur.Context.prototype.xqx_addOp = function() { d.setSeconds(d.getSeconds() + op2[1].sign * op2[1].second); } } - this.item.data = restype === 6 ? Fleur.dateToDate({d: d, tz: op1[1].tz}) : restype === 7 ? Fleur.dateToDateTime({d: d, tz: op1[1].tz}) : Fleur.dateToTime({d: d, tz: op1[1].tz}); + res.data = restype === 6 ? Fleur.dateToDate({d: d, tz: op1[1].tz}) : restype === 7 ? Fleur.dateToDateTime({d: d, tz: op1[1].tz}) : Fleur.dateToTime({d: d, tz: op1[1].tz}); } else if (op2[0] > 5 && op2[0] < 9 && op1[0] > 8) { d = op2[1].d; if (op1[0] === 9) { @@ -132,33 +118,34 @@ Fleur.Context.prototype.xqx_addOp = function() { d.setSeconds(d.getSeconds() + op1[1].sign * op1[1].second); } } - this.item.data = restype === 6 ? Fleur.dateToDate({d: d, tz: op2[1].tz}) : restype === 7 ? Fleur.dateToDateTime({d: d, tz: op2[1].tz}) : Fleur.dateToTime({d: d, tz: op2[1].tz}); + res.data = restype === 6 ? Fleur.dateToDate({d: d, tz: op2[1].tz}) : restype === 7 ? Fleur.dateToDateTime({d: d, tz: op2[1].tz}) : Fleur.dateToTime({d: d, tz: op2[1].tz}); } else if (op1[0] === 9 && op2[0] === 9) { - resvalue = op1[1].sign * (op1[1].year * 12 + op1[1].month) + op2[1].sign * (op2[1].year * 12 + op2[1].month); - res = { - sign: resvalue < 0 ? -1 : 1, - year: Math.floor(Math.abs(resvalue) / 12), - month: Math.abs(resvalue) % 12}; - this.item.data = (res.sign < 0 ? "-" : "") + "P" + (res.year !== 0 ? String(res.year) + "Y": "") + (res.month !== 0 || res.year === 0 ? String(res.month) + "M" : ""); + dresvalue = op1[1].sign * (op1[1].year * 12 + op1[1].month) + op2[1].sign * (op2[1].year * 12 + op2[1].month); + dres = { + sign: dresvalue < 0 ? -1 : 1, + year: Math.floor(Math.abs(dresvalue) / 12), + month: Math.abs(dresvalue) % 12}; + res.data = (dres.sign < 0 ? "-" : "") + "P" + (dres.year !== 0 ? String(dres.year) + "Y": "") + (dres.month !== 0 || dres.year === 0 ? String(dres.month) + "M" : ""); } else if (op1[0] === 10 && op2[0] === 10) { - resvalue = op1[1].sign * (((op1[1].day * 24 + op1[1].hour) * 60 + op1[1].minute) * 60 + op1[1].second) + op2[1].sign * (((op2[1].day * 24 + op2[1].hour) * 60 + op2[1].minute) * 60 + op2[1].second); - res = {sign: resvalue < 0 ? -1 : 1}; - resvalue = Math.abs(resvalue); - res.day = Math.floor(resvalue / 86400); - resvalue = resvalue % 86400; - res.hour = Math.floor(resvalue / 3600); - resvalue = resvalue % 3600; - res.minute = Math.floor(resvalue / 60); - res.second = resvalue % 60; - this.item.data = (res.sign < 0 ? "-" : "") + "P" + (res.day !== 0 ? String(res.day) + "D": "") + (res.hour !== 0 || res.minute !== 0 || res.second !== 0 || res.day + res.hour + res.minute === 0 ? "T" : "") + (res.hour !== 0 ? String(res.hour) + "H" : "") + (res.minute !== 0 ? String(res.minute) + "M" : "") + (res.second !== 0 || res.day + res.hour + res.minute === 0 ? String(res.second) + "S" : ""); + dresvalue = op1[1].sign * (((op1[1].day * 24 + op1[1].hour) * 60 + op1[1].minute) * 60 + op1[1].second) + op2[1].sign * (((op2[1].day * 24 + op2[1].hour) * 60 + op2[1].minute) * 60 + op2[1].second); + dres = {sign: dresvalue < 0 ? -1 : 1}; + dresvalue = Math.abs(dresvalue); + dres.day = Math.floor(dresvalue / 86400); + dresvalue = dresvalue % 86400; + dres.hour = Math.floor(dresvalue / 3600); + dresvalue = dresvalue % 3600; + dres.minute = Math.floor(dresvalue / 60); + dres.second = dresvalue % 60; + res.data = (dres.sign < 0 ? "-" : "") + "P" + (dres.day !== 0 ? String(dres.day) + "D": "") + (dres.hour !== 0 || dres.minute !== 0 || dres.second !== 0 || dres.day + dres.hour + dres.minute === 0 ? "T" : "") + (dres.hour !== 0 ? String(dres.hour) + "H" : "") + (dres.minute !== 0 ? String(dres.minute) + "M" : "") + (dres.second !== 0 || dres.day + dres.hour + dres.minute === 0 ? String(dres.second) + "S" : ""); } - this.item.schemaTypeInfo = Fleur.JSTypes[restype]; + res.schemaTypeInfo = Fleur.JSTypes[restype]; } else { Fleur.XQueryError_xqt(arg1.nodeType === Fleur.Node.ELEMENT_NODE || arg2.nodeType === Fleur.Node.ELEMENT_NODE ? "FORG0001" : "XPTY0004"); } + this.item = res; return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.addOp] = function(ctx, children, callback) { Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n1) { var op1, d; @@ -284,4 +271,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.addOp] = function(ctx, children, callback) { Fleur.callback(function() {callback(a1);}); }); }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/andOp.js b/src/js/fleur.js/XQuery/Operators/andOp.js index a679b71..345fee0 100644 --- a/src/js/fleur.js/XQuery/Operators/andOp.js +++ b/src/js/fleur.js/XQuery/Operators/andOp.js @@ -1,27 +1,49 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_andOp = function(children) { - let result = this.gen(children[0][1][0]).inst + "\n" + this.indent + "if (" + this.ctxvarname + ".fn_boolean_1().dropTrue()) {"; + const arg1 = this.gen(children[0][1][0]); + const arg2 = this.gen(children[1][1][0]); + if (arg1.value) { + const arg1boolvalue = this.staticargs([arg1]).fn_boolean_1(); + if (arg1boolvalue.item.data === "false") { + return { + inst: this.inst("xqx_constantExpr(Fleur.Type_boolean, 'false')", false).inst, + sequenceType: Fleur.SequenceType_boolean_1, + value: arg1boolvalue.item + }; + } + if (arg2.value) { + const arg2boolvalue = this.staticargs([arg2]).fn_boolean_1(); + return { + inst: this.inst("xqx_constantExpr(Fleur.Type_boolean, '" + arg2boolvalue.item.data + "')", false).inst, + sequenceType: Fleur.SequenceType_boolean_1, + value: arg2boolvalue.item + }; + } + let result = arg2.inst; + result += this.inst("fn_boolean_1()").inst; + return { + inst: result, + sequenceType: Fleur.SequenceType_boolean_1 + }; + } + let result = arg1.inst + "\n" + this.indent + "if (" + this.ctxvarname + ".fn_boolean_1().dropTrue()) {"; const previndent = this.indent; this.indent += this.step; - result += this.gen(children[1][1][0]).inst; + result += arg2.inst; result += this.inst("fn_boolean_1()").inst; this.indent = previndent; return { inst: result + "\n" + previndent + "}", - sequenceType: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "1" - } + sequenceType: Fleur.SequenceType_boolean_1 }; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.andOp] = function(ctx, children, callback) { var op1; Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { @@ -50,4 +72,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.andOp] = function(ctx, children, callback) { }); } }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/divOp.js b/src/js/fleur.js/XQuery/Operators/divOp.js index 4b96aa1..6a184e8 100644 --- a/src/js/fleur.js/XQuery/Operators/divOp.js +++ b/src/js/fleur.js/XQuery/Operators/divOp.js @@ -1,7 +1,7 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ @@ -21,27 +21,12 @@ Fleur.divOpTypes = [ ]; Fleur.Transpiler.prototype.xqx_divOp = function(children) { - const arg1 = this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }); - if (!arg1.sequenceType.schemaTypeInfo.as(Fleur.Type_numeric)) { - Fleur.XQueryError_xqt("XPST0017", null, "Not a number"); - } - const arg2 = this.gen(children[1][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }); - if (!arg2.sequenceType.schemaTypeInfo.as(Fleur.Type_numeric)) { - Fleur.XQueryError_xqt("XPST0017", null, "Not a number"); + const arg1 = this.gen(children[0][1][0], Fleur.SequenceType_numeric_1); + const arg2 = this.gen(children[1][1][0], Fleur.SequenceType_numeric_1); + if (arg1.value && arg2.value) { + return this.staticargs([arg1, arg2]).xqx_divOp().staticinst(this); } - return this.inst("xqx_divOp()", false, { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, arg1.inst + arg2.inst); + return this.inst("xqx_divOp()", false, Fleur.SequenceType_numeric_1, arg1.inst + arg2.inst); }; Fleur.Context.prototype.xqx_divOp = function() { @@ -56,22 +41,23 @@ Fleur.Context.prototype.xqx_divOp = function() { if (op2[0] < 0) { return this; } + const res = new Fleur.Text(); let restype = Fleur.divOpTypes[op1[0]][op2[0]]; if (restype !== -1) { - let res, resvalue; + let dres, dresvalue; if (op1[0] < 4 && op2[0] < 4) { if (isNaN(Number(op1[1]) / Number(op2[1]))) { - this.item.data = "NaN"; + res.data = "NaN"; } else if (Number(op1[1]) / Number(op2[1]) === -Infinity) { - this.item.data = "-INF"; + res.data = "-INF"; } else if (Number(op1[1]) / Number(op2[1]) === Infinity) { - this.item.data = "INF"; + res.data = "INF"; } else if (Number(op2[1]) / Number(op1[1]) === -Infinity) { - this.item.data = "-0"; + res.data = "-0"; } else if (Number(op2[1]) / Number(op1[1]) === Infinity) { - this.item.data = "0"; + res.data = "0"; } else { - this.item.data = restype > 1 ? Fleur.Type_double.canonicalize(String(Number(op1[1]) / Number(op2[1]))) : Fleur.NumberToDecimalString(Number(op1[1]) / Number(op2[1])); + res.data = restype > 1 ? Fleur.Type_double.canonicalize(String(Number(op1[1]) / Number(op2[1]))) : Fleur.NumberToDecimalString(Number(op1[1]) / Number(op2[1])); if (restype === 0) { var newv = parseFloat(this.item.data); if (newv !== Math.floor(newv)) { @@ -80,39 +66,38 @@ Fleur.Context.prototype.xqx_divOp = function() { } } } else if (op1[0] === 9 && op2[0] < 4) { - resvalue = op1[1].sign * Math.round((op1[1].year * 12 + op1[1].month) / op2[1]); - res = { - sign: resvalue < 0 ? -1 : 1, - year: Math.floor(Math.abs(resvalue) / 12), - month: Math.abs(resvalue) % 12}; - this.item.data = (res.sign < 0 ? "-" : "") + "P" + (res.year !== 0 ? String(res.year) + "Y": "") + (res.month !== 0 || res.year === 0 ? String(res.month) + "M" : ""); + dresvalue = op1[1].sign * Math.round((op1[1].year * 12 + op1[1].month) / op2[1]); + dres = { + sign: dresvalue < 0 ? -1 : 1, + year: Math.floor(Math.abs(dresvalue) / 12), + month: Math.abs(dresvalue) % 12}; + res.data = (dres.sign < 0 ? "-" : "") + "P" + (dres.year !== 0 ? String(dres.year) + "Y": "") + (dres.month !== 0 || dres.year === 0 ? String(dres.month) + "M" : ""); } else if (op1[0] === 10 && op2[0] < 4) { - resvalue = op1[1].sign * (((op1[1].day * 24 + op1[1].hour) * 60 + op1[1].minute) * 60 + op1[1].second) / op2[1]; - res = {sign: resvalue < 0 ? -1 : 1}; - resvalue = Math.abs(resvalue); - res.day = Math.floor(resvalue / 86400); - resvalue = resvalue % 86400; - res.hour = Math.floor(resvalue / 3600); - resvalue = resvalue % 3600; - res.minute = Math.floor(resvalue / 60); - res.second = resvalue % 60; - this.item.data = (res.sign < 0 ? "-" : "") + "P" + (res.day !== 0 ? String(res.day) + "D": "") + (res.hour !== 0 || res.minute !== 0 || res.second !== 0 || res.day + res.hour + res.minute === 0 ? "T" : "") + (res.hour !== 0 ? String(res.hour) + "H" : "") + (res.minute !== 0 ? String(res.minute) + "M" : "") + (res.second !== 0 || res.day + res.hour + res.minute === 0 ? String(res.second) + "S" : ""); + dresvalue = op1[1].sign * (((op1[1].day * 24 + op1[1].hour) * 60 + op1[1].minute) * 60 + op1[1].second) / op2[1]; + dres = {sign: dresvalue < 0 ? -1 : 1}; + dresvalue = Math.abs(dresvalue); + dres.day = Math.floor(dresvalue / 86400); + dresvalue = dresvalue % 86400; + dres.hour = Math.floor(dresvalue / 3600); + dresvalue = dresvalue % 3600; + dres.minute = Math.floor(dresvalue / 60); + dres.second = dresvalue % 60; + res.data = (dres.sign < 0 ? "-" : "") + "P" + (dres.day !== 0 ? String(dres.day) + "D": "") + (dres.hour !== 0 || dres.minute !== 0 || dres.second !== 0 || dres.day + dres.hour + dres.minute === 0 ? "T" : "") + (dres.hour !== 0 ? String(dres.hour) + "H" : "") + (dres.minute !== 0 ? String(dres.minute) + "M" : "") + (dres.second !== 0 || dres.day + dres.hour + dres.minute === 0 ? String(dres.second) + "S" : ""); } else if (op1[0] === 9 && op2[0] === 9) { - resvalue = op1[1].sign * (op1[1].year * 12 + op1[1].month) / (op2[1].sign * (op2[1].year * 12 + op2[1].month)); - this.item.data = Fleur.Type_double.canonicalize(String(resvalue)); + dresvalue = op1[1].sign * (op1[1].year * 12 + op1[1].month) / (op2[1].sign * (op2[1].year * 12 + op2[1].month)); + res.data = Fleur.Type_double.canonicalize(String(dresvalue)); } else if (op1[0] === 10 && op2[0] === 10) { - resvalue = op1[1].sign * (((op1[1].day * 24 + op1[1].hour) * 60 + op1[1].minute) * 60 + op1[1].second) / (op2[1].sign * (((op2[1].day * 24 + op2[1].hour) * 60 + op2[1].minute) * 60 + op2[1].second)); - this.item.data = Fleur.Type_double.canonicalize(String(resvalue)); + dresvalue = op1[1].sign * (((op1[1].day * 24 + op1[1].hour) * 60 + op1[1].minute) * 60 + op1[1].second) / (op2[1].sign * (((op2[1].day * 24 + op2[1].hour) * 60 + op2[1].minute) * 60 + op2[1].second)); + res.data = Fleur.Type_double.canonicalize(String(dresvalue)); } this.item.schemaTypeInfo = Fleur.JSTypes[restype]; } else { - this.item = new Fleur.Text(); - this.item.schemaTypeInfo = Fleur.Type_error; - this.item._setNodeNameLocalNamePrefix("http://www.w3.org/2005/xqt-errors", "err:XPTY0004"); + Fleur.XQueryError_xqt(arg1.nodeType === Fleur.Node.ELEMENT_NODE || arg2.nodeType === Fleur.Node.ELEMENT_NODE ? "FORG0001" : "XPTY0004"); } + this.item = res; return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.divOp] = function(ctx, children, callback) { Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { var op1; @@ -187,4 +172,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.divOp] = function(ctx, children, callback) { Fleur.callback(function() {callback(a1);}); }); }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/eqOp.js b/src/js/fleur.js/XQuery/Operators/eqOp.js index a4f83bf..caaaec5 100644 --- a/src/js/fleur.js/XQuery/Operators/eqOp.js +++ b/src/js/fleur.js/XQuery/Operators/eqOp.js @@ -1,29 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_eqOp = function(children) { - const arg1 = this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); - const arg2 = this.gen(children[1][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); + const arg1 = this.gen(children[0][1][0], Fleur.SequenceType_anyAtomicType_01); + const arg2 = this.gen(children[1][1][0], Fleur.SequenceType_anyAtomicType_01); if (!arg2.sequenceType.schemaTypeInfo.as(arg1.sequenceType.schemaTypeInfo) && !arg1.sequenceType.schemaTypeInfo.as(arg2.sequenceType.schemaTypeInfo)) { Fleur.XQueryError_xqt("XPST0017", null, "Not compatible types"); } - return this.inst("xqx_valueComp(Fleur.eqOp)", false, { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "?" - }, arg1.inst + arg2.inst); + if (arg1.value && arg2.value) { + return this.staticargs([arg1, arg2]).xqx_valueComp(Fleur.eqOp).staticinst(this); + } + return this.inst("xqx_valueComp(Fleur.eqOp)", false, Fleur.SequenceType_boolean_1, arg1.inst + arg2.inst); }; Fleur.eqOp = function(op1, op2, c) { @@ -54,6 +45,8 @@ Fleur.eqOp = function(op1, op2, c) { } return false; }; +/* Fleur.XQueryEngine[Fleur.XQueryX.eqOp] = function(ctx, children, callback) { Fleur.XPathTestOpFunction(ctx, children, Fleur.eqOp, callback); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/equalOp.js b/src/js/fleur.js/XQuery/Operators/equalOp.js index cead61c..9cb2d19 100644 --- a/src/js/fleur.js/XQuery/Operators/equalOp.js +++ b/src/js/fleur.js/XQuery/Operators/equalOp.js @@ -1,31 +1,23 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_equalOp = function(children) { - const arg1 = this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); - const arg2 = this.gen(children[1][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); + const arg1 = this.gen(children[0][1][0], Fleur.SequenceType_anyAtomicType_0n); + const arg2 = this.gen(children[1][1][0], Fleur.SequenceType_anyAtomicType_0n); if (!arg2.sequenceType.schemaTypeInfo.as(arg1.sequenceType.schemaTypeInfo) && !arg1.sequenceType.schemaTypeInfo.as(arg2.sequenceType.schemaTypeInfo)) { Fleur.XQueryError_xqt("XPST0017", null, "Not compatible types"); } - return this.inst("xqx_generalComp(Fleur.eqOp)", false, { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "?" - }, arg1.inst + arg2.inst); + if (arg1.value && arg2.value) { + return this.staticargs([arg1, arg2]).xqx_generalComp(Fleur.eqOp).staticinst(this); + } + return this.inst("xqx_generalComp(Fleur.eqOp)", false, Fleur.SequenceType_boolean_1, arg1.inst + arg2.inst); }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.equalOp] = function(ctx, children, callback) { Fleur.XPathGenTestOpFunction(ctx, children, Fleur.eqOp, callback); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/geOp.js b/src/js/fleur.js/XQuery/Operators/geOp.js index a23d7e8..6bbe27b 100644 --- a/src/js/fleur.js/XQuery/Operators/geOp.js +++ b/src/js/fleur.js/XQuery/Operators/geOp.js @@ -1,29 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_geOp = function(children) { - const arg1 = this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); - const arg2 = this.gen(children[1][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); + const arg1 = this.gen(children[0][1][0], Fleur.SequenceType_anyAtomicType_01); + const arg2 = this.gen(children[1][1][0], Fleur.SequenceType_anyAtomicType_01); if (!arg2.sequenceType.schemaTypeInfo.as(arg1.sequenceType.schemaTypeInfo) && !arg1.sequenceType.schemaTypeInfo.as(arg2.sequenceType.schemaTypeInfo)) { Fleur.XQueryError_xqt("XPST0017", null, "Not compatible types"); } - return this.inst("xqx_valueComp(Fleur.geOp)", false, { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "?" - }, arg1.inst + arg2.inst); + if (arg1.value && arg2.value) { + return this.staticargs([arg1, arg2]).xqx_valueComp(Fleur.geOp).staticinst(this); + } + return this.inst("xqx_valueComp(Fleur.geOp)", false, Fleur.SequenceType_boolean_1, arg1.inst + arg2.inst); }; Fleur.geOp = function(op1, op2) { @@ -31,7 +22,7 @@ Fleur.geOp = function(op1, op2) { return op1[1] >= op2[1]; } if (op1[0] === 4) { - return op1[1] >= op2[1] + return op1[1] >= op2[1]; } if (op1[0] === 5) { return (op1[1] === "true") >= (op2[1] === "true"); @@ -51,6 +42,8 @@ Fleur.geOp = function(op1, op2) { } return false; }; +/* Fleur.XQueryEngine[Fleur.XQueryX.geOp] = function(ctx, children, callback) { Fleur.XPathTestOpFunction(ctx, children, Fleur.geOp, callback); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/generalComp.js b/src/js/fleur.js/XQuery/Operators/generalComp.js index a221e63..1c10a5a 100644 --- a/src/js/fleur.js/XQuery/Operators/generalComp.js +++ b/src/js/fleur.js/XQuery/Operators/generalComp.js @@ -1,91 +1,56 @@ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Context.prototype.xqx_generalComp = function(f) { let arg1 = this.itemstack.pop(); const arg2 = this.item; - if (arg1.isEmpty()) { - this.item = new Fleur.Text(); - this.item.data = "false"; - this.item.schemaTypeInfo = Fleur.Type_boolean; + const res = new Fleur.Text(); + res.schemaTypeInfo = Fleur.Type_boolean; + if (arg1.isEmpty() || arg2.isEmpty()) { + res.data = "false"; + this.item = res; return this; } - if (arg1.schemaTypeInfo === Fleur.Type_error) { - this.item = arg1; - return this; - } - if (arg1.nodeType === Fleur.Node.SEQUENCE_NODE) { - arg1.childNodes.forEach(function(a) { - if (Fleur.numericTypes.indexOf(a.schemaTypeInfo) !== -1) { - a.schemaTypeInfo = Fleur.Type_double; - } else if (a.schemaTypeInfo === Fleur.Type_untypedAtomic) { - a.schemaTypeInfo = Fleur.Type_string; - } - }); - } else { - if (Fleur.numericTypes.indexOf(arg1.schemaTypeInfo) !== -1) { - arg1.schemaTypeInfo = Fleur.Type_double; - } else if (arg1.schemaTypeInfo === Fleur.Type_untypedAtomic) { - arg1.schemaTypeInfo = Fleur.Type_string; + let bres = false; + const itemtype = item => { + if (Fleur.numericTypes.indexOf(item.schemaTypeInfo) !== -1) { + const itemt = new Fleur.Text(item.data); + itemt.schemaTypeInfo = Fleur.Type_double; + return itemt; + } else if (item.schemaTypeInfo === Fleur.Type_untypedAtomic) { + const itemt = new Fleur.Text(item.data); + itemt.schemaTypeInfo = Fleur.Type_string; + return itemt; } - } - if (arg2.isEmpty()) { - this.item = new Fleur.Text(); - this.item.data = "false"; - this.item.schemaTypeInfo = Fleur.Type_boolean; - return this; - } - if (arg2.schemaTypeInfo === Fleur.Type_error) { - return this; - } - if (arg2.nodeType === Fleur.Node.SEQUENCE_NODE) { - arg2.childNodes.forEach(a => { - if (Fleur.numericTypes.indexOf(a.schemaTypeInfo) !== -1) { - a.schemaTypeInfo = Fleur.Type_double; - } else if (a.schemaTypeInfo === Fleur.Type_untypedAtomic) { - a.schemaTypeInfo = Fleur.Type_string; - } - }); - } else { - if (Fleur.numericTypes.indexOf(arg2.schemaTypeInfo) !== -1) { - arg2.schemaTypeInfo = Fleur.Type_double; - } else if (arg2.schemaTypeInfo === Fleur.Type_untypedAtomic) { - arg2.schemaTypeInfo = Fleur.Type_string; - } - } - let res = false; - do { - let i1; - if (arg1.nodeType === Fleur.Node.SEQUENCE_NODE) { - i1 = arg1.childNodes.shift(); - if (arg1.childNodes.length === 1) { - arg1 = arg1.childNodes[0]; - } - } else { - i1 = arg1; - arg1 = new Fleur.Sequence(); - } - const op1 = Fleur.toJSValue(i1, true, true, true, true, false, true); + return item; + }; + const itemcomp = item1 => { + const item1t = itemtype(item1); + const op1 = Fleur.toJSValue(item1t, true, true, true, true, false, true); if (arg2.nodeType === Fleur.Node.SEQUENCE_NODE) { - for (let b = 0, l = arg2.childNodes.length; b < l && !res; b++) { - const op2 = Fleur.toJSValue(arg2.childNodes[b], true, true, true, true, false, true); - res = f(op1, op2, Fleur.getCollation("http://www.w3.org/2005/xpath-functions/collation/codepoint")); + for (let b = 0, lb = arg2.childNodes.length; b < lb && !bres; b++) { + const item2t = itemtype(arg2.childNodes[b]); + const op2 = Fleur.toJSValue(item2t, true, true, true, true, false, true); + bres = f(op1, op2, Fleur.getCollation("http://www.w3.org/2005/xpath-functions/collation/codepoint")); } } else { - const op2 = Fleur.toJSValue(arg2, true, true, true, true, false, true); - res = f(op1, op2, Fleur.getCollation("http://www.w3.org/2005/xpath-functions/collation/codepoint")); + const item2t = itemtype(arg2); + const op2 = Fleur.toJSValue(item2t, true, true, true, true, false, true); + bres = f(op1, op2, Fleur.getCollation("http://www.w3.org/2005/xpath-functions/collation/codepoint")); } - if (res) { - break; + }; + if (arg1.nodeType === Fleur.Node.SEQUENCE_NODE) { + for (let a = 0, la = arg1.childNodes.length; a < la && !bres; a++) { + itemcomp(arg1.childNodes[a]); } - } while (arg1.isNotEmpty()); - this.item = new Fleur.Text(); - this.item.data = String(res); - this.item.schemaTypeInfo = Fleur.Type_boolean; + } else { + itemcomp(arg1); + } + res.data = String(bres); + this.item = res; return this; }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/greaterThanOp.js b/src/js/fleur.js/XQuery/Operators/greaterThanOp.js index 0ef1620..cb8f3d3 100644 --- a/src/js/fleur.js/XQuery/Operators/greaterThanOp.js +++ b/src/js/fleur.js/XQuery/Operators/greaterThanOp.js @@ -1,31 +1,23 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_greaterThanOp = function(children) { - const arg1 = this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); - const arg2 = this.gen(children[1][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); + const arg1 = this.gen(children[0][1][0], Fleur.SequenceType_anyAtomicType_0n); + const arg2 = this.gen(children[1][1][0], Fleur.SequenceType_anyAtomicType_0n); if (!arg2.sequenceType.schemaTypeInfo.as(arg1.sequenceType.schemaTypeInfo) && !arg1.sequenceType.schemaTypeInfo.as(arg2.sequenceType.schemaTypeInfo)) { Fleur.XQueryError_xqt("XPST0017", null, "Not compatible types"); } - return this.inst("xqx_generalComp(Fleur.gtOp)", false, { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "?" - }, arg1.inst + arg2.inst); + if (arg1.value && arg2.value) { + return this.staticargs([arg1, arg2]).xqx_generalComp(Fleur.gtOp).staticinst(this); + } + return this.inst("xqx_generalComp(Fleur.gtOp)", false, Fleur.SequenceType_boolean_1, arg1.inst + arg2.inst); }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.greaterThanOp] = function(ctx, children, callback) { Fleur.XPathGenTestOpFunction(ctx, children, Fleur.gtOp, callback); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/greaterThanOrEqualOp.js b/src/js/fleur.js/XQuery/Operators/greaterThanOrEqualOp.js index d4145e2..0a03b4a 100644 --- a/src/js/fleur.js/XQuery/Operators/greaterThanOrEqualOp.js +++ b/src/js/fleur.js/XQuery/Operators/greaterThanOrEqualOp.js @@ -1,31 +1,23 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_greaterThanOrEqualOp = function(children) { - const arg1 = this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); - const arg2 = this.gen(children[1][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); + const arg1 = this.gen(children[0][1][0], Fleur.SequenceType_anyAtomicType_0n); + const arg2 = this.gen(children[1][1][0], Fleur.SequenceType_anyAtomicType_0n); if (!arg2.sequenceType.schemaTypeInfo.as(arg1.sequenceType.schemaTypeInfo) && !arg1.sequenceType.schemaTypeInfo.as(arg2.sequenceType.schemaTypeInfo)) { Fleur.XQueryError_xqt("XPST0017", null, "Not compatible types"); } - return this.inst("xqx_generalComp(Fleur.geOp)", false, { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "?" - }, arg1.inst + arg2.inst); + if (arg1.value && arg2.value) { + return this.staticargs([arg1, arg2]).xqx_generalComp(Fleur.geOp).staticinst(this); + } + return this.inst("xqx_generalComp(Fleur.geOp)", false, Fleur.SequenceType_boolean_1, arg1.inst + arg2.inst); }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.greaterThanOrEqualOp] = function(ctx, children, callback) { Fleur.XPathGenTestOpFunction(ctx, children, Fleur.geOp, callback); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/gtOp.js b/src/js/fleur.js/XQuery/Operators/gtOp.js index 14750e8..0379037 100644 --- a/src/js/fleur.js/XQuery/Operators/gtOp.js +++ b/src/js/fleur.js/XQuery/Operators/gtOp.js @@ -1,29 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_gtOp = function(children) { - const arg1 = this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); - const arg2 = this.gen(children[1][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); + const arg1 = this.gen(children[0][1][0], Fleur.SequenceType_anyAtomicType_01); + const arg2 = this.gen(children[1][1][0], Fleur.SequenceType_anyAtomicType_01); if (!arg2.sequenceType.schemaTypeInfo.as(arg1.sequenceType.schemaTypeInfo) && !arg1.sequenceType.schemaTypeInfo.as(arg2.sequenceType.schemaTypeInfo)) { Fleur.XQueryError_xqt("XPST0017", null, "Not compatible types"); } - return this.inst("xqx_valueComp(Fleur.gtOp)", false, { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "?" - }, arg1.inst + arg2.inst); + if (arg1.value && arg2.value) { + return this.staticargs([arg1, arg2]).xqx_valueComp(Fleur.gtOp).staticinst(this); + } + return this.inst("xqx_valueComp(Fleur.gtOp)", false, Fleur.SequenceType_boolean_1, arg1.inst + arg2.inst); }; Fleur.gtOp = function(op1, op2) { @@ -51,6 +42,8 @@ Fleur.gtOp = function(op1, op2) { } return false; }; +/* Fleur.XQueryEngine[Fleur.XQueryX.gtOp] = function(ctx, children, callback) { Fleur.XPathTestOpFunction(ctx, children, Fleur.gtOp, callback); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/idivOp.js b/src/js/fleur.js/XQuery/Operators/idivOp.js index 6e7707e..d463c79 100644 --- a/src/js/fleur.js/XQuery/Operators/idivOp.js +++ b/src/js/fleur.js/XQuery/Operators/idivOp.js @@ -1,37 +1,23 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_idivOp = function(children) { - const arg1 = this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }); - if (!arg1.sequenceType.schemaTypeInfo.as(Fleur.Type_numeric)) { - Fleur.XQueryError_xqt("XPST0017", null, "Not a number"); - } - const arg2 = this.gen(children[1][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }); - if (!arg2.sequenceType.schemaTypeInfo.as(Fleur.Type_numeric)) { - Fleur.XQueryError_xqt("XPST0017", null, "Not a number"); + const arg1 = this.gen(children[0][1][0], Fleur.SequenceType_numeric_1); + const arg2 = this.gen(children[1][1][0], Fleur.SequenceType_numeric_1); + if (arg1.value && arg2.value) { + return this.staticargs([arg1, arg2]).xqx_idivOp().staticinst(this); } - return this.inst("xqx_idivOp()", false, { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_integer, - occurrence: "?" - }, arg1.inst + arg2.inst); + return this.inst("xqx_idivOp()", false, Fleur.SequenceType_integer_1, arg1.inst + arg2.inst); }; Fleur.Context.prototype.xqx_idivOp = function() { const arg1 = this.itemstack.pop(); const arg2 = this.item; + const res = new Fleur.Text(); const op1 = Fleur.toJSValue(arg1, true, false, false, false, false, true); if (op1[0] < 0) { this.item = arg1; @@ -42,11 +28,12 @@ Fleur.Context.prototype.xqx_idivOp = function() { return this; } const divres = typeof op1[1] === typeof op2[1] ? op1[1] / op2[1] : Number(op2[1]) / Number(op1[1]); - this.item.data = String(typeof divres === "number" ? Math.floor(divres) + (divres >= 0 ? 0 : 1) : divres + Fleur.BigInt(divres >= 0 ? 0 : 1)); - this.item.schemaTypeInfo = Fleur.Type_integer; + res.data = String(typeof divres === "number" ? Math.floor(divres) + (divres >= 0 ? 0 : 1) : divres + Fleur.BigInt(divres >= 0 ? 0 : 1)); + res.schemaTypeInfo = Fleur.Type_integer; + this.item = res; return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.idivOp] = function(ctx, children, callback) { Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { var op1; @@ -71,3 +58,4 @@ Fleur.XQueryEngine[Fleur.XQueryX.idivOp] = function(ctx, children, callback) { }); }); }; +*/ diff --git a/src/js/fleur.js/XQuery/Operators/leOp.js b/src/js/fleur.js/XQuery/Operators/leOp.js index 31b0993..3ad7557 100644 --- a/src/js/fleur.js/XQuery/Operators/leOp.js +++ b/src/js/fleur.js/XQuery/Operators/leOp.js @@ -1,29 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_leOp = function(children) { - const arg1 = this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); - const arg2 = this.gen(children[1][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); + const arg1 = this.gen(children[0][1][0], Fleur.SequenceType_anyAtomicType_01); + const arg2 = this.gen(children[1][1][0], Fleur.SequenceType_anyAtomicType_01); if (!arg2.sequenceType.schemaTypeInfo.as(arg1.sequenceType.schemaTypeInfo) && !arg1.sequenceType.schemaTypeInfo.as(arg2.sequenceType.schemaTypeInfo)) { Fleur.XQueryError_xqt("XPST0017", null, "Not compatible types"); } - return this.inst("xqx_valueComp(Fleur.leOp)", false, { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "?" - }, arg1.inst + arg2.inst); + if (arg1.value && arg2.value) { + return this.staticargs([arg1, arg2]).xqx_valueComp(Fleur.leOp).staticinst(this); + } + return this.inst("xqx_valueComp(Fleur.leOp)", false, Fleur.SequenceType_boolean_1, arg1.inst + arg2.inst); }; Fleur.leOp = function(op1, op2) { @@ -51,6 +42,8 @@ Fleur.leOp = function(op1, op2) { } return false; }; +/* Fleur.XQueryEngine[Fleur.XQueryX.leOp] = function(ctx, children, callback) { Fleur.XPathTestOpFunction(ctx, children, Fleur.leOp, callback); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/lessThanOp.js b/src/js/fleur.js/XQuery/Operators/lessThanOp.js index 8f76904..0f2b7cd 100644 --- a/src/js/fleur.js/XQuery/Operators/lessThanOp.js +++ b/src/js/fleur.js/XQuery/Operators/lessThanOp.js @@ -1,31 +1,23 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_lessThanOp = function(children) { - const arg1 = this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); - const arg2 = this.gen(children[1][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); + const arg1 = this.gen(children[0][1][0], Fleur.SequenceType_anyAtomicType_0n); + const arg2 = this.gen(children[1][1][0], Fleur.SequenceType_anyAtomicType_0n); if (!arg2.sequenceType.schemaTypeInfo.as(arg1.sequenceType.schemaTypeInfo) && !arg1.sequenceType.schemaTypeInfo.as(arg2.sequenceType.schemaTypeInfo)) { Fleur.XQueryError_xqt("XPST0017", null, "Not compatible types"); } - return this.inst("xqx_generalComp(Fleur.ltOp)", false, { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "?" - }, arg1.inst + arg2.inst); + if (arg1.value && arg2.value) { + return this.staticargs([arg1, arg2]).xqx_generalComp(Fleur.ltOp).staticinst(this); + } + return this.inst("xqx_generalComp(Fleur.ltOp)", false, Fleur.SequenceType_boolean_1, arg1.inst + arg2.inst); }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.lessThanOp] = function(ctx, children, callback) { Fleur.XPathGenTestOpFunction(ctx, children, Fleur.ltOp, callback); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/lessThanOrEqualOp.js b/src/js/fleur.js/XQuery/Operators/lessThanOrEqualOp.js index 633c7c2..c123b88 100644 --- a/src/js/fleur.js/XQuery/Operators/lessThanOrEqualOp.js +++ b/src/js/fleur.js/XQuery/Operators/lessThanOrEqualOp.js @@ -1,31 +1,23 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_lessThanOrEqualOp = function(children) { - const arg1 = this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); - const arg2 = this.gen(children[1][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); + const arg1 = this.gen(children[0][1][0], Fleur.SequenceType_anyAtomicType_0n); + const arg2 = this.gen(children[1][1][0], Fleur.SequenceType_anyAtomicType_0n); if (!arg2.sequenceType.schemaTypeInfo.as(arg1.sequenceType.schemaTypeInfo) && !arg1.sequenceType.schemaTypeInfo.as(arg2.sequenceType.schemaTypeInfo)) { Fleur.XQueryError_xqt("XPST0017", null, "Not compatible types"); } - return this.inst("xqx_generalComp(Fleur.leOp)", false, { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "?" - }, arg1.inst + arg2.inst); + if (arg1.value && arg2.value) { + return this.staticargs([arg1, arg2]).xqx_generalComp(Fleur.leOp).staticinst(this); + } + return this.inst("xqx_generalComp(Fleur.leOp)", false, Fleur.SequenceType_boolean_1, arg1.inst + arg2.inst); }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.lessThanOrEqualOp] = function(ctx, children, callback) { Fleur.XPathGenTestOpFunction(ctx, children, Fleur.leOp, callback); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/ltOp.js b/src/js/fleur.js/XQuery/Operators/ltOp.js index 6883823..92acfea 100644 --- a/src/js/fleur.js/XQuery/Operators/ltOp.js +++ b/src/js/fleur.js/XQuery/Operators/ltOp.js @@ -1,29 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_ltOp = function(children) { - const arg1 = this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); - const arg2 = this.gen(children[1][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); + const arg1 = this.gen(children[0][1][0], Fleur.SequenceType_anyAtomicType_01); + const arg2 = this.gen(children[1][1][0], Fleur.SequenceType_anyAtomicType_01); if (!arg2.sequenceType.schemaTypeInfo.as(arg1.sequenceType.schemaTypeInfo) && !arg1.sequenceType.schemaTypeInfo.as(arg2.sequenceType.schemaTypeInfo)) { Fleur.XQueryError_xqt("XPST0017", null, "Not compatible types"); } - return this.inst("xqx_valueComp(Fleur.ltOp)", false, { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "?" - }, arg1.inst + arg2.inst); + if (arg1.value && arg2.value) { + return this.staticargs([arg1, arg2]).xqx_valueComp(Fleur.ltOp).staticinst(this); + } + return this.inst("xqx_valueComp(Fleur.ltOp)", false, Fleur.SequenceType_boolean_1, arg1.inst + arg2.inst); }; Fleur.ltOp = function(op1, op2) { @@ -51,6 +42,8 @@ Fleur.ltOp = function(op1, op2) { } return false; }; +/* Fleur.XQueryEngine[Fleur.XQueryX.ltOp] = function(ctx, children, callback) { Fleur.XPathTestOpFunction(ctx, children, Fleur.ltOp, callback); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/modOp.js b/src/js/fleur.js/XQuery/Operators/modOp.js index 55b0029..90e8b42 100644 --- a/src/js/fleur.js/XQuery/Operators/modOp.js +++ b/src/js/fleur.js/XQuery/Operators/modOp.js @@ -1,32 +1,17 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_modOp = function(children) { - const arg1 = this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }); - if (!arg1.sequenceType.schemaTypeInfo.as(Fleur.Type_numeric)) { - Fleur.XQueryError_xqt("XPST0017", null, "Not a number"); - } - const arg2 = this.gen(children[1][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }); - if (!arg2.sequenceType.schemaTypeInfo.as(Fleur.Type_numeric)) { - Fleur.XQueryError_xqt("XPST0017", null, "Not a number"); + const arg1 = this.gen(children[0][1][0], Fleur.SequenceType_numeric_1); + const arg2 = this.gen(children[1][1][0], Fleur.SequenceType_numeric_1); + if (arg1.value && arg2.value) { + return this.staticargs([arg1, arg2]).xqx_modOp().staticinst(this); } - return this.inst("xqx_modOp()", false, { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, arg1.inst + arg2.inst); + return this.inst("xqx_modOp()", false, Fleur.SequenceType_numeric_1, arg1.inst + arg2.inst); }; Fleur.Context.prototype.xqx_modOp = function() { @@ -34,23 +19,24 @@ Fleur.Context.prototype.xqx_modOp = function() { const arg2 = this.item; const op1 = Fleur.toJSNumber(arg1); if (op1[0] < 0) { - this.item = arg1; - return this; + Fleur.XQueryError_xqt(arg1.nodeType === Fleur.Node.ELEMENT_NODE || arg2.nodeType === Fleur.Node.ELEMENT_NODE ? "FORG0001" : "XPTY0004"); } const op2 = Fleur.toJSNumber(arg2); if (op2[0] < 0) { - return this; + Fleur.XQueryError_xqt(arg1.nodeType === Fleur.Node.ELEMENT_NODE || arg2.nodeType === Fleur.Node.ELEMENT_NODE ? "FORG0001" : "XPTY0004"); } if (typeof op1[1] !== typeof op2[1]) { op1[1] = Number(op1[1]); op2[1] = Number(op2[1]); } const divres = op1[1] / op2[1]; - this.item.data = String(op1[1] - ((typeof divres === "number" ? Math.floor(divres) : divres) + Fleur.BigInt(divres >= 0 ? 0 : 1)) * op2[1]); - this.schemaTypeInfo = Fleur.numericTypes[Math.max(op1[0], op2[0])]; + const res = new Fleur.Text(); + res.data = String(op1[1] - ((typeof divres === "number" ? Math.floor(divres) + (divres >= 0 ? 0 : 1) : divres + Fleur.BigInt(divres >= 0 ? 0 : 1))) * op2[1]); + res.schemaTypeInfo = Fleur.numericTypes[Math.max(op1[0], op2[0])]; + this.item = res; return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.modOp] = function(ctx, children, callback) { Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { var op1; @@ -78,4 +64,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.modOp] = function(ctx, children, callback) { Fleur.callback(function() {callback(a1);}); }); }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/multiplyOp.js b/src/js/fleur.js/XQuery/Operators/multiplyOp.js index 846fe29..5588324 100644 --- a/src/js/fleur.js/XQuery/Operators/multiplyOp.js +++ b/src/js/fleur.js/XQuery/Operators/multiplyOp.js @@ -1,7 +1,7 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ @@ -21,27 +21,12 @@ Fleur.multiplyOpTypes = [ ]; Fleur.Transpiler.prototype.xqx_multiplyOp = function(children) { - const arg1 = this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }); - if (!arg1.sequenceType.schemaTypeInfo.as(Fleur.Type_numeric)) { - Fleur.XQueryError_xqt("XPST0017", null, "Not a number"); - } - const arg2 = this.gen(children[1][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }); - if (!arg2.sequenceType.schemaTypeInfo.as(Fleur.Type_numeric)) { - Fleur.XQueryError_xqt("XPST0017", null, "Not a number"); + const arg1 = this.gen(children[0][1][0], Fleur.SequenceType_numeric_1); + const arg2 = this.gen(children[1][1][0], Fleur.SequenceType_numeric_1); + if (arg1.value && arg2.value) { + return this.staticargs([arg1, arg2]).xqx_multiplyOp().staticinst(this); } - return this.inst("xqx_multiplyOp()", false, { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, arg1.inst + arg2.inst); + return this.inst("xqx_multiplyOp()", false, Fleur.SequenceType_numeric_1, arg1.inst + arg2.inst); }; Fleur.Context.prototype.xqx_multiplyOp = function() { @@ -56,78 +41,80 @@ Fleur.Context.prototype.xqx_multiplyOp = function() { if (op2[0] < 0) { return this; } + const res = new Fleur.Text(); const restype = Fleur.multiplyOpTypes[op1[0]][op2[0]]; if (restype !== -1) { - let res, resvalue; + let dres, dresvalue; if (op1[0] < 4 && op2[0] < 4) { if (isNaN(Number(op1[1]) * Number(op2[1]))) { - this.item.data = "NaN"; + res.data = "NaN"; } else if (Number(op1[1]) * Number(op2[1]) === -Infinity) { - this.item.data = "-INF"; + res.data = "-INF"; } else if (Number(op1[1]) * Number(op2[1]) === Infinity) { - this.item.data = "INF"; + res.data = "INF"; } else if (1 / (Number(op2[1]) * Number(op1[1])) === -Infinity) { - this.item.data = "-0"; + res.data = "-0"; } else if (1 / (Number(op2[1]) * Number(op1[1])) === Infinity) { - this.item.data = "0"; + res.data = "0"; } else { const val = typeof op1[1] === typeof op2[1] ? op1[1] * op2[1] : Number(op1[1]) * Number(op2[1]); if (restype > 1) { - this.item.data = Fleur.Type_double.canonicalize(String(val)); + res.data = Fleur.Type_double.canonicalize(String(val)); } else { const precision1 = arg1.data.indexOf(".") !== -1 ? arg1.data.length - arg1.data.indexOf(".") - 1 : 0; const precision2 = arg2.data.indexOf(".") !== -1 ? arg2.data.length - arg2.data.indexOf(".") - 1 : 0; - this.item.data = Fleur.NumberToDecimalString(val, precision1 + precision2); + res.data = Fleur.NumberToDecimalString(val, precision1 + precision2); } } } else if (op1[0] < 4 && op2[0] === 4) { - this.item.data = op2[1].repeat(op1[1]); + res.data = op2[1].repeat(op1[1]); } else if (op1[0] === 4 && op2[0] < 4) { - this.item.data = op1[1].repeat(op2[1]); + res.data = op1[1].repeat(op2[1]); } else if (op1[0] < 4 && op2[0] === 9) { - resvalue = op2[1].sign * Math.round((op2[1].year * 12 + op2[1].month) * Number(op1[1])); - res = { - sign: resvalue < 0 ? -1 : 1, - year: Math.floor(Math.abs(resvalue) / 12), - month: Math.abs(resvalue) % 12}; - this.item.data = (res.sign < 0 ? "-" : "") + "P" + (res.year !== 0 ? String(res.year) + "Y": "") + (res.month !== 0 || res.year === 0 ? String(res.month) + "M" : ""); + dresvalue = op2[1].sign * Math.round((op2[1].year * 12 + op2[1].month) * Number(op1[1])); + dres = { + sign: dresvalue < 0 ? -1 : 1, + year: Math.floor(Math.abs(dresvalue) / 12), + month: Math.abs(dresvalue) % 12}; + res.data = (dres.sign < 0 ? "-" : "") + "P" + (dres.year !== 0 ? String(dres.year) + "Y": "") + (dres.month !== 0 || dres.year === 0 ? String(dres.month) + "M" : ""); } else if (op1[0] === 9 && op2[0] < 4) { - resvalue = op1[1].sign * Math.round((op1[1].year * 12 + op1[1].month) * Number(op2[1])); - res = { - sign: resvalue < 0 ? -1 : 1, - year: Math.floor(Math.abs(resvalue) / 12), - month: Math.abs(resvalue) % 12}; - this.item.data = (res.sign < 0 ? "-" : "") + "P" + (res.year !== 0 ? String(res.year) + "Y": "") + (res.month !== 0 || res.year === 0 ? String(res.month) + "M" : ""); + dresvalue = op1[1].sign * Math.round((op1[1].year * 12 + op1[1].month) * Number(op2[1])); + dres = { + sign: dresvalue < 0 ? -1 : 1, + year: Math.floor(Math.abs(dresvalue) / 12), + month: Math.abs(dresvalue) % 12}; + res.data = (dres.sign < 0 ? "-" : "") + "P" + (dres.year !== 0 ? String(dres.year) + "Y": "") + (dres.month !== 0 || dres.year === 0 ? String(dres.month) + "M" : ""); } else if (op1[0] < 4 && op2[0] === 10) { - resvalue = Number(op1[1]) * op2[1].sign * (((op2[1].day * 24 + op2[1].hour) * 60 + op2[1].minute) * 60 + op2[1].second); - res = {sign: resvalue < 0 ? -1 : 1}; - resvalue = Math.abs(resvalue); - res.day = Math.floor(resvalue / 86400); - resvalue = resvalue % 86400; - res.hour = Math.floor(resvalue / 3600); - resvalue = resvalue % 3600; - res.minute = Math.floor(resvalue / 60); - res.second = resvalue % 60; - this.item.data = (res.sign < 0 ? "-" : "") + "P" + (res.day !== 0 ? String(res.day) + "D": "") + (res.hour !== 0 || res.minute !== 0 || res.second !== 0 || res.day + res.hour + res.minute === 0 ? "T" : "") + (res.hour !== 0 ? String(res.hour) + "H" : "") + (res.minute !== 0 ? String(res.minute) + "M" : "") + (res.second !== 0 || res.day + res.hour + res.minute === 0 ? String(res.second) + "S" : ""); + dresvalue = Number(op1[1]) * op2[1].sign * (((op2[1].day * 24 + op2[1].hour) * 60 + op2[1].minute) * 60 + op2[1].second); + dres = {sign: dresvalue < 0 ? -1 : 1}; + dresvalue = Math.abs(dresvalue); + dres.day = Math.floor(dresvalue / 86400); + dresvalue = dresvalue % 86400; + dres.hour = Math.floor(dresvalue / 3600); + dresvalue = dresvalue % 3600; + dres.minute = Math.floor(dresvalue / 60); + dres.second = dresvalue % 60; + res.data = (dres.sign < 0 ? "-" : "") + "P" + (dres.day !== 0 ? String(dres.day) + "D": "") + (dres.hour !== 0 || dres.minute !== 0 || dres.second !== 0 || dres.day + dres.hour + dres.minute === 0 ? "T" : "") + (dres.hour !== 0 ? String(dres.hour) + "H" : "") + (dres.minute !== 0 ? String(dres.minute) + "M" : "") + (dres.second !== 0 || dres.day + dres.hour + dres.minute === 0 ? String(dres.second) + "S" : ""); } else if (op1[0] === 10 && op2[0] < 4) { - resvalue = op1[1].sign * (((op1[1].day * 24 + op1[1].hour) * 60 + op1[1].minute) * 60 + op1[1].second) * Number(op2[1]); - res = {sign: resvalue < 0 ? -1 : 1}; - resvalue = Math.abs(resvalue); - res.day = Math.floor(resvalue / 86400); - resvalue = resvalue % 86400; - res.hour = Math.floor(resvalue / 3600); - resvalue = resvalue % 3600; - res.minute = Math.floor(resvalue / 60); - res.second = resvalue % 60; - this.item.data = (res.sign < 0 ? "-" : "") + "P" + (res.day !== 0 ? String(res.day) + "D": "") + (res.hour !== 0 || res.minute !== 0 || res.second !== 0 || res.day + res.hour + res.minute === 0 ? "T" : "") + (res.hour !== 0 ? String(res.hour) + "H" : "") + (res.minute !== 0 ? String(res.minute) + "M" : "") + (res.second !== 0 || res.day + res.hour + res.minute === 0 ? String(res.second) + "S" : ""); + dresvalue = op1[1].sign * (((op1[1].day * 24 + op1[1].hour) * 60 + op1[1].minute) * 60 + op1[1].second) * Number(op2[1]); + dres = {sign: dresvalue < 0 ? -1 : 1}; + dresvalue = Math.abs(dresvalue); + dres.day = Math.floor(dresvalue / 86400); + dresvalue = dresvalue % 86400; + dres.hour = Math.floor(dresvalue / 3600); + dresvalue = dresvalue % 3600; + dres.minute = Math.floor(dresvalue / 60); + dres.second = dresvalue % 60; + res.data = (dres.sign < 0 ? "-" : "") + "P" + (dres.day !== 0 ? String(dres.day) + "D": "") + (dres.hour !== 0 || dres.minute !== 0 || dres.second !== 0 || dres.day + dres.hour + dres.minute === 0 ? "T" : "") + (dres.hour !== 0 ? String(dres.hour) + "H" : "") + (dres.minute !== 0 ? String(dres.minute) + "M" : "") + (dres.second !== 0 || dres.day + dres.hour + dres.minute === 0 ? String(dres.second) + "S" : ""); } - this.item.schemaTypeInfo = Fleur.JSTypes[restype]; + res.schemaTypeInfo = Fleur.JSTypes[restype]; } else { - this.item = Fleur.error(this.ctx, "XPTY0004"); + Fleur.XQueryError_xqt(arg1.nodeType === Fleur.Node.ELEMENT_NODE || arg2.nodeType === Fleur.Node.ELEMENT_NODE ? "FORG0001" : "XPTY0004"); } + this.item = res; return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.multiplyOp] = function(ctx, children, callback) { Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { var op1; @@ -219,4 +206,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.multiplyOp] = function(ctx, children, callback) Fleur.callback(function() {callback(a1);}); }); }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/neOp.js b/src/js/fleur.js/XQuery/Operators/neOp.js index 3a203d5..6e56c64 100644 --- a/src/js/fleur.js/XQuery/Operators/neOp.js +++ b/src/js/fleur.js/XQuery/Operators/neOp.js @@ -1,29 +1,20 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_neOp = function(children) { - const arg1 = this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); - const arg2 = this.gen(children[1][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); + const arg1 = this.gen(children[0][1][0], Fleur.SequenceType_anyAtomicType_01); + const arg2 = this.gen(children[1][1][0], Fleur.SequenceType_anyAtomicType_01); if (!arg2.sequenceType.schemaTypeInfo.as(arg1.sequenceType.schemaTypeInfo) && !arg1.sequenceType.schemaTypeInfo.as(arg2.sequenceType.schemaTypeInfo)) { Fleur.XQueryError_xqt("XPST0017", null, "Not compatible types"); } - return this.inst("xqx_valueComp(Fleur.neOp)", false, { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "?" - }, arg1.inst + arg2.inst); + if (arg1.value && arg2.value) { + return this.staticargs([arg1, arg2]).xqx_valueComp(Fleur.neOp).staticinst(this); + } + return this.inst("xqx_valueComp(Fleur.neOp)", false, Fleur.SequenceType_boolean_1, arg1.inst + arg2.inst); }; Fleur.neOp = function(op1, op2, c) { @@ -51,6 +42,8 @@ Fleur.neOp = function(op1, op2, c) { } return false; }; +/* Fleur.XQueryEngine[Fleur.XQueryX.neOp] = function(ctx, children, callback) { Fleur.XPathTestOpFunction(ctx, children, Fleur.neOp, callback); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/notEqualOp.js b/src/js/fleur.js/XQuery/Operators/notEqualOp.js index 0f79152..7e0b5a1 100644 --- a/src/js/fleur.js/XQuery/Operators/notEqualOp.js +++ b/src/js/fleur.js/XQuery/Operators/notEqualOp.js @@ -1,31 +1,23 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_notEqualOp = function(children) { - const arg1 = this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); - const arg2 = this.gen(children[1][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); + const arg1 = this.gen(children[0][1][0], Fleur.SequenceType_anyAtomicType_0n); + const arg2 = this.gen(children[1][1][0], Fleur.SequenceType_anyAtomicType_0n); if (!arg2.sequenceType.schemaTypeInfo.as(arg1.sequenceType.schemaTypeInfo) && !arg1.sequenceType.schemaTypeInfo.as(arg2.sequenceType.schemaTypeInfo)) { Fleur.XQueryError_xqt("XPST0017", null, "Not compatible types"); } - return this.inst("xqx_generalComp(Fleur.neOp)", false, { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "?" - }, arg1.inst + arg2.inst); + if (arg1.value && arg2.value) { + return this.staticargs([arg1, arg2]).xqx_generalComp(Fleur.neOp).staticinst(this); + } + return this.inst("xqx_generalComp(Fleur.neOp)", false, Fleur.SequenceType_boolean_1, arg1.inst + arg2.inst); }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.notEqualOp] = function(ctx, children, callback) { Fleur.XPathGenTestOpFunction(ctx, children, Fleur.neOp, callback); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/orOp.js b/src/js/fleur.js/XQuery/Operators/orOp.js index 1a3eafe..bdaf1c1 100644 --- a/src/js/fleur.js/XQuery/Operators/orOp.js +++ b/src/js/fleur.js/XQuery/Operators/orOp.js @@ -1,27 +1,49 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_orOp = function(children) { - let result = this.gen(children[0][1][0]).inst + "\n" + this.indent + "if (" + this.ctxvarname + ".fn_boolean_1().dropFalse()) {"; + const arg1 = this.gen(children[0][1][0]); + const arg2 = this.gen(children[1][1][0]); + if (arg1.value) { + const arg1boolvalue = this.staticargs([arg1]).fn_boolean_1(); + if (arg1boolvalue.item.data === "true") { + return { + inst: this.inst("xqx_constantExpr(Fleur.Type_boolean, 'true')", false).inst, + sequenceType: Fleur.SequenceType_boolean_1, + value: arg1boolvalue.item + }; + } + if (arg2.value) { + const arg2boolvalue = this.staticargs([arg2]).fn_boolean_1(); + return { + inst: this.inst("xqx_constantExpr(Fleur.Type_boolean, '" + arg2boolvalue.item.data + "')", false).inst, + sequenceType: Fleur.SequenceType_boolean_1, + value: arg2boolvalue.item + }; + } + let result = arg2.inst; + result += this.inst("fn_boolean_1()").inst; + return { + inst: result, + sequenceType: Fleur.SequenceType_boolean_1 + }; + } + let result = arg1.inst + "\n" + this.indent + "if (" + this.ctxvarname + ".fn_boolean_1().dropFalse()) {"; const previndent = this.indent; this.indent += this.step; - result += this.gen(children[1][1][0]).inst; + result += arg2.inst; result += this.inst("fn_boolean_1()").inst; this.indent = previndent; return { inst: result + "\n" + previndent + "}", - sequenceType: { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_boolean, - occurrence: "1" - } + sequenceType: Fleur.SequenceType_boolean_1 }; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.orOp] = function(ctx, children, callback) { Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { var op1; @@ -50,4 +72,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.orOp] = function(ctx, children, callback) { }); } }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/stringConcatenateOp.js b/src/js/fleur.js/XQuery/Operators/stringConcatenateOp.js index 34508a2..32a118a 100644 --- a/src/js/fleur.js/XQuery/Operators/stringConcatenateOp.js +++ b/src/js/fleur.js/XQuery/Operators/stringConcatenateOp.js @@ -1,50 +1,29 @@ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.Transpiler.prototype.xqx_stringConcatenateOp = function(children) { - const arg1 = this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); - if (!arg1.sequenceType.schemaTypeInfo.as(Fleur.Type_string)) { - Fleur.XQueryError_xqt("XPST0017", null, "Not a string"); - } - const arg2 = this.gen(children[1][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }); - if (!arg2.sequenceType.schemaTypeInfo.as(Fleur.Type_string)) { - Fleur.XQueryError_xqt("XPST0017", null, "Not a string"); + const arg1 = this.gen(children[0][1][0], Fleur.SequenceType_string_01); + const arg2 = this.gen(children[1][1][0], Fleur.SequenceType_string_01); + if (arg1.value && arg2.value) { + return this.staticargs([arg1, arg2]).xqx_stringConcatenateOp().staticinst(this); } - return this.inst("xqx_stringConcatenateOp()", false, { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_string, - occurrence: "?" - }, arg1.inst + arg2.inst); + return this.inst("xqx_stringConcatenateOp()", false, Fleur.SequenceType_string_01, arg1.inst + arg2.inst); }; Fleur.Context.prototype.xqx_stringConcatenateOp = function() { let arg1 = this.itemstack.pop(); const arg2 = this.item; - if (arg1.isEmpty()) { - arg1 = new Fleur.Text(); - arg1.data = ""; - arg1.schemaTypeInfo = Fleur.Type_string; - } - if (arg2.isNotEmpty()) { - arg1.data += arg2.data; - } - this.item = arg1; + const res = new Fleur.Text(); + res.data = arg1.data + arg2.data; + res.schemaTypeInfo = Fleur.Type_string; + this.item = res; return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.stringConcatenateOp] = function(ctx, children, callback) { Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { var a1 = Fleur.Atomize(n, true); @@ -69,4 +48,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.stringConcatenateOp] = function(ctx, children, Fleur.callback(function() {callback(a1);}); }); }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/subtractOp.js b/src/js/fleur.js/XQuery/Operators/subtractOp.js index de62f44..e34daba 100644 --- a/src/js/fleur.js/XQuery/Operators/subtractOp.js +++ b/src/js/fleur.js/XQuery/Operators/subtractOp.js @@ -1,8 +1,7 @@ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ @@ -22,27 +21,12 @@ Fleur.subtractOpTypes = [ ]; Fleur.Transpiler.prototype.xqx_subtractOp = function(children) { - const arg1 = this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }); - if (!arg1.sequenceType.schemaTypeInfo.as(Fleur.Type_numeric)) { - Fleur.XQueryError_xqt("XPST0017", null, "Not a number"); - } - const arg2 = this.gen(children[1][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }); - if (!arg2.sequenceType.schemaTypeInfo.as(Fleur.Type_numeric)) { - Fleur.XQueryError_xqt("XPST0017", null, "Not a number"); + const arg1 = this.gen(children[0][1][0], Fleur.SequenceType_numeric_1); + const arg2 = this.gen(children[1][1][0], Fleur.SequenceType_numeric_1); + if (arg1.value && arg2.value) { + return this.staticargs([arg1, arg2]).xqx_substractOp().staticinst(this); } - return this.inst("xqx_substractOp()", false, { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: "?" - }, arg1.inst + arg2.inst); + return this.inst("xqx_substractOp()", false, Fleur.SequenceType_numeric_1, arg1.inst + arg2.inst); }; Fleur.Context.prototype.xqx_substractOp = function() { @@ -50,26 +34,27 @@ Fleur.Context.prototype.xqx_substractOp = function() { const arg2 = this.item; const op1 = Fleur.toJSValue(arg1, true, false, false, true, false, true); if (op1[0] < 0) { - return this; + Fleur.XQueryError_xqt(arg1.nodeType === Fleur.Node.ELEMENT_NODE || arg2.nodeType === Fleur.Node.ELEMENT_NODE ? "FORG0001" : "XPTY0004"); } const op2 = Fleur.toJSValue(arg2, true, false, false, true, false, true); if (op2[0] < 0) { - return arg; + Fleur.XQueryError_xqt(arg1.nodeType === Fleur.Node.ELEMENT_NODE || arg2.nodeType === Fleur.Node.ELEMENT_NODE ? "FORG0001" : "XPTY0004"); } + const res = new Fleur.Text(); const restype = Fleur.subtractOpTypes[op1[0]][op2[0]]; if (restype !== -1) { - let res, resvalue; + let dres, dresvalue; if (op1[0] < 4 && op2[0] < 4) { let val = typeof op1[1] === typeof op2[1] ? op1[1] - op2[1] : Number(op1[1]) - Number(op2[1]); if (restype > 1) { - this.item.data = Fleur.Type_double.canonicalize(String(val)); + res.data = Fleur.Type_double.canonicalize(String(val)); } else { var precision1 = arg1.data.indexOf(".") !== -1 ? arg1.data.length - arg1.data.indexOf(".") - 1 : 0; var precision2 = arg2.data.indexOf(".") !== -1 ? arg2.data.length - arg2.data.indexOf(".") - 1 : 0; - this.item.data = Fleur.NumberToDecimalString(val, Math.max(precision1, precision2)); + res.data = Fleur.NumberToDecimalString(val, Math.max(precision1, precision2)); } } else if (op1[0] > 5 && op1[0] < 9 && op2[0] > 5 && op2[0] < 9) { - this.item.data = Fleur.msToDayTimeDuration(op1[1].d - op1[1].tz * 60 * 1000 - op2[1].d + op2[1].tz * 60 * 1000); + res.data = Fleur.msToDayTimeDuration(op1[1].d - op1[1].tz * 60 * 1000 - op2[1].d + op2[1].tz * 60 * 1000); } else if (op1[0] > 5 && op1[0] < 9 && op2[0] > 8) { const d = op1[1].d; if (op2[0] === 9) { @@ -98,35 +83,34 @@ Fleur.Context.prototype.xqx_substractOp = function() { } } op1[1].d = d; - this.item.data = restype === 6 ? Fleur.dateToDate(op1[1]) : restype === 7 ? Fleur.dateToDateTime(op1[1]) : Fleur.dateToTime(op1[1]); + res.data = restype === 6 ? Fleur.dateToDate(op1[1]) : restype === 7 ? Fleur.dateToDateTime(op1[1]) : Fleur.dateToTime(op1[1]); } else if (op1[0] === 9 && op2[0] === 9) { - resvalue = op1[1].sign * (op1[1].year * 12 + op1[1].month) - op2[1].sign * (op2[1].year * 12 + op2[1].month); - res = { - sign: resvalue < 0 ? -1 : 1, - year: Math.floor(Math.abs(resvalue) / 12), - month: Math.abs(resvalue) % 12}; - this.item.data = (res.sign < 0 ? "-" : "") + "P" + (res.year !== 0 ? String(res.year) + "Y": "") + (res.month !== 0 || res.year === 0? String(res.month) + "M" : ""); + dresvalue = op1[1].sign * (op1[1].year * 12 + op1[1].month) - op2[1].sign * (op2[1].year * 12 + op2[1].month); + dres = { + sign: dresvalue < 0 ? -1 : 1, + year: Math.floor(Math.abs(dresvalue) / 12), + month: Math.abs(dresvalue) % 12}; + res.data = (dres.sign < 0 ? "-" : "") + "P" + (dres.year !== 0 ? String(dres.year) + "Y": "") + (dres.month !== 0 || dres.year === 0? String(dres.month) + "M" : ""); } else if (op1[0] === 10 && op2[0] === 10) { - resvalue = op1[1].sign * (((op1[1].day * 24 + op1[1].hour) * 60 + op1[1].minute) * 60 + op1[1].second) - op2[1].sign * (((op2[1].day * 24 + op2[1].hour) * 60 + op2[1].minute) * 60 + op2[1].second); - res = {sign: resvalue < 0 ? -1 : 1}; - resvalue = Math.abs(resvalue); - res.day = Math.floor(resvalue / 86400); - resvalue = resvalue % 86400; - res.hour = Math.floor(resvalue / 3600); - resvalue = resvalue % 3600; - res.minute = Math.floor(resvalue / 60); - res.second = resvalue % 60; - this.item.data = (res.sign < 0 ? "-" : "") + "P" + (res.day !== 0 ? String(res.day) + "D": "") + (res.hour !== 0 || res.minute !== 0 || res.second !== 0 || res.day + res.hour + res.minute === 0 ? "T" : "") + (res.hour !== 0 ? String(res.hour) + "H" : "") + (res.minute !== 0 ? String(res.minute) + "M" : "") + (res.second !== 0 || res.day + res.hour + res.minute === 0 ? String(res.second) + "S" : ""); + dresvalue = op1[1].sign * (((op1[1].day * 24 + op1[1].hour) * 60 + op1[1].minute) * 60 + op1[1].second) - op2[1].sign * (((op2[1].day * 24 + op2[1].hour) * 60 + op2[1].minute) * 60 + op2[1].second); + dres = {sign: dresvalue < 0 ? -1 : 1}; + dresvalue = Math.abs(dresvalue); + dres.day = Math.floor(dresvalue / 86400); + dresvalue = dresvalue % 86400; + dres.hour = Math.floor(dresvalue / 3600); + dresvalue = dresvalue % 3600; + dres.minute = Math.floor(dresvalue / 60); + dres.second = dresvalue % 60; + res.data = (dres.sign < 0 ? "-" : "") + "P" + (dres.day !== 0 ? String(dres.day) + "D": "") + (dres.hour !== 0 || dres.minute !== 0 || dres.second !== 0 || dres.day + dres.hour + dres.minute === 0 ? "T" : "") + (dres.hour !== 0 ? String(dres.hour) + "H" : "") + (dres.minute !== 0 ? String(dres.minute) + "M" : "") + (dres.second !== 0 || dres.day + dres.hour + dres.minute === 0 ? String(dres.second) + "S" : ""); } - this.item.schemaTypeInfo = Fleur.JSTypes[restype]; + res.schemaTypeInfo = Fleur.JSTypes[restype]; } else { - this.item = new Fleur.Text(); - this.item.schemaTypeInfo = Fleur.Type_error; - this.item._setNodeNameLocalNamePrefix("http://www.w3.org/2005/xqt-errors", "err:XPTY0004"); + Fleur.XQueryError_xqt(arg1.nodeType === Fleur.Node.ELEMENT_NODE || arg2.nodeType === Fleur.Node.ELEMENT_NODE ? "FORG0001" : "XPTY0004"); } + this.item = res; return this; }; - +/* Fleur.XQueryEngine[Fleur.XQueryX.subtractOp] = function(ctx, children, callback) { Fleur.XQueryEngine[children[0][1][0][0]](ctx, children[0][1][0][1], function(n) { var op1; @@ -216,4 +200,5 @@ Fleur.XQueryEngine[Fleur.XQueryX.subtractOp] = function(ctx, children, callback) Fleur.callback(function() {callback(a1);}); }); }); -}; \ No newline at end of file +}; +*/ \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/Operators/unaryMinusOp.js b/src/js/fleur.js/XQuery/Operators/unaryMinusOp.js index 1ba4e08..6102296 100644 --- a/src/js/fleur.js/XQuery/Operators/unaryMinusOp.js +++ b/src/js/fleur.js/XQuery/Operators/unaryMinusOp.js @@ -1,36 +1,40 @@ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ -Fleur.Transpiler.prototype.xqx_unaryMinusOp = function(children, expectedType) { - return this.inst("xqx_unaryMinusOp()", false, expectedType, this.gen(children[0][1][0], { - nodeType: Fleur.Node.TEXT_NODE, - schemaTypeInfo: Fleur.Type_numeric, - occurrence: 1 - })); +Fleur.Transpiler.prototype.xqx_unaryMinusOp = function(children, expectedSequenceType) { + const arg = this.gen(children[0][1][0], Fleur.SequenceType_numeric_1); + if (arg.value) { + return this.staticargs([arg]).xqx_unaryMinusOp().staticinst(this); + } + return this.inst("xqx_unaryMinusOp()", false, Fleur.SequenceType_numeric_1, arg.inst); }; Fleur.Context.prototype.xqx_unaryMinusOp = function() { const op = Fleur.toJSNumber(this.item); if (op[0] >= 0) { + const res = new Fleur.Text(); const schematype = this.item.schemaTypeInfo; if (schematype !== Fleur.Type_integer && schematype !== Fleur.Type_decimal && schematype !== Fleur.Type_float && schematype !== Fleur.Type_double) { if (schematype && schematype.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "integer", Fleur.TypeInfo.DERIVATION_RESTRICTION)) { - this.item.schemaTypeInfo = Fleur.Type_integer; + res.schemaTypeInfo = Fleur.Type_integer; } else if (schematype.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "decimal", Fleur.TypeInfo.DERIVATION_RESTRICTION)) { - this.item.schemaTypeInfo = Fleur.Type_decimal; + res.schemaTypeInfo = Fleur.Type_decimal; } else if (schematype.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "float", Fleur.TypeInfo.DERIVATION_RESTRICTION)) { - this.item.schemaTypeInfo = Fleur.Type_float; + res.schemaTypeInfo = Fleur.Type_float; } else if (schematype.isDerivedFrom("http://www.w3.org/2001/XMLSchema", "double", Fleur.TypeInfo.DERIVATION_RESTRICTION)) { - this.item.schemaTypeInfo = Fleur.Type_double; + res.schemaTypeInfo = Fleur.Type_double; } + } else { + res.schemaTypeInfo = schematype; } - this.item.data = this.item.schemaTypeInfo.canonicalize(String(-op[1])); + res.data = this.item.schemaTypeInfo.canonicalize(String(-op[1])); + this.item = res; } -return this; + return this; }; Fleur.XQueryEngine[Fleur.XQueryX.unaryMinusOp] = function(ctx, children, callback) { diff --git a/src/js/fleur.js/XQuery/Operators/unaryPlusOp.js b/src/js/fleur.js/XQuery/Operators/unaryPlusOp.js index 52d6dda..e35143d 100644 --- a/src/js/fleur.js/XQuery/Operators/unaryPlusOp.js +++ b/src/js/fleur.js/XQuery/Operators/unaryPlusOp.js @@ -1,9 +1,7 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ diff --git a/src/js/fleur.js/XQuery/Operators/valueComp.js b/src/js/fleur.js/XQuery/Operators/valueComp.js index 239f748..9a16616 100644 --- a/src/js/fleur.js/XQuery/Operators/valueComp.js +++ b/src/js/fleur.js/XQuery/Operators/valueComp.js @@ -1,8 +1,7 @@ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ diff --git a/src/js/fleur.js/XQuery/XQueryError.js b/src/js/fleur.js/XQuery/XQueryError.js index 613c4cb..36f78fe 100644 --- a/src/js/fleur.js/XQuery/XQueryError.js +++ b/src/js/fleur.js/XQuery/XQueryError.js @@ -8,7 +8,7 @@ Fleur.XQueryError = function(namespaceURI, localName, prefix, position, description, module, value, additional) { throw { name: "XQueryError", - message: "fn:error(xs:QName(\"" + (prefix ? prefix + ":" : "") + localName + "\"), \"" + description + "\"" + (value ? ", " + Fleur.Serializer._serializeNodeToXQuery(value, false, "") : "") + ")", + message: "fn:error(xs:QName('" + namespaceURI + "', '" + (prefix ? prefix + ":" : "") + localName + "')" + (!Fleur.TestSuite ? ", '" + description + "'" + (value ? ", " + Fleur.Serializer._serializeNodeToXQuery(value, false, "") : "") : "") + ")", namespaceURI: namespaceURI, localName: localName, prefix: prefix, diff --git a/src/js/fleur.js/XQuery/XQueryParser.js b/src/js/fleur.js/XQuery/XQueryParser.js index 160b982..ab4842e 100644 --- a/src/js/fleur.js/XQuery/XQueryParser.js +++ b/src/js/fleur.js/XQuery/XQueryParser.js @@ -257,7 +257,7 @@ Fleur.XQueryParser._calc = function(args, ops, newopprec, newop) { const op = ops.length !== 0 ? ops[ops.length - 1][1] : ""; const curprec = ops.length !== 0 ? ops[ops.length - 1][0] : 0; const prectest = ops.length === 0 || curprec > newopprec || ((newop === op || op === "then") && newop === "return") || newop === "then"; - console.log("XQuery - Consider \"" + newop + "\"[" + newopprec + "] vs. \"" + op + "\"[" + curprec + "] => " + (prectest ? "Do nothing" : "Evaluate \"" + op + "\"")); + //console.log("XQuery - Consider \"" + newop + "\"[" + newopprec + "] vs. \"" + op + "\"[" + curprec + "] => " + (prectest ? "Do nothing" : "Evaluate \"" + op + "\"")); if (prectest) { return [args, ops]; } @@ -461,9 +461,8 @@ Fleur.XQueryParser._calc = function(args, ops, newopprec, newop) { case "treat as?": case "treat as*": occ = op.charAt(8); - if (arg2val.indexOf("[Fleur.XQueryX.nameTest,") !== -1) { - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); - arg2 = [Fleur.XQueryX.atomicType,arg2[1][0]]; + if (arg2[1][0][1][1][0] === Fleur.XQueryX.nameTest) { + arg2 = [Fleur.XQueryX.atomicType, arg2[1][0][1][1][1]]; } else if (arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") !== -1) { arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") + 86); arg2val3 = arg2val2.substr(0, arg2val2.length - 4); @@ -482,10 +481,9 @@ Fleur.XQueryParser._calc = function(args, ops, newopprec, newop) { case "instance of?": case "instance of*": occ = op.charAt(11); - if (arg2val.indexOf("[Fleur.XQueryX.nameTest,") !== -1) { - arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.nameTest,") + 24); - arg2val3 = "[Fleur.XQueryX.atomicType," + arg2val2.substr(0, arg2val2.length - 4); - } else if (arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") !== -1) { + if (arg2[1][0][1][1][0] === Fleur.XQueryX.nameTest) { + arg2 = [Fleur.XQueryX.atomicType, arg2[1][0][1][1][1]]; + } else if (arg2[0] === Fleur.XQueryX.pathExpr) { arg2val2 = arg2val.substr(arg2val.indexOf("[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],") + 86); arg2val3 = arg2val2.substr(0, arg2val2.length - 4); } else { @@ -1048,19 +1046,19 @@ Fleur.XQueryParser._getPredParam = function(c, s, l, arg, allowpredicates, preds var r, t1; if (c2 !== "" && "0123456789".indexOf(c2) !== -1) { t1 = Fleur.XQueryParser._getNumber(c2 + d); - r = [Fleur.XQueryX.lookup,[[Fleur.XQueryX.integerConstantExpr,[[Fleur.XQueryX.value,[t1.replace(/e\+/, "e")]]]]]]; + t = [Fleur.XQueryX.lookup,[[Fleur.XQueryX.expr,[[Fleur.XQueryX.integerConstantExpr,[[Fleur.XQueryX.value,[t1.replace(/e\+/, "e")]]]]]]]]; plen = t1.length + 1; } else if (c2 !== "" && "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(c2) !== -1) { t1 = Fleur.XQueryParser._getName(c2 + d); - r = [Fleur.XQueryX.lookup,[[Fleur.XQueryX.NCName,[t1]]]]; + t = [Fleur.XQueryX.lookup,[[Fleur.XQueryX.NCName,[t1]]]]; plen = t1.length + 1; } else if (c2 === "*") { - r = [Fleur.XQueryX.lookup,[[Fleur.XQueryX.star,[]]]]; + t = [Fleur.XQueryX.lookup,[[Fleur.XQueryX.star,[]]]]; plen = 2; } else if (c2 === "(") { - t = Fleur.XQueryParser._xp2js(s.substr(i + 1), [], [999,"("]); - plen = s.length - parseInt(t.substr(0, t.indexOf(".")), 10) + 1 + i; - r = [Fleur.XQueryX.lookup,[[Fleur.XQueryX.expr,[t.substr(t.indexOf(".") + 1)]]]]; + t = Fleur.XQueryParser._xp2js(s.substr(i + 1), [], [[999, "("]]); + plen = s.length - t[3] + 1; + t = [Fleur.XQueryX.lookup,[[Fleur.XQueryX.expr,[[t[0], t[1]]]]]]; } } else { var func = []; @@ -1104,12 +1102,12 @@ Fleur.XQueryParser._getPredParam = function(c, s, l, arg, allowpredicates, preds p = [Fleur.XQueryX.computedCommentConstructor,(cargs[1] !== 0 ? [[Fleur.XQueryX.argExpr,[cargs]]] : []), 0, plen, 0]; break; case "map": - var cargs2 = cargs[0] === Fleur.XQueryX.arguments ? cargs[1] : cargs; - p = [Fleur.XQueryX.mapConstructor,[cargs2], 0, plen, 0]; + var cargs2 = cargs[0] === Fleur.XQueryX.sequenceExpr ? cargs[1] : [cargs]; + p = [Fleur.XQueryX.mapConstructor, cargs2, 0, plen, 0]; break; case "array": - var cargs3 = cargs[0] === Fleur.XQueryX.arguments ? cargs[1] : cargs; - p = [Fleur.XQueryX.arrayConstructor,[cargs3], 0, plen, 0]; + var cargs3 = cargs[0] === Fleur.XQueryX.arguments ? cargs[1] : [cargs]; + p = [Fleur.XQueryX.arrayConstructor, cargs3, 0, plen, 0]; break; case "entry": p = [Fleur.XQueryX.computedEntryConstructor,[[Fleur.XQueryX.tagNameExpr,[cargs]]], 0, plen, 0]; @@ -1201,8 +1199,8 @@ Fleur.XQueryParser._getPredParam = function(c, s, l, arg, allowpredicates, preds c = xq.charAt(j); var tdecl = []; if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) !== -1) { - d = xq.substr(j + 1); - r = Fleur.XQueryParser._getName(c + d); + let d = xq.substr(j + 1); + let r = Fleur.XQueryParser._getName(c + d); if (r === "as") { j = Fleur.XQueryParser._skipSpaces(xq, j + r.length); c = xq.charAt(j); @@ -1235,14 +1233,14 @@ Fleur.XQueryParser._getPredParam = function(c, s, l, arg, allowpredicates, preds j = Fleur.XQueryParser._skipSpaces(xq, j + 1); c = xq.charAt(j); if (c === "a") { - d = xq.substr(j + 1); - r = Fleur.XQueryParser._getName(c + d); + let d = xq.substr(j + 1); + let r = Fleur.XQueryParser._getName(c + d); if (r === "as") { j = Fleur.XQueryParser._skipSpaces(xq, j + r.length); c = xq.charAt(j); if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) !== -1) { d = xq.substr(j + 1); - ptype = Fleur.XQueryParser._getName(c + d); + let ptype = Fleur.XQueryParser._getName(c + d); pindex = ptype.indexOf(":"); np = pindex === -1 ? "'" + ptype + "'" : "'" + ptype.substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + ptype.substr(0, pindex) + "']]"; c = xq.charAt(j + ptype.length); @@ -1353,7 +1351,7 @@ Fleur.XQueryParser._getPredParam = function(c, s, l, arg, allowpredicates, preds arg1 = arg.substr(0, arg.length - 8).substr(77); arg2 = ""; } - fargs = t.length !== 0 && t[0] !== Fleur.XQueryX.arguments ? [Fleur.XQueryX.arguments,[t]] : t; + let fargs = t.length !== 0 && t[0] !== Fleur.XQueryX.arguments ? [Fleur.XQueryX.arguments,[t]] : t; arg1 = [arg1]; if (arg2.length !== 0) { arg1.push([lookup ? Fleur.XQueryX.lookup: Fleur.XQueryX.predicates,[arg2]]); @@ -1373,13 +1371,13 @@ Fleur.XQueryParser._getPredParam = function(c, s, l, arg, allowpredicates, preds p = [Fleur.XQueryX.flworExpr,t[0] === Fleur.XQueryX.arguments || t[0] === Fleur.XQueryX.flworExpr ? t[1] : [t], 0, plen, 0]; isret = true; } else if (arg[0] === Fleur.XQueryX.quantifiedExpr && arg[1][0] && arg[1][0][0] === Fleur.XQueryX.quantifier) { - fargs = t[0] === Fleur.XQueryX.arguments ? t[1] : [t]; + let fargs = t[0] === Fleur.XQueryX.arguments ? t[1] : [t]; arg[1].push(fargs); p = arg; p[3] = plen; isret = true; } else if (arg.length !== 0 && arg[1] !== 0) { - fargs = t[0] === Fleur.XQueryX.arguments ? t[1] : [t]; + let fargs = t[0] === Fleur.XQueryX.arguments ? t[1] : [t]; p = [Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.filterExpr,[[Fleur.XQueryX.dynamicFunctionInvocationExpr,[[Fleur.XQueryX.functionItem,[arg]],fargs]]]]]]]]; } else { p = t; @@ -1393,10 +1391,12 @@ Fleur.XQueryParser._getPredParam = function(c, s, l, arg, allowpredicates, preds const stepcontent = arg[1][0][1]; const laststepcontent = stepcontent[stepcontent.length - 1]; if (c === "?") { - if (arg.indexOf(",[Fleur.XQueryX.predicates,[") === -1) { - p = plen + "." + arg.substr(0, arg.length - 4) + "," + t.substr(t.indexOf(".") + 1) + "]]]]"; + if (laststepcontent[0] !== Fleur.XQueryX.predicates) { + stepcontent.push(t); + p = arg; + p[3] = plen; } else { - p = plen + "." + arg.substr(0, predstart) + predarr.reduce(function(s, pr) {return s + ",[Fleur.XQueryX.predicate,[" + pr + "]]";}, "") + "," + t.substr(t.indexOf(".") + 1) + "]]]]";; + p = plen + "." + arg.substr(0, predstart) + predarr.reduce(function(s, pr) {return s + ",[Fleur.XQueryX.predicate,[" + pr + "]]";}, "") + "," + t.substr(t.indexOf(".") + 1) + "]]]]"; } allowpredicates = false; } else if (laststepcontent[0] !== Fleur.XQueryX.predicates) { @@ -1506,12 +1506,12 @@ Fleur.XQueryParser._xp2js = function(xp, args, ops, begin) { const t51 = Fleur.XQueryParser._getName(d); const pt51 = (t51.indexOf(":") === -1 ? ":" : "") + t51; if ((ops.length !== 0 && ops[0][1] === "group by") || (ops.length > 1 && ops[0][1] === "~," && ops[1][1] === "group by")) { - r = [Fleur.XQueryX.groupingSpec,[[Fleur.XQueryX.varName,[pt51.substr(pt51.indexOf(":") + 1)]]], begin, t51.length + 1, 0]; + r = [Fleur.XQueryX.groupingSpec,[[Fleur.XQueryX.varName,[pt51.substring(pt51.indexOf(":") + 1)]]], begin, t51.length + 1, 0]; } else { - r = [Fleur.XQueryX.varRef,[[Fleur.XQueryX.name,[pt51.substr(pt51.indexOf(":") + 1)]]], begin, t51.length + 1, 0]; + r = [Fleur.XQueryX.varRef,[[Fleur.XQueryX.name,[pt51.substring(pt51.indexOf(":") + 1)]]], begin, t51.length + 1, 0]; } if (pt51.charAt(0) !== ":") { - r[1][0][1].push([Fleur.XQueryX.prefix,[pt51.substr(0, pt51.indexOf(":"))]]); + r[1][0][1].push([Fleur.XQueryX.prefix,[pt51.substring(0, pt51.indexOf(":"))]]); } } else if (c === "?") { var c2 = d.charAt(0); @@ -1747,7 +1747,7 @@ Fleur.XQueryParser._getVersion = function(xq) { var r = ""; var v, e; if (c === "" || "abcdefghijklmnopqrstuvwxyz".indexOf(c) === -1) { - return i + "."; + return [0, 0, i, 0, 0]; } r = Fleur.XQueryParser._getName(c + d); if (r === "xquery") { @@ -1755,7 +1755,7 @@ Fleur.XQueryParser._getVersion = function(xq) { c = xq.charAt(j); d = xq.substr(j + 1); if (c === "" || "abcdefghijklmnopqrstuvwxyz".indexOf(c) === -1) { - return i + "."; + return [0, 0, i, 0, 0]; } r = Fleur.XQueryParser._getName(c + d); if (r === "version") { @@ -1763,15 +1763,15 @@ Fleur.XQueryParser._getVersion = function(xq) { c = xq.charAt(j); d = xq.substr(j + 1); if (c !== "'" && c !== '"') { - return i + "."; + return [0, 0, i, 0, 0]; } - r = Fleur.XQueryParser._getStringLiteral(c + d); - var vl = r.substr(0, r.indexOf(".")); - v = r.substr(vl.length + 1); - j = Fleur.XQueryParser._skipSpaces(xq, j + parseInt(vl, 10)); + r = Fleur.XQueryParser._getStringLiteral(c + d, Fleur.XQueryX.version, i); + var vl = r[3]; + v = [r[0], r[1]]; + j = Fleur.XQueryParser._skipSpaces(xq, j + vl); c = xq.charAt(j); if (c === ";") { - return (j + 1) + ".[Fleur.XQueryX.versionDecl,[[Fleur.XQueryX.version,[" + v + "]]]],"; + return [Fleur.XQueryX.versionDecl,[v], i, j + 1, 0]; } d = xq.substr(j + 1); r = Fleur.XQueryParser._getName(c + d); @@ -1781,19 +1781,24 @@ Fleur.XQueryParser._getVersion = function(xq) { c = xq.charAt(j); d = xq.substr(j + 1); if (c !== "'" && c !== '"') { - return i + "."; + return [0, 0, i, 0, 0]; } - r = Fleur.XQueryParser._getStringLiteral(c + d); - var el = r.substr(0, r.indexOf(".")); - e = r.substr(el.length + 1); - j = Fleur.XQueryParser._skipSpaces(xq, j + parseInt(el, 10)); + r = Fleur.XQueryParser._getStringLiteral(c + d, Fleur.XQueryX.encoding, i); + var el = r[3]; + e = [r[0], r[1]]; + j = Fleur.XQueryParser._skipSpaces(xq, j + el); c = xq.charAt(j); if (c === ";") { - return (j + 1) + ".[Fleur.XQueryX.versionDecl,[" + (v ? "[Fleur.XQueryX.version,[" + v + "]]," : "") + "[Fleur.XQueryX.encoding,[" + e + "]]]],"; + r = [Fleur.XQueryX.versionDecl,[], i, j + 1, 0]; + if (v) { + r[1].push(v); + } + r[1].push(e); + return r; } } } - return i + "."; + return [0, 0, i, 0, 0]; }; Fleur.XQueryParser._getProlog = function(xq, i) { var pindex; @@ -1801,7 +1806,7 @@ Fleur.XQueryParser._getProlog = function(xq, i) { var c = xq.charAt(i); var d = xq.substr(i + 1); var r = "", prefix, v, vl; - var res = i + "."; + var res = [0, 0, i, 0, 0]; var end = xq.length; var updatingfunction = false; var j; @@ -1811,7 +1816,7 @@ Fleur.XQueryParser._getProlog = function(xq, i) { case "declare": j = Fleur.XQueryParser._skipSpaces(xq, i + r.length); c = xq.charAt(j); - d = xq.substr(j + 1); + d = xq.substring(j + 1); while (c === "%") { r = Fleur.XQueryParser._getName(d); if (r === "updating") { @@ -1827,7 +1832,7 @@ Fleur.XQueryParser._getProlog = function(xq, i) { case "default": j = Fleur.XQueryParser._skipSpaces(xq, j + r.length); c = xq.charAt(j); - d = xq.substr(j + 1); + d = xq.substring(j + 1); if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) !== -1) { r = Fleur.XQueryParser._getName(c + d); switch (r) { @@ -1844,13 +1849,12 @@ Fleur.XQueryParser._getProlog = function(xq, i) { c = xq.charAt(j); d = xq.substr(j + 1); if (c === "'" || c === '"') { - r = Fleur.XQueryParser._getStringLiteral(c + d); - vl = r.substr(0, r.indexOf(".")); - v = r.substr(vl.length + 1); - j = Fleur.XQueryParser._skipSpaces(xq, j + parseInt(vl, 10)); + r = Fleur.XQueryParser._getStringLiteral(c + d, Fleur.XQueryX.uri, 0); + vl = r[3]; + j = Fleur.XQueryParser._skipSpaces(xq, j + vl); c = xq.charAt(j); if (c === ";") { - return (j + 1) + ".[Fleur.XQueryX.defaultNamespaceDecl,[[Fleur.XQueryX.defaultNamespaceCategory,['" + category + "']],[Fleur.XQueryX.uri,[" + v + "]]]],"; + return [Fleur.XQueryX.defaultNamespaceDecl,[[Fleur.XQueryX.defaultNamespaceCategory,[category]],[r[0], r[1]]], i, j + 1, 0]; } } } @@ -1861,13 +1865,12 @@ Fleur.XQueryParser._getProlog = function(xq, i) { c = xq.charAt(j); d = xq.substr(j + 1); if (c === "'" || c === '"') { - r = Fleur.XQueryParser._getStringLiteral(c + d); - vl = r.substr(0, r.indexOf(".")); - v = r.substr(vl.length + 1); - j = Fleur.XQueryParser._skipSpaces(xq, j + parseInt(vl, 10)); + r = Fleur.XQueryParser._getStringLiteral(c + d, Fleur.XQueryX.defaultCollationDecl, 0); + vl = r[3]; + j = Fleur.XQueryParser._skipSpaces(xq, j + vl); c = xq.charAt(j); if (c === ";") { - return (j + 1) + ".[Fleur.XQueryX.defaultCollationDecl,[" + v + "]],"; + return [r[0], r[1], i, j + 1, 0]; } } break; @@ -1887,7 +1890,7 @@ Fleur.XQueryParser._getProlog = function(xq, i) { j = Fleur.XQueryParser._skipSpaces(xq, j + r.length); c = xq.charAt(j); if (c === ";") { - return (j + 1) + ".[Fleur.XQueryX.emptyOrderingDecl,['empty " + r + "']],"; + return [Fleur.XQueryX.emptyOrderingDecl,["empty " + r], i, j + 1]; } } } @@ -1910,7 +1913,7 @@ Fleur.XQueryParser._getProlog = function(xq, i) { j = Fleur.XQueryParser._skipSpaces(xq, j + r.length); c = xq.charAt(j); if (c === ";") { - return (j + 1) + ".[Fleur.XQueryX." + decl + ",['" + r + "']],"; + return [Fleur.XQueryX[decl],[r], i, j + 1, 0]; } } } @@ -1920,13 +1923,12 @@ Fleur.XQueryParser._getProlog = function(xq, i) { c = xq.charAt(j); d = xq.substr(j + 1); if (c === "'" || c === '"') { - r = Fleur.XQueryParser._getStringLiteral(c + d); - vl = r.substr(0, r.indexOf(".")); - v = r.substr(vl.length + 1); - j = Fleur.XQueryParser._skipSpaces(xq, j + parseInt(vl, 10)); + r = Fleur.XQueryParser._getStringLiteral(c + d, Fleur.XQueryX.baseUriDecl, 0); + vl = r[3]; + j = Fleur.XQueryParser._skipSpaces(xq, j + vl); c = xq.charAt(j); if (c === ";") { - return (j + 1) + ".[Fleur.XQueryX.baseUriDecl,[" + v + "]],"; + return [r[0], r[1], i, j + 1, 0]; } } break; @@ -1940,7 +1942,7 @@ Fleur.XQueryParser._getProlog = function(xq, i) { j = Fleur.XQueryParser._skipSpaces(xq, j + r.length); c = xq.charAt(j); if (c === ";") { - return (j + 1) + ".[Fleur.XQueryX.orderingModeDecl,['" + r + "']],"; + return [Fleur.XQueryX.orderingModeDecl,[r], i, j + 1, 0]; } } } @@ -1965,7 +1967,7 @@ Fleur.XQueryParser._getProlog = function(xq, i) { j = Fleur.XQueryParser._skipSpaces(xq, j + r.length); c = xq.charAt(j); if (c === ";") { - return (j + 1) + ".[Fleur.XQueryX.copyNamespacesDecl,[[Fleur.XQueryX.preserveMode,['" + preserve + "']],[Fleur.XQueryX.inheritMode,['" + r + "']]]],"; + return [Fleur.XQueryX.copyNamespacesDecl,[[Fleur.XQueryX.preserveMode,[preserve]],[Fleur.XQueryX.inheritMode,[r]]], i, j + 1, 0]; } } } @@ -1988,13 +1990,12 @@ Fleur.XQueryParser._getProlog = function(xq, i) { c = xq.charAt(j); d = xq.substr(j + 1); if (c === "'" || c === '"') { - r = Fleur.XQueryParser._getStringLiteral(c + d); - vl = r.substr(0, r.indexOf(".")); - v = r.substr(vl.length + 1); - j = Fleur.XQueryParser._skipSpaces(xq, j + parseInt(vl, 10)); + r = Fleur.XQueryParser._getStringLiteral(c + d, Fleur.XQueryX.uri, 0); + vl = r[3]; + j = Fleur.XQueryParser._skipSpaces(xq, j + vl); c = xq.charAt(j); if (c === ";") { - return (j + 1) + ".[Fleur.XQueryX.namespaceDecl,[[Fleur.XQueryX.prefixElt,['" + prefix + "']],[Fleur.XQueryX.uri,[" + v + "]]]],"; + return [Fleur.XQueryX.namespaceDecl,[[Fleur.XQueryX.prefixElt,[prefix]],[r[0], r[1]]], i, j + 1, 0]; } } } @@ -2015,25 +2016,23 @@ Fleur.XQueryParser._getProlog = function(xq, i) { var vname = Fleur.XQueryParser._getName(c + d); j = Fleur.XQueryParser._skipSpaces(xq, j + vname.length); c = xq.charAt(j); - d = xq.substr(j + 1); + d = xq.substring(j + 1); pindex = vname.indexOf(":"); - var np = pindex === -1 ? "'" + vname + "'" : "'" + vname.substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + vname.substr(0, pindex) + "']]"; - var fres = ".[Fleur.XQueryX.varDecl,[[Fleur.XQueryX.varName,[" + np + "]]"; - var nbpar = 0; + var np = pindex === -1 ? [vname] : [vname.substring(pindex + 1), [Fleur.XQueryX.prefix, [vname.substring(0, pindex)]]]; + var fres = [Fleur.XQueryX.varDecl, [[Fleur.XQueryX.varName, np]]]; r = Fleur.XQueryParser._getName(c + d); if (r === "external") { j = Fleur.XQueryParser._skipSpaces(xq, j + r.length); c = xq.charAt(j); - fres += ",[Fleur.XQueryX.external,[]]"; + fres[1].push([Fleur.XQueryX.external, []]); if (c === ";") { - return (j + 1) + fres + "]],"; + return [fres[0], fres[1], i, j + 1, 0]; } d = xq.substr(j + 1); } if (c + d.charAt(0) !== ":=") { return res; } - fres += ",[Fleur.XQueryX.varValue,["; j = Fleur.XQueryParser._skipSpaces(xq, j + 2); c = xq.charAt(j); var parents = 0; @@ -2059,11 +2058,11 @@ Fleur.XQueryParser._getProlog = function(xq, i) { c = xq.charAt(++j); } if (vvalue !== "") { - fres += Fleur.XQueryParser._xp2js(vvalue, [], [], 0); + const vcomp = Fleur.XQueryParser._xp2js(vvalue, [], [], 0); + fres[1].push([Fleur.XQueryX.varValue, [[vcomp[0], vcomp[1]]]]); } - fres += "]]]],"; if (c === ";") { - return (j + 1) + fres; + return [fres[0], fres[1], i, j + 1, 0]; } } break; @@ -2076,9 +2075,18 @@ Fleur.XQueryParser._getProlog = function(xq, i) { j = Fleur.XQueryParser._skipSpaces(xq, j + fname.length); c = xq.charAt(j); pindex = fname.indexOf(":"); - var np = pindex === -1 ? "'" + fname + "'" : "'" + fname.substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + fname.substr(0, pindex) + "']]"; - var fres = ".[Fleur.XQueryX.functionDecl,[" + (updatingfunction ? "[Fleur.XQueryX.updatingFunction,['true']]," : "") + "[Fleur.XQueryX.functionName,[" + np + "]],[Fleur.XQueryX.paramList,["; - var nbpar = 0; + let np; + if (pindex === -1) { + np = [fname]; + } else { + np = [fname.substring(pindex + 1), [Fleur.XQueryX.prefix, [fname.substring(0, pindex)]]]; + } + const fres = [Fleur.XQueryX.functionDecl,[]]; + if (updatingfunction) { + fres[1].push([Fleur.XQueryX.updatingFunction,["true"]]); + } + fres[1].push([Fleur.XQueryX.functionName, np]); + const plist = [Fleur.XQueryX.paramList,[]]; if (c === "(") { do { j = Fleur.XQueryParser._skipSpaces(xq, j + 1); @@ -2096,7 +2104,7 @@ Fleur.XQueryParser._getProlog = function(xq, i) { var pname = Fleur.XQueryParser._getName(c + d); j = Fleur.XQueryParser._skipSpaces(xq, j + pname.length); c = xq.charAt(j); - var tdecl = ""; + const param = [Fleur.XQueryX.param,[[Fleur.XQueryX.varName,[pname]]]]; if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) !== -1) { d = xq.substr(j + 1); r = Fleur.XQueryParser._getName(c + d); @@ -2107,30 +2115,31 @@ Fleur.XQueryParser._getProlog = function(xq, i) { d = xq.substr(j + 1); var ptype = Fleur.XQueryParser._getName(c + d); pindex = ptype.indexOf(":"); - np = pindex === -1 ? "'" + ptype + "'" : "'" + ptype.substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + ptype.substr(0, pindex) + "']]"; + let np; + if (pindex === -1) { + np = [ptype]; + } else { + np = [ptype.substring(pindex + 1) ,[Fleur.XQueryX.prefix, [ptype.substring(0, pindex)]]]; + } c = xq.charAt(j + ptype.length); - tdecl = ",[Fleur.XQueryX.typeDeclaration,[[Fleur.XQueryX.atomicType,[" + np + "]]"; + const tdecl = [Fleur.XQueryX.typeDeclaration, [[Fleur.XQueryX.atomicType, np]]]; if ("?+*".indexOf(c) !== -1) { - tdecl += ",[Fleur.XQueryX.occurrenceIndicator,['" + c + "']]"; + tdecl[1].push([Fleur.XQueryX.occurrenceIndicator,[c]]); j++; } - tdecl += "]]"; + param[1].push(tdecl); j = Fleur.XQueryParser._skipSpaces(xq, j + ptype.length); c = xq.charAt(j); } } } - if (nbpar !== 0) { - fres += ","; - } - fres += "[Fleur.XQueryX.param,[[Fleur.XQueryX.varName,['" + pname + "']]" + tdecl + "]]"; - nbpar++; + plist[1].push(param); } } while (c === ","); + fres[1].push(plist); if (c !== ")") { return res; } - fres += "]]"; j = Fleur.XQueryParser._skipSpaces(xq, j + 1); c = xq.charAt(j); if (c === "a") { @@ -2145,39 +2154,23 @@ Fleur.XQueryParser._getProlog = function(xq, i) { c = xq.charAt(++j); } np = Fleur.XQueryParser._xp2js(ftdecl, [], [], 0); - if (np === "[Fleur.XQueryX.pathExpr,[[Fleur.XQueryX.stepExpr,[[Fleur.XQueryX.xpathAxis,['child']],[Fleur.XQueryX.anyItemType,[]]]]]]") { - np = "[Fleur.XQueryX.anyItemType,[]]"; + if (np[1][0][1][1][0] === Fleur.XQueryX.anyItemType) { + np = [Fleur.XQueryX.anyItemType, []]; } else { - np = np.substr(np.indexOf("[Fleur.XQueryX.nameTest,") + 24); - np = "[Fleur.XQueryX.atomicType," + np.substr(0, np.length - 4); + //np = np.substr(np.indexOf("[Fleur.XQueryX.nameTest,") + 24); + np = [Fleur.XQueryX.atomicType,np[1][0][1][1][1]]; } - fres += ",[Fleur.XQueryX.typeDeclaration,[" + np; + const fdecl = [Fleur.XQueryX.typeDeclaration, [np]]; if ("?+*".indexOf(c) !== -1) { - fres += ",[Fleur.XQueryX.occurrenceIndicator,['" + c + "']]"; + fdecl[1].push([Fleur.XQueryX.occurrenceIndicator,[c]]); j++; } - fres += "]]"; + fres[1].push(fdecl); j = Fleur.XQueryParser._skipSpaces(xq, j); c = xq.charAt(j); -/* if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) !== -1) { - d = xq.substr(j + 1); - ptype = Fleur.XQueryParser._getName(c + d); - pindex = ptype.indexOf(":"); - np = pindex === -1 ? "'" + ptype + "'" : "'" + ptype.substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + ptype.substr(0, pindex) + "']]"; - c = xq.charAt(j + ptype.length); - fres += ",[Fleur.XQueryX.typeDeclaration,[[Fleur.XQueryX.atomicType,[" + np + "]]"; - if ("?+*".indexOf(c) !== -1) { - fres += ",[Fleur.XQueryX.occurrenceIndicator,['" + c + "']]"; - j++; - } - fres += "]]"; - j = Fleur.XQueryParser._skipSpaces(xq, j + ptype.length); - c = xq.charAt(j); - }*/ } } if (c === "{") { - fres += ",[Fleur.XQueryX.functionBody,["; var braces = 1; var body = ""; while ((c !== "}" || braces !== 0) && j !== end) { @@ -2192,13 +2185,15 @@ Fleur.XQueryParser._getProlog = function(xq, i) { } } if (body !== "") { - fres += Fleur.XQueryParser._xp2js(body, [], [], 0); + const fbres = Fleur.XQueryParser._xp2js(body, [], [], 0); + fres[1].push([Fleur.XQueryX.functionBody,[[fbres[0], fbres[1]]]]); + } else { + fres[1].push([Fleur.XQueryX.functionBody,[]]); } - fres += "]]]],"; j = Fleur.XQueryParser._skipSpaces(xq, j + 1); c = xq.charAt(j); if (c === ";") { - return (j + 1) + fres; + return [fres[0], fres[1], i, j + 1, 0]; } } else if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) !== -1) { d = xq.substr(j + 1); @@ -2206,9 +2201,9 @@ Fleur.XQueryParser._getProlog = function(xq, i) { if (r === "external") { j = Fleur.XQueryParser._skipSpaces(xq, j + r.length); c = xq.charAt(j); - fres += ",[Fleur.XQueryX.externalDefinition,[]]]],"; + fres[1].push([Fleur.XQueryX.externalDefinition,[]]); if (c === ";") { - return (j + 1) + fres; + return [fres[0], fres[1], i, j + 1, 0]; } } } @@ -2225,17 +2220,16 @@ Fleur.XQueryParser._getProlog = function(xq, i) { c = xq.charAt(j); d = xq.substr(j + 1); if (c === "'" || c === '"') { - r = Fleur.XQueryParser._getStringLiteral(c + d); - vl = r.substr(0, r.indexOf(".")); - v = r.substr(vl.length + 1); - j = Fleur.XQueryParser._skipSpaces(xq, j + parseInt(vl, 10)); + r = Fleur.XQueryParser._getStringLiteral(c + d, Fleur.XQueryX.optionContents, 0); + vl = r[3]; + j = Fleur.XQueryParser._skipSpaces(xq, j + vl); c = xq.charAt(j); if (c === ";") { pindex = optionname.indexOf(":"); if (pindex === -1) { - return (j + 1) + ".[Fleur.XQueryX.optionDecl,[[Fleur.XQueryX.optionName,['" + optionname + "']],[Fleur.XQueryX.optionContents,[" + v + "]]]],"; + return [Fleur.XQueryX.optionDecl,[[Fleur.XQueryX.optionName,[optionname]],[r[0], r[1]]], i, j + 1, 0]; } - return (j + 1) + ".[Fleur.XQueryX.optionDecl,[[Fleur.XQueryX.optionName,['" + optionname.substr(pindex + 1) + "',[Fleur.XQueryX.prefix,['" + optionname.substr(0, pindex) + "']]]],[Fleur.XQueryX.optionContents,[" + v + "]]]],"; + return [Fleur.XQueryX.optionDecl,[[Fleur.XQueryX.optionName,[optionname.substring(pindex + 1),[Fleur.XQueryX.prefix,[optionname.substring(0, pindex)]]]],[r[0], r[1]]], i, j + 1, 0]; } } } @@ -2259,13 +2253,12 @@ Fleur.XQueryParser._getProlog = function(xq, i) { c = xq.charAt(j); d = xq.substr(j + 1); if (c === "'" || c === '"') { - r = Fleur.XQueryParser._getStringLiteral(c + d); - vl = r.substr(0, r.indexOf(".")); - v = r.substr(vl.length + 1); + r = Fleur.XQueryParser._getStringLiteral(c + d, Fleur.XQueryX.targetLocation, 0); + vl = r[3]; j = Fleur.XQueryParser._skipSpaces(xq, j + parseInt(vl, 10)); c = xq.charAt(j); if (c === ";") { - return (j + 1) + ".[Fleur.XQueryX.javascriptImport,[[Fleur.XQueryX.targetLocation,[" + v + "]]]],"; + return [Fleur.XQueryX.javascriptImport,[[r[0], r[1]]], i, j + 1, 0]; } } } else { @@ -2304,10 +2297,10 @@ Fleur.XQueryParser._getProlog = function(xq, i) { } } if (c === "'" || c === '"') { - r = Fleur.XQueryParser._getStringLiteral(c + d); - vl = r.substr(0, r.indexOf(".")); - var modname = r.substr(vl.length + 1); - j = Fleur.XQueryParser._skipSpaces(xq, j + parseInt(vl, 10)); + r = Fleur.XQueryParser._getStringLiteral(c + d, Fleur.XQueryX.targetNamespace, 0); + vl = r[3]; + var modname = [r[0], r[1]]; + j = Fleur.XQueryParser._skipSpaces(xq, j + vl); c = xq.charAt(j); d = xq.substr(j + 1); v = null; @@ -2327,7 +2320,14 @@ Fleur.XQueryParser._getProlog = function(xq, i) { } } if (c === ";") { - return (j + 1) + ".[Fleur.XQueryX.moduleImport,[[Fleur.XQueryX.targetNamespace,[" + modname + "]]" + (prefix ? ",[Fleur.XQueryX.namespacePrefix,['" + prefix + "']]" : "") + (v ? ",[Fleur.XQueryX.targetLocationExpr,[" + v + "]]" : "") + "]],"; + const fres = [Fleur.XQueryX.moduleImport, [modname], i, j + 1, 0]; + if (prefix) { + fres[1].push([Fleur.XQueryX.namespacePrefix,[prefix]]); + } + if (v && v[0] !== 0) { + fres[1].push([Fleur.XQueryX.targetLocationExpr,[[v[0], v[1]]]]); + } + return fres; } } } @@ -2340,13 +2340,31 @@ Fleur.XQueryParser._xq2js = function(xq) { //console.log("_xq2js: " + xq); //xq = xq.replace(/^\s+|\s+$/gm, " "); const v = Fleur.XQueryParser._getVersion(xq); - const vl = v.substr(0, v.indexOf(".")); - let prolog = "", p, pc, pl = parseInt(vl, 10); + const prologs = []; + let pl = v[3]; do { - p = Fleur.XQueryParser._getProlog(xq, pl); - pl = parseInt(p.substr(0, p.indexOf(".")), 10); - pc = p.substr(p.indexOf(".") + 1); - prolog += pc; - } while (pc !== ""); - return "[Fleur.XQueryX.module,[" + v.substr(v.indexOf(".") + 1) + "[Fleur.XQueryX.mainModule,[" + (prolog === "" ? "" : "[Fleur.XQueryX.prolog,[" + prolog.substr(0, prolog.length - 1) + "]],") + "[Fleur.XQueryX.queryBody,[" + Fleur.XQueryParser._xp2js(xq.substr(pl), [], [], 0) + ']]]],[Fleur.XQueryX.xqx,["http://www.w3.org/2005/XQueryX"]],[Fleur.XQueryX.xqxuf,["http://www.w3.org/2007/xquery-update-10"]],[Fleur.XQueryX.schemaLocation,["http://www.w3.org/2007/xquery-update-10 http://www.w3.org/2007/xquery-update-10/xquery-update-10-xqueryx.xsd http://www.w3.org/2005/XQueryX http://www.w3.org/2005/XQueryX/xqueryx.xsd"]],[Fleur.XQueryX.xsi,["http://www.w3.org/2001/XMLSchema-instance"]]]]'; + const p = Fleur.XQueryParser._getProlog(xq, pl); + if (p[0] === 0) { + pl = p[2]; + break; + } + pl = p[3]; + prologs.push([p[0], p[1]]); + } while (true); + const r = [Fleur.XQueryX.module,[]]; + if (v[0] !== 0) { + r[1].push([v[0], v[1]]); + } + const mainmodule = [Fleur.XQueryX.mainModule,[]]; + if (prologs.length !== 0) { + mainmodule[1].push([Fleur.XQueryX.prolog, prologs]); + } + const xp = Fleur.XQueryParser._xp2js(xq.substr(pl), [], [], 0); + mainmodule[1].push([Fleur.XQueryX.queryBody, [[xp[0], xp[1]]]]); + r[1].push(mainmodule); + r[1].push([Fleur.XQueryX.xqx,["http://www.w3.org/2005/XQueryX"]]); + r[1].push([Fleur.XQueryX.xqxuf,["http://www.w3.org/2007/xquery-update-10"]]); + r[1].push([Fleur.XQueryX.schemaLocation,["http://www.w3.org/2007/xquery-update-10 http://www.w3.org/2007/xquery-update-10/xquery-update-10-xqueryx.xsd http://www.w3.org/2005/XQueryX http://www.w3.org/2005/XQueryX/xqueryx.xsd"]]); + r[1].push([Fleur.XQueryX.xsi,["http://www.w3.org/2001/XMLSchema-instance"]]); + return r; }; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/locale.js b/src/js/fleur.js/XQuery/locale.js index b3e3362..bc18469 100644 --- a/src/js/fleur.js/XQuery/locale.js +++ b/src/js/fleur.js/XQuery/locale.js @@ -1,147 +1,145 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ Fleur.locale = {}; Fleur.locale["ar"] = { - weekdays:["\u0627\u0644\u0623\u062D\u062F","\u0627\u0644\u0627\u062B\u0646\u064A\u0646","\u0627\u0644\u062B\u0644\u0627\u062B\u0627\u0621","\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621","\u0627\u0644\u062E\u0645\u064A\u0633","\u0627\u0644\u062C\u0645\u0639\u0629","\u0627\u0644\u0633\u0628\u062A"], - months: ["\u0631\u0628\u064A\u0639 \u0627\u0644\u0622\u062E\u0631","\u062C\u0645\u0627\u062F\u0649 \u0627\u0644\u0623\u0648\u0644\u0649","\u062C\u0645\u0627\u062F\u0649 \u0627\u0644\u0622\u062E\u0631\u0629","\u0631\u062C\u0628","\u0634\u0639\u0628\u0627\u0646","\u0631\u0645\u0636\u0627\u0646","\u0634\u0648\u0627\u0644","\u0630\u0648 \u0627\u0644\u0642\u0639\u062F\u0629","\u0630\u0648 \u0627\u0644\u062D\u062C\u0629","\u0645\u062D\u0631\u0645","\u0635\u0641\u0631","\u0631\u0628\u064A\u0639 \u0627\u0644\u0623\u0648\u0644"]}; + weekdays:["\u0627\u0644\u0623\u062D\u062F","\u0627\u0644\u0627\u062B\u0646\u064A\u0646","\u0627\u0644\u062B\u0644\u0627\u062B\u0627\u0621","\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621","\u0627\u0644\u062E\u0645\u064A\u0633","\u0627\u0644\u062C\u0645\u0639\u0629","\u0627\u0644\u0633\u0628\u062A"], + months: ["\u0631\u0628\u064A\u0639 \u0627\u0644\u0622\u062E\u0631","\u062C\u0645\u0627\u062F\u0649 \u0627\u0644\u0623\u0648\u0644\u0649","\u062C\u0645\u0627\u062F\u0649 \u0627\u0644\u0622\u062E\u0631\u0629","\u0631\u062C\u0628","\u0634\u0639\u0628\u0627\u0646","\u0631\u0645\u0636\u0627\u0646","\u0634\u0648\u0627\u0644","\u0630\u0648 \u0627\u0644\u0642\u0639\u062F\u0629","\u0630\u0648 \u0627\u0644\u062D\u062C\u0629","\u0645\u062D\u0631\u0645","\u0635\u0641\u0631","\u0631\u0628\u064A\u0639 \u0627\u0644\u0623\u0648\u0644"]}; Fleur.locale["as"] = { - weekdays:["\u09A6\u09C7\u0993\u09AC\u09BE\u09F0","\u09B8\u09CB\u09AE\u09AC\u09BE\u09F0","\u09AE\u0999\u09CD\u0997\u09B2\u09AC\u09BE\u09F0","\u09AC\u09C1\u09A7\u09AC\u09BE\u09F0","\u09AC\u09C3\u09B9\u09B8\u09CD\u09AA\u09A4\u09BF\u09AC\u09BE\u09F0","\u09B6\u09C1\u0995\u09CD\u09F0\u09AC\u09BE\u09F0","\u09B6\u09A8\u09BF\u09AC\u09BE\u09F0"], - months: ["\u099C\u09BE\u09A8\u09C1\u09F1\u09BE\u09F0\u09C0","\u09AB\u09C7\u09AC\u09CD\u09F0\u09C1\u09F1\u09BE\u09F0\u09C0","\u09AE\u09BE\u09F0\u09CD\u099A","\u098F\u09AA\u09CD\u09F0\u09BF\u09B2","\u09AE\u09C7\u2019","\u099C\u09C1\u09A8","\u099C\u09C1\u09B2\u09BE\u0987","\u0986\u0997\u09B7\u09CD\u099F","\u099B\u09C7\u09AA\u09CD\u09A4\u09C7\u09AE\u09CD\u09AC\u09F0","\u0985\u0995\u09CD\u099F\u09CB\u09AC\u09F0","\u09A8\u09F1\u09C7\u09AE\u09CD\u09AC\u09F0","\u09A1\u09BF\u099A\u09C7\u09AE\u09CD\u09AC\u09F0"]}; + weekdays:["\u09A6\u09C7\u0993\u09AC\u09BE\u09F0","\u09B8\u09CB\u09AE\u09AC\u09BE\u09F0","\u09AE\u0999\u09CD\u0997\u09B2\u09AC\u09BE\u09F0","\u09AC\u09C1\u09A7\u09AC\u09BE\u09F0","\u09AC\u09C3\u09B9\u09B8\u09CD\u09AA\u09A4\u09BF\u09AC\u09BE\u09F0","\u09B6\u09C1\u0995\u09CD\u09F0\u09AC\u09BE\u09F0","\u09B6\u09A8\u09BF\u09AC\u09BE\u09F0"], + months: ["\u099C\u09BE\u09A8\u09C1\u09F1\u09BE\u09F0\u09C0","\u09AB\u09C7\u09AC\u09CD\u09F0\u09C1\u09F1\u09BE\u09F0\u09C0","\u09AE\u09BE\u09F0\u09CD\u099A","\u098F\u09AA\u09CD\u09F0\u09BF\u09B2","\u09AE\u09C7\u2019","\u099C\u09C1\u09A8","\u099C\u09C1\u09B2\u09BE\u0987","\u0986\u0997\u09B7\u09CD\u099F","\u099B\u09C7\u09AA\u09CD\u09A4\u09C7\u09AE\u09CD\u09AC\u09F0","\u0985\u0995\u09CD\u099F\u09CB\u09AC\u09F0","\u09A8\u09F1\u09C7\u09AE\u09CD\u09AC\u09F0","\u09A1\u09BF\u099A\u09C7\u09AE\u09CD\u09AC\u09F0"]}; Fleur.locale["ast"] = { - weekdays:["domingu","llunes","martes","mi\u00E9rcoles","xueves","vienres","s\u00E1badu"], - months: ["xineru","febreru","marzu","abril","mayu","xunu","xunetu","agostu","setiembre","ochobre","payares","avientu"]}; + weekdays:["domingu","llunes","martes","mi\u00E9rcoles","xueves","vienres","s\u00E1badu"], + months: ["xineru","febreru","marzu","abril","mayu","xunu","xunetu","agostu","setiembre","ochobre","payares","avientu"]}; Fleur.locale["bg"] = { - weekdays:["\u043D\u0435\u0434\u0435\u043B\u044F","\u043F\u043E\u043D\u0435\u0434\u0435\u043B\u043D\u0438\u043A","\u0432\u0442\u043E\u0440\u043D\u0438\u043A","\u0441\u0440\u044F\u0434\u0430","\u0447\u0435\u0442\u0432\u044A\u0440\u0442\u044A\u043A","\u043F\u0435\u0442\u044A\u043A","\u0441\u044A\u0431\u043E\u0442\u0430"], - months: ["\u044F\u043D\u0443\u0430\u0440\u0438","\u0444\u0435\u0432\u0440\u0443\u0430\u0440\u0438","\u043C\u0430\u0440\u0442","\u0430\u043F\u0440\u0438\u043B","\u043C\u0430\u0439","\u044E\u043D\u0438","\u044E\u043B\u0438","\u0430\u0432\u0433\u0443\u0441\u0442","\u0441\u0435\u043F\u0442\u0435\u043C\u0432\u0440\u0438","\u043E\u043A\u0442\u043E\u043C\u0432\u0440\u0438","\u043D\u043E\u0435\u043C\u0432\u0440\u0438","\u0434\u0435\u043A\u0435\u043C\u0432\u0440\u0438"]}; + weekdays:["\u043D\u0435\u0434\u0435\u043B\u044F","\u043F\u043E\u043D\u0435\u0434\u0435\u043B\u043D\u0438\u043A","\u0432\u0442\u043E\u0440\u043D\u0438\u043A","\u0441\u0440\u044F\u0434\u0430","\u0447\u0435\u0442\u0432\u044A\u0440\u0442\u044A\u043A","\u043F\u0435\u0442\u044A\u043A","\u0441\u044A\u0431\u043E\u0442\u0430"], + months: ["\u044F\u043D\u0443\u0430\u0440\u0438","\u0444\u0435\u0432\u0440\u0443\u0430\u0440\u0438","\u043C\u0430\u0440\u0442","\u0430\u043F\u0440\u0438\u043B","\u043C\u0430\u0439","\u044E\u043D\u0438","\u044E\u043B\u0438","\u0430\u0432\u0433\u0443\u0441\u0442","\u0441\u0435\u043F\u0442\u0435\u043C\u0432\u0440\u0438","\u043E\u043A\u0442\u043E\u043C\u0432\u0440\u0438","\u043D\u043E\u0435\u043C\u0432\u0440\u0438","\u0434\u0435\u043A\u0435\u043C\u0432\u0440\u0438"]}; Fleur.locale["bn"] = { - weekdays:["\u09B0\u09AC\u09BF\u09AC\u09BE\u09B0","\u09B8\u09CB\u09AE\u09AC\u09BE\u09B0","\u09AE\u0999\u09CD\u0997\u09B2\u09AC\u09BE\u09B0","\u09AC\u09C1\u09A7\u09AC\u09BE\u09B0","\u09AC\u09C3\u09B9\u09B7\u09CD\u09AA\u09A4\u09BF\u09AC\u09BE\u09B0","\u09B6\u09C1\u0995\u09CD\u09B0\u09AC\u09BE\u09B0","\u09B6\u09A8\u09BF\u09AC\u09BE\u09B0"], - months: ["\u099C\u09BE\u09A8\u09C1\u09AF\u09BC\u09BE\u09B0\u09C0","\u09AB\u09C7\u09AC\u09CD\u09B0\u09C1\u09AF\u09BC\u09BE\u09B0\u09C0","\u09AE\u09BE\u09B0\u09CD\u099A","\u098F\u09AA\u09CD\u09B0\u09BF\u09B2","\u09AE\u09C7","\u099C\u09C1\u09A8","\u099C\u09C1\u09B2\u09BE\u0987","\u0986\u0997\u09B8\u09CD\u099F","\u09B8\u09C7\u09AA\u09CD\u099F\u09C7\u09AE\u09CD\u09AC\u09B0","\u0985\u0995\u09CD\u099F\u09CB\u09AC\u09B0","\u09A8\u09AD\u09C7\u09AE\u09CD\u09AC\u09B0","\u09A1\u09BF\u09B8\u09C7\u09AE\u09CD\u09AC\u09B0"]}; + weekdays:["\u09B0\u09AC\u09BF\u09AC\u09BE\u09B0","\u09B8\u09CB\u09AE\u09AC\u09BE\u09B0","\u09AE\u0999\u09CD\u0997\u09B2\u09AC\u09BE\u09B0","\u09AC\u09C1\u09A7\u09AC\u09BE\u09B0","\u09AC\u09C3\u09B9\u09B7\u09CD\u09AA\u09A4\u09BF\u09AC\u09BE\u09B0","\u09B6\u09C1\u0995\u09CD\u09B0\u09AC\u09BE\u09B0","\u09B6\u09A8\u09BF\u09AC\u09BE\u09B0"], + months: ["\u099C\u09BE\u09A8\u09C1\u09AF\u09BC\u09BE\u09B0\u09C0","\u09AB\u09C7\u09AC\u09CD\u09B0\u09C1\u09AF\u09BC\u09BE\u09B0\u09C0","\u09AE\u09BE\u09B0\u09CD\u099A","\u098F\u09AA\u09CD\u09B0\u09BF\u09B2","\u09AE\u09C7","\u099C\u09C1\u09A8","\u099C\u09C1\u09B2\u09BE\u0987","\u0986\u0997\u09B8\u09CD\u099F","\u09B8\u09C7\u09AA\u09CD\u099F\u09C7\u09AE\u09CD\u09AC\u09B0","\u0985\u0995\u09CD\u099F\u09CB\u09AC\u09B0","\u09A8\u09AD\u09C7\u09AE\u09CD\u09AC\u09B0","\u09A1\u09BF\u09B8\u09C7\u09AE\u09CD\u09AC\u09B0"]}; Fleur.locale["bs"] = { - weekdays:["nedjelja","ponedjeljak","utorak","srijeda","\u010Detvrtak","petak","subota"], - months: ["januar","februar","mart","april","maj","juni","juli","avgust","septembar","oktobar","novembar","decembar"]}; + weekdays:["nedjelja","ponedjeljak","utorak","srijeda","\u010Detvrtak","petak","subota"], + months: ["januar","februar","mart","april","maj","juni","juli","avgust","septembar","oktobar","novembar","decembar"]}; Fleur.locale["ca"] = { - weekdays:["diumenge","dilluns","dimarts","dimecres","dijous","divendres","dissabte"], - months: ["gener","febrer","mar\u00E7","abril","maig","juny","juliol","agost","setembre","octubre","novembre","desembre"]}; + weekdays:["diumenge","dilluns","dimarts","dimecres","dijous","divendres","dissabte"], + months: ["gener","febrer","mar\u00E7","abril","maig","juny","juliol","agost","setembre","octubre","novembre","desembre"]}; Fleur.locale["cs"] = { - weekdays:["ned\u011Ble","pond\u011Bl\u00ED","\u00FAter\u00FD","st\u0159eda","\u010Dtvrtek","p\u00E1tek","sobota"], - months: ["leden","\u00FAnor","b\u0159ezen","duben","kv\u011Bten","\u010Derven","\u010Dervenec","srpen","z\u00E1\u0159\u00ED","\u0159\u00EDjen","listopad","prosinec"]}; + weekdays:["ned\u011Ble","pond\u011Bl\u00ED","\u00FAter\u00FD","st\u0159eda","\u010Dtvrtek","p\u00E1tek","sobota"], + months: ["leden","\u00FAnor","b\u0159ezen","duben","kv\u011Bten","\u010Derven","\u010Dervenec","srpen","z\u00E1\u0159\u00ED","\u0159\u00EDjen","listopad","prosinec"]}; Fleur.locale["da"] = { - weekdays:["s\u00F8ndag","mandag","tirsdag","onsdag","torsdag","fredag","l\u00F8rdag"], - months: ["januar","februar","marts","april","maj","juni","juli","august","september","oktober","november","december"]}; + weekdays:["s\u00F8ndag","mandag","tirsdag","onsdag","torsdag","fredag","l\u00F8rdag"], + months: ["januar","februar","marts","april","maj","juni","juli","august","september","oktober","november","december"]}; Fleur.locale["de"] = { - weekdays:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"], - months: ["Januar","Februar","M\u00E4rz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"]}; + weekdays:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"], + months: ["Januar","Februar","M\u00E4rz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"]}; Fleur.locale["el"] = { - weekdays:["\u039A\u03C5\u03C1\u03B9\u03B1\u03BA\u03AE","\u0394\u03B5\u03C5\u03C4\u03AD\u03C1\u03B1","\u03A4\u03C1\u03AF\u03C4\u03B7","\u03A4\u03B5\u03C4\u03AC\u03C1\u03C4\u03B7","\u03A0\u03AD\u03BC\u03C0\u03C4\u03B7","\u03A0\u03B1\u03C1\u03B1\u03C3\u03BA\u03B5\u03C5\u03AE","\u03A3\u03AC\u03B2\u03B2\u03B1\u03C4\u03BF"], - months: ["\u0399\u03B1\u03BD\u03BF\u03C5\u03B1\u03C1\u03AF\u03BF\u03C5","\u03A6\u03B5\u03B2\u03C1\u03BF\u03C5\u03B1\u03C1\u03AF\u03BF\u03C5","\u039C\u03B1\u03C1\u03C4\u03AF\u03BF\u03C5","\u0391\u03C0\u03C1\u03B9\u03BB\u03AF\u03BF\u03C5","\u039C\u03B1\u0390\u03BF\u03C5","\u0399\u03BF\u03C5\u03BD\u03AF\u03BF\u03C5","\u0399\u03BF\u03C5\u03BB\u03AF\u03BF\u03C5","\u0391\u03C5\u03B3\u03BF\u03CD\u03C3\u03C4\u03BF\u03C5","\u03A3\u03B5\u03C0\u03C4\u03B5\u03BC\u03B2\u03C1\u03AF\u03BF\u03C5","\u039F\u03BA\u03C4\u03C9\u03B2\u03C1\u03AF\u03BF\u03C5","\u039D\u03BF\u03B5\u03BC\u03B2\u03C1\u03AF\u03BF\u03C5","\u0394\u03B5\u03BA\u03B5\u03BC\u03B2\u03C1\u03AF\u03BF\u03C5"]}; + weekdays:["\u039A\u03C5\u03C1\u03B9\u03B1\u03BA\u03AE","\u0394\u03B5\u03C5\u03C4\u03AD\u03C1\u03B1","\u03A4\u03C1\u03AF\u03C4\u03B7","\u03A4\u03B5\u03C4\u03AC\u03C1\u03C4\u03B7","\u03A0\u03AD\u03BC\u03C0\u03C4\u03B7","\u03A0\u03B1\u03C1\u03B1\u03C3\u03BA\u03B5\u03C5\u03AE","\u03A3\u03AC\u03B2\u03B2\u03B1\u03C4\u03BF"], + months: ["\u0399\u03B1\u03BD\u03BF\u03C5\u03B1\u03C1\u03AF\u03BF\u03C5","\u03A6\u03B5\u03B2\u03C1\u03BF\u03C5\u03B1\u03C1\u03AF\u03BF\u03C5","\u039C\u03B1\u03C1\u03C4\u03AF\u03BF\u03C5","\u0391\u03C0\u03C1\u03B9\u03BB\u03AF\u03BF\u03C5","\u039C\u03B1\u0390\u03BF\u03C5","\u0399\u03BF\u03C5\u03BD\u03AF\u03BF\u03C5","\u0399\u03BF\u03C5\u03BB\u03AF\u03BF\u03C5","\u0391\u03C5\u03B3\u03BF\u03CD\u03C3\u03C4\u03BF\u03C5","\u03A3\u03B5\u03C0\u03C4\u03B5\u03BC\u03B2\u03C1\u03AF\u03BF\u03C5","\u039F\u03BA\u03C4\u03C9\u03B2\u03C1\u03AF\u03BF\u03C5","\u039D\u03BF\u03B5\u03BC\u03B2\u03C1\u03AF\u03BF\u03C5","\u0394\u03B5\u03BA\u03B5\u03BC\u03B2\u03C1\u03AF\u03BF\u03C5"]}; Fleur.locale["es"] = { - weekdays:["domingo","lunes","martes","mi\u00E9rcoles","jueves","viernes","s\u00E1bado"], - months: ["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"]}; + weekdays:["domingo","lunes","martes","mi\u00E9rcoles","jueves","viernes","s\u00E1bado"], + months: ["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"]}; Fleur.locale["fa"] = { - weekdays:["\u06CC\u06A9\u0634\u0646\u0628\u0647","\u062F\u0648\u0634\u0646\u0628\u0647","\u0633\u0647\u200C\u0634\u0646\u0628\u0647","\u0686\u0647\u0627\u0631\u0634\u0646\u0628\u0647","\u067E\u0646\u062C\u0634\u0646\u0628\u0647","\u062C\u0645\u0639\u0647","\u0634\u0646\u0628\u0647"], - months: ["\u062F\u06CC","\u0628\u0647\u0645\u0646","\u0627\u0633\u0641\u0646\u062F","\u0641\u0631\u0648\u0631\u062F\u06CC\u0646","\u0627\u0631\u062F\u06CC\u0628\u0647\u0634\u062A","\u062E\u0631\u062F\u0627\u062F","\u062A\u06CC\u0631","\u0645\u0631\u062F\u0627\u062F","\u0634\u0647\u0631\u06CC\u0648\u0631","\u0645\u0647\u0631","\u0622\u0628\u0627\u0646","\u0622\u0630\u0631"]}; + weekdays:["\u06CC\u06A9\u0634\u0646\u0628\u0647","\u062F\u0648\u0634\u0646\u0628\u0647","\u0633\u0647\u200C\u0634\u0646\u0628\u0647","\u0686\u0647\u0627\u0631\u0634\u0646\u0628\u0647","\u067E\u0646\u062C\u0634\u0646\u0628\u0647","\u062C\u0645\u0639\u0647","\u0634\u0646\u0628\u0647"], + months: ["\u062F\u06CC","\u0628\u0647\u0645\u0646","\u0627\u0633\u0641\u0646\u062F","\u0641\u0631\u0648\u0631\u062F\u06CC\u0646","\u0627\u0631\u062F\u06CC\u0628\u0647\u0634\u062A","\u062E\u0631\u062F\u0627\u062F","\u062A\u06CC\u0631","\u0645\u0631\u062F\u0627\u062F","\u0634\u0647\u0631\u06CC\u0648\u0631","\u0645\u0647\u0631","\u0622\u0628\u0627\u0646","\u0622\u0630\u0631"]}; Fleur.locale["fi"] = { - weekdays:["sunnuntai","maanantai","tiistai","keskiviikko","torstai","perjantai","lauantai"], - months: ["tammikuu","helmikuu","maaliskuu","huhtikuu","toukokuu","kes\u00E4kuu","hein\u00E4kuu","elokuu","syyskuu","lokakuu","marraskuu","joulukuu"]}; + weekdays:["sunnuntai","maanantai","tiistai","keskiviikko","torstai","perjantai","lauantai"], + months: ["tammikuu","helmikuu","maaliskuu","huhtikuu","toukokuu","kes\u00E4kuu","hein\u00E4kuu","elokuu","syyskuu","lokakuu","marraskuu","joulukuu"]}; Fleur.locale["fr"] = { - weekdays:["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"], - months: ["janvier","f\u00E9vrier","mars","avril","mai","juin","juillet","ao\u00FBt","septembre","octobre","novembre","d\u00E9cembre"]}; + weekdays:["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"], + months: ["janvier","f\u00E9vrier","mars","avril","mai","juin","juillet","ao\u00FBt","septembre","octobre","novembre","d\u00E9cembre"]}; Fleur.locale["gu"] = { - weekdays:["\u0AB0\u0AB5\u0ABF\u0AB5\u0ABE\u0AB0","\u0AB8\u0ACB\u0AAE\u0AB5\u0ABE\u0AB0","\u0AAE\u0A82\u0A97\u0AB3\u0AB5\u0ABE\u0AB0","\u0AAC\u0AC1\u0AA7\u0AB5\u0ABE\u0AB0","\u0A97\u0AC1\u0AB0\u0AC1\u0AB5\u0ABE\u0AB0","\u0AB6\u0AC1\u0A95\u0ACD\u0AB0\u0AB5\u0ABE\u0AB0","\u0AB6\u0AA8\u0ABF\u0AB5\u0ABE\u0AB0"], - months: ["\u0A9C\u0ABE\u0AA8\u0ACD\u0AAF\u0AC1\u0A86\u0AB0\u0AC0","\u0AAB\u0AC7\u0AAC\u0ACD\u0AB0\u0AC1\u0A86\u0AB0\u0AC0","\u0AAE\u0ABE\u0AB0\u0ACD\u0A9A","\u0A8F\u0AAA\u0ACD\u0AB0\u0ABF\u0AB2","\u0AAE\u0AC7","\u0A9C\u0AC2\u0AA8","\u0A9C\u0AC1\u0AB2\u0ABE\u0A88","\u0A91\u0A97\u0AB8\u0ACD\u0A9F","\u0AB8\u0AAA\u0ACD\u0A9F\u0AC7\u0AAE\u0ACD\u0AAC\u0AB0","\u0A91\u0A95\u0ACD\u0A9F\u0ACB\u0AAC\u0AB0","\u0AA8\u0AB5\u0AC7\u0AAE\u0ACD\u0AAC\u0AB0","\u0AA1\u0ABF\u0AB8\u0AC7\u0AAE\u0ACD\u0AAC\u0AB0"]}; + weekdays:["\u0AB0\u0AB5\u0ABF\u0AB5\u0ABE\u0AB0","\u0AB8\u0ACB\u0AAE\u0AB5\u0ABE\u0AB0","\u0AAE\u0A82\u0A97\u0AB3\u0AB5\u0ABE\u0AB0","\u0AAC\u0AC1\u0AA7\u0AB5\u0ABE\u0AB0","\u0A97\u0AC1\u0AB0\u0AC1\u0AB5\u0ABE\u0AB0","\u0AB6\u0AC1\u0A95\u0ACD\u0AB0\u0AB5\u0ABE\u0AB0","\u0AB6\u0AA8\u0ABF\u0AB5\u0ABE\u0AB0"], + months: ["\u0A9C\u0ABE\u0AA8\u0ACD\u0AAF\u0AC1\u0A86\u0AB0\u0AC0","\u0AAB\u0AC7\u0AAC\u0ACD\u0AB0\u0AC1\u0A86\u0AB0\u0AC0","\u0AAE\u0ABE\u0AB0\u0ACD\u0A9A","\u0A8F\u0AAA\u0ACD\u0AB0\u0ABF\u0AB2","\u0AAE\u0AC7","\u0A9C\u0AC2\u0AA8","\u0A9C\u0AC1\u0AB2\u0ABE\u0A88","\u0A91\u0A97\u0AB8\u0ACD\u0A9F","\u0AB8\u0AAA\u0ACD\u0A9F\u0AC7\u0AAE\u0ACD\u0AAC\u0AB0","\u0A91\u0A95\u0ACD\u0A9F\u0ACB\u0AAC\u0AB0","\u0AA8\u0AB5\u0AC7\u0AAE\u0ACD\u0AAC\u0AB0","\u0AA1\u0ABF\u0AB8\u0AC7\u0AAE\u0ACD\u0AAC\u0AB0"]}; Fleur.locale["he"] = { - weekdays:["\u05D9\u05D5\u05DD \u05E8\u05D0\u05E9\u05D5\u05DF","\u05D9\u05D5\u05DD \u05E9\u05E0\u05D9","\u05D9\u05D5\u05DD \u05E9\u05DC\u05D9\u05E9\u05D9","\u05D9\u05D5\u05DD \u05E8\u05D1\u05D9\u05E2\u05D9","\u05D9\u05D5\u05DD \u05D7\u05DE\u05D9\u05E9\u05D9","\u05D9\u05D5\u05DD \u05E9\u05D9\u05E9\u05D9","\u05D9\u05D5\u05DD \u05E9\u05D1\u05EA"], - months: ["\u05D9\u05E0\u05D5\u05D0\u05E8","\u05E4\u05D1\u05E8\u05D5\u05D0\u05E8","\u05DE\u05E8\u05E5","\u05D0\u05E4\u05E8\u05D9\u05DC","\u05DE\u05D0\u05D9","\u05D9\u05D5\u05E0\u05D9","\u05D9\u05D5\u05DC\u05D9","\u05D0\u05D5\u05D2\u05D5\u05E1\u05D8","\u05E1\u05E4\u05D8\u05DE\u05D1\u05E8","\u05D0\u05D5\u05E7\u05D8\u05D5\u05D1\u05E8","\u05E0\u05D5\u05D1\u05DE\u05D1\u05E8","\u05D3\u05E6\u05DE\u05D1\u05E8"]}; + weekdays:["\u05D9\u05D5\u05DD \u05E8\u05D0\u05E9\u05D5\u05DF","\u05D9\u05D5\u05DD \u05E9\u05E0\u05D9","\u05D9\u05D5\u05DD \u05E9\u05DC\u05D9\u05E9\u05D9","\u05D9\u05D5\u05DD \u05E8\u05D1\u05D9\u05E2\u05D9","\u05D9\u05D5\u05DD \u05D7\u05DE\u05D9\u05E9\u05D9","\u05D9\u05D5\u05DD \u05E9\u05D9\u05E9\u05D9","\u05D9\u05D5\u05DD \u05E9\u05D1\u05EA"], + months: ["\u05D9\u05E0\u05D5\u05D0\u05E8","\u05E4\u05D1\u05E8\u05D5\u05D0\u05E8","\u05DE\u05E8\u05E5","\u05D0\u05E4\u05E8\u05D9\u05DC","\u05DE\u05D0\u05D9","\u05D9\u05D5\u05E0\u05D9","\u05D9\u05D5\u05DC\u05D9","\u05D0\u05D5\u05D2\u05D5\u05E1\u05D8","\u05E1\u05E4\u05D8\u05DE\u05D1\u05E8","\u05D0\u05D5\u05E7\u05D8\u05D5\u05D1\u05E8","\u05E0\u05D5\u05D1\u05DE\u05D1\u05E8","\u05D3\u05E6\u05DE\u05D1\u05E8"]}; Fleur.locale["hi"] = { - weekdays:["\u0930\u0935\u093F\u0935\u093E\u0930","\u0938\u094B\u092E\u0935\u093E\u0930","\u092E\u0902\u0917\u0932\u0935\u093E\u0930","\u092C\u0941\u0927\u0935\u093E\u0930","\u0917\u0941\u0930\u0941\u0935\u093E\u0930","\u0936\u0941\u0915\u094D\u0930\u0935\u093E\u0930","\u0936\u0928\u093F\u0935\u093E\u0930"], - months: ["\u091C\u0928\u0935\u0930\u0940","\u092B\u093C\u0930\u0935\u0930\u0940","\u092E\u093E\u0930\u094D\u091A","\u0905\u092A\u094D\u0930\u0948\u0932","\u092E\u0908","\u091C\u0942\u0928","\u091C\u0941\u0932\u093E\u0908","\u0905\u0917\u0938\u094D\u0924","\u0938\u093F\u0924\u0902\u092C\u0930","\u0905\u0915\u094D\u0924\u0942\u092C\u0930","\u0928\u0935\u0902\u092C\u0930","\u0926\u093F\u0938\u0902\u092C\u0930"]}; + weekdays:["\u0930\u0935\u093F\u0935\u093E\u0930","\u0938\u094B\u092E\u0935\u093E\u0930","\u092E\u0902\u0917\u0932\u0935\u093E\u0930","\u092C\u0941\u0927\u0935\u093E\u0930","\u0917\u0941\u0930\u0941\u0935\u093E\u0930","\u0936\u0941\u0915\u094D\u0930\u0935\u093E\u0930","\u0936\u0928\u093F\u0935\u093E\u0930"], + months: ["\u091C\u0928\u0935\u0930\u0940","\u092B\u093C\u0930\u0935\u0930\u0940","\u092E\u093E\u0930\u094D\u091A","\u0905\u092A\u094D\u0930\u0948\u0932","\u092E\u0908","\u091C\u0942\u0928","\u091C\u0941\u0932\u093E\u0908","\u0905\u0917\u0938\u094D\u0924","\u0938\u093F\u0924\u0902\u092C\u0930","\u0905\u0915\u094D\u0924\u0942\u092C\u0930","\u0928\u0935\u0902\u092C\u0930","\u0926\u093F\u0938\u0902\u092C\u0930"]}; Fleur.locale["hr"] = { - weekdays:["nedjelja","ponedjeljak","utorak","srijeda","\u010Detvrtak","petak","subota"], - months: ["sije\u010Danj","velja\u010Da","o\u017Eujak","travanj","svibanj","lipanj","srpanj","kolovoz","rujan","listopad","studeni","prosinac"]}; + weekdays:["nedjelja","ponedjeljak","utorak","srijeda","\u010Detvrtak","petak","subota"], + months: ["sije\u010Danj","velja\u010Da","o\u017Eujak","travanj","svibanj","lipanj","srpanj","kolovoz","rujan","listopad","studeni","prosinac"]}; Fleur.locale["hu"] = { - weekdays:["vas\u00E1rnap","h\u00E9tf\u0151","kedd","szerda","cs\u00FCt\u00F6rt\u00F6k","p\u00E9ntek","szombat"], - months: ["janu\u00E1r","febru\u00E1r","m\u00E1rcius","\u00E1prilis","m\u00E1jus","j\u00FAnius","j\u00FAlius","augusztus","szeptember","okt\u00F3ber","november","december"]}; + weekdays:["vas\u00E1rnap","h\u00E9tf\u0151","kedd","szerda","cs\u00FCt\u00F6rt\u00F6k","p\u00E9ntek","szombat"], + months: ["janu\u00E1r","febru\u00E1r","m\u00E1rcius","\u00E1prilis","m\u00E1jus","j\u00FAnius","j\u00FAlius","augusztus","szeptember","okt\u00F3ber","november","december"]}; Fleur.locale["is"] = { - weekdays:["sunnudagur","m\u00E1nudagur","\u00FEri\u00F0judagur","mi\u00F0vikudagur","fimmtudagur","f\u00F6studagur","laugardagur"], - months: ["jan\u00FAar","febr\u00FAar","mars","apr\u00EDl","ma\u00ED","j\u00FAn\u00ED","j\u00FAl\u00ED","\u00E1g\u00FAst","september","okt\u00F3ber","n\u00F3vember","desember"]}; + weekdays:["sunnudagur","m\u00E1nudagur","\u00FEri\u00F0judagur","mi\u00F0vikudagur","fimmtudagur","f\u00F6studagur","laugardagur"], + months: ["jan\u00FAar","febr\u00FAar","mars","apr\u00EDl","ma\u00ED","j\u00FAn\u00ED","j\u00FAl\u00ED","\u00E1g\u00FAst","september","okt\u00F3ber","n\u00F3vember","desember"]}; Fleur.locale["it"] = { - weekdays:["domenica","luned\u00EC","marted\u00EC","mercoled\u00EC","gioved\u00EC","venerd\u00EC","sabato"], - months: ["gennaio","febbraio","marzo","aprile","maggio","giugno","luglio","agosto","settembre","ottobre","novembre","dicembre"]}; + weekdays:["domenica","luned\u00EC","marted\u00EC","mercoled\u00EC","gioved\u00EC","venerd\u00EC","sabato"], + months: ["gennaio","febbraio","marzo","aprile","maggio","giugno","luglio","agosto","settembre","ottobre","novembre","dicembre"]}; Fleur.locale["ja"] = { - weekdays:["\u65E5\u66DC\u65E5","\u6708\u66DC\u65E5","\u706B\u66DC\u65E5","\u6C34\u66DC\u65E5","\u6728\u66DC\u65E5","\u91D1\u66DC\u65E5","\u571F\u66DC\u65E5"], - months: ["1\u6708","2\u6708","3\u6708","4\u6708","5\u6708","6\u6708","7\u6708","8\u6708","9\u6708","10\u6708","11\u6708","12\u6708"]}; + weekdays:["\u65E5\u66DC\u65E5","\u6708\u66DC\u65E5","\u706B\u66DC\u65E5","\u6C34\u66DC\u65E5","\u6728\u66DC\u65E5","\u91D1\u66DC\u65E5","\u571F\u66DC\u65E5"], + months: ["1\u6708","2\u6708","3\u6708","4\u6708","5\u6708","6\u6708","7\u6708","8\u6708","9\u6708","10\u6708","11\u6708","12\u6708"]}; Fleur.locale["kn"] = { - weekdays:["\u0CAD\u0CBE\u0CA8\u0CC1\u0CB5\u0CBE\u0CB0","\u0CB8\u0CCB\u0CAE\u0CB5\u0CBE\u0CB0","\u0CAE\u0C82\u0C97\u0CB3\u0CB5\u0CBE\u0CB0","\u0CAC\u0CC1\u0CA7\u0CB5\u0CBE\u0CB0","\u0C97\u0CC1\u0CB0\u0CC1\u0CB5\u0CBE\u0CB0","\u0CB6\u0CC1\u0C95\u0CCD\u0CB0\u0CB5\u0CBE\u0CB0","\u0CB6\u0CA8\u0CBF\u0CB5\u0CBE\u0CB0"], - months: ["\u0C9C\u0CA8\u0CB5\u0CB0\u0CBF","\u0CAB\u0CC6\u0CAC\u0CCD\u0CB0\u0CB5\u0CB0\u0CBF","\u0CAE\u0CBE\u0CB0\u0CCD\u0C9A\u0CCD","\u0C8F\u0CAA\u0CCD\u0CB0\u0CBF\u0CB2\u0CCD","\u0CAE\u0CC7","\u0C9C\u0CC2\u0CA8\u0CCD","\u0C9C\u0CC1\u0CB2\u0CC8","\u0C86\u0C97\u0CB8\u0CCD\u0C9F\u0CCD","\u0CB8\u0CC6\u0CAA\u0CCD\u0C9F\u0CC6\u0C82\u0CAC\u0CB0\u0CCD","\u0C85\u0C95\u0CCD\u0C9F\u0CCB\u0CAC\u0CB0\u0CCD","\u0CA8\u0CB5\u0CC6\u0C82\u0CAC\u0CB0\u0CCD","\u0CA1\u0CBF\u0CB8\u0CC6\u0C82\u0CAC\u0CB0\u0CCD"]}; + weekdays:["\u0CAD\u0CBE\u0CA8\u0CC1\u0CB5\u0CBE\u0CB0","\u0CB8\u0CCB\u0CAE\u0CB5\u0CBE\u0CB0","\u0CAE\u0C82\u0C97\u0CB3\u0CB5\u0CBE\u0CB0","\u0CAC\u0CC1\u0CA7\u0CB5\u0CBE\u0CB0","\u0C97\u0CC1\u0CB0\u0CC1\u0CB5\u0CBE\u0CB0","\u0CB6\u0CC1\u0C95\u0CCD\u0CB0\u0CB5\u0CBE\u0CB0","\u0CB6\u0CA8\u0CBF\u0CB5\u0CBE\u0CB0"], + months: ["\u0C9C\u0CA8\u0CB5\u0CB0\u0CBF","\u0CAB\u0CC6\u0CAC\u0CCD\u0CB0\u0CB5\u0CB0\u0CBF","\u0CAE\u0CBE\u0CB0\u0CCD\u0C9A\u0CCD","\u0C8F\u0CAA\u0CCD\u0CB0\u0CBF\u0CB2\u0CCD","\u0CAE\u0CC7","\u0C9C\u0CC2\u0CA8\u0CCD","\u0C9C\u0CC1\u0CB2\u0CC8","\u0C86\u0C97\u0CB8\u0CCD\u0C9F\u0CCD","\u0CB8\u0CC6\u0CAA\u0CCD\u0C9F\u0CC6\u0C82\u0CAC\u0CB0\u0CCD","\u0C85\u0C95\u0CCD\u0C9F\u0CCB\u0CAC\u0CB0\u0CCD","\u0CA8\u0CB5\u0CC6\u0C82\u0CAC\u0CB0\u0CCD","\u0CA1\u0CBF\u0CB8\u0CC6\u0C82\u0CAC\u0CB0\u0CCD"]}; Fleur.locale["ko"] = { - weekdays:["\uC77C\uC694\uC77C","\uC6D4\uC694\uC77C","\uD654\uC694\uC77C","\uC218\uC694\uC77C","\uBAA9\uC694\uC77C","\uAE08\uC694\uC77C","\uD1A0\uC694\uC77C"], - months: ["1\uC6D4","2\uC6D4","3\uC6D4","4\uC6D4","5\uC6D4","6\uC6D4","7\uC6D4","8\uC6D4","9\uC6D4","10\uC6D4","11\uC6D4","12\uC6D4"]}; + weekdays:["\uC77C\uC694\uC77C","\uC6D4\uC694\uC77C","\uD654\uC694\uC77C","\uC218\uC694\uC77C","\uBAA9\uC694\uC77C","\uAE08\uC694\uC77C","\uD1A0\uC694\uC77C"], + months: ["1\uC6D4","2\uC6D4","3\uC6D4","4\uC6D4","5\uC6D4","6\uC6D4","7\uC6D4","8\uC6D4","9\uC6D4","10\uC6D4","11\uC6D4","12\uC6D4"]}; Fleur.locale["lv"] = { - weekdays:["Sv\u0113tdiena","Pirmdiena","Otrdiena","Tre\u0161diena","Ceturtdiena","Piektdiena","Sestdiena"], - months: ["janv\u0101ris","febru\u0101ris","marts","apr\u012Blis","maijs","j\u016Bnijs","j\u016Blijs","augusts","septembris","oktobris","novembris","decembris"]}; + weekdays:["Sv\u0113tdiena","Pirmdiena","Otrdiena","Tre\u0161diena","Ceturtdiena","Piektdiena","Sestdiena"], + months: ["janv\u0101ris","febru\u0101ris","marts","apr\u012Blis","maijs","j\u016Bnijs","j\u016Blijs","augusts","septembris","oktobris","novembris","decembris"]}; Fleur.locale["ml"] = { - weekdays:["\u0D1E\u0D3E\u0D2F\u0D31\u0D3E\u0D34\u0D4D\u200C\u0D1A","\u0D24\u0D3F\u0D19\u0D4D\u0D15\u0D33\u0D3E\u0D34\u0D4D\u200C\u0D1A","\u0D1A\u0D4A\u0D35\u0D4D\u0D35\u0D3E\u0D34\u0D4D\u200C\u0D1A","\u0D2C\u0D41\u0D27\u0D28\u0D3E\u0D34\u0D4D\u200C\u0D1A","\u0D35\u0D4D\u0D2F\u0D3E\u0D34\u0D3E\u0D34\u0D4D\u200C\u0D1A","\u0D35\u0D46\u0D33\u0D4D\u0D33\u0D3F\u0D2F\u0D3E\u0D34\u0D4D\u200C\u0D1A","\u0D36\u0D28\u0D3F\u0D2F\u0D3E\u0D34\u0D4D\u200C\u0D1A"], - months: ["\u0D1C\u0D28\u0D41\u0D35\u0D30\u0D3F","\u0D2B\u0D46\u0D2C\u0D4D\u0D30\u0D41\u0D35\u0D30\u0D3F","\u0D2E\u0D3E\u0D7C\u0D1A\u0D4D\u0D1A\u0D4D","\u0D0F\u0D2A\u0D4D\u0D30\u0D3F\u0D7D","\u0D2E\u0D47\u0D2F\u0D4D","\u0D1C\u0D42\u0D7A","\u0D1C\u0D42\u0D32\u0D48","\u0D13\u0D17\u0D38\u0D4D\u0D31\u0D4D\u0D31\u0D4D","\u0D38\u0D46\u0D2A\u0D4D\u0D31\u0D4D\u0D31\u0D02\u0D2C\u0D7C","\u0D12\u0D15\u0D4D\u200C\u0D1F\u0D4B\u0D2C\u0D7C","\u0D28\u0D35\u0D02\u0D2C\u0D7C","\u0D21\u0D3F\u0D38\u0D02\u0D2C\u0D7C"]}; + weekdays:["\u0D1E\u0D3E\u0D2F\u0D31\u0D3E\u0D34\u0D4D\u200C\u0D1A","\u0D24\u0D3F\u0D19\u0D4D\u0D15\u0D33\u0D3E\u0D34\u0D4D\u200C\u0D1A","\u0D1A\u0D4A\u0D35\u0D4D\u0D35\u0D3E\u0D34\u0D4D\u200C\u0D1A","\u0D2C\u0D41\u0D27\u0D28\u0D3E\u0D34\u0D4D\u200C\u0D1A","\u0D35\u0D4D\u0D2F\u0D3E\u0D34\u0D3E\u0D34\u0D4D\u200C\u0D1A","\u0D35\u0D46\u0D33\u0D4D\u0D33\u0D3F\u0D2F\u0D3E\u0D34\u0D4D\u200C\u0D1A","\u0D36\u0D28\u0D3F\u0D2F\u0D3E\u0D34\u0D4D\u200C\u0D1A"], + months: ["\u0D1C\u0D28\u0D41\u0D35\u0D30\u0D3F","\u0D2B\u0D46\u0D2C\u0D4D\u0D30\u0D41\u0D35\u0D30\u0D3F","\u0D2E\u0D3E\u0D7C\u0D1A\u0D4D\u0D1A\u0D4D","\u0D0F\u0D2A\u0D4D\u0D30\u0D3F\u0D7D","\u0D2E\u0D47\u0D2F\u0D4D","\u0D1C\u0D42\u0D7A","\u0D1C\u0D42\u0D32\u0D48","\u0D13\u0D17\u0D38\u0D4D\u0D31\u0D4D\u0D31\u0D4D","\u0D38\u0D46\u0D2A\u0D4D\u0D31\u0D4D\u0D31\u0D02\u0D2C\u0D7C","\u0D12\u0D15\u0D4D\u200C\u0D1F\u0D4B\u0D2C\u0D7C","\u0D28\u0D35\u0D02\u0D2C\u0D7C","\u0D21\u0D3F\u0D38\u0D02\u0D2C\u0D7C"]}; Fleur.locale["mr"] = { - weekdays:["\u0930\u0935\u093F\u0935\u093E\u0930","\u0938\u094B\u092E\u0935\u093E\u0930","\u092E\u0902\u0917\u0933\u0935\u093E\u0930","\u092C\u0941\u0927\u0935\u093E\u0930","\u0917\u0941\u0930\u0941\u0935\u093E\u0930","\u0936\u0941\u0915\u094D\u0930\u0935\u093E\u0930","\u0936\u0928\u093F\u0935\u093E\u0930"], - months: ["\u091C\u093E\u0928\u0947\u0935\u093E\u0930\u0940","\u092B\u0947\u092C\u094D\u0930\u0941\u0935\u093E\u0930\u0940","\u092E\u093E\u0930\u094D\u091A","\u090F\u092A\u094D\u0930\u093F\u0932","\u092E\u0947","\u091C\u0942\u0928","\u091C\u0941\u0932\u0948","\u0911\u0917\u0938\u094D\u091F","\u0938\u092A\u094D\u091F\u0947\u0902\u092C\u0930","\u0911\u0915\u094D\u091F\u094B\u092C\u0930","\u0928\u094B\u0935\u094D\u0939\u0947\u0902\u092C\u0930","\u0921\u093F\u0938\u0947\u0902\u092C\u0930"]}; + weekdays:["\u0930\u0935\u093F\u0935\u093E\u0930","\u0938\u094B\u092E\u0935\u093E\u0930","\u092E\u0902\u0917\u0933\u0935\u093E\u0930","\u092C\u0941\u0927\u0935\u093E\u0930","\u0917\u0941\u0930\u0941\u0935\u093E\u0930","\u0936\u0941\u0915\u094D\u0930\u0935\u093E\u0930","\u0936\u0928\u093F\u0935\u093E\u0930"], + months: ["\u091C\u093E\u0928\u0947\u0935\u093E\u0930\u0940","\u092B\u0947\u092C\u094D\u0930\u0941\u0935\u093E\u0930\u0940","\u092E\u093E\u0930\u094D\u091A","\u090F\u092A\u094D\u0930\u093F\u0932","\u092E\u0947","\u091C\u0942\u0928","\u091C\u0941\u0932\u0948","\u0911\u0917\u0938\u094D\u091F","\u0938\u092A\u094D\u091F\u0947\u0902\u092C\u0930","\u0911\u0915\u094D\u091F\u094B\u092C\u0930","\u0928\u094B\u0935\u094D\u0939\u0947\u0902\u092C\u0930","\u0921\u093F\u0938\u0947\u0902\u092C\u0930"]}; Fleur.locale["nb"] = { - weekdays:["s\u00F8ndag","mandag","tirsdag","onsdag","torsdag","fredag","l\u00F8rdag"], - months: ["januar","februar","mars","april","mai","juni","juli","august","september","oktober","november","desember"]}; + weekdays:["s\u00F8ndag","mandag","tirsdag","onsdag","torsdag","fredag","l\u00F8rdag"], + months: ["januar","februar","mars","april","mai","juni","juli","august","september","oktober","november","desember"]}; Fleur.locale["nl"] = { - weekdays:["zondag","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag"], - months: ["januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december"]}; + weekdays:["zondag","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag"], + months: ["januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december"]}; Fleur.locale["or"] = { - weekdays:["\u0B30\u0B2C\u0B3F\u0B2C\u0B3E\u0B30","\u0B38\u0B4B\u0B2E\u0B2C\u0B3E\u0B30","\u0B2E\u0B19\u0B4D\u0B17\u0B33\u0B2C\u0B3E\u0B30","\u0B2C\u0B41\u0B27\u0B2C\u0B3E\u0B30","\u0B17\u0B41\u0B30\u0B41\u0B2C\u0B3E\u0B30","\u0B36\u0B41\u0B15\u0B4D\u0B30\u0B2C\u0B3E\u0B30","\u0B36\u0B28\u0B3F\u0B2C\u0B3E\u0B30"], - months: ["\u0B1C\u0B3E\u0B28\u0B41\u0B06\u0B30\u0B40","\u0B2B\u0B47\u0B2C\u0B43\u0B06\u0B30\u0B40","\u0B2E\u0B3E\u0B30\u0B4D\u0B1A\u0B4D\u0B1A","\u0B05\u0B2A\u0B4D\u0B30\u0B47\u0B32","\u0B2E\u0B07","\u0B1C\u0B41\u0B28","\u0B1C\u0B41\u0B32\u0B3E\u0B07","\u0B05\u0B17\u0B37\u0B4D\u0B1F","\u0B38\u0B47\u0B2A\u0B4D\u0B1F\u0B47\u0B2E\u0B4D\u0B2C\u0B30","\u0B05\u0B15\u0B4D\u0B1F\u0B4B\u0B2C\u0B30","\u0B28\u0B2D\u0B47\u0B2E\u0B4D\u0B2C\u0B30","\u0B21\u0B3F\u0B38\u0B47\u0B2E\u0B4D\u0B2C\u0B30"]}; + weekdays:["\u0B30\u0B2C\u0B3F\u0B2C\u0B3E\u0B30","\u0B38\u0B4B\u0B2E\u0B2C\u0B3E\u0B30","\u0B2E\u0B19\u0B4D\u0B17\u0B33\u0B2C\u0B3E\u0B30","\u0B2C\u0B41\u0B27\u0B2C\u0B3E\u0B30","\u0B17\u0B41\u0B30\u0B41\u0B2C\u0B3E\u0B30","\u0B36\u0B41\u0B15\u0B4D\u0B30\u0B2C\u0B3E\u0B30","\u0B36\u0B28\u0B3F\u0B2C\u0B3E\u0B30"], + months: ["\u0B1C\u0B3E\u0B28\u0B41\u0B06\u0B30\u0B40","\u0B2B\u0B47\u0B2C\u0B43\u0B06\u0B30\u0B40","\u0B2E\u0B3E\u0B30\u0B4D\u0B1A\u0B4D\u0B1A","\u0B05\u0B2A\u0B4D\u0B30\u0B47\u0B32","\u0B2E\u0B07","\u0B1C\u0B41\u0B28","\u0B1C\u0B41\u0B32\u0B3E\u0B07","\u0B05\u0B17\u0B37\u0B4D\u0B1F","\u0B38\u0B47\u0B2A\u0B4D\u0B1F\u0B47\u0B2E\u0B4D\u0B2C\u0B30","\u0B05\u0B15\u0B4D\u0B1F\u0B4B\u0B2C\u0B30","\u0B28\u0B2D\u0B47\u0B2E\u0B4D\u0B2C\u0B30","\u0B21\u0B3F\u0B38\u0B47\u0B2E\u0B4D\u0B2C\u0B30"]}; Fleur.locale["pa"] = { - weekdays:["\u0A10\u0A24\u0A35\u0A3E\u0A30","\u0A38\u0A4B\u0A2E\u0A35\u0A3E\u0A30","\u0A2E\u0A70\u0A17\u0A32\u0A35\u0A3E\u0A30","\u0A2C\u0A41\u0A71\u0A27\u0A35\u0A3E\u0A30","\u0A35\u0A40\u0A30\u0A35\u0A3E\u0A30","\u0A38\u0A3C\u0A41\u0A71\u0A15\u0A30\u0A35\u0A3E\u0A30","\u0A38\u0A3C\u0A28\u0A3F\u0A71\u0A1A\u0A30\u0A35\u0A3E\u0A30"], - months: ["\u0A1C\u0A28\u0A35\u0A30\u0A40","\u0A2B\u0A3C\u0A30\u0A35\u0A30\u0A40","\u0A2E\u0A3E\u0A30\u0A1A","\u0A05\u0A2A\u0A4D\u0A30\u0A48\u0A32","\u0A2E\u0A08","\u0A1C\u0A42\u0A28","\u0A1C\u0A41\u0A32\u0A3E\u0A08","\u0A05\u0A17\u0A38\u0A24","\u0A38\u0A24\u0A70\u0A2C\u0A30","\u0A05\u0A15\u0A24\u0A42\u0A2C\u0A30","\u0A28\u0A35\u0A70\u0A2C\u0A30","\u0A26\u0A38\u0A70\u0A2C\u0A30"]}; + weekdays:["\u0A10\u0A24\u0A35\u0A3E\u0A30","\u0A38\u0A4B\u0A2E\u0A35\u0A3E\u0A30","\u0A2E\u0A70\u0A17\u0A32\u0A35\u0A3E\u0A30","\u0A2C\u0A41\u0A71\u0A27\u0A35\u0A3E\u0A30","\u0A35\u0A40\u0A30\u0A35\u0A3E\u0A30","\u0A38\u0A3C\u0A41\u0A71\u0A15\u0A30\u0A35\u0A3E\u0A30","\u0A38\u0A3C\u0A28\u0A3F\u0A71\u0A1A\u0A30\u0A35\u0A3E\u0A30"], + months: ["\u0A1C\u0A28\u0A35\u0A30\u0A40","\u0A2B\u0A3C\u0A30\u0A35\u0A30\u0A40","\u0A2E\u0A3E\u0A30\u0A1A","\u0A05\u0A2A\u0A4D\u0A30\u0A48\u0A32","\u0A2E\u0A08","\u0A1C\u0A42\u0A28","\u0A1C\u0A41\u0A32\u0A3E\u0A08","\u0A05\u0A17\u0A38\u0A24","\u0A38\u0A24\u0A70\u0A2C\u0A30","\u0A05\u0A15\u0A24\u0A42\u0A2C\u0A30","\u0A28\u0A35\u0A70\u0A2C\u0A30","\u0A26\u0A38\u0A70\u0A2C\u0A30"]}; Fleur.locale["pl"] = { - weekdays:["niedziela","poniedzia\u0142ek","wtorek","\u015Broda","czwartek","pi\u0105tek","sobota"], - months: ["stycze\u0144","luty","marzec","kwiecie\u0144","maj","czerwiec","lipiec","sierpie\u0144","wrzesie\u0144","pa\u017Adziernik","listopad","grudzie\u0144"]}; + weekdays:["niedziela","poniedzia\u0142ek","wtorek","\u015Broda","czwartek","pi\u0105tek","sobota"], + months: ["stycze\u0144","luty","marzec","kwiecie\u0144","maj","czerwiec","lipiec","sierpie\u0144","wrzesie\u0144","pa\u017Adziernik","listopad","grudzie\u0144"]}; Fleur.locale["pt"] = { - weekdays:["domingo","segunda-feira","ter\u00E7a-feira","quarta-feira","quinta-feira","sexta-feira","s\u00E1bado"], - months: ["janeiro","fevereiro","mar\u00E7o","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"]}; + weekdays:["domingo","segunda-feira","ter\u00E7a-feira","quarta-feira","quinta-feira","sexta-feira","s\u00E1bado"], + months: ["janeiro","fevereiro","mar\u00E7o","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"]}; Fleur.locale["ru"] = { - weekdays:["\u0432\u043E\u0441\u043A\u0440\u0435\u0441\u0435\u043D\u044C\u0435","\u043F\u043E\u043D\u0435\u0434\u0435\u043B\u044C\u043D\u0438\u043A","\u0432\u0442\u043E\u0440\u043D\u0438\u043A","\u0441\u0440\u0435\u0434\u0430","\u0447\u0435\u0442\u0432\u0435\u0440\u0433","\u043F\u044F\u0442\u043D\u0438\u0446\u0430","\u0441\u0443\u0431\u0431\u043E\u0442\u0430"], - months: ["\u044F\u043D\u0432\u0430\u0440\u044C","\u0444\u0435\u0432\u0440\u0430\u043B\u044C","\u043C\u0430\u0440\u0442","\u0430\u043F\u0440\u0435\u043B\u044C","\u043C\u0430\u0439","\u0438\u044E\u043D\u044C","\u0438\u044E\u043B\u044C","\u0430\u0432\u0433\u0443\u0441\u0442","\u0441\u0435\u043D\u0442\u044F\u0431\u0440\u044C","\u043E\u043A\u0442\u044F\u0431\u0440\u044C","\u043D\u043E\u044F\u0431\u0440\u044C","\u0434\u0435\u043A\u0430\u0431\u0440\u044C"]}; + weekdays:["\u0432\u043E\u0441\u043A\u0440\u0435\u0441\u0435\u043D\u044C\u0435","\u043F\u043E\u043D\u0435\u0434\u0435\u043B\u044C\u043D\u0438\u043A","\u0432\u0442\u043E\u0440\u043D\u0438\u043A","\u0441\u0440\u0435\u0434\u0430","\u0447\u0435\u0442\u0432\u0435\u0440\u0433","\u043F\u044F\u0442\u043D\u0438\u0446\u0430","\u0441\u0443\u0431\u0431\u043E\u0442\u0430"], + months: ["\u044F\u043D\u0432\u0430\u0440\u044C","\u0444\u0435\u0432\u0440\u0430\u043B\u044C","\u043C\u0430\u0440\u0442","\u0430\u043F\u0440\u0435\u043B\u044C","\u043C\u0430\u0439","\u0438\u044E\u043D\u044C","\u0438\u044E\u043B\u044C","\u0430\u0432\u0433\u0443\u0441\u0442","\u0441\u0435\u043D\u0442\u044F\u0431\u0440\u044C","\u043E\u043A\u0442\u044F\u0431\u0440\u044C","\u043D\u043E\u044F\u0431\u0440\u044C","\u0434\u0435\u043A\u0430\u0431\u0440\u044C"]}; Fleur.locale["si"] = { - weekdays:["\u0D89\u0DBB\u0DD2\u0DAF\u0DCF","\u0DC3\u0DB3\u0DD4\u0DAF\u0DCF","\u0D85\u0D9F\u0DC4\u0DBB\u0DD4\u0DC0\u0DCF\u0DAF\u0DCF","\u0DB6\u0DAF\u0DCF\u0DAF\u0DCF","\u0DB6\u0DCA\u200D\u0DBB\u0DC4\u0DC3\u0DCA\u0DB4\u0DAD\u0DD2\u0DB1\u0DCA\u0DAF\u0DCF","\u0DC3\u0DD2\u0D9A\u0DD4\u0DBB\u0DCF\u0DAF\u0DCF","\u0DC3\u0DD9\u0DB1\u0DC3\u0DD4\u0DBB\u0DCF\u0DAF\u0DCF"], - months: ["\u0DA2\u0DB1\u0DC0\u0DCF\u0DBB\u0DD2","\u0DB4\u0DD9\u0DB6\u0DBB\u0DC0\u0DCF\u0DBB\u0DD2","\u0DB8\u0DCF\u0DBB\u0DCA\u0DAD\u0DD4","\u0D85\u0DB4\u0DCA\u200D\u0DBB\u0DDA\u0DBD\u0DCA","\u0DB8\u0DD0\u0DBA\u0DD2","\u0DA2\u0DD6\u0DB1\u0DD2","\u0DA2\u0DD6\u0DBD\u0DD2","\u0D85\u0D9C\u0DDD\u0DC3\u0DCA\u0DAD\u0DD4","\u0DC3\u0DD0\u0DB4\u0DCA\u0DAD\u0DD0\u0DB8\u0DCA\u0DB6\u0DBB\u0DCA","\u0D94\u0D9A\u0DCA\u0DAD\u0DDD\u0DB6\u0DBB\u0DCA","\u0DB1\u0DDC\u0DC0\u0DD0\u0DB8\u0DCA\u0DB6\u0DBB\u0DCA","\u0DAF\u0DD9\u0DC3\u0DD0\u0DB8\u0DCA\u0DB6\u0DBB\u0DCA"]};Fleur.locale["sk-SK"] = { - weekdays:["nede\u013Ea","pondelok","utorok","streda","\u0161tvrtok","piatok","sobota"], - months: ["janu\u00E1r","febru\u00E1r","marec","apr\u00EDl","m\u00E1j","j\u00FAn","j\u00FAl","august","september","okt\u00F3ber","november","december"]}; + weekdays:["\u0D89\u0DBB\u0DD2\u0DAF\u0DCF","\u0DC3\u0DB3\u0DD4\u0DAF\u0DCF","\u0D85\u0D9F\u0DC4\u0DBB\u0DD4\u0DC0\u0DCF\u0DAF\u0DCF","\u0DB6\u0DAF\u0DCF\u0DAF\u0DCF","\u0DB6\u0DCA\u200D\u0DBB\u0DC4\u0DC3\u0DCA\u0DB4\u0DAD\u0DD2\u0DB1\u0DCA\u0DAF\u0DCF","\u0DC3\u0DD2\u0D9A\u0DD4\u0DBB\u0DCF\u0DAF\u0DCF","\u0DC3\u0DD9\u0DB1\u0DC3\u0DD4\u0DBB\u0DCF\u0DAF\u0DCF"], + months: ["\u0DA2\u0DB1\u0DC0\u0DCF\u0DBB\u0DD2","\u0DB4\u0DD9\u0DB6\u0DBB\u0DC0\u0DCF\u0DBB\u0DD2","\u0DB8\u0DCF\u0DBB\u0DCA\u0DAD\u0DD4","\u0D85\u0DB4\u0DCA\u200D\u0DBB\u0DDA\u0DBD\u0DCA","\u0DB8\u0DD0\u0DBA\u0DD2","\u0DA2\u0DD6\u0DB1\u0DD2","\u0DA2\u0DD6\u0DBD\u0DD2","\u0D85\u0D9C\u0DDD\u0DC3\u0DCA\u0DAD\u0DD4","\u0DC3\u0DD0\u0DB4\u0DCA\u0DAD\u0DD0\u0DB8\u0DCA\u0DB6\u0DBB\u0DCA","\u0D94\u0D9A\u0DCA\u0DAD\u0DDD\u0DB6\u0DBB\u0DCA","\u0DB1\u0DDC\u0DC0\u0DD0\u0DB8\u0DCA\u0DB6\u0DBB\u0DCA","\u0DAF\u0DD9\u0DC3\u0DD0\u0DB8\u0DCA\u0DB6\u0DBB\u0DCA"]};Fleur.locale["sk-SK"] = { + weekdays:["nede\u013Ea","pondelok","utorok","streda","\u0161tvrtok","piatok","sobota"], + months: ["janu\u00E1r","febru\u00E1r","marec","apr\u00EDl","m\u00E1j","j\u00FAn","j\u00FAl","august","september","okt\u00F3ber","november","december"]}; Fleur.locale["sr-Cyrl-RS"] = { - weekdays:["\u043D\u0435\u0434\u0435\u0459\u0430","\u043F\u043E\u043D\u0435\u0434\u0435\u0459\u0430\u043A","\u0443\u0442\u043E\u0440\u0430\u043A","\u0441\u0440\u0435\u0434\u0430","\u0447\u0435\u0442\u0432\u0440\u0442\u0430\u043A","\u043F\u0435\u0442\u0430\u043A","\u0441\u0443\u0431\u043E\u0442\u0430"], - months: ["\u0458\u0430\u043D\u0443\u0430\u0440","\u0444\u0435\u0431\u0440\u0443\u0430\u0440","\u043C\u0430\u0440\u0442","\u0430\u043F\u0440\u0438\u043B","\u043C\u0430\u0458","\u0458\u0443\u043D","\u0458\u0443\u043B","\u0430\u0432\u0433\u0443\u0441\u0442","\u0441\u0435\u043F\u0442\u0435\u043C\u0431\u0430\u0440","\u043E\u043A\u0442\u043E\u0431\u0430\u0440","\u043D\u043E\u0432\u0435\u043C\u0431\u0430\u0440","\u0434\u0435\u0446\u0435\u043C\u0431\u0430\u0440"]}; + weekdays:["\u043D\u0435\u0434\u0435\u0459\u0430","\u043F\u043E\u043D\u0435\u0434\u0435\u0459\u0430\u043A","\u0443\u0442\u043E\u0440\u0430\u043A","\u0441\u0440\u0435\u0434\u0430","\u0447\u0435\u0442\u0432\u0440\u0442\u0430\u043A","\u043F\u0435\u0442\u0430\u043A","\u0441\u0443\u0431\u043E\u0442\u0430"], + months: ["\u0458\u0430\u043D\u0443\u0430\u0440","\u0444\u0435\u0431\u0440\u0443\u0430\u0440","\u043C\u0430\u0440\u0442","\u0430\u043F\u0440\u0438\u043B","\u043C\u0430\u0458","\u0458\u0443\u043D","\u0458\u0443\u043B","\u0430\u0432\u0433\u0443\u0441\u0442","\u0441\u0435\u043F\u0442\u0435\u043C\u0431\u0430\u0440","\u043E\u043A\u0442\u043E\u0431\u0430\u0440","\u043D\u043E\u0432\u0435\u043C\u0431\u0430\u0440","\u0434\u0435\u0446\u0435\u043C\u0431\u0430\u0440"]}; Fleur.locale["sr-Latn-RS"] = { - weekdays:["nedelja","ponedeljak","utorak","sreda","\u010Detvrtak","petak","subota"], - months: ["januar","februar","mart","april","maj","jun","jul","avgust","septembar","oktobar","novembar","decembar"]}; + weekdays:["nedelja","ponedeljak","utorak","sreda","\u010Detvrtak","petak","subota"], + months: ["januar","februar","mart","april","maj","jun","jul","avgust","septembar","oktobar","novembar","decembar"]}; Fleur.locale["sv"] = { - weekdays:["s\u00F6ndag","m\u00E5ndag","tisdag","onsdag","torsdag","fredag","l\u00F6rdag"], - months: ["januari","februari","mars","april","maj","juni","juli","augusti","september","oktober","november","december"]}; + weekdays:["s\u00F6ndag","m\u00E5ndag","tisdag","onsdag","torsdag","fredag","l\u00F6rdag"], + months: ["januari","februari","mars","april","maj","juni","juli","augusti","september","oktober","november","december"]}; Fleur.locale["ta"] = { - weekdays:["\u0B9E\u0BBE\u0BAF\u0BBF\u0BB1\u0BC1","\u0BA4\u0BBF\u0B99\u0BCD\u0B95\u0BB3\u0BCD","\u0B9A\u0BC6\u0BB5\u0BCD\u0BB5\u0BBE\u0BAF\u0BCD","\u0BAA\u0BC1\u0BA4\u0BA9\u0BCD","\u0BB5\u0BBF\u0BAF\u0BBE\u0BB4\u0BA9\u0BCD","\u0BB5\u0BC6\u0BB3\u0BCD\u0BB3\u0BBF","\u0B9A\u0BA9\u0BBF"], - months: ["\u0B9C\u0BA9\u0BB5\u0BB0\u0BBF","\u0BAA\u0BBF\u0BAA\u0BCD\u0BB0\u0BB5\u0BB0\u0BBF","\u0BAE\u0BBE\u0BB0\u0BCD\u0B9A\u0BCD","\u0B8F\u0BAA\u0BCD\u0BB0\u0BB2\u0BCD","\u0BAE\u0BC7","\u0B9C\u0BC2\u0BA9\u0BCD","\u0B9C\u0BC2\u0BB2\u0BC8","\u0B86\u0B95\u0BB8\u0BCD\u0B9F\u0BCD","\u0B9A\u0BC6\u0BAA\u0BCD\u0B9F\u0BAE\u0BCD\u0BAA\u0BB0\u0BCD","\u0B85\u0B95\u0BCD\u0B9F\u0BCB\u0BAA\u0BB0\u0BCD","\u0BA8\u0BB5\u0BAE\u0BCD\u0BAA\u0BB0\u0BCD","\u0B9F\u0BBF\u0B9A\u0BAE\u0BCD\u0BAA\u0BB0\u0BCD"]}; + weekdays:["\u0B9E\u0BBE\u0BAF\u0BBF\u0BB1\u0BC1","\u0BA4\u0BBF\u0B99\u0BCD\u0B95\u0BB3\u0BCD","\u0B9A\u0BC6\u0BB5\u0BCD\u0BB5\u0BBE\u0BAF\u0BCD","\u0BAA\u0BC1\u0BA4\u0BA9\u0BCD","\u0BB5\u0BBF\u0BAF\u0BBE\u0BB4\u0BA9\u0BCD","\u0BB5\u0BC6\u0BB3\u0BCD\u0BB3\u0BBF","\u0B9A\u0BA9\u0BBF"], + months: ["\u0B9C\u0BA9\u0BB5\u0BB0\u0BBF","\u0BAA\u0BBF\u0BAA\u0BCD\u0BB0\u0BB5\u0BB0\u0BBF","\u0BAE\u0BBE\u0BB0\u0BCD\u0B9A\u0BCD","\u0B8F\u0BAA\u0BCD\u0BB0\u0BB2\u0BCD","\u0BAE\u0BC7","\u0B9C\u0BC2\u0BA9\u0BCD","\u0B9C\u0BC2\u0BB2\u0BC8","\u0B86\u0B95\u0BB8\u0BCD\u0B9F\u0BCD","\u0B9A\u0BC6\u0BAA\u0BCD\u0B9F\u0BAE\u0BCD\u0BAA\u0BB0\u0BCD","\u0B85\u0B95\u0BCD\u0B9F\u0BCB\u0BAA\u0BB0\u0BCD","\u0BA8\u0BB5\u0BAE\u0BCD\u0BAA\u0BB0\u0BCD","\u0B9F\u0BBF\u0B9A\u0BAE\u0BCD\u0BAA\u0BB0\u0BCD"]}; Fleur.locale["te"] = { - weekdays:["\u0C06\u0C26\u0C3F\u0C35\u0C3E\u0C30\u0C02","\u0C38\u0C4B\u0C2E\u0C35\u0C3E\u0C30\u0C02","\u0C2E\u0C02\u0C17\u0C33\u0C35\u0C3E\u0C30\u0C02","\u0C2C\u0C41\u0C27\u0C35\u0C3E\u0C30\u0C02","\u0C17\u0C41\u0C30\u0C41\u0C35\u0C3E\u0C30\u0C02","\u0C36\u0C41\u0C15\u0C4D\u0C30\u0C35\u0C3E\u0C30\u0C02","\u0C36\u0C28\u0C3F\u0C35\u0C3E\u0C30\u0C02"], - months: ["\u0C1C\u0C28\u0C35\u0C30\u0C3F","\u0C2B\u0C3F\u0C2C\u0C4D\u0C30\u0C35\u0C30\u0C3F","\u0C2E\u0C3E\u0C30\u0C4D\u0C1A\u0C3F","\u0C0F\u0C2A\u0C4D\u0C30\u0C3F\u0C32\u0C4D","\u0C2E\u0C47","\u0C1C\u0C42\u0C28\u0C4D","\u0C1C\u0C41\u0C32\u0C48","\u0C06\u0C17\u0C38\u0C4D\u0C1F\u0C41","\u0C38\u0C46\u0C2A\u0C4D\u0C1F\u0C46\u0C02\u0C2C\u0C30\u0C4D","\u0C05\u0C15\u0C4D\u0C1F\u0C4B\u0C2C\u0C30\u0C4D","\u0C28\u0C35\u0C02\u0C2C\u0C30\u0C4D","\u0C21\u0C3F\u0C38\u0C46\u0C02\u0C2C\u0C30\u0C4D"]}; + weekdays:["\u0C06\u0C26\u0C3F\u0C35\u0C3E\u0C30\u0C02","\u0C38\u0C4B\u0C2E\u0C35\u0C3E\u0C30\u0C02","\u0C2E\u0C02\u0C17\u0C33\u0C35\u0C3E\u0C30\u0C02","\u0C2C\u0C41\u0C27\u0C35\u0C3E\u0C30\u0C02","\u0C17\u0C41\u0C30\u0C41\u0C35\u0C3E\u0C30\u0C02","\u0C36\u0C41\u0C15\u0C4D\u0C30\u0C35\u0C3E\u0C30\u0C02","\u0C36\u0C28\u0C3F\u0C35\u0C3E\u0C30\u0C02"], + months: ["\u0C1C\u0C28\u0C35\u0C30\u0C3F","\u0C2B\u0C3F\u0C2C\u0C4D\u0C30\u0C35\u0C30\u0C3F","\u0C2E\u0C3E\u0C30\u0C4D\u0C1A\u0C3F","\u0C0F\u0C2A\u0C4D\u0C30\u0C3F\u0C32\u0C4D","\u0C2E\u0C47","\u0C1C\u0C42\u0C28\u0C4D","\u0C1C\u0C41\u0C32\u0C48","\u0C06\u0C17\u0C38\u0C4D\u0C1F\u0C41","\u0C38\u0C46\u0C2A\u0C4D\u0C1F\u0C46\u0C02\u0C2C\u0C30\u0C4D","\u0C05\u0C15\u0C4D\u0C1F\u0C4B\u0C2C\u0C30\u0C4D","\u0C28\u0C35\u0C02\u0C2C\u0C30\u0C4D","\u0C21\u0C3F\u0C38\u0C46\u0C02\u0C2C\u0C30\u0C4D"]}; Fleur.locale["th"] = { - weekdays:["\u0E27\u0E31\u0E19\u0E2D\u0E32\u0E17\u0E34\u0E15\u0E22\u0E4C","\u0E27\u0E31\u0E19\u0E08\u0E31\u0E19\u0E17\u0E23\u0E4C","\u0E27\u0E31\u0E19\u0E2D\u0E31\u0E07\u0E04\u0E32\u0E23","\u0E27\u0E31\u0E19\u0E1E\u0E38\u0E18","\u0E27\u0E31\u0E19\u0E1E\u0E24\u0E2B\u0E31\u0E2A\u0E1A\u0E14\u0E35","\u0E27\u0E31\u0E19\u0E28\u0E38\u0E01\u0E23\u0E4C","\u0E27\u0E31\u0E19\u0E40\u0E2A\u0E32\u0E23\u0E4C"], - months: ["\u0E21\u0E01\u0E23\u0E32\u0E04\u0E21","\u0E01\u0E38\u0E21\u0E20\u0E32\u0E1E\u0E31\u0E19\u0E18\u0E4C","\u0E21\u0E35\u0E19\u0E32\u0E04\u0E21","\u0E40\u0E21\u0E29\u0E32\u0E22\u0E19","\u0E1E\u0E24\u0E29\u0E20\u0E32\u0E04\u0E21","\u0E21\u0E34\u0E16\u0E38\u0E19\u0E32\u0E22\u0E19","\u0E01\u0E23\u0E01\u0E0E\u0E32\u0E04\u0E21","\u0E2A\u0E34\u0E07\u0E2B\u0E32\u0E04\u0E21","\u0E01\u0E31\u0E19\u0E22\u0E32\u0E22\u0E19","\u0E15\u0E38\u0E25\u0E32\u0E04\u0E21","\u0E1E\u0E24\u0E28\u0E08\u0E34\u0E01\u0E32\u0E22\u0E19","\u0E18\u0E31\u0E19\u0E27\u0E32\u0E04\u0E21"]}; + weekdays:["\u0E27\u0E31\u0E19\u0E2D\u0E32\u0E17\u0E34\u0E15\u0E22\u0E4C","\u0E27\u0E31\u0E19\u0E08\u0E31\u0E19\u0E17\u0E23\u0E4C","\u0E27\u0E31\u0E19\u0E2D\u0E31\u0E07\u0E04\u0E32\u0E23","\u0E27\u0E31\u0E19\u0E1E\u0E38\u0E18","\u0E27\u0E31\u0E19\u0E1E\u0E24\u0E2B\u0E31\u0E2A\u0E1A\u0E14\u0E35","\u0E27\u0E31\u0E19\u0E28\u0E38\u0E01\u0E23\u0E4C","\u0E27\u0E31\u0E19\u0E40\u0E2A\u0E32\u0E23\u0E4C"], + months: ["\u0E21\u0E01\u0E23\u0E32\u0E04\u0E21","\u0E01\u0E38\u0E21\u0E20\u0E32\u0E1E\u0E31\u0E19\u0E18\u0E4C","\u0E21\u0E35\u0E19\u0E32\u0E04\u0E21","\u0E40\u0E21\u0E29\u0E32\u0E22\u0E19","\u0E1E\u0E24\u0E29\u0E20\u0E32\u0E04\u0E21","\u0E21\u0E34\u0E16\u0E38\u0E19\u0E32\u0E22\u0E19","\u0E01\u0E23\u0E01\u0E0E\u0E32\u0E04\u0E21","\u0E2A\u0E34\u0E07\u0E2B\u0E32\u0E04\u0E21","\u0E01\u0E31\u0E19\u0E22\u0E32\u0E22\u0E19","\u0E15\u0E38\u0E25\u0E32\u0E04\u0E21","\u0E1E\u0E24\u0E28\u0E08\u0E34\u0E01\u0E32\u0E22\u0E19","\u0E18\u0E31\u0E19\u0E27\u0E32\u0E04\u0E21"]}; Fleur.locale["uk"] = { - weekdays:["\u043D\u0435\u0434\u0456\u043B\u044F","\u043F\u043E\u043D\u0435\u0434\u0456\u043B\u043E\u043A","\u0432\u0456\u0432\u0442\u043E\u0440\u043E\u043A","\u0441\u0435\u0440\u0435\u0434\u0430","\u0447\u0435\u0442\u0432\u0435\u0440","\u043F\u02BC\u044F\u0442\u043D\u0438\u0446\u044F","\u0441\u0443\u0431\u043E\u0442\u0430"], - months: ["\u0441\u0456\u0447\u0435\u043D\u044C","\u043B\u044E\u0442\u0438\u0439","\u0431\u0435\u0440\u0435\u0437\u0435\u043D\u044C","\u043A\u0432\u0456\u0442\u0435\u043D\u044C","\u0442\u0440\u0430\u0432\u0435\u043D\u044C","\u0447\u0435\u0440\u0432\u0435\u043D\u044C","\u043B\u0438\u043F\u0435\u043D\u044C","\u0441\u0435\u0440\u043F\u0435\u043D\u044C","\u0432\u0435\u0440\u0435\u0441\u0435\u043D\u044C","\u0436\u043E\u0432\u0442\u0435\u043D\u044C","\u043B\u0438\u0441\u0442\u043E\u043F\u0430\u0434","\u0433\u0440\u0443\u0434\u0435\u043D\u044C"]}; + weekdays:["\u043D\u0435\u0434\u0456\u043B\u044F","\u043F\u043E\u043D\u0435\u0434\u0456\u043B\u043E\u043A","\u0432\u0456\u0432\u0442\u043E\u0440\u043E\u043A","\u0441\u0435\u0440\u0435\u0434\u0430","\u0447\u0435\u0442\u0432\u0435\u0440","\u043F\u02BC\u044F\u0442\u043D\u0438\u0446\u044F","\u0441\u0443\u0431\u043E\u0442\u0430"], + months: ["\u0441\u0456\u0447\u0435\u043D\u044C","\u043B\u044E\u0442\u0438\u0439","\u0431\u0435\u0440\u0435\u0437\u0435\u043D\u044C","\u043A\u0432\u0456\u0442\u0435\u043D\u044C","\u0442\u0440\u0430\u0432\u0435\u043D\u044C","\u0447\u0435\u0440\u0432\u0435\u043D\u044C","\u043B\u0438\u043F\u0435\u043D\u044C","\u0441\u0435\u0440\u043F\u0435\u043D\u044C","\u0432\u0435\u0440\u0435\u0441\u0435\u043D\u044C","\u0436\u043E\u0432\u0442\u0435\u043D\u044C","\u043B\u0438\u0441\u0442\u043E\u043F\u0430\u0434","\u0433\u0440\u0443\u0434\u0435\u043D\u044C"]}; Fleur.locale["zh-CN"] = { - weekdays:["\u661F\u671F\u65E5","\u661F\u671F\u4E00","\u661F\u671F\u4E8C","\u661F\u671F\u4E09","\u661F\u671F\u56DB","\u661F\u671F\u4E94","\u661F\u671F\u516D"], - months: ["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00\u6708","\u5341\u4E8C\u6708"]}; + weekdays:["\u661F\u671F\u65E5","\u661F\u671F\u4E00","\u661F\u671F\u4E8C","\u661F\u671F\u4E09","\u661F\u671F\u56DB","\u661F\u671F\u4E94","\u661F\u671F\u516D"], + months: ["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00\u6708","\u5341\u4E8C\u6708"]}; Fleur.locale["zh-TW"] = { - weekdays:["\u661F\u671F\u65E5","\u661F\u671F\u4E00","\u661F\u671F\u4E8C","\u661F\u671F\u4E09","\u661F\u671F\u56DB","\u661F\u671F\u4E94","\u661F\u671F\u516D"], - months: ["1\u6708","2\u6708","3\u6708","4\u6708","5\u6708","6\u6708","7\u6708","8\u6708","9\u6708","10\u6708","11\u6708","12\u6708"]}; \ No newline at end of file + weekdays:["\u661F\u671F\u65E5","\u661F\u671F\u4E00","\u661F\u671F\u4E8C","\u661F\u671F\u4E09","\u661F\u671F\u56DB","\u661F\u671F\u4E94","\u661F\u671F\u516D"], + months: ["1\u6708","2\u6708","3\u6708","4\u6708","5\u6708","6\u6708","7\u6708","8\u6708","9\u6708","10\u6708","11\u6708","12\u6708"]}; \ No newline at end of file diff --git a/src/js/fleur.js/XQuery/toJS.js b/src/js/fleur.js/XQuery/toJS.js index 82cf85c..cdf71ab 100644 --- a/src/js/fleur.js/XQuery/toJS.js +++ b/src/js/fleur.js/XQuery/toJS.js @@ -14,26 +14,41 @@ Fleur.pad = function(number) { return String(number); }; Fleur.dateToDate = function(dtz) { - return String(dtz.d.getFullYear()) + '-' + Fleur.pad(dtz.d.getMonth() + 1) + '-' + Fleur.pad(dtz.d.getDate()) + (dtz.tz !== null ? dtz.tz === 0 ? "Z" : (dtz.tz < 0 ? "-" : "+") + Fleur.pad(Math.floor(Math.abs(dtz.tz) / 60)) + ":" + Fleur.pad(Math.abs(dtz.tz) % 60) : ""); + return String(dtz.d.getFullYear()) + '-' + Fleur.pad(dtz.d.getMonth() + 1) + '-' + Fleur.pad(dtz.d.getDate()) + (dtz.tz !== null ? dtz.tz === 0 ? "Z" : (dtz.tz < 0 ? "+" : "-") + Fleur.pad(Math.floor(Math.abs(dtz.tz) / 60)) + ":" + Fleur.pad(Math.abs(dtz.tz) % 60) : ""); }; Fleur.dateToDateTime = function(dtz) { - return String(dtz.d.getFullYear()) + '-' + Fleur.pad(dtz.d.getMonth() + 1) + '-' + Fleur.pad(dtz.d.getDate()) + 'T' + Fleur.pad(dtz.d.getHours()) + ':' + Fleur.pad(dtz.d.getMinutes()) + ':' + Fleur.pad(dtz.d.getSeconds()) + (dtz.d.getMilliseconds() !== 0 ? '.' + (dtz.d.getMilliseconds() / 1000).toFixed(3).slice(2, 5) : "") + (dtz.tz !== null ? dtz.tz === 0 ? "Z" : (dtz.tz < 0 ? "-" : "+") + Fleur.pad(Math.floor(Math.abs(dtz.tz) / 60)) + ":" + Fleur.pad(Math.abs(dtz.tz) % 60) : ""); + if (!dtz) { + const d = new Date(); + dtz = { + d: d, + tz: d.getTimezoneOffset() + }; + } + return String(dtz.d.getFullYear()) + '-' + Fleur.pad(dtz.d.getMonth() + 1) + '-' + Fleur.pad(dtz.d.getDate()) + 'T' + Fleur.pad(dtz.d.getHours()) + ':' + Fleur.pad(dtz.d.getMinutes()) + ':' + Fleur.pad(dtz.d.getSeconds()) + (dtz.d.getMilliseconds() !== 0 ? '.' + (dtz.d.getMilliseconds() / 1000).toFixed(3).slice(2, 5) : "") + (dtz.tz !== null ? dtz.tz === 0 ? "Z" : (dtz.tz < 0 ? "+" : "-") + Fleur.pad(Math.floor(Math.abs(dtz.tz) / 60)) + ":" + Fleur.pad(Math.abs(dtz.tz) % 60) : ""); }; Fleur.dateToTime = function(dtz) { - return Fleur.pad(dtz.d.getHours()) + ':' + Fleur.pad(dtz.d.getMinutes()) + ':' + Fleur.pad(dtz.d.getSeconds()) + (dtz.d.getMilliseconds() !== 0 ? '.' + (dtz.d.getMilliseconds() / 1000).toFixed(3).slice(2, 5) : "") + (dtz.tz !== null ? dtz.tz === 0 ? "Z" : (dtz.tz < 0 ? "-" : "+") + Fleur.pad(Math.floor(Math.abs(dtz.tz) / 60)) + ":" + Fleur.pad(Math.abs(dtz.tz) % 60) : ""); + return Fleur.pad(dtz.d.getHours()) + ':' + Fleur.pad(dtz.d.getMinutes()) + ':' + Fleur.pad(dtz.d.getSeconds()) + (dtz.d.getMilliseconds() !== 0 ? '.' + (dtz.d.getMilliseconds() / 1000).toFixed(3).slice(2, 5) : "") + (dtz.tz !== null ? dtz.tz === 0 ? "Z" : (dtz.tz < 0 ? "+" : "-") + Fleur.pad(Math.floor(Math.abs(dtz.tz) / 60)) + ":" + Fleur.pad(Math.abs(dtz.tz) % 60) : ""); }; Fleur.toDate = function(s) { + let d = new Date(parseInt(s.substr(0, 4), 10), parseInt(s.substr(5, 2), 10) - 1, parseInt(s.substr(8, 2), 10)); + if (d.getMonth() + 1 !== Number(s.substr(5, 2))) { + throw new Fleur.DOMException(Fleur.DOMException.VALIDATION_ERR); + } return { - d: new Date(parseInt(s.substr(0, 4), 10), parseInt(s.substr(5, 2), 10) - 1, parseInt(s.substr(8, 2), 10)), + d: d, tz: s.endsWith("Z") ? 0 : - s.substr(s.length - 6, 1) === "+" ? parseInt(s.substr(s.length - 5, 2), 10) * 60 + parseInt(s.substr(s.length - 2, 2), 10) : - s.substr(s.length - 6, 1) === "-" && s.substr(s.length - 3, 1) === ":"? -parseInt(s.substr(s.length - 5, 2), 10) * 60 - parseInt(s.substr(s.length - 2, 2), 10) : + s.substr(s.length - 6, 1) === "-" && s.substr(s.length - 3, 1) === ":" ? parseInt(s.substr(s.length - 5, 2), 10) * 60 + parseInt(s.substr(s.length - 2, 2), 10) : + s.substr(s.length - 6, 1) === "+" && s.substr(s.length - 3, 1) === ":" ? -parseInt(s.substr(s.length - 5, 2), 10) * 60 - parseInt(s.substr(s.length - 2, 2), 10) : null }; }; Fleur.toDateTime = function(s) { + let d = new Date(parseInt(s.substr(0, 4), 10), parseInt(s.substr(5, 2), 10) - 1, parseInt(s.substr(8, 2), 10), parseInt(s.substr(11, 2), 10), parseInt(s.substr(14, 2), 10), parseInt(s.substr(17, 2), 10), s.charAt(19) === "." ? parseFloat("0." + s.substr(20).replace(/\+\-Z/, "Z").split("Z")[0]) * 1000 : 0); + if (d.getMonth() + 1 !== Number(s.substr(5, 2))) { + throw new Fleur.DOMException(Fleur.DOMException.VALIDATION_ERR); + } return { - d: new Date(parseInt(s.substr(0, 4), 10), parseInt(s.substr(5, 2), 10) - 1, parseInt(s.substr(8, 2), 10), parseInt(s.substr(11, 2), 10), parseInt(s.substr(14, 2), 10), parseInt(s.substr(17, 2), 10), s.charAt(19) === "." ? parseFloat("0." + s.substr(20).replace(/\+\-Z/, "Z").split("Z")[0]) * 1000 : 0), + d: d, tz: s.endsWith("Z") ? 0 : s.substr(s.length - 6, 1) === "+" ? parseInt(s.substr(s.length - 5, 2), 10) * 60 + parseInt(s.substr(s.length - 2, 2), 10) : s.substr(s.length - 6, 1) === "-" && s.substr(s.length - 3, 1) === ":"? -parseInt(s.substr(s.length - 5, 2), 10) * 60 - parseInt(s.substr(s.length - 2, 2), 10) : @@ -50,8 +65,8 @@ Fleur.toTime = function(s) { return { d: d, tz: s.endsWith("Z") ? 0 : - s.substr(s.length - 6, 1) === "+" ? parseInt(s.substr(s.length - 5, 2), 10) * 60 + parseInt(s.substr(s.length - 2, 2), 10) : - s.substr(s.length - 6, 1) === "-" && s.substr(s.length - 3, 1) === ":"? -parseInt(s.substr(s.length - 5, 2), 10) * 60 - parseInt(s.substr(s.length - 2, 2), 10) : + s.substr(s.length - 6, 1) === "-" && s.substr(s.length - 3, 1) === ":" ? parseInt(s.substr(s.length - 5, 2), 10) * 60 + parseInt(s.substr(s.length - 2, 2), 10) : + s.substr(s.length - 6, 1) === "+" && s.substr(s.length - 3, 1) === ":" ? -parseInt(s.substr(s.length - 5, 2), 10) * 60 - parseInt(s.substr(s.length - 2, 2), 10) : null }; }; @@ -126,7 +141,7 @@ Fleur.NumberToDecimalString = function(n, precision) { s[1] = s[1] || ""; if (exp >= 0) { if (exp < s[1].length) { - return s[0] + s[1].substr(0, s[1].length - exp) + "." + s[1].substr(s[1].length - exp); + return s[0] + s[1].substring(0, s[1].length - exp) + "." + s[1].substring(s[1].length - exp); } return s[0] + s[1] + "0".repeat(exp - s[1].length); } diff --git a/src/js/fleur.js/project.json b/src/js/fleur.js/project.json index f611941..bf6a21e 100644 --- a/src/js/fleur.js/project.json +++ b/src/js/fleur.js/project.json @@ -1,6 +1,6 @@ { "Name":"fleur.js", - "Header":"\"use strict\";\ntry{console.info('Fleur $$$VersionName$$$ ($$$VersionNumber$$$), $$$VersionDescription$$$, copyright (C) $$$VersionYear$$$ agenceXML - Alain Couthures, contact at fleur@agencexml.com');}catch(e){}\n", + "Header":"\"use strict\";\ntry{if (typeof window !== 'undefined') console.info('Fleur $$$VersionName$$$ ($$$VersionNumber$$$), $$$VersionDescription$$$, copyright (C) $$$VersionYear$$$ agenceXML - Alain Couthures, contact at fleur@agencexml.com');}catch(e){}\n", "Footer":"", "Components":[ ["(function(Fleur) {\nFleur.version = '$$$VersionName$$$';\n"], diff --git a/src/js/fleur.js/scriptrun.js b/src/js/fleur.js/scriptrun.js index 6a15c3b..579db5f 100644 --- a/src/js/fleur.js/scriptrun.js +++ b/src/js/fleur.js/scriptrun.js @@ -1,10 +1,7 @@ -/*eslint-env browser, node*/ -/*globals Fleur */ -/*eslint-disable no-console */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module * @description */ @@ -34,6 +31,7 @@ if ((new Function("try {return this === window;} catch(e) {return false;}"))()) }, false); } else if (global) { global.fs = require('fs'); + global.fsPromises = require("fs/promises"); global.http = require('http'); global.path = require('path'); global.url = require('url'); @@ -46,17 +44,19 @@ if ((new Function("try {return this === window;} catch(e) {return false;}"))()) if (i >= startparams) { if (!params.q && !params.qs) { if (val.startsWith("-q:") && val.length > 3) { - params.q = val.substr(3); + params.q = val.substring(3); } else if (val.startsWith("-qs:") && val.length > 4) { - params.qs = val.substr(4); + params.qs = val.substring(4); + } else if (val.startsWith("-js:") && val.length > 4) { + params.js = val.substring(4); } else if (val.startsWith("-s:") && !params.s && val.length > 3) { - params.s = val.substr(3); + params.s = val.substring(3); } else if (val.startsWith("-o:") && !params.o && val.length > 3) { - params.o = val.substr(3); + params.o = val.substring(3); } else if (val.startsWith("-p:") && !params.p && val.length > 3) { - params.p = parseInt(val.substr(3), 10); + params.p = parseInt(val.substring(3), 10); } else if (val.startsWith("-f:") && !params.f && val.length > 3) { - params.f = val.substr(3); + params.f = val.substring(3); } else { params.usage = true; } @@ -68,8 +68,9 @@ if ((new Function("try {return this === window;} catch(e) {return false;}"))()) } }); if (params.usage || (!params.qs && !params.q && (params.s || params.o))) { - process.stdout.write("Usage: node fleur ([-s:xmlfile] [-o:outfile] (-q:queryfile|-qs:querystring) [params]|[-p:port] [-f:folder])\n"); + process.stdout.write("Usage: node fleur ([-s:xmlfile] [-js:jsfile|-o:outfile] (-q:queryfile|-qs:querystring) [params]|[-p:port] [-f:folder])\n"); process.stdout.write(" -s: XML input file (optional)\n"); + process.stdout.write(" -js: Javascript output file (optional)\n"); process.stdout.write(" -o: output file (optional)\n"); process.stdout.write(" -q: query file\n"); process.stdout.write(" -qs: query string\n"); @@ -92,7 +93,7 @@ if ((new Function("try {return this === window;} catch(e) {return false;}"))()) }; } try { - var d1 = new Date(); + var d1 = new Date(); xmldoc.evaluate(xexpr, null, env).then( function(res) { if (out) { @@ -116,6 +117,11 @@ if ((new Function("try {return this === window;} catch(e) {return false;}"))()) } }; Fleur.baseDir = params.q ? global.path.dirname(params.q) : process.cwd(); + var sourcejs = function(xexpr, out) { + const arr = Fleur.XQueryParser._xq2js(xexpr, [], [], 0); + const jscript = (new Fleur.Transpiler()).source(arr); + global.fs.writeFile(out, jscript, function(err) {if (err) process.stdout.write(err);}); + }; var sourceval = function(xml) { if (params.qs) { parseval(xml, params.qs, params.o); @@ -129,7 +135,19 @@ if ((new Function("try {return this === window;} catch(e) {return false;}"))()) }); } }; - if (params.s) { + if (params.js) { + if (params.qs) { + sourcejs(params.qs, params.js); + } else { + global.fs.readFile(params.q, 'binary', function(err, file){ + if (err) { + process.stdout.write(err); + } else { + sourcejs(file, params.js); + } + }); + } + } else if (params.s) { global.fs.readFile(params.s, 'binary', function(err, file){ if (err) { process.stdout.write(err); diff --git a/src/js/xsltforms.js/actions/abstractAction.js b/src/js/xsltforms.js/actions/abstractAction.js index a72e324..797c666 100644 --- a/src/js/xsltforms.js/actions/abstractAction.js +++ b/src/js/xsltforms.js/actions/abstractAction.js @@ -1,104 +1,102 @@ -/*eslint-env browser*/ -/*globals XsltForms_xpath XsltForms_globals XsltForms_listener XsltForms_browser XsltForms_idManager*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module abstractAction * @description === "XsltForms_abstractAction" class === * Parent class for each Action class */ - + function XsltForms_abstractAction() { } - + /** * * '''init''' method : "if", "while" and "iterate" attributes are defined in this class */ XsltForms_abstractAction.prototype.init = function(elt) { - var ifexpr = elt.getAttribute("xf-if"); - var whileexpr = elt.getAttribute("xf-while"); - var iterateexpr = elt.getAttribute("xf-iterate"); - this.ifexpr = ifexpr? XsltForms_xpath.create(this.subform, ifexpr) : null; - this.whileexpr = whileexpr? XsltForms_xpath.create(this.subform, whileexpr) : null; - this.iterateexpr = iterateexpr? XsltForms_xpath.create(this.subform, iterateexpr) : null; - this.element = elt; - var mainaction = elt; - while (mainaction && mainaction.hasAttribute && !mainaction.hasAttribute("ev-event")) { - mainaction = mainaction.parentNode; - } - if (mainaction.hasAttribute) { - this.observer = mainaction.hasAttribute("ev-observer") ? XsltForms_idManager.find(mainaction.getAttribute("ev-observer")) : mainaction.parentNode; - if (elt === mainaction) { - var action = this; - new XsltForms_listener(this.subform, this.observer, null, elt.getAttribute("ev-event"), null, function(evt) { - XsltForms_browser.run(action, action.observer, evt, false, true); - }, true); - } - } + var ifexpr = elt.getAttribute("xf-if"); + var whileexpr = elt.getAttribute("xf-while"); + var iterateexpr = elt.getAttribute("xf-iterate"); + this.ifexpr = ifexpr? XsltForms_xpath.create(this.subform, ifexpr) : null; + this.whileexpr = whileexpr? XsltForms_xpath.create(this.subform, whileexpr) : null; + this.iterateexpr = iterateexpr? XsltForms_xpath.create(this.subform, iterateexpr) : null; + this.element = elt; + var mainaction = elt; + while (mainaction && mainaction.hasAttribute && !mainaction.hasAttribute("ev-event")) { + mainaction = mainaction.parentNode; + } + if (mainaction.hasAttribute) { + this.observer = mainaction.hasAttribute("ev-observer") ? XsltForms_idManager.find(mainaction.getAttribute("ev-observer")) : mainaction.parentNode; + if (elt === mainaction) { + var action = this; + new XsltForms_listener(this.subform, this.observer, null, elt.getAttribute("ev-event"), null, function(evt) { + XsltForms_browser.run(action, action.observer, evt, false, true); + }, true); + } + } }; - + /** * * '''build''' method : empty method for actions */ XsltForms_abstractAction.prototype.build = function() {}; - + /** * * '''execute''' method : "while" attribute process calling "if" attribute process */ XsltForms_abstractAction.prototype.execute = function(element, ctx, evt) { - if (evt.stopped) { return; } - if (!ctx) { - ctx = element.node || (XsltForms_globals.defaultModel.getInstanceDocument() ? XsltForms_globals.defaultModel.getInstanceDocument().documentElement : null); - } - // for now, iterate overrides while. - if (this.iterateexpr) { - if (this.whileexpr) { - XsltForms_globals.error(this.element, "xforms-compute-exception", "@iterate cannot be used with @while"); - } - var nodes = this.iterateexpr.xpath_evaluate(ctx).toArray(); - for (var i = 0, len = nodes.length; i < len; i++) { - this.exec_(element, nodes[i], evt); - } - } else if (this.whileexpr) { - while (XsltForms_globals.booleanValue(this.whileexpr.xpath_evaluate(ctx))) { - if (!this.exec_(element, ctx, evt)) { - break; - } - } - } else { - this.exec_(element, ctx, evt); - } + if (evt.stopped) { return; } + if (!ctx) { + ctx = element.node || (XsltForms_globals.defaultModel.getInstanceDocument() ? XsltForms_globals.defaultModel.getInstanceDocument().documentElement : null); + } + // for now, iterate overrides while. + if (this.iterateexpr) { + if (this.whileexpr) { + XsltForms_globals.error(this.element, "xforms-compute-exception", "@iterate cannot be used with @while"); + } + var nodes = this.iterateexpr.xpath_evaluate(ctx, null, null, element).toArray(); + for (var i = 0, len = nodes.length; i < len; i++) { + this.exec_(element, nodes[i], evt); + } + } else if (this.whileexpr) { + while (XsltForms_globals.booleanValue(this.whileexpr.xpath_evaluate(ctx, null, null, element))) { + if (!this.exec_(element, ctx, evt)) { + break; + } + } + } else { + this.exec_(element, ctx, evt); + } }; - + /** * * '''exec_''' method : "if" attribute process calling specific "run" method */ XsltForms_abstractAction.prototype.exec_ = function(element, ctx, evt) { - if (this.ifexpr) { - if (XsltForms_globals.booleanValue(this.ifexpr.xpath_evaluate(ctx))) { - this.run(element, ctx, evt); - } else { - return false; - } - } else { - this.run(element, ctx, evt); - } - return true; + if (this.ifexpr) { + if (XsltForms_globals.booleanValue(this.ifexpr.xpath_evaluate(ctx, null, null, element))) { + this.run(element, ctx, evt); + } else { + return false; + } + } else { + this.run(element, ctx, evt); + } + return true; }; - + /** * * '''run''' method : Empty method to be defined in each sub-class */ diff --git a/src/js/xsltforms.js/actions/action.js b/src/js/xsltforms.js/actions/action.js index dd27e2f..e3754d6 100644 --- a/src/js/xsltforms.js/actions/action.js +++ b/src/js/xsltforms.js/actions/action.js @@ -1,55 +1,72 @@ -/*eslint-env browser*/ -/*globals XsltForms_abstractAction XsltForms_browser XsltForms_class XsltForms_subform*/ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module action - * @description === "XsltForms_action" class === - * Action Class - * * constructor function : specifically initializes at no child - */ - -new XsltForms_class("XsltForms_action", "HTMLElement", "xforms-action"); - +"use strict"; +/** + * @author Alain Couthures + * @license LGPL - See file 'LICENSE.md' in this project. + * @module action + * @description === "XsltForms_action" class === + * Action Class + * * constructor function : specifically initializes at no child + */ + +new XsltForms_class("XsltForms_action", "HTMLElement", "xforms-action"); + function XsltForms_action(subform, elt) { - this.subform = subform; - this.init(elt); + this.subform = subform; + this.init(elt); + this.jsaction = elt.getAttribute("xf-type") === "text/javascript"; + if (this.jsaction) { + let body = "", params = []; + Array.prototype.slice.call(elt.children).forEach(function(n) { + switch(n.localName.toLowerCase()) { + case "xforms-body": + body = n.textContent; + break; + case "xforms-param": + params.push({ + name: n.getAttribute("xf-name"), + value: n.hasAttribute("xf-value") ? new XsltForms_binding(subform, n, null, "constant") : n.textContent + }); + break; + } + }); + this.params = params; + this.jsfunction = eval( + "(" + + params.reduce((s, p) => s === "" ? p.name : s + ", " + p.name, "") + + ") => {" + + body + + "}" + ); + } } XsltForms_action.prototype = new XsltForms_abstractAction(); - - -/** - * * '''add''' method : adds a child action to this action - */ + + +/** + * * '''add''' method : adds a child action to this action + */ //XsltForms_action.prototype.add = function(action) { -// this.childs.push(action); -// action.parentAction = this; -// return this; +// this.childs.push(action); +// action.parentAction = this; +// return this; //}; - - -/** - * * '''run''' method : executes each child action of this action - */ + + +/** + * * '''run''' method : executes each child action of this action + */ XsltForms_action.prototype.run = function(element, ctx, evt) { - var p = element; - while (p) { - if (p.xfElement) { - if (p.xfElement.varResolver) { - this.varResolver = {}; - for (var v in p.xfElement.varResolver) { - this.varResolver[v] = p.xfElement.varResolver[v]; - } - } - break; - } - p = p.parentNode; - } - XsltForms_browser.forEach(Array.prototype.slice.call(this.element.children).map(function(elt) { return elt.xfElement; }), "execute", element, ctx, evt); + if (this.jsaction) { + const args = this.params.map(p => p.value.bind_evaluate ? + p.value.bind_evaluate(this.subform, ctx, element) : + p.value); + this.jsfunction.apply(null, args); + return; + } + XsltForms_browser.forEach(Array.prototype.slice.call(this.element.children).map(function(elt) { return elt.xfElement; }), "execute", element, ctx, evt); }; \ No newline at end of file diff --git a/src/js/xsltforms.js/actions/confirm.js b/src/js/xsltforms.js/actions/confirm.js index 185c7c2..53f5385 100644 --- a/src/js/xsltforms.js/actions/confirm.js +++ b/src/js/xsltforms.js/actions/confirm.js @@ -1,44 +1,42 @@ -/*eslint-env browser*/ -/*globals XsltForms_abstractAction XsltForms_browser XsltForms_idManager XsltForms_globals XsltForms_class XsltForms_subform XsltForms_binding*/ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module confirm - * @description - */ - -new XsltForms_class("XsltForms_confirm", "HTMLElement", "xforms-confirm"); - +"use strict"; +/** + * @author Alain Couthures + * @license LGPL - See file 'LICENSE.md' in this project. + * @module confirm + * @description + */ + +new XsltForms_class("XsltForms_confirm", "HTMLElement", "xforms-confirm"); + function XsltForms_confirm(subform, elt) { - this.subform = subform; - this.binding = elt.hasAttribute("xf-ref") || elt.hasAttribute("xf-bind") ? new XsltForms_binding(this.subform, elt) : null; - this.id = elt.id; - this.init(elt); + this.subform = subform; + this.binding = elt.hasAttribute("xf-ref") || elt.hasAttribute("xf-bind") ? new XsltForms_binding(this.subform, elt) : null; + this.id = elt.id; + this.init(elt); } XsltForms_confirm.prototype = new XsltForms_abstractAction(); -/** - * @callback - */ +/** + * @callback + */ XsltForms_confirm.prototype.run = function(element, ctx, evt) { - var text; - if (this.binding) { - var node = this.binding.bind_evaluate(ctx)[0]; - if (node) { - text = XsltForms_browser.getValue(node); - } - } else { - var e = XsltForms_idManager.find(this.id); - XsltForms_globals.build(e, ctx); - text = e.textContent || e.innerText; - } - if (text) { - var res = XsltForms_browser.confirm(text.trim()); - if (!res) { - evt.stopPropagation(); - evt.stopped = true; - } - } + var text; + if (this.binding) { + var node = this.binding.bind_evaluate(ctx)[0]; + if (node) { + text = XsltForms_browser.getValue(node); + } + } else { + var e = XsltForms_idManager.find(this.id); + XsltForms_globals.build(e, ctx); + text = e.textContent || e.innerText; + } + if (text) { + var res = XsltForms_browser.confirm(text.trim()); + if (!res) { + evt.stopPropagation(); + evt.stopped = true; + } + } }; \ No newline at end of file diff --git a/src/js/xsltforms.js/actions/delete.js b/src/js/xsltforms.js/actions/delete.js index c179937..bd6b89c 100644 --- a/src/js/xsltforms.js/actions/delete.js +++ b/src/js/xsltforms.js/actions/delete.js @@ -1,95 +1,92 @@ -/*eslint-env browser*/ -/*globals XsltForms_binding XsltForms_xpath XsltForms_abstractAction XsltForms_browser XsltForms_globals XsltForms_exprContext Fleur XsltForms_mipbinding XsltForms_xmlevents XsltForms_class XsltForms_collection XsltForms_subform*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module delete * @description === "XsltForms_Delete" class === * Delete Action Class * * constructor function : resolves the properties of this delete action */ - + new XsltForms_class("XsltForms_delete", "HTMLElement", "xforms-delete"); function XsltForms_delete(subform, elt) { - this.subform = subform; - this.binding = new XsltForms_binding(this.subform, elt); - this.at = elt.hasAttribute("xf-at") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-at")) : null; - this.context = elt.hasAttribute("xf-context") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-context")) : null; - this.init(elt); + this.subform = subform; + this.binding = new XsltForms_binding(this.subform, elt); + this.at = elt.hasAttribute("xf-at") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-at")) : null; + this.context = elt.hasAttribute("xf-context") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-context")) : null; + this.init(elt); } XsltForms_delete.prototype = new XsltForms_abstractAction(); - + /** * * '''run''' method : executes this delete action and dispatches "xforms-delete" */ XsltForms_delete.prototype.run = function(element, ctx) { -// if (!element.xfElement) { +// if (!element.xfElement) { //console.log(Date.now() + ' ' +"missing"); -// return; -// } +// return; +// } //console.log(Date.now() + ' ' +"valid"); - var i, len; - if (this.context) { - ctx = this.context.xpath_evaluate(ctx, null, this.subform).head(); - } - if (!ctx) { - return; - } - var varresolver = this.parentAction ? this.parentAction.varResolver : element.xfElement.varResolver; - var nodes = this.binding.bind_evaluate(this.subform, ctx, varresolver).toArray(); - for (i = 0; i < nodes.length; i++) { - if (!nodes[i].ownerDocument || nodes[i].ownerDocument.documentElement === nodes[i]) { - nodes.splice(i, 1); - i--; - } - } - if(this.at) { - var index = XsltForms_globals.numberValue(this.at.xpath_evaluate(new XsltForms_exprContext(this.subform, ctx, 1, nodes, null, null, null, varresolver))); - if(!nodes[index - 1]) { - return; - } - nodes = [nodes[index - 1]]; - } - var model; - var instance; - if (nodes.length > 0) { - model = document.getElementById(XsltForms_browser.getDocMeta(nodes[0].nodeType === Fleur.Node.DOCUMENT_NODE ? nodes[0] : nodes[0].ownerDocument, "model")).xfElement; - instance = model.findInstance(nodes[0]); - } - var deletedNodes = []; - for (i = 0, len = nodes.length; i < len; i++) { - var node = nodes[i]; - XsltForms_mipbinding.nodedispose(node); - var repeat = XsltForms_browser.getMeta(node, "repeat"); - if (repeat) { - XsltForms_collection[repeat].xfElement.deleteNode(node); - } - if (node.nodeType === Fleur.Node.ATTRIBUTE_NODE) { - var oldOwnerElement = node.ownerElement? node.ownerElement: node.selectSingleNode(".."); - //XsltForms_browser.clearMeta(node); - if (oldOwnerElement.removeAttributeNS) { - oldOwnerElement.removeAttributeNS(node.namespaceURI, node.nodeName); - } else { - oldOwnerElement.removeAttributeNode(node); - } - if (!XsltForms_browser.isIE && !XsltForms_browser.isIE11) { - node.oldOwnerElement = oldOwnerElement; - } - } else { - node.parentNode.removeChild(node); - } - deletedNodes.push(node); - } - if (deletedNodes.length > 0) { - XsltForms_globals.addChange(model); - model.setRebuilded(true); - var evcontext = {"deleted-nodes": deletedNodes, "delete-location": index}; - XsltForms_xmlevents.dispatch(instance, "xforms-delete", null, null, null, null, evcontext); - } + var i, len; + if (this.context) { + ctx = this.context.xpath_evaluate(ctx, null, this.subform).head(); + } + if (!ctx) { + return; + } + var nodes = this.binding.bind_evaluate(this.subform, ctx, this.element).toArray(); + for (i = 0; i < nodes.length; i++) { + if (!nodes[i].ownerDocument || nodes[i].ownerDocument.documentElement === nodes[i]) { + nodes.splice(i, 1); + i--; + } + } + if(this.at) { + var index = XsltForms_globals.numberValue(this.at.xpath_evaluate(new XsltForms_exprContext(this.subform, ctx, 1, nodes, null, null, null, this.element))); + if(!nodes[index - 1]) { + return; + } + nodes = [nodes[index - 1]]; + } + var model; + var instance; + if (nodes.length > 0) { + model = document.getElementById(XsltForms_browser.getDocMeta(nodes[0].nodeType === Fleur.Node.DOCUMENT_NODE ? nodes[0] : nodes[0].ownerDocument, "model")).xfElement; + instance = model.findInstance(nodes[0]); + } + var deletedNodes = []; + for (i = 0, len = nodes.length; i < len; i++) { + var node = nodes[i]; + XsltForms_mipbinding.nodedispose(node); + var repeat = XsltForms_browser.getMeta(node, "repeat"); + if (repeat) { + XsltForms_collection[repeat].xfElement.deleteNode(node); + } + if (node.nodeType === Fleur.Node.ATTRIBUTE_NODE) { + var oldOwnerElement = node.ownerElement? node.ownerElement: node.selectSingleNode(".."); + //XsltForms_browser.clearMeta(node); + if (oldOwnerElement.removeAttributeNS) { + oldOwnerElement.removeAttributeNS(node.namespaceURI, node.nodeName); + } else { + oldOwnerElement.removeAttributeNode(node); + } + if (!XsltForms_browser.isIE && !XsltForms_browser.isIE11) { + node.oldOwnerElement = oldOwnerElement; + } + } else { + node.parentNode.removeChild(node); + } + deletedNodes.push(node); + } + if (deletedNodes.length > 0) { + XsltForms_globals.addChange(model); + model.setRebuilded(true); + var evcontext = {"deleted-nodes": deletedNodes, "delete-location": index}; + XsltForms_xmlevents.dispatch(instance, "xforms-delete", null, null, null, null, evcontext); + } }; \ No newline at end of file diff --git a/src/js/xsltforms.js/actions/dispatch.js b/src/js/xsltforms.js/actions/dispatch.js index 0b2393a..e376667 100644 --- a/src/js/xsltforms.js/actions/dispatch.js +++ b/src/js/xsltforms.js/actions/dispatch.js @@ -1,15 +1,13 @@ -/*eslint-env browser*/ -/*globals XsltForms_abstractAction XsltForms_globals XsltForms_browser XsltForms_xmlevents XsltForms_class XsltForms_subform XsltForms_binding*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module dispatch * @description === "XsltForms_dispatch" class === * Dispatch Action Class * * constructor function : stores specific properties */ - + new XsltForms_class("XsltForms_dispatch", "HTMLElement", "xforms-dispatch"); new XsltForms_class("XsltForms_dispatch", "HTMLElement", "xforms-hide"); new XsltForms_class("XsltForms_dispatch", "HTMLElement", "xforms-rebuild"); @@ -21,124 +19,124 @@ new XsltForms_class("XsltForms_dispatch", "HTMLElement", "xforms-send"); new XsltForms_class("XsltForms_dispatch", "HTMLElement", "xforms-setfocus"); new XsltForms_class("XsltForms_dispatch", "HTMLElement", "xforms-show"); -function XsltForms_dispatch(subform, elt) { - switch(elt.localName.toLowerCase()) { - case "xforms-dispatch": - var properties = {}; - var targetid, name, delay; - Array.prototype.slice.call(elt.children).forEach(function(n) { - switch(n.localName.toLowerCase()) { - case "xforms-targetid": - targetid = n; - break; - case "xforms-name": - name = n; - break; - case "xforms-delay": - delay = n; - break; - case "xforms-property": - properties[n.getAttribute("xf-name")] = n.hasAttribute("xf-value") ? new XsltForms_binding(subform, n) : n.textContent; - break; - } - }); - this.name = name ? (name.hasAttribute("xf-value") ? new XsltForms_binding(subform, name) : name.textContent) : elt.getAttribute("xf-name"); - this.target = targetid ? (targetid.hasAttribute("xf-value") ? new XsltForms_binding(subform, targetid) : targetid.textContent) : elt.getAttribute("xf-targetid"); - this.delay = delay ? (delay.hasAttribute("xf-value") ? new XsltForms_binding(subform, delay) : delay.textContent) : elt.getAttribute("xf-delay"); - this.properties = properties; - break; - case "xforms-hide": - this.name = "xforms-dialog-close"; - this.target = elt.getAttribute("xf-dialog"); - break; - case "xforms-rebuild": - case "xforms-recalculate": - case "xforms-refresh": - case "xforms-reset": - case "xforms-revalidate": - this.name = elt.localName.toLowerCase(); - this.target = elt.getAttribute("xf-model"); - break; - case "xforms-send": - this.name = "xforms-submit"; - this.target = elt.getAttribute("xf-submission"); - break; - case "xforms-setfocus": - var control; - Array.prototype.slice.call(elt.children).forEach(function(n) { - switch(n.localName.toLowerCase()) { - case "xforms-control": - control = n; - break; - } - }); - this.name = "xforms-focus"; - this.target = control ? (control.hasAttribute("xf-value") ? new XsltForms_binding(subform, control) : control.textContent) : elt.getAttribute("xf-control"); - break; - case "xforms-show": - this.name = "xforms-dialog-open"; - this.target = elt.getAttribute("xf-dialog"); - break; +function XsltForms_dispatch(subform, elt) { + switch(elt.localName.toLowerCase()) { + case "xforms-dispatch": + var properties = {}; + var targetid, name, delay; + Array.prototype.slice.call(elt.children).forEach(function(n) { + switch(n.localName.toLowerCase()) { + case "xforms-targetid": + targetid = n; + break; + case "xforms-name": + name = n; + break; + case "xforms-delay": + delay = n; + break; + case "xforms-property": + properties[n.getAttribute("xf-name")] = n.hasAttribute("xf-value") ? new XsltForms_binding(subform, n) : n.textContent; + break; + } + }); + this.name = name ? (name.hasAttribute("xf-value") ? new XsltForms_binding(subform, name) : name.textContent) : elt.getAttribute("xf-name"); + this.target = targetid ? (targetid.hasAttribute("xf-value") ? new XsltForms_binding(subform, targetid) : targetid.textContent) : elt.getAttribute("xf-targetid"); + this.delay = delay ? (delay.hasAttribute("xf-value") ? new XsltForms_binding(subform, delay) : delay.textContent) : elt.getAttribute("xf-delay"); + this.properties = properties; + break; + case "xforms-hide": + this.name = "xforms-dialog-close"; + this.target = elt.getAttribute("xf-dialog"); + break; + case "xforms-rebuild": + case "xforms-recalculate": + case "xforms-refresh": + case "xforms-reset": + case "xforms-revalidate": + this.name = elt.localName.toLowerCase(); + this.target = elt.getAttribute("xf-model"); + break; + case "xforms-send": + this.name = "xforms-submit"; + this.target = elt.getAttribute("xf-submission"); + break; + case "xforms-setfocus": + var control; + Array.prototype.slice.call(elt.children).forEach(function(n) { + switch(n.localName.toLowerCase()) { + case "xforms-control": + control = n; + break; + } + }); + this.name = "xforms-focus"; + this.target = control ? (control.hasAttribute("xf-value") ? new XsltForms_binding(subform, control) : control.textContent) : elt.getAttribute("xf-control"); + break; + case "xforms-show": + this.name = "xforms-dialog-open"; + this.target = elt.getAttribute("xf-dialog"); + break; +} + this.subform = subform; + this.init(elt); } - this.subform = subform; - this.init(elt); -} - -XsltForms_dispatch.prototype = new XsltForms_abstractAction(); - - +XsltForms_dispatch.prototype = new XsltForms_abstractAction(); + + + /** * * '''run''' method : dispatches an XForms event * @callback */ - -XsltForms_dispatch.prototype.run = function(element, ctx, evt) { - var evname = this.name; - if (evname.bind_evaluate) { - evname = XsltForms_globals.stringValue(evname.bind_evaluate(this.subform)); - } - var target = this.target; - if (target && target.bind_evaluate) { - target = XsltForms_globals.stringValue(target.bind_evaluate(this.subform)); - } - if (!target) { - switch (evname) { - case "xforms-submit": - target = document.getElementById(XsltForms_browser.getDocMeta(ctx.ownerDocument, "model")).xfElement.defaultSubmission; - break; - case "xforms-rebuild": - case "xforms-recalculate": - case "xforms-refresh": - case "xforms-reset": - case "xforms-revalidate": - target = document.getElementById(XsltForms_browser.getDocMeta(ctx.ownerDocument, "model")).xfElement; - break; - } - } else { - target = typeof target === "string"? XsltForms_idManager.find(target) : target; - if (!target && evname.indexOf("xforms-") === 0) { - evname = "xforms-binding-exception"; - target = element; - } - } - var evtctx = {}; - for (var prop in this.properties) { - if (prop !== "" && this.properties.hasOwnProperty(prop)) { - evtctx[prop] = this.properties[prop].bind_evaluate ? this.properties[prop].bind_evaluate(this.subform) : this.properties[prop]; - } - } - var delay = 0; - if (this.delay) { - if (this.delay.bind_evaluate) { - delay = XsltForms_globals.numberValue(this.delay.bind_evaluate(this.subform)); - } else { - delay = XsltForms_globals.numberValue(this.delay); - } - } - if (delay > 0 ) { - window.setTimeout("XsltForms_xmlevents.dispatch(document.getElementById('"+target.id+"'),'"+evname+"')", delay); - } else { - XsltForms_xmlevents.dispatch(target, evname, null, null, null, null, evtctx); - } + +XsltForms_dispatch.prototype.run = function(element, ctx, evt) { + var evname = this.name; + if (evname.bind_evaluate) { + evname = XsltForms_globals.stringValue(evname.bind_evaluate(this.subform)); + } + var target = this.target; + if (target && target.bind_evaluate) { + target = XsltForms_globals.stringValue(target.bind_evaluate(this.subform)); + } + if (!target) { + switch (evname) { + case "xforms-submit": + target = document.getElementById(XsltForms_browser.getDocMeta(ctx.ownerDocument, "model")).xfElement.defaultSubmission; + break; + case "xforms-rebuild": + case "xforms-recalculate": + case "xforms-refresh": + case "xforms-reset": + case "xforms-revalidate": + target = document.getElementById(XsltForms_browser.getDocMeta(ctx.ownerDocument, "model")).xfElement; + break; + } + } else { + target = typeof target === "string"? XsltForms_idManager.find(target) : target; + if (!target && evname.indexOf("xforms-") === 0) { + evname = "xforms-binding-exception"; + target = element; + } + } + var evtctx = {}; + for (var prop in this.properties) { + if (prop !== "" && this.properties.hasOwnProperty(prop)) { + evtctx[prop] = this.properties[prop].bind_evaluate ? this.properties[prop].bind_evaluate(this.subform) : this.properties[prop]; + } + } + var delay = 0; + if (this.delay) { + if (this.delay.bind_evaluate) { + delay = XsltForms_globals.numberValue(this.delay.bind_evaluate(this.subform)); + } else { + delay = XsltForms_globals.numberValue(this.delay); + } + } + if (delay > 0 ) { + window.setTimeout("XsltForms_xmlevents.dispatch(document.getElementById('"+target.id+"'),'"+evname+"')", delay); + } else { + XsltForms_xmlevents.dispatch(target, evname, null, null, null, null, evtctx); + } }; \ No newline at end of file diff --git a/src/js/xsltforms.js/actions/insert.js b/src/js/xsltforms.js/actions/insert.js index adde0ab..1fdaaeb 100644 --- a/src/js/xsltforms.js/actions/insert.js +++ b/src/js/xsltforms.js/actions/insert.js @@ -1,113 +1,110 @@ -/*eslint-env browser*/ -/*globals XsltForms_binding XsltForms_xpath XsltForms_abstractAction XsltForms_browser Fleur XsltForms_globals XsltForms_xmlevents XsltForms_exprContext XsltForms_class XsltForms_collection XsltForms_subform*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module insert * @description === "XsltForms_insert" class === * Insert Action Class * * constructor function : resolves specific properties */ - + new XsltForms_class("XsltForms_insert", "HTMLElement", "xforms-insert"); function XsltForms_insert(subform, elt) { - this.subform = subform; - this.binding = new XsltForms_binding(this.subform, elt); - this.origin = elt.hasAttribute("xf-origin") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-origin")) : null; - this.at = elt.hasAttribute("xf-at") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-at")) : null; - this.context = elt.hasAttribute("xf-context") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-context")) : null; - this.position = elt.getAttribute("xf-position") || "after"; - this.init(elt); + this.subform = subform; + this.binding = new XsltForms_binding(this.subform, elt); + this.origin = elt.hasAttribute("xf-origin") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-origin")) : null; + this.at = elt.hasAttribute("xf-at") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-at")) : null; + this.context = elt.hasAttribute("xf-context") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-context")) : null; + this.position = elt.getAttribute("xf-position") || "after"; + this.init(elt); } XsltForms_insert.prototype = new XsltForms_abstractAction(); - + /** * * '''run''' method : clones then inserts a new element and dispatches the "xforms-insert" */ XsltForms_insert.prototype.run = function(element, ctx) { - var varresolver = this.parentAction ? this.parentAction.varResolver : element.xfElement.varResolver; - if (this.context) { - ctx = this.context.xpath_evaluate(ctx).head(); - } - if (!ctx) { - return; - } - var nodes = []; - if( this.binding.bind || this.binding.xpath ) { - nodes = this.binding.bind_evaluate(this.subform, ctx, varresolver).toArray(); - } - var index = 0; - var node = null; - var originNodes = []; - var parentNode = null; - var pos = this.position === "after"? 1 : 0; - var res = 0; - if (this.origin) { - originNodes = this.origin.xpath_evaluate(ctx).toArray(); - } - if (originNodes.length === 0) { - if (nodes.length === 0) { - return; - } - originNodes.push(nodes[nodes.length - 1]); - } - for(var i = 0, len = originNodes.length; i < len; i += 1) { - node = originNodes[i]; - if (nodes.length === 0) { - parentNode = ctx; - } else { - parentNode = nodes[0].nodeType === Fleur.Node.DOCUMENT_NODE? nodes[0] : nodes[0].nodeType === Fleur.Node.ATTRIBUTE_NODE? nodes[0].ownerDocument ? nodes[0].ownerDocument : nodes[0].selectSingleNode("..") : nodes[0].parentNode; - if (parentNode.nodeType !== Fleur.Node.DOCUMENT_NODE && node.nodeType !== Fleur.Node.ATTRIBUTE_NODE) { - res = this.at ? Math.round(XsltForms_globals.numberValue(this.at.xpath_evaluate(new XsltForms_exprContext(this.subform, ctx, 1, nodes, null, null, null, varresolver)))) + i - 1: nodes.length - 1; - index = isNaN(res)? nodes.length : res + pos; - } - } - XsltForms_browser.debugConsole.write("insert " + node.nodeName + " in " + parentNode.nodeName + " at " + index + " - " + ctx.nodeName); - var clone = parentNode.ownerDocument ? parentNode.ownerDocument.importNode(node, true) : parentNode.importNode(node, true); - XsltForms_browser.clearMeta(clone); - if (node.nodeType === Fleur.Node.ATTRIBUTE_NODE) { - XsltForms_browser.setAttributeNS(parentNode, node.namespaceURI, node.nodeName, node.nodeValue); - } else { - if (parentNode.nodeType === Fleur.Node.DOCUMENT_NODE) { - var first = parentNode.documentElement; - var prevmodel = XsltForms_browser.getDocMeta(parentNode, "model"); - var previnst = XsltForms_browser.getDocMeta(parentNode, "instance"); - parentNode.removeChild(first); - first = null; - parentNode.appendChild(clone); - XsltForms_browser.setDocMeta(parentNode, "instance", previnst); - XsltForms_browser.setDocMeta(parentNode, "model", prevmodel); - } else { - var nodeAfter; - if (index >= nodes.length && nodes.length !== 0) { - nodeAfter = nodes[nodes.length - 1].nextSibling; - } else { - nodeAfter = nodes[index]; - } - if (nodeAfter) { - nodeAfter.parentNode.insertBefore(clone, nodeAfter); - } else if (nodes.length === 0 && parentNode.firstChild) { - parentNode.insertBefore(clone, parentNode.firstChild); - } else { - parentNode.appendChild(clone); - } - var repeat = nodes.length > 0? XsltForms_browser.getMeta(nodes[0], "repeat") : null; - nodes.push(clone); - if (repeat) { - XsltForms_collection[repeat].xfElement.insertNode(clone, nodeAfter); - } - } - } - } - var model = document.getElementById(XsltForms_browser.getDocMeta(parentNode.nodeType === Fleur.Node.DOCUMENT_NODE ? parentNode : parentNode.ownerDocument, "model")).xfElement; - XsltForms_globals.addChange(model); - model.setRebuilded(true); - var evcontext = {"inserted-nodes": [clone], "origin-nodes": originNodes, "insert-location-node": index, position: this.position}; - XsltForms_xmlevents.dispatch(model.findInstance(parentNode), "xforms-insert", null, null, null, null, evcontext); + if (this.context) { + ctx = this.context.xpath_evaluate(ctx).head(); + } + if (!ctx) { + return; + } + var nodes = []; + if( this.binding.bind || this.binding.xpath ) { + nodes = this.binding.bind_evaluate(this.subform, ctx, this.element).toArray(); + } + var index = 0; + var node = null; + var originNodes = []; + var parentNode = null; + var pos = this.position === "after"? 1 : 0; + var res = 0; + if (this.origin) { + originNodes = this.origin.xpath_evaluate(ctx, null, null, this.element).toArray(); + } + if (originNodes.length === 0) { + if (nodes.length === 0) { + return; + } + originNodes.push(nodes[nodes.length - 1]); + } + for(var i = 0, len = originNodes.length; i < len; i += 1) { + node = originNodes[i]; + if (nodes.length === 0) { + parentNode = ctx; + } else { + parentNode = nodes[0].nodeType === Fleur.Node.DOCUMENT_NODE? nodes[0] : nodes[0].nodeType === Fleur.Node.ATTRIBUTE_NODE? nodes[0].ownerDocument ? nodes[0].ownerDocument : nodes[0].selectSingleNode("..") : nodes[0].parentNode; + if (parentNode.nodeType !== Fleur.Node.DOCUMENT_NODE && node.nodeType !== Fleur.Node.ATTRIBUTE_NODE) { + res = this.at ? Math.round(XsltForms_globals.numberValue(this.at.xpath_evaluate(new XsltForms_exprContext(this.subform, ctx, 1, nodes, null, null, null, this.element)))) + i - 1: nodes.length - 1; + index = isNaN(res)? nodes.length : res + pos; + } + } + XsltForms_browser.debugConsole.write("insert " + node.nodeName + " in " + parentNode.nodeName + " at " + index + " - " + ctx.nodeName); + var clone = parentNode.ownerDocument ? parentNode.ownerDocument.importNode(node, true) : parentNode.importNode(node, true); + XsltForms_browser.clearMeta(clone); + if (node.nodeType === Fleur.Node.ATTRIBUTE_NODE) { + XsltForms_browser.setAttributeNS(parentNode, node.namespaceURI, node.nodeName, node.nodeValue); + } else { + if (parentNode.nodeType === Fleur.Node.DOCUMENT_NODE) { + var first = parentNode.documentElement; + var prevmodel = XsltForms_browser.getDocMeta(parentNode, "model"); + var previnst = XsltForms_browser.getDocMeta(parentNode, "instance"); + parentNode.removeChild(first); + first = null; + parentNode.appendChild(clone); + XsltForms_browser.setDocMeta(parentNode, "instance", previnst); + XsltForms_browser.setDocMeta(parentNode, "model", prevmodel); + } else { + var nodeAfter; + if (index >= nodes.length && nodes.length !== 0) { + nodeAfter = nodes[nodes.length - 1].nextSibling; + } else { + nodeAfter = nodes[index]; + } + if (nodeAfter) { + nodeAfter.parentNode.insertBefore(clone, nodeAfter); + } else if (nodes.length === 0 && parentNode.firstChild) { + parentNode.insertBefore(clone, parentNode.firstChild); + } else { + parentNode.appendChild(clone); + } + var repeat = nodes.length > 0? XsltForms_browser.getMeta(nodes[0], "repeat") : null; + nodes.push(clone); + if (repeat) { + XsltForms_collection[repeat].xfElement.insertNode(clone, nodeAfter); + } + } + } + } + var model = document.getElementById(XsltForms_browser.getDocMeta(parentNode.nodeType === Fleur.Node.DOCUMENT_NODE ? parentNode : parentNode.ownerDocument, "model")).xfElement; + XsltForms_globals.addChange(model); + model.setRebuilded(true); + var evcontext = {"inserted-nodes": [clone], "origin-nodes": originNodes, "insert-location-node": index, position: this.position}; + XsltForms_xmlevents.dispatch(model.findInstance(parentNode), "xforms-insert", null, null, null, null, evcontext); }; \ No newline at end of file diff --git a/src/js/xsltforms.js/actions/load.js b/src/js/xsltforms.js/actions/load.js index a265456..0e9d22c 100644 --- a/src/js/xsltforms.js/actions/load.js +++ b/src/js/xsltforms.js/actions/load.js @@ -1,204 +1,201 @@ -/*eslint-env browser*/ -/*globals XsltForms_abstractAction XsltForms_schema XsltForms_browser XsltForms_globals XsltForms_idManager XsltForms_submission XsltForms_xmlevents Fleur XsltForms_repeat XsltForms_class XsltForms_subform XsltForms_binding XsltForms_classes XsltForms_collection XsltForms_avt*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module load * @description === "XsltForms_load" class === * Load Action Class * * constructor function : stores specific properties */ - + new XsltForms_class("XsltForms_load", "HTMLElement", "xforms-load"); function XsltForms_load(subform, elt) { - this.subform = subform; - this.binding = elt.hasAttribute("xf-ref") || elt.hasAttribute("xf-bind") ? new XsltForms_binding(this.subform, elt) : null; - if (elt.hasAttribute("xf-resource")) { - this.resource = elt.getAttribute("xf-resource"); - } else if (elt.children.length !== 0 && elt.children[0].nodeName.toUpperCase() === "XFORMS-RESOURCE") { - if (elt.children[0].hasAttribute("xf-value")) { - this.resource = new XsltForms_binding(this.subform, elt.children[0]); - } else { - this.resource = elt.children[0].textContent; - } - } - this.show = elt.getAttribute("xf-show"); - this.targetid = elt.getAttribute("xf-target") || elt.getAttribute("xf-targetid") || "_self"; - this.init(elt); + this.subform = subform; + this.binding = elt.hasAttribute("xf-ref") || elt.hasAttribute("xf-bind") ? new XsltForms_binding(this.subform, elt) : null; + if (elt.hasAttribute("xf-resource")) { + this.resource = elt.getAttribute("xf-resource"); + } else if (elt.children.length !== 0 && elt.children[0].nodeName.toUpperCase() === "XFORMS-RESOURCE") { + if (elt.children[0].hasAttribute("xf-value")) { + this.resource = new XsltForms_binding(this.subform, elt.children[0]); + } else { + this.resource = elt.children[0].textContent; + } + } + this.show = elt.getAttribute("xf-show"); + this.targetid = elt.getAttribute("xf-target") || elt.getAttribute("xf-targetid") || "_self"; + this.init(elt); } XsltForms_load.prototype = new XsltForms_abstractAction(); - + /** * * '''run''' method : opens a new window or changes current location according to "show" attribute */ XsltForms_load.prototype.run = function(element, ctx) { - var href = this.resource; - var node; - if (this.binding) { - var varresolver = this.parentAction ? this.parentAction.varResolver : element.xfElement.varResolver; - node = this.binding.bind_evaluate(this.subform, ctx, varresolver).head(); - if (node) { - var t = XsltForms_schema.getType(XsltForms_browser.getType(node)); - if (!t.hasBase("xf:HTMLFragment")) { - href = XsltForms_browser.getValue(node); - } - } - } else { - if (href && typeof href === 'object') { - href = XsltForms_globals.stringValue(this.resource.xpath.xpath_evaluate(ctx)); - } else { - if (typeof href === 'string') { - href = XsltForms_browser.unescape(href); - } - } - } - if (href) { - if(href.substr(0, 11) === "javascript:") { - try { - eval("{XsltForms_context={elementId:\""+element.getAttribute("id")+"\"};"+href.substr(11)+"}"); - } catch (e) { - alert("XSLTForms Exception\n--------------------------\n\nError evaluating the following Javascript expression :\n\n"+href.substr(11)+"\n\n"+e); - } - } else if (this.show === "new" || this.targetid === "_blank") { - window.open(href); - } else if (this.show === "embed" || (this.targetid !== "" && this.targetid !== "_blank" && this.targetid !== "_self")) { - XsltForms_globals.openAction("XsltForms_load.prototype.run"); - var req = null; - var method = "get"; - var evcontext = {"method": method, "resource-uri": href}; - try { - req = XsltForms_browser.openRequest(method, href, false); - XsltForms_browser.debugConsole.write("Load " + href); - req.send(null); - if (req.status !== 0 && (req.status < 200 || req.status >= 300)) { - evcontext["error-type"] = "resource-error"; - this.issueLoadException_(evcontext, req, null); - XsltForms_globals.closeAction("XsltForms_load.prototype.run"); - return; - } - XsltForms_submission.requesteventlog(evcontext, req); - XsltForms_globals.closeAction("XsltForms_load.prototype.run"); - var resp = req.responseText; - var piindex = resp.indexOf("")).replace(/^.*href=\"([^\"]*)\".*$/, "$1"); - resp = XsltForms_browser.transformText(resp, xslhref, false); - piindex = resp.indexOf(""); - var subbody; - var targetelt = XsltForms_idManager.find(this.targetid); - if (sp.length === 1) { - subbody = resp; - } else { - subbody = sp[1]; - } - var targetid = targetelt.id; - var targetxf = targetelt.xfElement; - if (targetelt.xfElement) { - targetelt = targetelt.querySelector("xforms-body"); - } - targetelt.innerHTML = subbody; - targetelt.hasXFElement = null; - var parentNode = targetelt.parentNode; - while (parentNode) { - if (parentNode.hasXFElement !== false) { - break; - } - parentNode.hasXFElement = null; - parentNode = parentNode.parentNode; - } - var subformidx = XsltForms_globals.nbsubforms++; - var newsubform = new XsltForms_subform(this.subform, "xsltforms-subform-" + String(subformidx), targetid); - XsltForms_class.activateAll(newsubform, targetelt, function() { - newsubform.construct(); - if (!targetxf || !targetxf.isComponent) { - XsltForms_globals.openAction("XsltForms_subform.prototype.construct"); - XsltForms_globals.closeChanges(true); - XsltForms_globals.closeAction("XsltForms_subform.prototype.construct"); - } - if (targetxf) { - XsltForms_xmlevents.dispatch(targetxf, "xforms-load-done", null, null, null, null, evcontext); - } - }); - } catch(e2) { - XsltForms_browser.debugConsole.write(e2.message || e2); - evcontext["error-type"] = "resource-error"; - this.issueLoadException_(evcontext, req, e2); - XsltForms_globals.closeAction("XsltForms_load.prototype.run"); - } - } else { - location.href = href; - } - } else { - if (node) { - try { - var v = XsltForms_browser.getValue(node).replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&"); - var lw; - if (this.show === "new" || this.targetid === "_blank") { - lw = window.open("about:blank","_blank"); - lw.document.write(v); - lw.document.close(); - } else { - lw = window.open("about:blank", "_self"); - lw.document.write(v); - lw.document.close(); - } - } catch (e) { - XsltForms_browser.debugConsole.write("ERROR: Load:" + e.message); - } - } - } + var href = this.resource; + var node; + if (this.binding) { + node = this.binding.bind_evaluate(this.subform, ctx, this.element).head(); + if (node) { + var t = XsltForms_schema.getType(XsltForms_browser.getType(node)); + if (!t.hasBase("xf:HTMLFragment")) { + href = XsltForms_browser.getValue(node); + } + } + } else { + if (href && typeof href === 'object') { + href = XsltForms_globals.stringValue(this.resource.xpath.xpath_evaluate(ctx)); + } else { + if (typeof href === 'string') { + href = XsltForms_browser.unescape(href); + } + } + } + if (href) { + if(href.substr(0, 11) === "javascript:") { + try { + eval("{XsltForms_context={elementId:\""+element.getAttribute("id")+"\"};"+href.substr(11)+"}"); + } catch (e) { + alert("XSLTForms Exception\n--------------------------\n\nError evaluating the following Javascript expression :\n\n"+href.substr(11)+"\n\n"+e); + } + } else if (this.show === "new" || this.targetid === "_blank") { + window.open(href); + } else if (this.show === "embed" || (this.targetid !== "" && this.targetid !== "_blank" && this.targetid !== "_self")) { + XsltForms_globals.openAction("XsltForms_load.prototype.run"); + var req = null; + var method = "get"; + var evcontext = {"method": method, "resource-uri": href}; + try { + req = XsltForms_browser.openRequest(method, href, false); + XsltForms_browser.debugConsole.write("Load " + href); + req.send(null); + if (req.status !== 0 && (req.status < 200 || req.status >= 300)) { + evcontext["error-type"] = "resource-error"; + this.issueLoadException_(evcontext, req, null); + XsltForms_globals.closeAction("XsltForms_load.prototype.run"); + return; + } + XsltForms_submission.requesteventlog(evcontext, req); + XsltForms_globals.closeAction("XsltForms_load.prototype.run"); + var resp = req.responseText; + var piindex = resp.indexOf("")).replace(/^.*href=\"([^\"]*)\".*$/, "$1"); + resp = XsltForms_browser.transformText(resp, xslhref, false); + piindex = resp.indexOf("") + 1), "")[0]; + } + var targetid = targetelt.id; + var targetxf = targetelt.xfElement; + if (targetelt.xfElement) { + targetelt = targetelt.querySelector("xforms-body"); + } + targetelt.innerHTML = subbody; + targetelt.hasXFElement = null; + var parentNode = targetelt.parentNode; + while (parentNode) { + if (parentNode.hasXFElement !== false) { + break; + } + parentNode.hasXFElement = null; + parentNode = parentNode.parentNode; + } + var subformidx = XsltForms_globals.nbsubforms++; + var newsubform = new XsltForms_subform(this.subform, "xsltforms-subform-" + String(subformidx), targetid); + XsltForms_class.activateAll(newsubform, targetelt, function() { + newsubform.construct(); + if (!targetxf || !targetxf.isComponent) { + XsltForms_globals.openAction("XsltForms_subform.prototype.construct"); + XsltForms_globals.closeChanges(true); + XsltForms_globals.closeAction("XsltForms_subform.prototype.construct"); + } + if (targetxf) { + XsltForms_xmlevents.dispatch(targetxf, "xforms-load-done", null, null, null, null, evcontext); + } + }); + } catch(e2) { + XsltForms_browser.debugConsole.write(e2.message || e2); + evcontext["error-type"] = "resource-error"; + this.issueLoadException_(evcontext, req, e2); + XsltForms_globals.closeAction("XsltForms_load.prototype.run"); + } + } else { + location.href = href; + } + } else { + if (node) { + try { + var v = XsltForms_browser.getValue(node).replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&"); + var lw; + if (this.show === "new" || this.targetid === "_blank") { + lw = window.open("about:blank","_blank"); + lw.document.write(v); + lw.document.close(); + } else { + lw = window.open("about:blank", "_self"); + lw.document.write(v); + lw.document.close(); + } + } catch (e) { + XsltForms_browser.debugConsole.write("ERROR: Load:" + e.message); + } + } + } }; - + /** * * '''issueLoadException_''' method : Prepares the event-context and issues a 'xforms-load-error' event. */ XsltForms_load.prototype.issueLoadException_ = function(evcontext, req, ex) { - if (ex) { - evcontext.message = ex.message || ex; - evcontext["stack-trace"] = ex.stack; - } - if (req) { - XsltForms_submission.requesteventlog(evcontext, req); - } - XsltForms_xmlevents.dispatch(document.getElementById(this.targetid), "xforms-link-exception", null, null, null, null, evcontext); + if (ex) { + evcontext.message = ex.message || ex; + evcontext["stack-trace"] = ex.stack; + } + if (req) { + XsltForms_submission.requesteventlog(evcontext, req); + } + XsltForms_xmlevents.dispatch(document.getElementById(this.targetid), "xforms-link-exception", null, null, null, null, evcontext); }; - + /** * * '''subform''' method : loads a subform directly from Javascript instruction */ XsltForms_load.subform = function(resource, targetid, ref) { - if (ref) { - var parentNode = ref; - while (parentNode && parentNode.nodeType === Fleur.Node.ELEMENT_NODE) { - if (parentNode.localName.toLowerCase() === "xforms-repeat-item" || parentNode.getAttribute("xforms-name") === "repeat-item") { - XsltForms_repeat.selectItem(parentNode); - } - parentNode = parentNode.parentNode; - } - } - var targetelt = XsltForms_idManager.find(targetid); - var subform = null; - parentNode = targetelt; - while (parentNode && parentNode.nodeType === Fleur.Node.ELEMENT_NODE) { - if (parentNode.xfSubform) { - subform = parentNode.xfSubform; - break; - } - parentNode = parentNode.parentNode; - } - var a = new XsltForms_load(subform, null, resource, "embed", targetid); - a.run(); + if (ref) { + var parentNode = ref; + while (parentNode && parentNode.nodeType === Fleur.Node.ELEMENT_NODE) { + if (parentNode.localName.toLowerCase() === "xforms-repeat-item" || parentNode.getAttribute("xforms-name") === "repeat-item") { + XsltForms_repeat.selectItem(parentNode); + } + parentNode = parentNode.parentNode; + } + } + var targetelt = XsltForms_idManager.find(targetid); + var subform = null; + parentNode = targetelt; + while (parentNode && parentNode.nodeType === Fleur.Node.ELEMENT_NODE) { + if (parentNode.xfSubform) { + subform = parentNode.xfSubform; + break; + } + parentNode = parentNode.parentNode; + } + var a = new XsltForms_load(subform, null, resource, "embed", targetid); + a.run(); }; \ No newline at end of file diff --git a/src/js/xsltforms.js/actions/message.js b/src/js/xsltforms.js/actions/message.js index f17005f..3666073 100644 --- a/src/js/xsltforms.js/actions/message.js +++ b/src/js/xsltforms.js/actions/message.js @@ -1,52 +1,50 @@ -/*eslint-env browser*/ -/*globals XsltForms_abstractAction XsltForms_browser XsltForms_idManager XsltForms_globals XsltForms_class XsltForms_subform XsltForms_binding*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module message * @description === "XsltForms_message" class === * Message Action Class * * constructor function : stores specific properties */ - + new XsltForms_class("XsltForms_message", "HTMLElement", "xforms-message"); function XsltForms_message(subform, elt) { - this.subform = subform; - this.binding = elt.hasAttribute("xf-ref") || elt.hasAttribute("xf-bind") ? new XsltForms_binding(this.subform, elt) : null; - //this.id = elt.id; - this.level = elt.getAttribute("xf-level"); - this.init(elt); + this.subform = subform; + this.binding = elt.hasAttribute("xf-ref") || elt.hasAttribute("xf-bind") ? new XsltForms_binding(this.subform, elt) : null; + //this.id = elt.id; + this.level = elt.getAttribute("xf-level"); + this.init(elt); } XsltForms_message.prototype = new XsltForms_abstractAction(); - + /** * * '''run''' method : displays an alert message box containing a node value */ XsltForms_message.prototype.run = function(element, ctx) { - var text; - if (this.binding) { - var node = this.binding.bind_evaluate(this.subform, ctx, this.parentAction ? this.parentAction.varResolver : element.xfElement.varResolver).head(); - if (node) { - text = XsltForms_browser.getValue(node); - } - } else { - var e = this.element;//XsltForms_idManager.find(this.id); - var building = XsltForms_globals.building; - XsltForms_globals.building = true; - this.running = true; - XsltForms_globals.build(e, ctx, null, this.parentAction ? this.parentAction.varResolver : element.xfElement.varResolver); - this.running = false; - XsltForms_globals.building = building; - text = this.element.textContent || this.element.innerText; - } + var text; + if (this.binding) { + var node = this.binding.bind_evaluate(this.subform, ctx, this.element).head(); + if (node) { + text = XsltForms_browser.getValue(node); + } + } else { + var e = this.element;//XsltForms_idManager.find(this.id); + var building = XsltForms_globals.building; + XsltForms_globals.building = true; + this.running = true; + XsltForms_globals.build(e, ctx, null, this.element); + this.running = false; + XsltForms_globals.building = building; + text = this.element.textContent || this.element.innerText; + } - if (text) { - alert(text.trim()); - } + if (text) { + alert(text.trim()); + } }; \ No newline at end of file diff --git a/src/js/xsltforms.js/actions/project.json b/src/js/xsltforms.js/actions/project.json index 18413af..7fff6be 100644 --- a/src/js/xsltforms.js/actions/project.json +++ b/src/js/xsltforms.js/actions/project.json @@ -1,23 +1,23 @@ { - "Name":"actions.js", - "Description":"== XForms Action Management ==\nEach action is stored as a Javascript object created by the XSLT transformation.\nThe abstractAction is the parent class for all action classes.", - "Components": - ["confirm.js", - "setproperty.js", - "abstractAction.js", - "action.js", - "delete.js", - "dispatch.js", - "insert.js", - "load.js", - "message.js", - "script.js", - "setindex.js", - "setnode.js", - "setselection.js", - "setvalue.js", - "split.js", - "toggle.js", - "unload.js", - "wrap.js"] + "Name":"actions.js", + "Description":"== XForms Action Management ==\nEach action is stored as a Javascript object created by the XSLT transformation.\nThe abstractAction is the parent class for all action classes.", + "Components": + ["confirm.js", + "setproperty.js", + "abstractAction.js", + "action.js", + "delete.js", + "dispatch.js", + "insert.js", + "load.js", + "message.js", + "script.js", + "setindex.js", + "setnode.js", + "setselection.js", + "setvalue.js", + "split.js", + "toggle.js", + "unload.js", + "wrap.js"] } \ No newline at end of file diff --git a/src/js/xsltforms.js/actions/script.js b/src/js/xsltforms.js/actions/script.js index fdc06b9..99c73ed 100644 --- a/src/js/xsltforms.js/actions/script.js +++ b/src/js/xsltforms.js/actions/script.js @@ -1,61 +1,59 @@ -/*eslint-env browser*/ -/*globals XsltForms_abstractAction XsltForms_browser XsltForms_globals XsltForms_class XsltForms_subform XsltForms_binding*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module script * @description === "XsltForms_script" class === * Script Action Class * * constructor function : stores specific properties */ - + new XsltForms_class("XsltForms_script", "HTMLElement", "xforms-script"); function XsltForms_script(subform, elt) { - this.subform = subform; - this.binding = elt.hasAttribute("xf-ref") || elt.hasAttribute("xf-bind") ? new XsltForms_binding(this.subform, elt) : null; - this.stype = elt.getAttribute("xf-type"); - this.script = elt.textContent; - this.init(elt); + this.subform = subform; + this.binding = elt.hasAttribute("xf-ref") || elt.hasAttribute("xf-bind") ? new XsltForms_binding(this.subform, elt) : null; + this.stype = elt.getAttribute("xf-type"); + this.script = elt.textContent; + this.init(elt); } XsltForms_script.prototype = new XsltForms_abstractAction(); - + /** * * '''run''' method : opens a new window or changes current location according to "show" attribute */ XsltForms_script.prototype.run = function(element, ctx) { - var script = this.script; - switch (this.stype) { - case "text/javascript": - if (this.binding) { - var node = this.binding.bind_evaluate(this.subform, ctx).head(); - if (node) { - script = XsltForms_browser.getValue(node); - } - } else { - if (typeof script === 'object') { - script = XsltForms_globals.stringValue(this.script.xpath.xpath_evaluate(ctx)); - } else { - if (typeof script === 'string') { - script = XsltForms_browser.unescape(script); - } - } - } - if (script) { - try { - eval("{XsltForms_context={elementId:\""+element.getAttribute("id")+"\"};"+script+"}"); - } catch (e) { - alert("XSLTForms Exception\n--------------------------\n\nError evaluating the following Javascript expression :\n\n"+script+"\n\n"+e); - } - } - break; - case "application/xquery": - this.script.xpath.xpath_evaluate(ctx); - break; - } + var script = this.script; + switch (this.stype) { + case "text/javascript": + if (this.binding) { + var node = this.binding.bind_evaluate(this.subform, ctx).head(); + if (node) { + script = XsltForms_browser.getValue(node); + } + } else { + if (typeof script === 'object') { + script = XsltForms_globals.stringValue(this.script.xpath.xpath_evaluate(ctx)); + } else { + if (typeof script === 'string') { + script = XsltForms_browser.unescape(script); + } + } + } + if (script) { + try { + eval("{XsltForms_context={elementId:\""+element.getAttribute("id")+"\"};"+script+"}"); + } catch (e) { + alert("XSLTForms Exception\n--------------------------\n\nError evaluating the following Javascript expression :\n\n"+script+"\n\n"+e); + } + } + break; + case "application/xquery": + this.script.xpath.xpath_evaluate(ctx); + break; + } }; \ No newline at end of file diff --git a/src/js/xsltforms.js/actions/setindex.js b/src/js/xsltforms.js/actions/setindex.js index 5084ecd..ef4ebc7 100644 --- a/src/js/xsltforms.js/actions/setindex.js +++ b/src/js/xsltforms.js/actions/setindex.js @@ -1,46 +1,44 @@ -/*eslint-env browser*/ -/*globals XsltForms_xpath XsltForms_abstractAction XsltForms_idManager XsltForms_globals XsltForms_browser XsltForms_xmlevents XsltForms_class XsltForms_subform*/ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module setindex - * @description === "XsltForms_setindex" class === - * SetIndex Action Class - * * constructor function : resolves specific properties - */ - -new XsltForms_class("XsltForms_setindex", "HTMLElement", "xforms-setindex"); - +"use strict"; +/** + * @author Alain Couthures + * @license LGPL - See file 'LICENSE.md' in this project. + * @module setindex + * @description === "XsltForms_setindex" class === + * SetIndex Action Class + * * constructor function : resolves specific properties + */ + +new XsltForms_class("XsltForms_setindex", "HTMLElement", "xforms-setindex"); + function XsltForms_setindex(subform, elt) { - this.subform = subform; - this.repeat = elt.getAttribute("xf-repeat"); - this.index = elt.hasAttribute("xf-index") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-index")) : null; - this.context = elt.hasAttribute("xf-context") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-context")) : null; - this.init(elt); + this.subform = subform; + this.repeat = elt.getAttribute("xf-repeat"); + this.index = elt.hasAttribute("xf-index") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-index")) : null; + this.context = elt.hasAttribute("xf-context") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-context")) : null; + this.init(elt); } XsltForms_setindex.prototype = new XsltForms_abstractAction(); - - -/** - * * '''run''' method : sets the current index of a repeat structure - * @callback - */ + + +/** + * * '''run''' method : sets the current index of a repeat structure + * @callback + */ XsltForms_setindex.prototype.run = function(element, ctx) { - var repeat = XsltForms_idManager.find(this.repeat); - var index = XsltForms_globals.numberValue(this.index.xpath_evaluate(ctx)); - XsltForms_browser.debugConsole.write("setIndex " + index); - if (!isNaN(index)) { - if (index < 1) { - index = 1; - XsltForms_xmlevents.dispatch(repeat.xfElement, "xforms-scroll-first"); - } else if (index > repeat.xfElement.nodes.length) { - index = repeat.xfElement.nodes.length; - XsltForms_xmlevents.dispatch(repeat.xfElement, "xforms-scroll-last"); - } - repeat.xfElement.setIndex(index); - } + var repeat = XsltForms_idManager.find(this.repeat); + var index = XsltForms_globals.numberValue(this.index.xpath_evaluate(ctx)); + XsltForms_browser.debugConsole.write("setIndex " + index); + if (!isNaN(index)) { + if (index < 1) { + index = 1; + XsltForms_xmlevents.dispatch(repeat.xfElement, "xforms-scroll-first"); + } else if (index > repeat.xfElement.nodes.length) { + index = repeat.xfElement.nodes.length; + XsltForms_xmlevents.dispatch(repeat.xfElement, "xforms-scroll-last"); + } + repeat.xfElement.setIndex(index); + } }; \ No newline at end of file diff --git a/src/js/xsltforms.js/actions/setnode.js b/src/js/xsltforms.js/actions/setnode.js index 8aaa11c..31b161e 100644 --- a/src/js/xsltforms.js/actions/setnode.js +++ b/src/js/xsltforms.js/actions/setnode.js @@ -1,62 +1,60 @@ -/*eslint-env browser*/ -/*globals XsltForms_xpath XsltForms_abstractAction XsltForms_globals XsltForms_browser XsltForms_xmlevents XsltForms_class XsltForms_subform XsltForms_binding*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module setnode * @description === "XsltForms_setnode" class === * SetNode Action Class * * constructor function : resolves specific properties */ - + new XsltForms_class("XsltForms_setnode", "HTMLElement", "xforms-setnode"); function XsltForms_setnode(subform, elt) { - this.subform = subform; - this.binding = new XsltForms_binding(this.subform, elt); - this.inout = elt.hasAttribute("xf-inner"); - this.value = this.inout ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-inner")) : XsltForms_xpath.create(this.subform, elt.getAttribute("xf-outer")); - this.context = elt.hasAttribute("xf-context") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-context")) : null; - this.init(elt); + this.subform = subform; + this.binding = new XsltForms_binding(this.subform, elt); + this.inout = elt.hasAttribute("xf-inner"); + this.value = this.inout ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-inner")) : XsltForms_xpath.create(this.subform, elt.getAttribute("xf-outer")); + this.context = elt.hasAttribute("xf-context") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-context")) : null; + this.init(elt); } XsltForms_setnode.prototype = new XsltForms_abstractAction(); - + /** * * '''run''' method : sets the value of a node and records it in the changes collection * @callback */ XsltForms_setnode.prototype.run = function(element, ctx) { - var node = this.binding.bind_evaluate(this.subform, ctx).head(); - if (node) { - if (this.context) { - ctx = this.context.xpath_evaluate(ctx).head(); - } - var value = this.value? XsltForms_globals.stringValue(this.context ? this.value.xpath_evaluate(ctx, ctx) : this.value.xpath_evaluate(node, ctx)) : this.literal; - var modelid = XsltForms_browser.getDocMeta(node.ownerDocument, "model"); - var instanceid = XsltForms_browser.getDocMeta(node.ownerDocument, "instance"); - XsltForms_globals.openAction("XsltForms_setnode.prototype.run"); - if (this.inout) { - while (node.firstChild) { - node.removeChild(node.firstChild); - } - var tempnode = node.ownerDocument.createTextNode("temp"); - node.appendChild(tempnode); - XsltForms_browser.loadNode(tempnode, value || "", "application/xml"); - } else { - XsltForms_browser.loadNode(node, value || "", "application/xml"); - XsltForms_browser.setDocMeta(node.ownerDocument, "model", modelid); - XsltForms_browser.setDocMeta(node.ownerDocument, "instance", instanceid); - } - var model = document.getElementById(modelid).xfElement; - XsltForms_globals.addChange(model); - XsltForms_browser.debugConsole.write("Setnode " + node.nodeName + (this.inout ? " inner" : " outer") + " = " + value); - XsltForms_xmlevents.dispatch(model, "xforms-rebuild"); - XsltForms_globals.refresh(); - XsltForms_globals.closeAction("XsltForms_setnode.prototype.run"); - } + var node = this.binding.bind_evaluate(this.subform, ctx).head(); + if (node) { + if (this.context) { + ctx = this.context.xpath_evaluate(ctx).head(); + } + var value = this.value? XsltForms_globals.stringValue(this.context ? this.value.xpath_evaluate(ctx, ctx) : this.value.xpath_evaluate(node, ctx)) : this.literal; + var modelid = XsltForms_browser.getDocMeta(node.ownerDocument, "model"); + var instanceid = XsltForms_browser.getDocMeta(node.ownerDocument, "instance"); + XsltForms_globals.openAction("XsltForms_setnode.prototype.run"); + if (this.inout) { + while (node.firstChild) { + node.removeChild(node.firstChild); + } + var tempnode = node.ownerDocument.createTextNode("temp"); + node.appendChild(tempnode); + XsltForms_browser.loadNode(tempnode, value || "", "application/xml"); + } else { + XsltForms_browser.loadNode(node, value || "", "application/xml"); + XsltForms_browser.setDocMeta(node.ownerDocument, "model", modelid); + XsltForms_browser.setDocMeta(node.ownerDocument, "instance", instanceid); + } + var model = document.getElementById(modelid).xfElement; + XsltForms_globals.addChange(model); + XsltForms_browser.debugConsole.write("Setnode " + node.nodeName + (this.inout ? " inner" : " outer") + " = " + value); + XsltForms_xmlevents.dispatch(model, "xforms-rebuild"); + XsltForms_globals.refresh(); + XsltForms_globals.closeAction("XsltForms_setnode.prototype.run"); + } }; \ No newline at end of file diff --git a/src/js/xsltforms.js/actions/setproperty.js b/src/js/xsltforms.js/actions/setproperty.js index 3bb4bcb..b101fc8 100644 --- a/src/js/xsltforms.js/actions/setproperty.js +++ b/src/js/xsltforms.js/actions/setproperty.js @@ -1,38 +1,36 @@ -/*eslint-env browser*/ -/*globals XsltForms_abstractAction XsltForms_browser XsltForms_class XsltForms_subform XsltForms_xpath*/ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module setproperty - * @description - */ - -new XsltForms_class("XsltForms_setproperty", "HTMLElement", "xforms-setproperty"); - +"use strict"; +/** + * @author Alain Couthures + * @license LGPL - See file 'LICENSE.md' in this project. + * @module setproperty + * @description + */ + +new XsltForms_class("XsltForms_setproperty", "HTMLElement", "xforms-setproperty"); + function XsltForms_setproperty(subform, elt) { - this.subform = subform; - this.name = elt.getAttribute("xf-pname"); - this.value = elt.hasAttribute("xf-value") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-value")) : null; - this.literal = elt.textContent || ""; - this.init(elt); + this.subform = subform; + this.name = elt.getAttribute("xf-pname"); + this.value = elt.hasAttribute("xf-value") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-value")) : null; + this.literal = elt.textContent || ""; + this.init(elt); } XsltForms_setproperty.prototype = new XsltForms_abstractAction(); -/** - * @callback - */ +/** + * @callback + */ XsltForms_setproperty.prototype.run = function(element, ctx) { - var value = this.literal; - if (this.value) { - //value = this.value.evaluate(node); // ??? What is node? - if (typeof(value) !== "string" && typeof(value.length) !== "undefined") { - value = value.length > 0? XsltForms_browser.getValue(value[0]) : ""; - } - } - if (value) { - XsltForms_browser.i18n.lang = value; - XsltForms_browser.debugConsole.write("setproperty " + name + " = " + value); - } + var value = this.literal; + if (this.value) { + //value = this.value.evaluate(node); // ??? What is node? + if (typeof(value) !== "string" && typeof(value.length) !== "undefined") { + value = value.length > 0? XsltForms_browser.getValue(value[0]) : ""; + } + } + if (value) { + XsltForms_browser.i18n.lang = value; + XsltForms_browser.debugConsole.write("setproperty " + name + " = " + value); + } }; \ No newline at end of file diff --git a/src/js/xsltforms.js/actions/setselection.js b/src/js/xsltforms.js/actions/setselection.js index d010af7..d9c498b 100644 --- a/src/js/xsltforms.js/actions/setselection.js +++ b/src/js/xsltforms.js/actions/setselection.js @@ -1,60 +1,57 @@ -/*eslint-env browser*/ -/*globals XsltForms_xpath XsltForms_abstractAction XsltForms_globals XsltForms_browser XsltForms_idManager XsltForms_xmlevents XsltForms_class XsltForms_subform*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module setselection * @description === "XsltForms_setselection" class === * Setselection Action Class * * constructor function : resolves specific properties */ - + new XsltForms_class("XsltForms_setselection", "HTMLElement", "xforms-setselection"); function XsltForms_setselection(subform, elt) { - this.subform = subform; - this.control = elt.getAttribute("xf-control"); - this.value = elt.hasAttribute("xf-value") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-value")) : null; - this.context = elt.hasAttribute("xf-context") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-context")) : null; - this.init(elt); + this.subform = subform; + this.control = elt.getAttribute("xf-control"); + this.value = elt.hasAttribute("xf-value") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-value")) : null; + this.context = elt.hasAttribute("xf-context") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-context")) : null; + this.init(elt); } XsltForms_setselection.prototype = new XsltForms_abstractAction(); - + /** * * '''run''' method : sets the value of a node and records it in the changes collection */ XsltForms_setselection.prototype.run = function(element, ctx) { - var varresolver = this.parentAction ? this.parentAction.varResolver : element.xfElement.varResolver; - if (this.context) { - ctx = this.context.xpath_evaluate(element.xfElement.subform, ctx, null, varresolver).head(); - } - var controlid = this.control; - if (controlid && controlid.bind_evaluate) { - controlid = XsltForms_globals.stringValue(controlid.bind_evaluate(this.subform, ctx, varresolver)); - } - var control = XsltForms_idManager.find(controlid).xfElement; - var input = control.input; - var value = XsltForms_globals.stringValue(this.value.xpath_evaluate(ctx, ctx, element.xfElement.subform, varresolver)); - var start = input.selectionStart; - var end = input.selectionEnd; - var newvalue = input.value.substring(0, start) + value + input.value.substring(end); - XsltForms_globals.openAction("XsltForms_setselection.prototype.run"); - try { - XsltForms_browser.setValue(control.boundnodes[0], newvalue); - input.value = newvalue; - if (!XsltForms_browser.isChrome) { - input.focus(); - } - input.setSelectionRange(start, start + value.length); - document.getElementById(XsltForms_browser.getDocMeta(control.boundnodes[0].ownerDocument, "model")).xfElement.addChange(control.boundnodes[0]); - XsltForms_browser.debugConsole.write("Set selection " + controlid + " = " + newvalue); - } catch (e) { - XsltForms_browser.debugConsole.write("ERROR: cannot set selection on " + controlid + " = " + newvalue + "(context " + XsltForms_browser.name2string(ctx) + ")"); - } - XsltForms_globals.closeAction("XsltForms_setselection.prototype.run"); + if (this.context) { + ctx = this.context.xpath_evaluate(element.xfElement.subform, ctx, null, this.element).head(); + } + var controlid = this.control; + if (controlid && controlid.bind_evaluate) { + controlid = XsltForms_globals.stringValue(controlid.bind_evaluate(this.subform, ctx, this.element)); + } + var control = XsltForms_idManager.find(controlid).xfElement; + var input = control.input; + var value = XsltForms_globals.stringValue(this.value.xpath_evaluate(ctx, ctx, element.xfElement.subform, this.element)); + var start = input.selectionStart; + var end = input.selectionEnd; + var newvalue = input.value.substring(0, start) + value + input.value.substring(end); + XsltForms_globals.openAction("XsltForms_setselection.prototype.run"); + try { + XsltForms_browser.setValue(control.boundnodes[0], newvalue); + input.value = newvalue; + if (!XsltForms_browser.isChrome) { + input.focus(); + } + input.setSelectionRange(start, start + value.length); + document.getElementById(XsltForms_browser.getDocMeta(control.boundnodes[0].ownerDocument, "model")).xfElement.addChange(control.boundnodes[0]); + XsltForms_browser.debugConsole.write("Set selection " + controlid + " = " + newvalue); + } catch (e) { + XsltForms_browser.debugConsole.write("ERROR: cannot set selection on " + controlid + " = " + newvalue + "(context " + XsltForms_browser.name2string(ctx) + ")"); + } + XsltForms_globals.closeAction("XsltForms_setselection.prototype.run"); }; \ No newline at end of file diff --git a/src/js/xsltforms.js/actions/setvalue.js b/src/js/xsltforms.js/actions/setvalue.js index f91f189..263110f 100644 --- a/src/js/xsltforms.js/actions/setvalue.js +++ b/src/js/xsltforms.js/actions/setvalue.js @@ -1,53 +1,50 @@ -/*eslint-env browser*/ -/*globals XsltForms_xpath XsltForms_abstractAction XsltForms_globals XsltForms_browser XsltForms_class XsltForms_binding XsltForms_subform*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module setvalue * @description === "XsltForms_setvalue" class === * SetValue Action Class * * constructor function : resolves specific properties */ - + new XsltForms_class("XsltForms_setvalue", "HTMLElement", "xforms-setvalue"); function XsltForms_setvalue(subform, elt) { - this.subform = subform; - this.binding = elt.hasAttribute("xf-ref") || elt.hasAttribute("xf-bind") ? new XsltForms_binding(this.subform, elt) : null; - this.value = elt.hasAttribute("xf-value") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-value")) : null; - this.literal = elt.textContent || ""; - this.context = elt.hasAttribute("xf-context") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-context")) : null; - this.init(elt); + this.subform = subform; + this.binding = elt.hasAttribute("xf-ref") || elt.hasAttribute("xf-bind") ? new XsltForms_binding(this.subform, elt) : null; + this.value = elt.hasAttribute("xf-value") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-value")) : null; + this.literal = elt.textContent || ""; + this.context = elt.hasAttribute("xf-context") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-context")) : null; + this.init(elt); } XsltForms_setvalue.prototype = new XsltForms_abstractAction(); - + /** * * '''run''' method : sets the value of a node and records it in the changes collection */ XsltForms_setvalue.prototype.run = function(element, ctx) { - var varresolver = this.parentAction ? this.parentAction.varResolver : element.xfElement.varResolver; - var nodeset = this.binding.bind_evaluate(element.xfElement.subform, ctx, varresolver).toArray(); - if (nodeset.length !== 0 && this.context) { - ctx = this.context.xpath_evaluate(element.xfElement.subform, ctx, null, varresolver).head(); - } - for (var i = 0, l = nodeset.length; i < l; i++) { - var node = nodeset[i]; - if (node) { - var value = this.value? XsltForms_globals.stringValue(this.context ? this.value.xpath_evaluate(ctx, ctx, element.xfElement.subform, varresolver) : this.value.xpath_evaluate(node, ctx, element.xfElement.subform, varresolver)) : this.literal; - XsltForms_globals.openAction("XsltForms_setvalue.prototype.run"); - try { - XsltForms_browser.setValue(node, value || ""); - document.getElementById(XsltForms_browser.getDocMeta(node.ownerDocument, "model")).xfElement.addChange(node); - XsltForms_browser.debugConsole.write("Setvalue " + XsltForms_browser.name2string(node) + " = " + value); - } catch (e) { - XsltForms_browser.debugConsole.write("ERROR: cannot setvalue on " + XsltForms_browser.name2string(node) + " = " + value + "(context " + XsltForms_browser.name2string(ctx) + ")"); - } - XsltForms_globals.closeAction("XsltForms_setvalue.prototype.run"); - } - } + var nodeset = this.binding.bind_evaluate(element.xfElement.subform, ctx, this.element).toArray(); + if (nodeset.length !== 0 && this.context) { + ctx = this.context.xpath_evaluate(element.xfElement.subform, ctx, null, this.element).head(); + } + for (var i = 0, l = nodeset.length; i < l; i++) { + var node = nodeset[i]; + if (node) { + var value = this.value? XsltForms_globals.stringValue(this.context ? this.value.xpath_evaluate(ctx, ctx, element.xfElement.subform, this.element) : this.value.xpath_evaluate(node, ctx, element.xfElement.subform, this.element)) : this.literal; + XsltForms_globals.openAction("XsltForms_setvalue.prototype.run"); + try { + XsltForms_browser.setValue(node, value || ""); + document.getElementById(XsltForms_browser.getDocMeta(node.ownerDocument, "model")).xfElement.addChange(node); + XsltForms_browser.debugConsole.write("Setvalue " + XsltForms_browser.name2string(node) + " = " + value); + } catch (e) { + XsltForms_browser.debugConsole.write("ERROR: cannot setvalue on " + XsltForms_browser.name2string(node) + " = " + value + "(context " + XsltForms_browser.name2string(ctx) + ")"); + } + XsltForms_globals.closeAction("XsltForms_setvalue.prototype.run"); + } + } }; \ No newline at end of file diff --git a/src/js/xsltforms.js/actions/split.js b/src/js/xsltforms.js/actions/split.js index ea975b5..fc5f7b4 100644 --- a/src/js/xsltforms.js/actions/split.js +++ b/src/js/xsltforms.js/actions/split.js @@ -1,56 +1,53 @@ -/*eslint-env browser*/ -/*globals XsltForms_xpath XsltForms_abstractAction XsltForms_globals XsltForms_browser XsltForms_class XsltForms_binding XsltForms_subform*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module split * @description === "XsltForms_split" class === * Split Action Class * * constructor function : resolves specific properties */ - + new XsltForms_class("XsltForms_split", "HTMLElement", "xforms-split"); function XsltForms_split(subform, elt) { - this.subform = subform; - this.binding = new XsltForms_binding(this.subform, elt); - this.separator = elt.getAttribute("xf-separator"); - var leftTrim = elt.getAttribute("xf-left-trim"); - this.leftTrim = leftTrim && leftTrim !== "" ? new RegExp(leftTrim) : null; - var rightTrim = elt.getAttribute("xf-right-trim"); - this.rightTrim = rightTrim && rightTrim !== "" ? new RegExp(rightTrim) : null; - this.context = elt.hasAttribute("xf-context") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-context")) : null; - this.init(elt); + this.subform = subform; + this.binding = new XsltForms_binding(this.subform, elt); + this.separator = elt.getAttribute("xf-separator"); + var leftTrim = elt.getAttribute("xf-left-trim"); + this.leftTrim = leftTrim && leftTrim !== "" ? new RegExp(leftTrim) : null; + var rightTrim = elt.getAttribute("xf-right-trim"); + this.rightTrim = rightTrim && rightTrim !== "" ? new RegExp(rightTrim) : null; + this.context = elt.hasAttribute("xf-context") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-context")) : null; + this.init(elt); } XsltForms_split.prototype = new XsltForms_abstractAction(); - + /** * * '''run''' method : sets the value of a node and records it in the changes collection */ XsltForms_split.prototype.run = function(element, ctx) { - var node; - var varresolver = this.parentAction ? this.parentAction.varResolver : element.xfElement.varResolver; - var nodes = this.binding.bind_evaluate(element.xfElement.subform, ctx, varresolver).toArray(); - if (nodes.length !== 0) { - if (this.context) { - ctx = this.context.xpath_evaluate(element.xfElement.subform, ctx, null, varresolver).head(); - } - XsltForms_globals.openAction("XsltForms_split.prototype.run"); - try { - for (var i = 0, l = nodes.length; i < l; i++) { - node = nodes[i]; - XsltForms_browser.splitNode(node, this.separator || ",", this.leftTrim, this.rightTrim); - document.getElementById(XsltForms_browser.getDocMeta(node.ownerDocument, "model")).xfElement.addChange(node); - XsltForms_browser.debugConsole.write("Split " + XsltForms_browser.name2string(node) + " = '" + XsltForms_browser.getValue(node) + "' with " + this.separator); - } - } catch (e) { - XsltForms_browser.debugConsole.write("ERROR: cannot split on " + XsltForms_browser.name2string(node) + " with " + this.separator + "(context " + XsltForms_browser.name2string(ctx) + ")"); - } - XsltForms_globals.closeAction("XsltForms_split.prototype.run"); - } + var node; + var nodes = this.binding.bind_evaluate(element.xfElement.subform, ctx, this.element).toArray(); + if (nodes.length !== 0) { + if (this.context) { + ctx = this.context.xpath_evaluate(element.xfElement.subform, ctx, null, this.element).head(); + } + XsltForms_globals.openAction("XsltForms_split.prototype.run"); + try { + for (var i = 0, l = nodes.length; i < l; i++) { + node = nodes[i]; + XsltForms_browser.splitNode(node, this.separator || ",", this.leftTrim, this.rightTrim); + document.getElementById(XsltForms_browser.getDocMeta(node.ownerDocument, "model")).xfElement.addChange(node); + XsltForms_browser.debugConsole.write("Split " + XsltForms_browser.name2string(node) + " = '" + XsltForms_browser.getValue(node) + "' with " + this.separator); + } + } catch (e) { + XsltForms_browser.debugConsole.write("ERROR: cannot split on " + XsltForms_browser.name2string(node) + " with " + this.separator + "(context " + XsltForms_browser.name2string(ctx) + ")"); + } + XsltForms_globals.closeAction("XsltForms_split.prototype.run"); + } }; \ No newline at end of file diff --git a/src/js/xsltforms.js/actions/toggle.js b/src/js/xsltforms.js/actions/toggle.js index 4bff731..0981d36 100644 --- a/src/js/xsltforms.js/actions/toggle.js +++ b/src/js/xsltforms.js/actions/toggle.js @@ -1,72 +1,70 @@ -/*eslint-env browser*/ -/*globals XsltForms_abstractAction XsltForms_globals XsltForms_idManager XsltForms_browser XsltForms_xmlevents XsltForms_class XsltForms_subform XsltForms_binding*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module toggle * @description === "XsltForms_toggle" class === * Toggle Action Class * * constructor function : stores specific property */ - + new XsltForms_class("XsltForms_toggle", "HTMLElement", "xforms-toggle"); -function XsltForms_toggle(subform, elt) { - this.subform = subform; - var tcase; - Array.prototype.slice.call(elt.children).forEach(function(n) { - switch(n.localName.toLowerCase()) { - case "xforms-case": - tcase = n; - break; - } - }); - this.caseId = tcase ? tcase.hasAttribute("xf-value") ? new XsltForms_binding(this.subform, tcase) : tcase.textContent : elt.getAttribute("xf-case"); - this.init(elt); -} - -XsltForms_toggle.prototype = new XsltForms_abstractAction(); - +function XsltForms_toggle(subform, elt) { + this.subform = subform; + var tcase; + Array.prototype.slice.call(elt.children).forEach(function(n) { + switch(n.localName.toLowerCase()) { + case "xforms-case": + tcase = n; + break; + } + }); + this.caseId = tcase ? tcase.hasAttribute("xf-value") ? new XsltForms_binding(this.subform, tcase) : tcase.textContent : elt.getAttribute("xf-case"); + this.init(elt); +} - +XsltForms_toggle.prototype = new XsltForms_abstractAction(); + + + /** * * '''run''' method : toggles on the associated element * @callback */ - -XsltForms_toggle.prototype.run = function(element, ctx) { - XsltForms_toggle.toggle(this.caseId, ctx); -}; - - +XsltForms_toggle.prototype.run = function(element, ctx) { + XsltForms_toggle.toggle(this.caseId, ctx); +}; + + + /** * * '''toggle''' method : toggles on the element according to its id and dispatches the "xforms-deselect" event */ - -XsltForms_toggle.toggle = function(caseId, ctx) { - XsltForms_globals.openAction("XsltForms_toggle.toggle"); - if (typeof caseId === 'object') { - if (!ctx) { - ctx = XsltForms_globals.defaultModel.getInstanceDocument() ? XsltForms_globals.defaultModel.getInstanceDocument().documentElement : null; - } - caseId = XsltForms_globals.stringValue(caseId.xpath.xpath_evaluate(ctx)); - } - var element = XsltForms_idManager.find(caseId); - var childs = element ? element.parentNode.children : []; - for (var i = 0, len = childs.length; i < len; i++) { - var child = childs[i]; - if (child !== element && child.hasAttribute("xf-selected")) { - child.removeAttribute("xf-selected"); - //XsltForms_browser.setClass(child, "xforms-enabled", false); - XsltForms_xmlevents.dispatch(child, "xforms-deselect"); - } - } - if (element) { - //XsltForms_browser.setClass(element, "xforms-enabled", true); - element.setAttribute("xf-selected", "true"); - XsltForms_xmlevents.dispatch(element, "xforms-select"); - } - XsltForms_globals.closeAction("XsltForms_toggle.toggle"); + +XsltForms_toggle.toggle = function(caseId, ctx) { + XsltForms_globals.openAction("XsltForms_toggle.toggle"); + if (typeof caseId === 'object') { + if (!ctx) { + ctx = XsltForms_globals.defaultModel.getInstanceDocument() ? XsltForms_globals.defaultModel.getInstanceDocument().documentElement : null; + } + caseId = XsltForms_globals.stringValue(caseId.xpath.xpath_evaluate(ctx)); + } + var element = XsltForms_idManager.find(caseId); + var childs = element ? element.parentNode.children : []; + for (var i = 0, len = childs.length; i < len; i++) { + var child = childs[i]; + if (child !== element && child.hasAttribute("xf-selected")) { + child.removeAttribute("xf-selected"); + //XsltForms_browser.setClass(child, "xforms-enabled", false); + XsltForms_xmlevents.dispatch(child, "xforms-deselect"); + } + } + if (element) { + //XsltForms_browser.setClass(element, "xforms-enabled", true); + element.setAttribute("xf-selected", "true"); + XsltForms_xmlevents.dispatch(element, "xforms-select"); + } + XsltForms_globals.closeAction("XsltForms_toggle.toggle"); }; \ No newline at end of file diff --git a/src/js/xsltforms.js/actions/unload.js b/src/js/xsltforms.js/actions/unload.js index 08e3836..21cfad4 100644 --- a/src/js/xsltforms.js/actions/unload.js +++ b/src/js/xsltforms.js/actions/unload.js @@ -1,90 +1,88 @@ -/*eslint-env browser*/ -/*globals XsltForms_abstractAction XsltForms_idManager XsltForms_browser XsltForms_xmlevents XsltForms_repeat Fleur XsltForms_class XsltForms_subform*/ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module unload - * @description === "XsltForms_unload" class === - * Unload Action Class - * * constructor function : stores specific properties - */ - -new XsltForms_class("XsltForms_unload", "HTMLElement", "xforms-unload"); - +"use strict"; +/** + * @author Alain Couthures + * @license LGPL - See file 'LICENSE.md' in this project. + * @module unload + * @description === "XsltForms_unload" class === + * Unload Action Class + * * constructor function : stores specific properties + */ + +new XsltForms_class("XsltForms_unload", "HTMLElement", "xforms-unload"); + function XsltForms_unload(subform, elt) { - this.subform = subform; - this.targetid = elt.getAttribute("xf-targetid"); - this.init(elt); + this.subform = subform; + this.targetid = elt.getAttribute("xf-targetid"); + this.init(elt); } XsltForms_unload.prototype = new XsltForms_abstractAction(); - - -/** - * * '''run''' method : unload the targeted subform - * @callback - */ + + +/** + * * '''run''' method : unload the targeted subform + * @callback + */ XsltForms_unload.prototype.run = function(element, ctx) { - var targetid = this.targetid || this.subform.eltid; - var targetelt = XsltForms_idManager.find(targetid); - if (targetelt.xfSubform) { - targetelt.xfSubform.dispose(); - } - targetelt.xfSubform = null; - var targetxf = targetelt.xfElement; - if (targetxf) { - targetelt = targetelt.children[targetelt.children.length - 1]; - } - targetelt.innerHTML = ""; - /* - var node = targetelt.firstChild; - alert("before " + (node.remove? "remove" : "removeChild")); - while (node = targetelt.firstChild) { - if (node.remove) { - node.remove(); - } else { - targetelt.removeChild(node); - } - node = null; - } - alert("after"); - */ - targetelt.hasXFElement = null; - XsltForms_browser.setClass(targetelt, "xforms-subform-loaded", false); - if (targetxf) { - XsltForms_xmlevents.dispatch(targetxf, "xforms-unload-done"); - } - XsltForms_browser.debugConsole.write("unload-done"); + var targetid = this.targetid || this.subform.eltid; + var targetelt = XsltForms_idManager.find(targetid); + if (targetelt.xfSubform) { + targetelt.xfSubform.dispose(); + } + targetelt.xfSubform = null; + var targetxf = targetelt.xfElement; + if (targetxf) { + targetelt = targetelt.children[targetelt.children.length - 1]; + } + targetelt.innerHTML = ""; + /* + var node = targetelt.firstChild; + alert("before " + (node.remove? "remove" : "removeChild")); + while (node = targetelt.firstChild) { + if (node.remove) { + node.remove(); + } else { + targetelt.removeChild(node); + } + node = null; + } + alert("after"); + */ + targetelt.hasXFElement = null; + XsltForms_browser.setClass(targetelt, "xforms-subform-loaded", false); + if (targetxf) { + XsltForms_xmlevents.dispatch(targetxf, "xforms-unload-done"); + } + XsltForms_browser.debugConsole.write("unload-done"); }; - - -/** - * * '''subform''' method : unloads a subform directly from Javascript instruction - */ + + +/** + * * '''subform''' method : unloads a subform directly from Javascript instruction + */ XsltForms_unload.subform = function(targetid, ref) { - if (ref) { - var parentNode = ref; - while (parentNode && parentNode.nodeType === Fleur.Node.ELEMENT_NODE) { - if (parentNode.localName.toLowerCase() === "xforms-repeat-item" || parentNode.getAttribute("xforms-name") === "repeat-item") { - XsltForms_repeat.selectItem(parentNode); - } - parentNode = parentNode.parentNode; - } - } - var targetelt = XsltForms_idManager.find(targetid); - var subform = null; - parentNode = targetelt; - while (parentNode && parentNode.nodeType === Fleur.Node.ELEMENT_NODE) { - if (parentNode.xfSubform) { - subform = parentNode.xfSubform; - break; - } - parentNode = parentNode.parentNode; - } - var a = new XsltForms_unload(subform, targetid); - a.run(); + if (ref) { + var parentNode = ref; + while (parentNode && parentNode.nodeType === Fleur.Node.ELEMENT_NODE) { + if (parentNode.localName.toLowerCase() === "xforms-repeat-item" || parentNode.getAttribute("xforms-name") === "repeat-item") { + XsltForms_repeat.selectItem(parentNode); + } + parentNode = parentNode.parentNode; + } + } + var targetelt = XsltForms_idManager.find(targetid); + var subform = null; + parentNode = targetelt; + while (parentNode && parentNode.nodeType === Fleur.Node.ELEMENT_NODE) { + if (parentNode.xfSubform) { + subform = parentNode.xfSubform; + break; + } + parentNode = parentNode.parentNode; + } + var a = new XsltForms_unload(subform, targetid); + a.run(); }; \ No newline at end of file diff --git a/src/js/xsltforms.js/actions/wrap.js b/src/js/xsltforms.js/actions/wrap.js index 4311c14..30695e7 100644 --- a/src/js/xsltforms.js/actions/wrap.js +++ b/src/js/xsltforms.js/actions/wrap.js @@ -1,70 +1,67 @@ -/*eslint-env browser*/ -/*globals XsltForms_xpath XsltForms_abstractAction XsltForms_globals XsltForms_browser XsltForms_idManager XsltForms_xmlevents XsltForms_class XsltForms_subform*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module wrap * @description === "XsltForms_wrap" class === * Wrap Action Class * * constructor function : resolves specific properties */ - + new XsltForms_class("XsltForms_wrap", "HTMLElement", "xforms-wrap"); function XsltForms_wrap(subform, elt) { - this.subform = subform; - this.control = elt.getAttribute("xf-control"); - this.prevalue = elt.hasAttribute("xf-pre") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-pre")) : null; - this.postvalue = elt.hasAttribute("xf-post") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-post")) : null; - this.context = elt.hasAttribute("xf-context") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-context")) : null; - this.init(elt); + this.subform = subform; + this.control = elt.getAttribute("xf-control"); + this.prevalue = elt.hasAttribute("xf-pre") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-pre")) : null; + this.postvalue = elt.hasAttribute("xf-post") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-post")) : null; + this.context = elt.hasAttribute("xf-context") ? XsltForms_xpath.create(this.subform, elt.getAttribute("xf-context")) : null; + this.init(elt); } XsltForms_wrap.prototype = new XsltForms_abstractAction(); - + /** * * '''run''' method : sets the value of a node and records it in the changes collection */ XsltForms_wrap.prototype.run = function(element, ctx) { - var varresolver = this.parentAction ? this.parentAction.varResolver : element.xfElement.varResolver; - if (this.context) { - ctx = this.context.xpath_evaluate(element.xfElement.subform, ctx, null, varresolver).head(); - } - var controlid = this.control; - if (controlid && controlid.bind_evaluate) { - controlid = XsltForms_globals.stringValue(controlid.bind_evaluate(this.subform, ctx, varresolver)); - } - var control = XsltForms_idManager.find(controlid).xfElement; - var input = control.input; - var prevalue = this.prevalue; - if (prevalue && prevalue.bind_evaluate) { - prevalue = XsltForms_globals.stringValue(prevalue.bind_evaluate(this.subform, ctx, varresolver)); - } - var postvalue = this.postvalue; - if (postvalue && postvalue.bind_evaluate) { - postvalue = XsltForms_globals.stringValue(postvalue.bind_evaluate(this.subform, ctx, varresolver)); - } - if (prevalue + postvalue !== "") { - var start = input.selectionStart; - var end = input.selectionEnd; - var wrapvalue = input.value.substring(0, start) + prevalue + input.value.substring(start, end) + postvalue + input.value.substring(end); - XsltForms_globals.openAction("XsltForms_wrap.prototype.run"); - try { - XsltForms_browser.setValue(control.boundnodes[0], wrapvalue || ""); - input.value = wrapvalue || ""; - if (!XsltForms_browser.isChrome) { - input.focus(); - } - input.setSelectionRange(start, end + prevalue.length + postvalue.length); - document.getElementById(XsltForms_browser.getDocMeta(control.boundnodes[0].ownerDocument, "model")).xfElement.addChange(control.boundnodes[0]); - XsltForms_browser.debugConsole.write("Wrap " + controlid + " = " + wrapvalue); - } catch (e) { - XsltForms_browser.debugConsole.write("ERROR: cannot wrap on " + controlid + " = " + wrapvalue + "(context " + XsltForms_browser.name2string(ctx) + ")"); - } - XsltForms_globals.closeAction("XsltForms_wrap.prototype.run"); - } + if (this.context) { + ctx = this.context.xpath_evaluate(element.xfElement.subform, ctx, null, this.element).head(); + } + var controlid = this.control; + if (controlid && controlid.bind_evaluate) { + controlid = XsltForms_globals.stringValue(controlid.bind_evaluate(this.subform, ctx, this.element)); + } + var control = XsltForms_idManager.find(controlid).xfElement; + var input = control.input; + var prevalue = this.prevalue; + if (prevalue && prevalue.bind_evaluate) { + prevalue = XsltForms_globals.stringValue(prevalue.bind_evaluate(this.subform, ctx, this.element)); + } + var postvalue = this.postvalue; + if (postvalue && postvalue.bind_evaluate) { + postvalue = XsltForms_globals.stringValue(postvalue.bind_evaluate(this.subform, ctx, this.element)); + } + if (prevalue + postvalue !== "") { + var start = input.selectionStart; + var end = input.selectionEnd; + var wrapvalue = input.value.substring(0, start) + prevalue + input.value.substring(start, end) + postvalue + input.value.substring(end); + XsltForms_globals.openAction("XsltForms_wrap.prototype.run"); + try { + XsltForms_browser.setValue(control.boundnodes[0], wrapvalue || ""); + input.value = wrapvalue || ""; + if (!XsltForms_browser.isChrome) { + input.focus(); + } + input.setSelectionRange(start, end + prevalue.length + postvalue.length); + document.getElementById(XsltForms_browser.getDocMeta(control.boundnodes[0].ownerDocument, "model")).xfElement.addChange(control.boundnodes[0]); + XsltForms_browser.debugConsole.write("Wrap " + controlid + " = " + wrapvalue); + } catch (e) { + XsltForms_browser.debugConsole.write("ERROR: cannot wrap on " + controlid + " = " + wrapvalue + "(context " + XsltForms_browser.name2string(ctx) + ")"); + } + XsltForms_globals.closeAction("XsltForms_wrap.prototype.run"); + } }; \ No newline at end of file diff --git a/src/js/xsltforms.js/controls/AVT.js b/src/js/xsltforms.js/controls/AVT.js index 8afdd23..a1b778e 100644 --- a/src/js/xsltforms.js/controls/AVT.js +++ b/src/js/xsltforms.js/controls/AVT.js @@ -1,89 +1,87 @@ -/*eslint-env browser*/ -/*globals XsltForms_control Fleur XsltForms_globals XsltForms_browser XsltForms_binding*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module AVT * @description === "XsltForms_avt" class === * AVT Control Class * * constructor function : initializes specific properties and initializes focus and blur event management */ //XsltForms_browser.addLoadListener(new Function( -// "Array.prototype.slice.call(document.querySelectorAll('*[xf-avt]')).forEach(function(elt) { if (!elt.xfElement) { elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); } Array.prototype.slice.call(elt.attributes).filter(function(a) {return a.nodeName.startsWith('xf-template-');}).forEach(function(a) { new XsltForms_avt(XsltForms_subform.subforms['xsltforms-mainform'], elt, a.nodeName.substr(12)); }); });" +// "Array.prototype.slice.call(document.querySelectorAll('*[xf-avt]')).forEach(function(elt) { if (!elt.xfElement) { elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); } Array.prototype.slice.call(elt.attributes).filter(function(a) {return a.nodeName.startsWith('xf-template-');}).forEach(function(a) { new XsltForms_avt(XsltForms_subform.subforms['xsltforms-mainform'], elt, a.nodeName.substr(12)); }); });" //)); - -function XsltForms_avt(subform, elt, attrname) { - this.init(subform, elt); - this.controlName = "avt"; - this.attrname = attrname; - this.binding = new XsltForms_binding(subform, elt, "xf-template-" + attrname, "xsd:string"); - this.hasBinding = true; - this.isOutput = true; - if (attrname.toLowerCase() === "id") { - var calcid = "xsltforms-id-"; - var prev = 1; - while (elt.nodeType === Fleur.Node.ELEMENT_NODE) { - while (elt.previousSibling) { - if (elt.nodeType === Fleur.Node.ELEMENT_NODE) { - prev++; - } - elt = elt.previousSibling; - } - calcid += prev + "_"; - elt = elt.parentNode; - prev = 1; - } - this.element.setAttribute("id", calcid); - } else if (this.binding && this.binding.type) { - this.element.setAttribute(this.attrname, ""); - } -} - -XsltForms_avt.prototype = new XsltForms_control(); - + +function XsltForms_avt(subform, elt, attrname) { + this.init(subform, elt); + this.controlName = "avt"; + this.attrname = attrname; + this.binding = new XsltForms_binding(subform, elt, "xf-template-" + attrname, "xsd:string"); + this.hasBinding = true; + this.isOutput = true; + if (attrname.toLowerCase() === "id") { + var calcid = "xsltforms-id-"; + var prev = 1; + while (elt.nodeType === Fleur.Node.ELEMENT_NODE) { + while (elt.previousSibling) { + if (elt.nodeType === Fleur.Node.ELEMENT_NODE) { + prev++; + } + elt = elt.previousSibling; + } + calcid += prev + "_"; + elt = elt.parentNode; + prev = 1; + } + this.element.setAttribute("id", calcid); + } else if (this.binding && this.binding.type) { + this.element.setAttribute(this.attrname, ""); + } +} - +XsltForms_avt.prototype = new XsltForms_control(); + + + /** * * '''clone''' method : creates a new output control with the given id */ - -XsltForms_avt.prototype.clone = function(id) { - return new XsltForms_avt(this.subform, id, this.attrname, this.binding); -}; - - +XsltForms_avt.prototype.clone = function(id) { + return new XsltForms_avt(this.subform, id, this.attrname, this.binding); +}; + + + /** * * '''dispose''' method : clears properties of this control and calls the parent dispose() method */ - -XsltForms_avt.prototype.dispose = function() { - XsltForms_control.prototype.dispose.call(this); -}; - - +XsltForms_avt.prototype.dispose = function() { + XsltForms_control.prototype.dispose.call(this); +}; + + + /** * * '''setValue''' method : sets the value of this AVT control */ - + XsltForms_avt.prototype.setValue = function(value) { - if (this.attrname === "id" && this.element.id === this.element.getAttribute("oldid")) { - if (!XsltForms_globals.idalt) { - XsltForms_globals.idalt = {}; - } - XsltForms_globals.idalt[this.element.id] = this.element; - } - this.element.setAttribute(this.attrname, value); -}; + if (this.attrname === "id" && this.element.id === this.element.getAttribute("oldid")) { + if (!XsltForms_globals.idalt) { + XsltForms_globals.idalt = {}; + } + XsltForms_globals.idalt[this.element.id] = this.element; + } + this.element.setAttribute(this.attrname, value); +}; - + /** * * '''getValue''' method : gets the value of this AVT control * @callback */ - -XsltForms_avt.prototype.getValue = function(value) { - return this.element.getAttribute(this.attrname); + +XsltForms_avt.prototype.getValue = function(value) { + return this.element.getAttribute(this.attrname); }; \ No newline at end of file diff --git a/src/js/xsltforms.js/controls/Calendar.js b/src/js/xsltforms.js/controls/Calendar.js index b77fa62..e7c0883 100644 --- a/src/js/xsltforms.js/controls/Calendar.js +++ b/src/js/xsltforms.js/controls/Calendar.js @@ -1,208 +1,206 @@ -/*eslint-env browser*/ -/*globals XsltForms_browser XsltForms_numberList*/ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module Calendar - * @description === "Calendar" class === - * Calendar Class for Date/DateTime Control - * * constructor function : dynamically creates a table element - */ - +"use strict"; +/** + * @author Alain Couthures + * @license LGPL - See file 'LICENSE.md' in this project. + * @module Calendar + * @description === "Calendar" class === + * Calendar Class for Date/DateTime Control + * * constructor function : dynamically creates a table element + */ + function XsltForms_calendar() { - var body = XsltForms_browser.isXhtml ? document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "body")[0] : document.getElementsByTagName("body")[0]; - this.element = XsltForms_browser.createElement("table", body, null, "xsltforms-calendar"); - var tHead = XsltForms_browser.createElement("thead", this.element); - var trTitle = XsltForms_browser.createElement("tr", tHead); - var title = XsltForms_browser.createElement("td", trTitle, null, "xsltforms-calendar-title"); - title.colSpan = 7; - this.selectMonth = XsltForms_browser.createElement("select", title); - XsltForms_browser.events.attach(this.selectMonth, "change", function() { - XsltForms_calendar.INSTANCE.refresh(); - } ); - for (var i = 0; i < 12; i++) { - var o = XsltForms_browser.createElement("option", this.selectMonth, XsltForms_browser.i18n.get("calendar.month" + i)); - o.setAttribute("value", i); - } - this.inputYear = XsltForms_browser.createElement("input", title); - this.inputYear.readOnly = true; - XsltForms_browser.events.attach(this.inputYear, "mouseup", function() { - var cal = XsltForms_calendar.INSTANCE; - cal.yearList.show(); - } ); - XsltForms_browser.events.attach(this.inputYear, "change", function() { - XsltForms_calendar.INSTANCE.refresh(); - } ); - var closeElt = XsltForms_browser.createElement("button", title, "X"); - closeElt.setAttribute("type", "button"); - closeElt.setAttribute("title", XsltForms_browser.i18n.get("calendar.close", "Close")); - XsltForms_browser.events.attach(closeElt, "click", function() { - XsltForms_calendar.close(); - } ); - var trDays = XsltForms_browser.createElement("tr", tHead, null, "xsltforms-calendar-names"); - var ini = parseInt(XsltForms_browser.i18n.get("calendar.initDay"), 10); - for (var j = 0; j < 7; j++) { - var ind = (j + ini) % 7; - this.createElement(trDays, "xsltforms-calendar-name", XsltForms_browser.i18n.get("calendar.day" + ind)); - } - this.tBody = XsltForms_browser.createElement("tbody", this.element); - var handler = function(evt) { - var value = XsltForms_browser.events.getTarget(evt).childNodes[0].nodeValue; - var cal = XsltForms_calendar.INSTANCE; - if (value !== "") { - cal.day = value; - var date = new Date(cal.inputYear.value,cal.selectMonth.value,cal.day); - if (cal.isTimestamp) { - date.setSeconds(cal.inputSec.value); - date.setMinutes(cal.inputMin.value); - date.setHours(cal.inputHour.value); - cal.input.value = XsltForms_browser.i18n.format(date, null, true); - } else { - cal.input.value = XsltForms_browser.i18n.formatDate(date); - } - XsltForms_calendar.close(); - XsltForms_browser.events.dispatch(cal.input, "keyup"); - cal.input.focus(); - } - }; - for (var dtr = 0; dtr < 6; dtr++) { - var trLine = XsltForms_browser.createElement("tr", this.tBody); - for (var day = 0; day < 7; day++) { - this.createElement(trLine, "xsltforms-calendar-day", " ", 1, handler); - } - } - var tFoot = XsltForms_browser.createElement("tfoot", this.element); - var trFoot = XsltForms_browser.createElement("tr", tFoot); - var tdFoot = XsltForms_browser.createElement("td", trFoot); - tdFoot.colSpan = 7; - this.inputHour = XsltForms_browser.createElement("input", tdFoot); - this.inputHour.readOnly = true; - XsltForms_browser.events.attach(this.inputHour, "mouseup", function() { - XsltForms_calendar.INSTANCE.hourList.show(); - } ); - tdFoot.appendChild(document.createTextNode(":")); - this.inputMin = XsltForms_browser.createElement("input", tdFoot); - this.inputMin.readOnly = true; - XsltForms_browser.events.attach(this.inputMin, "mouseup", function() { - XsltForms_calendar.INSTANCE.minList.show(); - } ); - tdFoot.appendChild(document.createTextNode(":")); - this.inputSec = XsltForms_browser.createElement("input", tdFoot); - this.inputSec.readOnly = true; - XsltForms_browser.events.attach(this.inputSec, "mouseup", function() { - if (XsltForms_calendar.INSTANCE.type >= XsltForms_calendar.SECONDS) { - XsltForms_calendar.INSTANCE.secList.show(); - } - } ); - this.yearList = new XsltForms_numberList(title, "xsltforms-calendarList", this.inputYear, 1900, 2050); - this.hourList = new XsltForms_numberList(tdFoot, "xsltforms-calendarList", this.inputHour, 0, 23, 2); - this.minList = new XsltForms_numberList(tdFoot, "xsltforms-calendarList", this.inputMin, 0, 59, 2); - this.secList = new XsltForms_numberList(tdFoot, "xsltforms-calendarList", this.inputSec, 0, 59, 2); + var body = XsltForms_browser.isXhtml ? document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "body")[0] : document.getElementsByTagName("body")[0]; + this.element = XsltForms_browser.createElement("table", body, null, "xsltforms-calendar"); + var tHead = XsltForms_browser.createElement("thead", this.element); + var trTitle = XsltForms_browser.createElement("tr", tHead); + var title = XsltForms_browser.createElement("td", trTitle, null, "xsltforms-calendar-title"); + title.colSpan = 7; + this.selectMonth = XsltForms_browser.createElement("select", title); + XsltForms_browser.events.attach(this.selectMonth, "change", function() { + XsltForms_calendar.INSTANCE.refresh(); + } ); + for (var i = 0; i < 12; i++) { + var o = XsltForms_browser.createElement("option", this.selectMonth, XsltForms_browser.i18n.get("calendar.month" + i)); + o.setAttribute("value", i); + } + this.inputYear = XsltForms_browser.createElement("input", title); + this.inputYear.readOnly = true; + XsltForms_browser.events.attach(this.inputYear, "mouseup", function() { + var cal = XsltForms_calendar.INSTANCE; + cal.yearList.show(); + } ); + XsltForms_browser.events.attach(this.inputYear, "change", function() { + XsltForms_calendar.INSTANCE.refresh(); + } ); + var closeElt = XsltForms_browser.createElement("button", title, "X"); + closeElt.setAttribute("type", "button"); + closeElt.setAttribute("title", XsltForms_browser.i18n.get("calendar.close", "Close")); + XsltForms_browser.events.attach(closeElt, "click", function() { + XsltForms_calendar.close(); + } ); + var trDays = XsltForms_browser.createElement("tr", tHead, null, "xsltforms-calendar-names"); + var ini = parseInt(XsltForms_browser.i18n.get("calendar.initDay"), 10); + for (var j = 0; j < 7; j++) { + var ind = (j + ini) % 7; + this.createElement(trDays, "xsltforms-calendar-name", XsltForms_browser.i18n.get("calendar.day" + ind)); + } + this.tBody = XsltForms_browser.createElement("tbody", this.element); + var handler = function(evt) { + var value = XsltForms_browser.events.getTarget(evt).childNodes[0].nodeValue; + var cal = XsltForms_calendar.INSTANCE; + if (value !== "") { + cal.day = value; + var date = new Date(cal.inputYear.value,cal.selectMonth.value,cal.day); + if (cal.isTimestamp) { + date.setSeconds(cal.inputSec.value); + date.setMinutes(cal.inputMin.value); + date.setHours(cal.inputHour.value); + cal.input.value = XsltForms_browser.i18n.format(date, null, true); + } else { + cal.input.value = XsltForms_browser.i18n.formatDate(date); + } + XsltForms_calendar.close(); + XsltForms_browser.events.dispatch(cal.input, "keyup"); + cal.input.focus(); + } + }; + for (var dtr = 0; dtr < 6; dtr++) { + var trLine = XsltForms_browser.createElement("tr", this.tBody); + for (var day = 0; day < 7; day++) { + this.createElement(trLine, "xsltforms-calendar-day", " ", 1, handler); + } + } + var tFoot = XsltForms_browser.createElement("tfoot", this.element); + var trFoot = XsltForms_browser.createElement("tr", tFoot); + var tdFoot = XsltForms_browser.createElement("td", trFoot); + tdFoot.colSpan = 7; + this.inputHour = XsltForms_browser.createElement("input", tdFoot); + this.inputHour.readOnly = true; + XsltForms_browser.events.attach(this.inputHour, "mouseup", function() { + XsltForms_calendar.INSTANCE.hourList.show(); + } ); + tdFoot.appendChild(document.createTextNode(":")); + this.inputMin = XsltForms_browser.createElement("input", tdFoot); + this.inputMin.readOnly = true; + XsltForms_browser.events.attach(this.inputMin, "mouseup", function() { + XsltForms_calendar.INSTANCE.minList.show(); + } ); + tdFoot.appendChild(document.createTextNode(":")); + this.inputSec = XsltForms_browser.createElement("input", tdFoot); + this.inputSec.readOnly = true; + XsltForms_browser.events.attach(this.inputSec, "mouseup", function() { + if (XsltForms_calendar.INSTANCE.type >= XsltForms_calendar.SECONDS) { + XsltForms_calendar.INSTANCE.secList.show(); + } + } ); + this.yearList = new XsltForms_numberList(title, "xsltforms-calendarList", this.inputYear, 1900, 2050); + this.hourList = new XsltForms_numberList(tdFoot, "xsltforms-calendarList", this.inputHour, 0, 23, 2); + this.minList = new XsltForms_numberList(tdFoot, "xsltforms-calendarList", this.inputMin, 0, 59, 2); + this.secList = new XsltForms_numberList(tdFoot, "xsltforms-calendarList", this.inputSec, 0, 59, 2); } - - -/** - * * '''today''' method : sets the value of this Calendar object to the current date - */ + + +/** + * * '''today''' method : sets the value of this Calendar object to the current date + */ XsltForms_calendar.prototype.today = function() { - this.refreshControls(new Date()); + this.refreshControls(new Date()); }; - - -/** - * * '''refreshControls''' method : refreshes this Calendar object according to a given date - */ + + +/** + * * '''refreshControls''' method : refreshes this Calendar object according to a given date + */ XsltForms_calendar.prototype.refreshControls = function(date) { - this.day = date.getDate(); - this.selectMonth.value = date.getMonth(); - this.inputYear.value = date.getYear() < 1000 ? 1900 + date.getYear() : date.getYear(); - if (this.isTimestamp) { - this.inputHour.value = XsltForms_browser.zeros(date.getHours(), 2); - this.inputMin.value = this.type >= XsltForms_calendar.MINUTES ? XsltForms_browser.zeros(date.getMinutes(), 2) : "00"; - this.inputSec.value = this.type >= XsltForms_calendar.SECONDS ? XsltForms_browser.zeros(date.getSeconds(), 2) : "00"; - } - this.refresh(); + this.day = date.getDate(); + this.selectMonth.value = date.getMonth(); + this.inputYear.value = date.getYear() < 1000 ? 1900 + date.getYear() : date.getYear(); + if (this.isTimestamp) { + this.inputHour.value = XsltForms_browser.zeros(date.getHours(), 2); + this.inputMin.value = this.type >= XsltForms_calendar.MINUTES ? XsltForms_browser.zeros(date.getMinutes(), 2) : "00"; + this.inputSec.value = this.type >= XsltForms_calendar.SECONDS ? XsltForms_browser.zeros(date.getSeconds(), 2) : "00"; + } + this.refresh(); }; - - -/** - * * '''refresh''' method : refreshes this Calendar object - */ + + +/** + * * '''refresh''' method : refreshes this Calendar object + */ XsltForms_calendar.prototype.refresh = function() { - var firstDay = this.getFirstDay(); - var daysOfMonth = this.getDaysOfMonth(); - var ini = parseInt(XsltForms_browser.i18n.get("calendar.initDay"), 10); - var cont = 0; - var day = 1; - var currentMonthYear = this.selectMonth.value === this.currentMonth && this.inputYear.value === this.currentYear; - for (var i = 0; i < 6; i++) { - var trLine = this.tBody.childNodes[i]; - for (var j = 0; j < 7; j++, cont++) { - var cell = trLine.childNodes[j]; - var dayInMonth = (cont >= firstDay && cont < firstDay + daysOfMonth); - XsltForms_browser.setClass(cell, "xsltforms-listHover", false); - XsltForms_browser.setClass(cell, "xsltforms-calendar-today", currentMonthYear && day === this.currentDay); - XsltForms_browser.setClass(cell, "xsltforms-calendar-selected", dayInMonth && day === this.day); - XsltForms_browser.setClass(cell, "xsltforms-calendar-weekend", (j+ini)%7 > 4); - cell.firstChild.nodeValue = dayInMonth ? day++ : ""; - } - } + var firstDay = this.getFirstDay(); + var daysOfMonth = this.getDaysOfMonth(); + var ini = parseInt(XsltForms_browser.i18n.get("calendar.initDay"), 10); + var cont = 0; + var day = 1; + var currentMonthYear = this.selectMonth.value === this.currentMonth && this.inputYear.value === this.currentYear; + for (var i = 0; i < 6; i++) { + var trLine = this.tBody.childNodes[i]; + for (var j = 0; j < 7; j++, cont++) { + var cell = trLine.childNodes[j]; + var dayInMonth = (cont >= firstDay && cont < firstDay + daysOfMonth); + XsltForms_browser.setClass(cell, "xsltforms-listHover", false); + XsltForms_browser.setClass(cell, "xsltforms-calendar-today", currentMonthYear && day === this.currentDay); + XsltForms_browser.setClass(cell, "xsltforms-calendar-selected", dayInMonth && day === this.day); + XsltForms_browser.setClass(cell, "xsltforms-calendar-weekend", (j+ini)%7 > 4); + cell.firstChild.nodeValue = dayInMonth ? day++ : ""; + } + } }; - - -/** - * * '''getFirstDay''' method : gets the first day of the selected month - */ + + +/** + * * '''getFirstDay''' method : gets the first day of the selected month + */ XsltForms_calendar.prototype.getFirstDay = function() { - var date = new Date(); - date.setDate(1); - date.setMonth(this.selectMonth.value); - date.setYear(this.inputYear.value); - var ini = parseInt(XsltForms_browser.i18n.get("calendar.initDay"), 10); - var d = date.getDay(); - return (d + (6 - ini)) % 7; + var date = new Date(); + date.setDate(1); + date.setMonth(this.selectMonth.value); + date.setYear(this.inputYear.value); + var ini = parseInt(XsltForms_browser.i18n.get("calendar.initDay"), 10); + var d = date.getDay(); + return (d + (6 - ini)) % 7; }; - - -/** - * * '''getDaysOfMonth''' method : gets the number of days of the selected month - */ + + +/** + * * '''getDaysOfMonth''' method : gets the number of days of the selected month + */ XsltForms_calendar.prototype.getDaysOfMonth = function() { - var year = parseInt(this.inputYear.value, 10); - var month = parseInt(this.selectMonth.value, 10); - if (month === 1 && ((0 === (year % 4)) && ((0 !== (year % 100)) || (0 === (year % 400))))) { - return 29; - } - return XsltForms_calendar.daysOfMonth[this.selectMonth.value]; + var year = parseInt(this.inputYear.value, 10); + var month = parseInt(this.selectMonth.value, 10); + if (month === 1 && ((0 === (year % 4)) && ((0 !== (year % 100)) || (0 === (year % 400))))) { + return 29; + } + return XsltForms_calendar.daysOfMonth[this.selectMonth.value]; }; - - -/** - * * '''createElement''' method : creates a new clickable day within this Calendar object - */ + + +/** + * * '''createElement''' method : creates a new clickable day within this Calendar object + */ XsltForms_calendar.prototype.createElement = function(parent, className, text, colspan, handler) { - var element = XsltForms_browser.createElement("td", parent, text, className); - if (colspan > 1) { - element.colSpan = colspan; - } - if (handler) { - XsltForms_browser.events.attach(element, "click", handler); - XsltForms_browser.initHover(element); - } - return element; + var element = XsltForms_browser.createElement("td", parent, text, className); + if (colspan > 1) { + element.colSpan = colspan; + } + if (handler) { + XsltForms_browser.events.attach(element, "click", handler); + XsltForms_browser.initHover(element); + } + return element; }; XsltForms_calendar.daysOfMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; @@ -212,47 +210,47 @@ XsltForms_calendar.HOURS = 1; XsltForms_calendar.MINUTES = 2; XsltForms_calendar.SECONDS = 3; - - -/** - * * '''show''' function : shows a Calendar object of a given type for a given input - */ + + +/** + * * '''show''' function : shows a Calendar object of a given type for a given input + */ XsltForms_calendar.show = function(input, type) { - var cal = XsltForms_calendar.INSTANCE; - if (!cal) { - cal = new XsltForms_calendar(); - XsltForms_calendar.INSTANCE = cal; - } - if (!type) { - type = XsltForms_calendar.ONLY_DATE; - } - cal.input = input; - cal.type = type; - cal.isTimestamp = type !== XsltForms_calendar.ONLY_DATE; - XsltForms_browser.setClass(cal.element, "xsltforms-calendar-date", !cal.isTimestamp); - var date; - try { - date = cal.isTimestamp? XsltForms_browser.i18n.parse(input.value) : XsltForms_browser.i18n.parseDate(input.value); - } catch (e) { - date = new Date(); - } - if (date) { - cal.refreshControls(date); - } else { - cal.today(); - } - XsltForms_browser.dialog.show(cal.element, input, false); + var cal = XsltForms_calendar.INSTANCE; + if (!cal) { + cal = new XsltForms_calendar(); + XsltForms_calendar.INSTANCE = cal; + } + if (!type) { + type = XsltForms_calendar.ONLY_DATE; + } + cal.input = input; + cal.type = type; + cal.isTimestamp = type !== XsltForms_calendar.ONLY_DATE; + XsltForms_browser.setClass(cal.element, "xsltforms-calendar-date", !cal.isTimestamp); + var date; + try { + date = cal.isTimestamp? XsltForms_browser.i18n.parse(input.value) : XsltForms_browser.i18n.parseDate(input.value); + } catch (e) { + date = new Date(); + } + if (date) { + cal.refreshControls(date); + } else { + cal.today(); + } + XsltForms_browser.dialog.show(cal.element, input, false); }; - - -/** - * * '''close''' function : hides the current Calendar object - */ + + +/** + * * '''close''' function : hides the current Calendar object + */ XsltForms_calendar.close = function() { - var cal = XsltForms_calendar.INSTANCE; - cal.yearList.close(); - XsltForms_browser.dialog.hide(cal.element, false); + var cal = XsltForms_calendar.INSTANCE; + cal.yearList.close(); + XsltForms_browser.dialog.hide(cal.element, false); }; \ No newline at end of file diff --git a/src/js/xsltforms.js/controls/case.js b/src/js/xsltforms.js/controls/case.js index 3a52fea..4ac899e 100644 --- a/src/js/xsltforms.js/controls/case.js +++ b/src/js/xsltforms.js/controls/case.js @@ -1,19 +1,17 @@ -/*eslint-env browser*/ -/*globals XsltForms_element XsltForms_class XsltForms_globals XsltForms_browser XsltForms_subform*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module group * @description === "XsltForms_case" class === * Case Element Class * * constructor function : sets specific properties */ - + new XsltForms_class("XsltForms_case", "HTMLElement", "xforms-case"); - + function XsltForms_case(subform, elt) { - this.init(subform, elt); + this.init(subform, elt); } XsltForms_case.prototype = new XsltForms_element(); diff --git a/src/js/xsltforms.js/controls/component.js b/src/js/xsltforms.js/controls/component.js index 00deabd..a8bb6e2 100644 --- a/src/js/xsltforms.js/controls/component.js +++ b/src/js/xsltforms.js/controls/component.js @@ -1,139 +1,137 @@ -/*eslint-env browser*/ -/*globals XsltForms_globals XsltForms_browser XsltForms_control XsltForms_class*/ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module component - * @description === "XsltForms_component" class === - * Component Control Class - * * constructor function : initializes specific properties - */ - -new XsltForms_class("XsltForms_component", "HTMLElement", "xforms-component"); - +"use strict"; +/** + * @author Alain Couthures + * @license LGPL - See file 'LICENSE.md' in this project. + * @module component + * @description === "XsltForms_component" class === + * Component Control Class + * * constructor function : initializes specific properties + */ + +new XsltForms_class("XsltForms_component", "HTMLElement", "xforms-component"); + function XsltForms_component(subform, id, valoff, binding, href) { - XsltForms_globals.counters.component++; - this.init(subform, id); - this.valoff = valoff; - var children = this.element.children || this.element.childNodes; - if (children.length !== 0) { - var cells = children; - this.valueElement = cells[valoff]; - } else { - this.valueElement = this.element; - } - this.hasBinding = true; - this.binding = binding; - this.resource = href; - this.isComponent = true; - if (this.binding && this.binding.type) { - XsltForms_browser.setClass(this.element, "xforms-disabled", false); - } - //this.subformid = "xsltforms-subform-" + XsltForms_globals.nbsubforms; - var req = null; - var method = "get"; - // var evcontext = {"method": method, "resource-uri": href}; - try { - req = XsltForms_browser.openRequest(method, href, false); - XsltForms_browser.debugConsole.write("Load Component " + href); - req.send(null); - if (req.status !== 0 && (req.status < 200 || req.status >= 300)) { - return; - } - var resp = req.responseText; - var piindex = resp.indexOf("")).replace(/^.*href=\"([^\"]*)\".*$/, "$1"); - resp = XsltForms_browser.transformText(resp, xslhref, false); - piindex = resp.indexOf(""; - imain = subbody.indexOf(' id="xsltforms-mainform'); - while (imain !== -1) { - subbody = subbody.substring(0, imain) + ' id="xsltforms-subform-' + XsltForms_globals.nbsubforms + subbody.substring(imain + 23); - imain = subbody.indexOf(' id="xsltforms-mainform'); - } - } - targetelt.innerHTML = subbody; - targetelt.hasXFElement = null; - var parentNode = targetelt.parentNode; - while (parentNode) { - if (parentNode.hasXFElement !== false) { - break; - } - parentNode.hasXFElement = null; - parentNode = parentNode.parentNode; - } - if (sp.length !== 1) { - XsltForms_globals.componentLoads.push(subjs); - this.subjs = subjs; - this.evaljs = true; - } - XsltForms_browser.setClass(targetelt, "xforms-subform-loaded", true); - XsltForms_globals.nbsubforms++; - } catch(e2) { - XsltForms_browser.debugConsole.write(e2.message || e2); - } + XsltForms_globals.counters.component++; + this.init(subform, id); + this.valoff = valoff; + var children = this.element.children || this.element.childNodes; + if (children.length !== 0) { + var cells = children; + this.valueElement = cells[valoff]; + } else { + this.valueElement = this.element; + } + this.hasBinding = true; + this.binding = binding; + this.resource = href; + this.isComponent = true; + if (this.binding && this.binding.type) { + XsltForms_browser.setClass(this.element, "xforms-disabled", false); + } + //this.subformid = "xsltforms-subform-" + XsltForms_globals.nbsubforms; + var req = null; + var method = "get"; + // var evcontext = {"method": method, "resource-uri": href}; + try { + req = XsltForms_browser.openRequest(method, href, false); + XsltForms_browser.debugConsole.write("Load Component " + href); + req.send(null); + if (req.status !== 0 && (req.status < 200 || req.status >= 300)) { + return; + } + var resp = req.responseText; + var piindex = resp.indexOf("")).replace(/^.*href=\"([^\"]*)\".*$/, "$1"); + resp = XsltForms_browser.transformText(resp, xslhref, false); + piindex = resp.indexOf(""; + imain = subbody.indexOf(' id="xsltforms-mainform'); + while (imain !== -1) { + subbody = subbody.substring(0, imain) + ' id="xsltforms-subform-' + XsltForms_globals.nbsubforms + subbody.substring(imain + 23); + imain = subbody.indexOf(' id="xsltforms-mainform'); + } + } + targetelt.innerHTML = subbody; + targetelt.hasXFElement = null; + var parentNode = targetelt.parentNode; + while (parentNode) { + if (parentNode.hasXFElement !== false) { + break; + } + parentNode.hasXFElement = null; + parentNode = parentNode.parentNode; + } + if (sp.length !== 1) { + XsltForms_globals.componentLoads.push(subjs); + this.subjs = subjs; + this.evaljs = true; + } + XsltForms_browser.setClass(targetelt, "xforms-subform-loaded", true); + XsltForms_globals.nbsubforms++; + } catch(e2) { + XsltForms_browser.debugConsole.write(e2.message || e2); + } } XsltForms_component.prototype = new XsltForms_control(); - - -/** - * * '''clone''' method : creates a new output control with the given id - */ + + +/** + * * '''clone''' method : creates a new output control with the given id + */ XsltForms_component.prototype.clone = function(id) { - return new XsltForms_component(this.subform, id, this.valoff, this.binding, this.resource); + return new XsltForms_component(this.subform, id, this.valoff, this.binding, this.resource); }; - - -/** - * * '''dispose''' method : clears properties of this control and calls the parent dispose() method - */ + + +/** + * * '''dispose''' method : clears properties of this control and calls the parent dispose() method + */ XsltForms_component.prototype.dispose = function() { - this.valueElement = null; - XsltForms_globals.counters.component--; - XsltForms_control.prototype.dispose.call(this); + this.valueElement = null; + XsltForms_globals.counters.component--; + XsltForms_control.prototype.dispose.call(this); }; - - -/** - * * '''blur''' method : empty method - */ + + +/** + * * '''blur''' method : empty method + */ XsltForms_component.prototype.blur = function () { }; - - -/** - * * '''setValue''' method : sets the value of this component control - * @callback - */ + + +/** + * * '''setValue''' method : sets the value of this component control + * @callback + */ XsltForms_component.prototype.setValue = function(value) { - XsltForms_browser.forEach(this.valueElement.children[0].xfElement.subform.binds, "propagate"); + XsltForms_browser.forEach(this.valueElement.children[0].xfElement.subform.binds, "propagate"); }; \ No newline at end of file diff --git a/src/js/xsltforms.js/controls/control.js b/src/js/xsltforms.js/controls/control.js index c7fdb2d..873934f 100644 --- a/src/js/xsltforms.js/controls/control.js +++ b/src/js/xsltforms.js/controls/control.js @@ -1,317 +1,315 @@ -/*eslint-env browser*/ -/*globals XsltForms_element XsltForms_browser XsltForms_globals Fleur XsltForms_xmlevents XsltForms_repeat XsltForms_schema XsltForms_class*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module control * @description === "XsltForms_control" class === * Control Class * * constructor function : just sets this element as a control */ - + function XsltForms_control() { - this.isControl = true; + this.isControl = true; } XsltForms_control.prototype = new XsltForms_element(); - + /** * * '''initFocus''' method : attaches event handlers for "focus" and "blur" */ XsltForms_control.prototype.initFocus = function(element, principal) { - if (principal) { - this.focusControl = element; - } - XsltForms_browser.events.attach(element, "focus", XsltForms_control.focusHandler); - //XsltForms_browser.events.attach(element, "mousein", XsltForms_control.focusHandler); - XsltForms_browser.events.attach(element, "blur", XsltForms_control.blurHandler); - //XsltForms_browser.events.attach(element, "mouseout", XsltForms_control.blurHandler); + if (principal) { + this.focusControl = element; + } + XsltForms_browser.events.attach(element, "focus", XsltForms_control.focusHandler); + //XsltForms_browser.events.attach(element, "mousein", XsltForms_control.focusHandler); + XsltForms_browser.events.attach(element, "blur", XsltForms_control.blurHandler); + //XsltForms_browser.events.attach(element, "mouseout", XsltForms_control.blurHandler); }; - + /** * * '''dispose''' method : calls the parent "dispose()" method */ XsltForms_control.prototype.dispose = function() { - this.focusControl = null; - XsltForms_element.prototype.dispose.call(this); + this.focusControl = null; + XsltForms_element.prototype.dispose.call(this); }; - + /** * * '''focus''' method : manages focus and dispatches the "DOMFocusIn" event */ XsltForms_control.prototype.focus = function(focusEvent, evcontext) { - if (this.isOutput) { - return; - } - if (XsltForms_globals.focus !== this) { - XsltForms_globals.openAction("XsltForms_control.prototype.focus"); - XsltForms_globals.blur(true); - XsltForms_globals.focus = this; - this.element.setAttribute("xf-focus", ""); - //XsltForms_browser.setClass(this.element, "xforms-focus", true); - //XsltForms_browser.setClass(this.element, "xforms-disabled", false); - var parentNode = this.element.parentNode; - while (parentNode.nodeType === Fleur.Node.ELEMENT_NODE) { - if (typeof parentNode.node !== "undefined" && (parentNode.localName.toLowerCase() === "xforms-repeat-item" || parentNode.getAttribute("xforms-name") === "repeat-item")) { - XsltForms_repeat.selectItem(parentNode); - } - parentNode = parentNode.parentNode; - } - XsltForms_xmlevents.dispatch(XsltForms_globals.focus, "DOMFocusIn", null, null, null, null, evcontext); - XsltForms_globals.closeAction("XsltForms_control.prototype.focus"); - if (this.full && !focusEvent) { // select full - this.focusFirst(); - } - } - var fcontrol = this.focusControl; - XsltForms_globals.posibleBlur = false; - if (fcontrol && !focusEvent) { - var control = this.focusControl; - var cname = control.nodeName.toLowerCase(); - try { - control.focus(); - control.focus(); - } catch (e) { - XsltForms_browser.debugConsole.write("ERROR: Could not focus on element " + control); - } - if (cname === "input" || cname === "textarea") { - try { - control.select(); - } catch (e) { - } - } - } + if (this.isOutput) { + return; + } + if (XsltForms_globals.focus !== this) { + XsltForms_globals.openAction("XsltForms_control.prototype.focus"); + XsltForms_globals.blur(true); + XsltForms_globals.focus = this; + this.element.setAttribute("xf-focus", ""); + //XsltForms_browser.setClass(this.element, "xforms-focus", true); + //XsltForms_browser.setClass(this.element, "xforms-disabled", false); + var parentNode = this.element.parentNode; + while (parentNode.nodeType === Fleur.Node.ELEMENT_NODE) { + if (typeof parentNode.node !== "undefined" && (parentNode.localName.toLowerCase() === "xforms-repeat-item" || parentNode.getAttribute("xforms-name") === "repeat-item")) { + XsltForms_repeat.selectItem(parentNode); + } + parentNode = parentNode.parentNode; + } + XsltForms_xmlevents.dispatch(XsltForms_globals.focus, "DOMFocusIn", null, null, null, null, evcontext); + XsltForms_globals.closeAction("XsltForms_control.prototype.focus"); + if (this.full && !focusEvent) { // select full + this.focusFirst(); + } + } + var fcontrol = this.focusControl; + XsltForms_globals.posibleBlur = false; + if (fcontrol && !focusEvent) { + var control = this.focusControl; + var cname = control.nodeName.toLowerCase(); + try { + control.focus(); + control.focus(); + } catch (e) { + XsltForms_browser.debugConsole.write("ERROR: Could not focus on element " + control); + } + if (cname === "input" || cname === "textarea") { + try { + control.select(); + } catch (e) { + } + } + } }; - + /** * * '''build_''' method : specific build method updating dependencies */ -XsltForms_control.prototype.build_ = function(ctx, varresolver) { - if (this.controlName === "output") { - var p = this.element.parentNode; - if (p.localName.toLowerCase() === "xforms-message" && !p.xfElement.running) { - return; - } - } - var result = this.evaluateBinding(this.binding, ctx, varresolver); - if (typeof result === "object") { - var node = result.head(); - var element = this.element; - var old = element.node; - if (old !== node || !XsltForms_globals.ready) { - element.node = node; - this.nodeChanged = true; - } - if (node) { - this.depsNodesRefresh.push(node); - element.setAttribute("xf-bound", ""); - } else { - element.removeAttribute("xf-bound"); - } - } else { - this.outputValue = result; - } +XsltForms_control.prototype.build_ = function(ctx) { + if (this.controlName === "output") { + var p = this.element.parentNode; + if (p.localName.toLowerCase() === "xforms-message" && !p.xfElement.running) { + return; + } + } + var result = this.evaluateBinding(this.binding, ctx, this.element); + if (typeof result === "object") { + var node = result.head(); + var element = this.element; + var old = element.node; + if (old !== node || !XsltForms_globals.ready) { + element.node = node; + this.nodeChanged = true; + } + if (node) { + this.depsNodesRefresh.push(node); + element.setAttribute("xf-bound", ""); + } else { + element.removeAttribute("xf-bound"); + } + } else { + this.outputValue = result; + } }; - + /** * * '''refresh''' method : refreshes this control according to the value of the corresponding node and dispatches according events */ XsltForms_control.prototype.refresh = function() { - if (this.controlName === "var" || this.controlName === "action-var") { - return; - } - var element = this.element; - var node = element.node; - if (this.outputValue !== undefined) { - if (this.controlName !== "var") { - this.setValue(this.outputValue); - this.eventDispatch("xforms-disabled", "xforms-enabled", false); - } - } else if (node) { - if (!this.value) { - this.value = this.hasCopy ? [] : ""; - } - var value = this.value instanceof Array ? XsltForms_browser.getValueItemsetCopy(node) : XsltForms_browser.getValue(node, true, this.complex); - XsltForms_globals.openAction("XsltForms_control.prototype.refresh"); - var changed; - if (this.currentValue instanceof Array) { - changed = false; - if (this.currentValue.length !== value.length) { - changed = true; - } else { - for (var i = 0, l = this.currentValue.length; i < l; i++) { - if (this.currentValue[i] !== value[i]) { - changed = true; - break; - } - } - } - changed = changed || this.nodeChanged; - } else { - changed = value !== this.currentValue || this.nodeChanged; - } - //if (this.relevant) { - // XsltForms_browser.setClass(element, "xforms-disabled", false); - //} - this.changeProp(node, "required", "xforms-required", "xforms-optional", changed, value); - this.changeProp(node, "notrelevant", "xforms-disabled", "xforms-enabled", changed, value); - this.changeProp(node, "readonly", "xforms-readonly", "xforms-readwrite", changed, value); - this.changeProp(node, "invalid", "xforms-invalid", "xforms-valid", changed, value); - this.currentValue = value instanceof Array ? value.slice(0) : value; - if (changed) { - this.setValue(value); - if (!this.nodeChanged && !this.isTrigger) { - XsltForms_xmlevents.dispatch(element, "xforms-value-changed"); - } - } - XsltForms_globals.closeAction("XsltForms_control.prototype.refresh"); - } else { - this.eventDispatch("xforms-disabled", "xforms-enabled", !this.hasValue); - } - this.nodeChanged = false; + if (this.controlName === "var" || this.controlName === "action-var") { + return; + } + var element = this.element; + var node = element.node; + if (this.outputValue !== undefined) { + if (this.controlName !== "var") { + this.setValue(this.outputValue); + this.eventDispatch("xforms-disabled", "xforms-enabled", false); + } + } else if (node) { + if (!this.value) { + this.value = this.hasCopy ? [] : ""; + } + var value = this.value instanceof Array ? XsltForms_browser.getValueItemsetCopy(node) : XsltForms_browser.getValue(node, true, this.complex); + XsltForms_globals.openAction("XsltForms_control.prototype.refresh"); + var changed; + if (this.currentValue instanceof Array) { + changed = false; + if (this.currentValue.length !== value.length) { + changed = true; + } else { + for (var i = 0, l = this.currentValue.length; i < l; i++) { + if (this.currentValue[i] !== value[i]) { + changed = true; + break; + } + } + } + changed = changed || this.nodeChanged; + } else { + changed = value !== this.currentValue || this.nodeChanged; + } + //if (this.relevant) { + // XsltForms_browser.setClass(element, "xforms-disabled", false); + //} + this.changeProp(node, "required", "xforms-required", "xforms-optional", changed, value); + this.changeProp(node, "notrelevant", "xforms-disabled", "xforms-enabled", changed, value); + this.changeProp(node, "readonly", "xforms-readonly", "xforms-readwrite", changed, value); + this.changeProp(node, "invalid", "xforms-invalid", "xforms-valid", changed, value); + this.currentValue = value instanceof Array ? value.slice(0) : value; + if (changed) { + this.setValue(value); + if (!this.nodeChanged && !this.isTrigger) { + XsltForms_xmlevents.dispatch(element, "xforms-value-changed"); + } + } + XsltForms_globals.closeAction("XsltForms_control.prototype.refresh"); + } else { + this.eventDispatch("xforms-disabled", "xforms-enabled", !this.hasValue); + } + this.nodeChanged = false; }; - + /** * * '''eventdispatch''' method : dispatches corresponding event */ XsltForms_control.prototype.eventDispatch = function(onTrue, onFalse, value) { - if ((!this.nodeChanged || XsltForms_globals.ready) && !this.isTrigger) { - XsltForms_xmlevents.dispatch(this.element, (value? onTrue : onFalse)); - } - //XsltForms_browser.setClass(this.element, onTrue, value); - //XsltForms_browser.setClass(this.element, onFalse, !value); + if ((!this.nodeChanged || XsltForms_globals.ready) && !this.isTrigger) { + XsltForms_xmlevents.dispatch(this.element, (value? onTrue : onFalse)); + } + //XsltForms_browser.setClass(this.element, onTrue, value); + //XsltForms_browser.setClass(this.element, onFalse, !value); }; - + /** * * '''changeProp''' method : changes a property, such as '''required''', '''relevant''', '''readonly''' and '''valid''', of this control */ XsltForms_control.prototype.changeProp = function(node, prop, onTrue, onFalse, changed, nvalue) { - var value = (prop === "invalid" && nvalue === "" && !XsltForms_globals.validationError) ? false : XsltForms_browser.getBoolMeta(node, prop); - if (changed || value !== this[prop]) { - this.eventDispatch(onTrue, onFalse, value); - this[prop] = value; - if (value) { - this.element.setAttribute("xf-" + prop, ""); - } else { - this.element.removeAttribute("xf-" + prop); - } - if(prop === "readonly" && this.changeReadonly) { - this.changeReadonly(); - } - } + var value = (prop === "invalid" && nvalue === "" && !XsltForms_globals.validationError) ? false : XsltForms_browser.getBoolMeta(node, prop); + if (changed || value !== this[prop]) { + this.eventDispatch(onTrue, onFalse, value); + this[prop] = value; + if (value) { + this.element.setAttribute("xf-" + prop, ""); + } else { + this.element.removeAttribute("xf-" + prop); + } + if(prop === "readonly" && this.changeReadonly) { + this.changeReadonly(); + } + } }; - + /** * * '''valueChanged''' method : changes the value of this control and dispatches the "xforms-recalculate" event */ XsltForms_control.prototype.valueChanged = function(value, force) { - var node = this.element.node; - var model = document.getElementById(XsltForms_browser.getDocMeta(node.ownerDocument, "model")).xfElement; - var schtyp = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string"); - if (value && !(value instanceof Array) && value.length > 0 && schtyp.parse) { - try { value = schtyp.parse(value); } catch(e) { } - } - var changed; - if (value instanceof Array) { - var prevvalue = XsltForms_browser.getValueItemsetCopy(node); - changed = true; - var i = 0, l = value.length; - if (prevvalue.length === l) { - changed = false; - for (; i < l; i++) { - if (prevvalue[i] !== value[i]) { - changed = true; - break; - } - } - } - } else { - changed = value !== XsltForms_browser.getValue(node); - } - if (changed || force) { - if (value instanceof Array || this.currentValue instanceof Array) { - XsltForms_browser.setValue(node, value); - model.addChange(node); - XsltForms_globals.addChange(model); - model.setRebuilded(true); - } else { - XsltForms_globals.openAction("XsltForms_control.prototype.valueChanged"); - XsltForms_browser.setValue(node, value); - model.addChange(node); - XsltForms_xmlevents.dispatch(model, "xforms-recalculate"); - XsltForms_globals.refresh(); - XsltForms_globals.closeAction("XsltForms_control.prototype.valueChanged"); - } - } + var node = this.element.node; + var model = document.getElementById(XsltForms_browser.getDocMeta(node.ownerDocument, "model")).xfElement; + var schtyp = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string"); + if (value && !(value instanceof Array) && value.length > 0 && schtyp.parse) { + try { value = schtyp.parse(value); } catch(e) { } + } + var changed; + if (value instanceof Array) { + var prevvalue = XsltForms_browser.getValueItemsetCopy(node); + changed = true; + var i = 0, l = value.length; + if (prevvalue.length === l) { + changed = false; + for (; i < l; i++) { + if (prevvalue[i] !== value[i]) { + changed = true; + break; + } + } + } + } else { + changed = value !== XsltForms_browser.getValue(node); + } + if (changed || force) { + if (value instanceof Array || this.currentValue instanceof Array) { + XsltForms_browser.setValue(node, value); + model.addChange(node); + XsltForms_globals.addChange(model); + model.setRebuilded(true); + } else { + XsltForms_globals.openAction("XsltForms_control.prototype.valueChanged"); + XsltForms_browser.setValue(node, value); + model.addChange(node); + XsltForms_xmlevents.dispatch(model, "xforms-recalculate"); + XsltForms_globals.refresh(); + XsltForms_globals.closeAction("XsltForms_control.prototype.valueChanged"); + } + } }; - + /** * * '''getXFElement''' function : gets the ancestor-or-self XFElement value for an element */ XsltForms_control.getXFElement = function(element) { - var xf = null; - while (!xf && element) { - xf = element.xfElement; - if (xf && !xf.isControl) { - xf = null; - } - element = element.parentNode; - } - return xf; + var xf = null; + while (!xf && element) { + xf = element.xfElement; + if (xf && !xf.isControl) { + xf = null; + } + element = element.parentNode; + } + return xf; }; - + /** * * '''focusHandler''' function : focus handler */ XsltForms_control.focusHandler = function() { - var xf = XsltForms_control.getXFElement(this); - if (XsltForms_globals.focus !== xf) { - xf.focus(true); - } else { - XsltForms_globals.posibleBlur = false; - } + var xf = XsltForms_control.getXFElement(this); + if (XsltForms_globals.focus !== xf) { + xf.focus(true); + } else { + XsltForms_globals.posibleBlur = false; + } }; - + /** * * '''blurHandler''' function : blur handler including a delay */ XsltForms_control.blurHandler = function() { - if (XsltForms_control.getXFElement(this) === XsltForms_globals.focus) { - XsltForms_globals.posibleBlur = true; - //setTimeout(function(){XsltForms_globals.blur();}, 200); - XsltForms_globals.blur(); - } + if (XsltForms_control.getXFElement(this) === XsltForms_globals.focus) { + XsltForms_globals.posibleBlur = true; + //setTimeout(function(){XsltForms_globals.blur();}, 200); + XsltForms_globals.blur(); + } }; \ No newline at end of file diff --git a/src/js/xsltforms.js/controls/dialog.js b/src/js/xsltforms.js/controls/dialog.js index a9808f9..5a8c3a8 100644 --- a/src/js/xsltforms.js/controls/dialog.js +++ b/src/js/xsltforms.js/controls/dialog.js @@ -1,30 +1,28 @@ -/*eslint-env browser*/ -/*globals XsltForms_element XsltForms_class XsltForms_globals XsltForms_browser XsltForms_subform XsltForms_binding*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module group * @description === "XsltForms_dialog" class === * Dialog Element Class * * constructor function : sets specific properties */ - + new XsltForms_class("XsltForms_dialog", "HTMLElement", "xforms-dialog"); - + function XsltForms_dialog(subform, elt) { - var ds = document.getElementsByTagName("xforms-dialog-surround"); - if (ds.length === 0) { - document.body.appendChild(document.createElement("xforms-dialog-surround")); - } - XsltForms_globals.counters.dialog++; - this.init(subform, elt); - this.controlName = "dialog"; - this.binding = elt.hasAttribute("xf-ref") || elt.hasAttribute("xf-bind") ? new XsltForms_binding(subform, elt) : null; - if (this.binding) { - this.hasBinding = true; - } - //this.casebinding = casebinding; + var ds = document.getElementsByTagName("xforms-dialog-surround"); + if (ds.length === 0) { + document.querySelector("xforms-form").appendChild(document.createElement("xforms-dialog-surround")); + } + XsltForms_globals.counters.dialog++; + this.init(subform, elt); + this.controlName = "dialog"; + this.binding = elt.hasAttribute("xf-ref") || elt.hasAttribute("xf-bind") ? new XsltForms_binding(subform, elt) : null; + if (this.binding) { + this.hasBinding = true; + } + //this.casebinding = casebinding; } XsltForms_dialog.prototype = new XsltForms_element(); diff --git a/src/js/xsltforms.js/controls/element.js b/src/js/xsltforms.js/controls/element.js index 7cd18aa..5d938d2 100644 --- a/src/js/xsltforms.js/controls/element.js +++ b/src/js/xsltforms.js/controls/element.js @@ -1,9 +1,7 @@ -/*eslint-env browser*/ -/*globals XsltForms_browser XsltForms_globals XsltForms_xmlevents XsltForms_element XsltForms_class*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module element * @description === "XsltForms_element" class === * Element Class @@ -12,7 +10,7 @@ function XsltForms_element() { } - + /** * * '''init''' method : initializes properties */ @@ -20,171 +18,158 @@ function XsltForms_element() { var XsltForms_element_depsId = 0; XsltForms_element.prototype.init = function(subform, elt) { - this.subform = subform; - this.element = elt; - if (this.element.xfElement) { - if (!(this.element.xfElement instanceof Array)) { - this.element.xfElement = [this.element.xfElement]; - } - this.element.xfElement.push(this); - } else { - this.element.xfElement = this; - } - this.depsElements = []; - this.depsNodesBuild = []; - this.depsNodesRefresh = []; - this.depsIdB = XsltForms_element_depsId++; - this.depsIdR = XsltForms_element_depsId++; - var p = this.element.parentNode; - while (p) { - if (p.varScope) { - for (var v in p.varScope) { - if (!this.varResolver) { - this.varResolver = {}; - } - this.varResolver[v] = p.varScope[v]; - } - } - p = p.parentNode; - } + this.subform = subform; + this.element = elt; + if (this.element.xfElement) { + if (!(this.element.xfElement instanceof Array)) { + this.element.xfElement = [this.element.xfElement]; + } + this.element.xfElement.push(this); + } else { + this.element.xfElement = this; + } + this.depsElements = []; + this.depsNodesBuild = []; + this.depsNodesRefresh = []; + this.depsIdB = XsltForms_element_depsId++; + this.depsIdR = XsltForms_element_depsId++; + const htmlAttrs = {}; + Array.prototype.slice.call(elt.attributes).forEach(attr => { + if (attr.name.startsWith("html-")) { + htmlAttrs[attr.name.substring(5)] = attr.value; + } + }); + this.htmlAttrs = htmlAttrs; }; - + /** * * '''dispose''' method : clears properties of this element */ XsltForms_element.prototype.dispose = function() { - if(this.element) { - this.element.xfElement = null; - this.element.hasXFElement = null; - this.element = null; - } - this.depsElements = null; - if (this.depsNodesBuild) { - for (var i = 0, len = this.depsNodesBuild.length; i < len; i++) { - XsltForms_browser.rmValueMeta(this.depsNodesBuild[i], "depfor", this.depsIdB); - } - } - this.depsNodesBuild = null; - if (this.depsNodesRefresh) { - for (var i2 = 0, len2 = this.depsNodesRefresh.length; i2 < len2; i2++) { - XsltForms_browser.rmValueMeta(this.depsNodesRefresh[i2], "depfor", this.depsIdR); - } - } - this.depsNodesRefresh = null; - for (var key in this) { - if (this.hasOwnProperty(key)) { - this[key] = null; - delete this[key]; - } - } + if(this.element) { + this.element.xfElement = null; + this.element.hasXFElement = null; + this.element = null; + } + this.depsElements = null; + if (this.depsNodesBuild) { + for (var i = 0, len = this.depsNodesBuild.length; i < len; i++) { + XsltForms_browser.rmValueMeta(this.depsNodesBuild[i], "depfor", this.depsIdB); + } + } + this.depsNodesBuild = null; + if (this.depsNodesRefresh) { + for (var i2 = 0, len2 = this.depsNodesRefresh.length; i2 < len2; i2++) { + XsltForms_browser.rmValueMeta(this.depsNodesRefresh[i2], "depfor", this.depsIdR); + } + } + this.depsNodesRefresh = null; + for (var key in this) { + if (this.hasOwnProperty(key)) { + this[key] = null; + delete this[key]; + } + } }; - + /** * * '''build''' method : abstractly builds this element from dependencies */ -XsltForms_element.prototype.build = function(ctx, varresolver) { - if (this.hasBinding) { - var deps = this.depsElements; - var depsN = this.depsNodesBuild; - var depsR = this.depsNodesRefresh; - var build = !XsltForms_globals.ready || (deps.length === 0) || ctx !== this.ctx; - //console.log(this.element.localName + " [" + deps.reduce((s, d) => s + (s === "" ? "" : ", ") + d.element.nodeName, "") + "] [" + depsN.reduce((s, d) => s + (s === "" ? "" : ", ") + d.nodeName, "") + "] [" + depsR.reduce((s, d) => s + (s === "" ? "" : ", ") + (d ? d.nodeName : "undefined"), "") + "] " + build); - var refresh = false; - var changes = XsltForms_globals.changes; - for (var i0 = 0, len0 = depsN.length; !build && i0 < len0; i0++) { - build = depsN[i0].nodeName === ""; - } - for (var i = 0, len = deps.length; !build && i < len; i++) { - var el = deps[i]; - for (var j = 0, len1 = changes.length; !build && j < len1; j++) { - if (el === changes[j]) { - if (el.instances) { //model - if (el.rebuilded || el.newRebuilded) { - build = true; - } else { - for (var k = 0, len2 = depsN.length; !build && k < len2; k++) { - build = XsltForms_browser.inArray(depsN[k], el.nodesChanged); - } - if (!build) { - for (var n = 0, len3 = depsR.length; n < len3; n++) { - refresh = XsltForms_browser.inArray(depsR[n], el.nodesChanged); - } - } - } - } else { - build = true; - } - } - } - } - this.changed = build || refresh; - if (build) { - for (var i4 = 0, len4 = depsN.length; i4 < len4; i4++) { - XsltForms_browser.rmValueMeta(depsN[i4], "depfor", this.depsIdB); - } - depsN.length = 0; - for (var i5 = 0, len5 = depsR.length; i5 < len5; i5++) { - XsltForms_browser.rmValueMeta(depsR[i5], "depfor", this.depsIdR); - } - depsR.length = 0; - deps.length = 0; - this.ctx = ctx; - this.build_(ctx, varresolver); - } - } else { - this.element.node = this.controlName === "item" ? this.element.node || ctx : ctx; - } +XsltForms_element.prototype.build = function(ctx) { + if (this.hasBinding) { + var deps = this.depsElements; + var depsN = this.depsNodesBuild; + var depsR = this.depsNodesRefresh; + var build = !XsltForms_globals.ready || (deps.length === 0) || ctx !== this.ctx; + //console.log(this.element.localName + " [" + deps.reduce((s, d) => s + (s === "" ? "" : ", ") + d.element.nodeName, "") + "] [" + depsN.reduce((s, d) => s + (s === "" ? "" : ", ") + d.nodeName, "") + "] [" + depsR.reduce((s, d) => s + (s === "" ? "" : ", ") + (d ? d.nodeName : "undefined"), "") + "] " + build); + var refresh = false; + var changes = XsltForms_globals.changes; + for (var i0 = 0, len0 = depsN.length; !build && i0 < len0; i0++) { + build = depsN[i0].nodeName === ""; + } + for (var i = 0, len = deps.length; !build && i < len; i++) { + var el = deps[i]; + for (var j = 0, len1 = changes.length; !build && j < len1; j++) { + if (el === changes[j]) { + if (el.instances) { //model + if (el.rebuilded || el.newRebuilded) { + build = true; + } else { + for (var k = 0, len2 = depsN.length; !build && k < len2; k++) { + build = XsltForms_browser.inArray(depsN[k], el.nodesChanged); + } + if (!build) { + for (var n = 0, len3 = depsR.length; n < len3; n++) { + refresh = XsltForms_browser.inArray(depsR[n], el.nodesChanged); + } + } + } + } else { + build = true; + } + } + } + } + this.changed = build || refresh; + if (build) { + for (var i4 = 0, len4 = depsN.length; i4 < len4; i4++) { + XsltForms_browser.rmValueMeta(depsN[i4], "depfor", this.depsIdB); + } + depsN.length = 0; + for (var i5 = 0, len5 = depsR.length; i5 < len5; i5++) { + XsltForms_browser.rmValueMeta(depsR[i5], "depfor", this.depsIdR); + } + depsR.length = 0; + deps.length = 0; + this.ctx = ctx; + this.build_(ctx); + } + } else { + this.element.node = this.controlName === "item" ? this.element.node || ctx : ctx; + } }; - + /** * * '''evaluateBinding''' method : evaluates the spec'ed binding and gathers any errors */ -XsltForms_element.prototype.evaluateBinding = function(binding, ctx, varresolver) { - this.boundnodes = null; - var errmsg = null; - if (binding) { - if (this.varResolver) { - for (var v in this.varResolver) { - if (!varresolver) { - varresolver = {}; - } - varresolver[v] = this.varResolver[v]; - } - } - this.boundnodes = binding.bind_evaluate(this.subform, ctx, varresolver, this.depsNodesBuild, this.depsIdB, this.depsElements); - if (!Fleur.minimal && this.boundnodes.nodeType) { - this.boundnodes = this.boundnodes.toArray(); - } - if (this.boundnodes instanceof Array && this.boundnodes.length !== 0) { - this.element.setAttribute("xf-bound", ""); - } else { - this.element.removeAttribute("xf-bound"); - } - if (this.boundnodes || this.boundnodes === "" || this.boundnodes === 0) { - return this.boundnodes; - } - // A 'null' binding means bind-ID was not found. - errmsg = "non-existent bind-ID("+ binding.bind + ") on element(" + this.element.localName + ")!"; - } else { - errmsg = "no binding defined for element("+ this.element.localName + ")!"; - } - XsltForms_browser.assert(errmsg); - if (XsltForms_globals.building && XsltForms_globals.debugMode) { - // - // Do not fail here, to keep on searching for more errors. - XsltForms_globals.bindErrMsgs.push(errmsg); - XsltForms_xmlevents.dispatch(this.element, "xforms-binding-exception"); - this.nodes = []; - } else { - XsltForms_globals.error(this.element, "xforms-binding-exception", errmsg); - } - return this.boundnodes; +XsltForms_element.prototype.evaluateBinding = function(binding, ctx) { + this.boundnodes = null; + var errmsg = null; + if (binding) { + this.boundnodes = binding.bind_evaluate(this.subform, ctx, this.element, this.depsNodesBuild, this.depsIdB, this.depsElements); + if (!Fleur.minimal && this.boundnodes.nodeType) { + this.boundnodes = this.boundnodes.toArray(); + } + if (this.boundnodes instanceof Array && this.boundnodes.length !== 0) { + this.element.setAttribute("xf-bound", ""); + } else { + this.element.removeAttribute("xf-bound"); + } + if (this.boundnodes || this.boundnodes === "" || this.boundnodes === 0 || this.boundnodes === false) { + return this.boundnodes; + } + // A 'null' binding means bind-ID was not found. + errmsg = "non-existent bind-ID("+ binding.bind + ") on element(" + this.element.localName + ")!"; + } else { + errmsg = "no binding defined for element("+ this.element.localName + ")!"; + } + XsltForms_browser.assert(errmsg); + if (XsltForms_globals.building && XsltForms_globals.debugMode) { + // + // Do not fail here, to keep on searching for more errors. + XsltForms_globals.bindErrMsgs.push(errmsg); + XsltForms_xmlevents.dispatch(this.element, "xforms-binding-exception"); + this.nodes = []; + } else { + XsltForms_globals.error(this.element, "xforms-binding-exception", errmsg); + } + return this.boundnodes; }; \ No newline at end of file diff --git a/src/js/xsltforms.js/controls/group.js b/src/js/xsltforms.js/controls/group.js index a5d0296..5fb3490 100644 --- a/src/js/xsltforms.js/controls/group.js +++ b/src/js/xsltforms.js/controls/group.js @@ -1,132 +1,130 @@ -/*eslint-env browser*/ -/*globals XsltForms_element XsltForms_globals XsltForms_browser XsltForms_toggle XsltForms_class XsltForms_binding XsltForms_subform*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module group * @description === "XsltForms_group" class === * Group Element Class * * constructor function : sets specific properties */ - + new XsltForms_class("XsltForms_group", "HTMLElement", "xforms-group", ""); new XsltForms_class("XsltForms_group", "HTMLElement", "xforms-switch"); XsltForms_browser.addLoadListener(new Function( - "Array.prototype.slice.call(document.querySelectorAll('*[xforms-name=\"group\"]')).forEach(function(elt) { if (!elt.xfElement) { elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); elt.xfElement = new XsltForms_group(XsltForms_subform.subforms['xsltforms-mainform'], elt); } });" + "Array.prototype.slice.call(document.querySelectorAll('*[xforms-name=\"group\"]')).forEach(function(elt) { if (!elt.xfElement) { elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); elt.xfElement = new XsltForms_group(XsltForms_subform.subforms['xsltforms-mainform'], elt); } });" )); - + function XsltForms_group(subform, elt) { - this.init(subform, elt); - var binding = elt.hasAttribute("xf-ref") || elt.hasAttribute("xf-bind") ? new XsltForms_binding(subform, elt) : null; - XsltForms_globals.counters.group++; - this.init(subform, elt); - this.controlName = "group"; - if (elt.localName.toLowerCase() === "xforms-switch") { - var cells = Array.prototype.slice.call(this.element.children || this.element.childNodes); - for (var i = 0, l = cells.length; i < l; i++) { - var selected = cells[i].getAttribute("xf-selected"); - if (selected === "true") { - break; - } - } - if (i === l) { - cells[0].setAttribute("xf-selected", "true"); - } - } - if (binding) { - this.hasBinding = true; - this.binding = binding; - //} else { - // XsltForms_browser.setClass(this.element, "xforms-enabled", true); - } - this.casebinding = elt.hasAttribute("xf-caseref") ? new XsltForms_binding(subform, elt) : null; + this.init(subform, elt); + var binding = elt.hasAttribute("xf-ref") || elt.hasAttribute("xf-bind") ? new XsltForms_binding(subform, elt) : null; + XsltForms_globals.counters.group++; + this.init(subform, elt); + this.controlName = "group"; + if (elt.localName.toLowerCase() === "xforms-switch") { + var cells = Array.prototype.slice.call(this.element.children || this.element.childNodes); + for (var i = 0, l = cells.length; i < l; i++) { + var selected = cells[i].getAttribute("xf-selected"); + if (selected === "true") { + break; + } + } + if (i === l) { + cells[0].setAttribute("xf-selected", "true"); + } + } + if (binding) { + this.hasBinding = true; + this.binding = binding; + //} else { + // XsltForms_browser.setClass(this.element, "xforms-enabled", true); + } + this.casebinding = elt.hasAttribute("xf-caseref") ? new XsltForms_binding(subform, elt) : null; } XsltForms_group.prototype = new XsltForms_element(); - + /** * * '''dispose''' method : decrements the number of groups and calls the parent dispose() method */ XsltForms_group.prototype.dispose = function() { - XsltForms_globals.counters.group--; - XsltForms_element.prototype.dispose.call(this); + XsltForms_globals.counters.group--; + XsltForms_element.prototype.dispose.call(this); }; - + /** * * '''clone''' method : creates a new group with the given id */ XsltForms_group.prototype.clone = function(id) { - return new XsltForms_group(this.subform, id, this.binding, this.casebinding); + return new XsltForms_group(this.subform, id, this.binding, this.casebinding); }; - + /** * * '''build_''' method : specific build method */ XsltForms_group.prototype.build_ = function(ctx) { - var node = this.evaluateBinding(this.binding, ctx).head(); - this.element.node = node; - this.depsNodesRefresh.push(node); - if (this.casebinding) { - var caseref = this.evaluateBinding(this.casebinding, node); - if (caseref) { - XsltForms_toggle.toggle(XsltForms_globals.stringValue(caseref)); - } - } + var node = this.evaluateBinding(this.binding, ctx).head(); + this.element.node = node; + this.depsNodesRefresh.push(node); + if (this.casebinding) { + var caseref = this.evaluateBinding(this.casebinding, node); + if (caseref) { + XsltForms_toggle.toggle(XsltForms_globals.stringValue(caseref)); + } + } }; - + /** * * '''refresh''' method : sets "xforms-disabled" CSS class */ XsltForms_group.prototype.refresh = function() { - var element = this.element; - var disabled = !element.node || XsltForms_browser.getBoolMeta(element.node, "notrelevant"); - if (disabled) { - this.element.setAttribute("xf-notrelevant", ""); - } else { - this.element.removeAttribute("xf-notrelevant"); - } - //XsltForms_browser.setClass(element, "xforms-disabled", disabled); - //var ul = element.parentNode.children ? element.parentNode.children[0] : element.parentNode.childNodes[0]; - //if (ul.nodeName.toLowerCase() === "ul") { - // var childs = element.parentNode.children || element.parentNode.childNodes; - // var tab; - // for (var i = 1, len = childs.length; i < len; i++) { - // if (childs[i] === element) { - // tab = ul.childNodes[i - 1]; - // } - // } - // XsltForms_browser.setClass(tab, "xforms-disabled", disabled); - //} + var element = this.element; + var disabled = !element.node || XsltForms_browser.getBoolMeta(element.node, "notrelevant"); + if (disabled) { + this.element.setAttribute("xf-notrelevant", ""); + } else { + this.element.removeAttribute("xf-notrelevant"); + } + //XsltForms_browser.setClass(element, "xforms-disabled", disabled); + //var ul = element.parentNode.children ? element.parentNode.children[0] : element.parentNode.childNodes[0]; + //if (ul.nodeName.toLowerCase() === "ul") { + // var childs = element.parentNode.children || element.parentNode.childNodes; + // var tab; + // for (var i = 1, len = childs.length; i < len; i++) { + // if (childs[i] === element) { + // tab = ul.childNodes[i - 1]; + // } + // } + // XsltForms_browser.setClass(tab, "xforms-disabled", disabled); + //} }; - + /** * * '''collapse''' method : expands/collapses group content */ XsltForms_group.prototype.collapse = function() { - var label = this.element.children[0]; - var content = this.element.children[1]; - if (XsltForms_browser.hasClass(label, "xforms-group-label-collapsed")) { - XsltForms_browser.setClass(label, "xforms-group-label-collapsed", false); - XsltForms_browser.setClass(label, "xforms-group-label-expanded", true); - XsltForms_browser.setClass(content, "xforms-disabled", false); - } else { - XsltForms_browser.setClass(label, "xforms-group-label-collapsed", true); - XsltForms_browser.setClass(label, "xforms-group-label-expanded", false); - XsltForms_browser.setClass(content, "xforms-disabled", true); - } + var label = this.element.children[0]; + var content = this.element.children[1]; + if (XsltForms_browser.hasClass(label, "xforms-group-label-collapsed")) { + XsltForms_browser.setClass(label, "xforms-group-label-collapsed", false); + XsltForms_browser.setClass(label, "xforms-group-label-expanded", true); + XsltForms_browser.setClass(content, "xforms-disabled", false); + } else { + XsltForms_browser.setClass(label, "xforms-group-label-collapsed", true); + XsltForms_browser.setClass(label, "xforms-group-label-expanded", false); + XsltForms_browser.setClass(content, "xforms-disabled", true); + } }; diff --git a/src/js/xsltforms.js/controls/include.js b/src/js/xsltforms.js/controls/include.js index 0d65a78..45c4a71 100644 --- a/src/js/xsltforms.js/controls/include.js +++ b/src/js/xsltforms.js/controls/include.js @@ -1,63 +1,61 @@ -/*eslint-env browser*/ -/*globals XsltForms_element XsltForms_class XsltForms_browser XsltForms_globals XsltForms_classes XsltForms_collection XsltForms_avt*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module group * @description === "XsltForms_dialog" class === * Dialog Element Class * * constructor function : sets specific properties */ - + new XsltForms_class("XsltForms_include", "HTMLElement", "xforms-include"); - + function XsltForms_include(subform, elt) { - this.init(subform, elt); - var href = elt.getAttribute("xf-src"); - var req = null; - var method = "get"; - try { - req = XsltForms_browser.openRequest(method, href, false); - XsltForms_browser.debugConsole.write("Include " + href); - req.send(null); - if (req.status !== 0 && (req.status < 200 || req.status >= 300)) { + this.init(subform, elt); + var href = elt.getAttribute("xf-src"); + var req = null; + var method = "get"; + try { + req = XsltForms_browser.openRequest(method, href, false); + XsltForms_browser.debugConsole.write("Include " + href); + req.send(null); + if (req.status !== 0 && (req.status < 200 || req.status >= 300)) { - return; - } - var resp = req.responseText; - var piindex = resp.indexOf("")).replace(/^.*href=\"([^\"]*)\".*$/, "$1"); - resp = XsltForms_browser.transformText(resp, xslhref, false); - piindex = resp.indexOf(""); - var subbody; - if (sp.length === 1) { - subbody = resp; - } else { - subbody = sp[1]; - } - elt.innerHTML = subbody; - for (var xcname in XsltForms_classes) { - if (XsltForms_classes.hasOwnProperty(xcname)) { - Array.prototype.slice.call(elt.getElementsByTagName(xcname)).forEach(function(elt2) { XsltForms_classes[elt2.localName].classbinding(subform, elt2); }); - } - } - Array.prototype.slice.call(elt.querySelectorAll('*[xf-avt]')).forEach(function(elt2) { - if (!elt2.xfElement) { - elt2.xfIndex = XsltForms_collection.length; - XsltForms_collection.push(elt2); - Array.prototype.slice.call(elt2.attributes).filter(function(a) { - return a.nodeName.startsWith('xf-template-'); - }).forEach(function(a) { - new XsltForms_avt(subform, elt2, a.nodeName.substr(12)); - }); - } - }); - } catch(e2) { - } + return; + } + var resp = req.responseText; + var piindex = resp.indexOf("")).replace(/^.*href=\"([^\"]*)\".*$/, "$1"); + resp = XsltForms_browser.transformText(resp, xslhref, false); + piindex = resp.indexOf("") + 1), "")[0]; + } + elt.innerHTML = subbody; + for (var xcname in XsltForms_classes) { + if (XsltForms_classes.hasOwnProperty(xcname)) { + Array.prototype.slice.call(elt.getElementsByTagName(xcname)).forEach(function(elt2) { XsltForms_classes[elt2.localName].classbinding(subform, elt2); }); + } + } + Array.prototype.slice.call(elt.querySelectorAll('*[xf-avt]')).forEach(function(elt2) { + if (!elt2.xfElement) { + elt2.xfIndex = XsltForms_collection.length; + XsltForms_collection.push(elt2); + Array.prototype.slice.call(elt2.attributes).filter(function(a) { + return a.nodeName.startsWith('xf-template-'); + }).forEach(function(a) { + new XsltForms_avt(subform, elt2, a.nodeName.substr(12)); + }); + } + }); + } catch(e2) { + } } XsltForms_include.prototype = new XsltForms_element(); diff --git a/src/js/xsltforms.js/controls/input.js b/src/js/xsltforms.js/controls/input.js index 6957784..f351b86 100644 --- a/src/js/xsltforms.js/controls/input.js +++ b/src/js/xsltforms.js/controls/input.js @@ -1,611 +1,626 @@ -/*eslint-env browser*/ -/*globals XsltForms_globals XsltForms_browser XsltForms_control tinyMCE XsltForms_schema CKEDITOR Fleur tinymce XsltForms_xmlevents XsltForms_calendar XsltForms_subform XsltForms_binding XsltForms_class*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module input * @description === "XsltForms_input" class === * Input Control Class * * constructor function : initializes specific properties including aid button management */ - + new XsltForms_class("XsltForms_input", "HTMLElement", "xforms-input", ""); new XsltForms_class("XsltForms_input", "HTMLElement", "xforms-secret", ""); new XsltForms_class("XsltForms_input", "HTMLElement", "xforms-textarea", ""); - + function XsltForms_input(subform, elt, clone) { - XsltForms_globals.counters.input++; - this.init(subform, elt); - this.controlName = "input"; - this.binding = new XsltForms_binding(subform, elt); - this.inputmode = XsltForms_input.InputMode[elt.getAttribute("xf-inputmode")]; - this.incremental = elt.getAttribute("xf-incremental") === "true"; - this.delay = elt.getAttribute("xf-delay"); - this.timer = null; - var cells = this.element.children; - for (var i = 0, l = cells.length; i < l; i++) { - var cname = cells[i].localName.toLowerCase(); - if (cname === "xforms-body") { - this.cell = cells[i]; - } else if (cname === "xforms-hint" && cells[i].getAttribute("xf-appearance") === "minimal") { - elt.setAttribute("title", cells[i].textContent); - } - } - this.isClone = clone; - this.hasBinding = true; - this.itype = elt.localName.toLowerCase().substr(7); - this.mediatype = elt.getAttribute("xf-mediatype"); - //this.initFocus(this.cell.children[0], true); + this.name = "i" + String(XsltForms_globals.counters.input++); + this.init(subform, elt); + this.controlName = "input"; + this.binding = new XsltForms_binding(subform, elt); + this.inputmode = XsltForms_input.InputMode[elt.getAttribute("xf-inputmode")]; + this.incremental = elt.getAttribute("xf-incremental") === "true"; + this.delay = elt.getAttribute("xf-delay"); + this.autocomplete = elt.getAttribute("autocomplete"); + if (this.autocomplete) { + const autos = this.autocomplete.split(" "); + if (autos.includes("username")) { + XsltForms_globals.hasusername = true; + } + if (autos.includes("current-password") || autos.includes("new-password")) { + XsltForms_globals.haspassword = true; + } + } + this.timer = null; + var cells = this.element.children; + for (var i = 0, l = cells.length; i < l; i++) { + var cname = cells[i].localName.toLowerCase(); + if (cname === "xforms-body") { + this.cell = cells[i]; + } else if (cname === "xforms-hint" && cells[i].getAttribute("xf-appearance") === "minimal") { + elt.setAttribute("title", cells[i].textContent); + } + } + this.isClone = clone; + this.hasBinding = true; + this.itype = elt.localName.toLowerCase().substr(7); + this.mediatype = elt.getAttribute("xf-mediatype"); + //this.initFocus(this.cell.children[0], true); } XsltForms_input.prototype = new XsltForms_control(); - + /** * * '''clone''' method : creates a new input with the given id */ XsltForms_input.prototype.clone = function(id) { - return new XsltForms_input(this.subform, id, this.valoff, this.itype, this.binding, this.inputmode, this.incremental, this.delay, this.mediatype, this.bolAidButton, true); + return new XsltForms_input(this.subform, id, this.valoff, this.itype, this.binding, this.inputmode, this.incremental, this.delay, this.mediatype, this.bolAidButton, true); }; - + /** * * '''dispose''' method : clears properties of this element and calls the parent dispose() method */ XsltForms_input.prototype.dispose = function() { - if (this.mediatype === "application/xhtml+xml" && this.type.rte) { - switch(this.type.rte.toLowerCase()) { - case "tinymce": - try { - if (XsltForms_globals.jslibraries["http://www.tinymce.com"].substr(0, 2) === "3.") { - tinyMCE.execCommand("mceFocus", false, this.cell.children[0].id); - tinyMCE.execCommand("mceRemoveControl", false, this.cell.children[0].id); - } else { - tinyMCE.editors[this.cell.children[1].id].remove(); - } - } catch(e) { - //alert(e); - } - break; - case "ckeditor": - if (this.rte) { - this.rte.destroy(); - this.rte = null; - } - } - } - this.cell = null; - this.calendarButton = null; - XsltForms_globals.counters.input--; - XsltForms_control.prototype.dispose.call(this); + if (this.mediatype === "application/xhtml+xml" && this.type.rte) { + switch(this.type.rte.toLowerCase()) { + case "tinymce": + try { + if (XsltForms_globals.jslibraries["http://www.tinymce.com"].substr(0, 2) === "3.") { + tinyMCE.execCommand("mceFocus", false, this.cell.children[0].id); + tinyMCE.execCommand("mceRemoveControl", false, this.cell.children[0].id); + } else { + tinyMCE.editors[this.cell.children[1].id].remove(); + } + } catch(e) { + //alert(e); + } + break; + case "ckeditor": + if (this.rte) { + this.rte.destroy(); + this.rte = null; + } + } + } + this.cell = null; + this.calendarButton = null; + XsltForms_globals.counters.input--; + XsltForms_control.prototype.dispose.call(this); }; - + /** * * '''initBody''' method : initializes the input control body according to its type (password/textarea/boolean/date/datetime) */ XsltForms_input.prototype.initBody = function(type) { - var cell = this.cell; - var input = cell.children[0]; - var tclass = type["class"]; - var initinfo = {}; - if (!input || type !== this.type) { - var inputid = input ? input.id : ""; - this.type = type; - if (tclass === "boolean" || !input || this.itype !== input.type) { - while (cell.firstChild) { - cell.removeChild(cell.firstChild); - } - } else { - while (cell.firstChild.nodeType === Fleur.Node.TEXT_NODE) { - cell.removeChild(cell.firstChild); - } - for (var i = cell.childNodes.length - 1; i >= 1; i--) { - cell.removeChild(cell.childNodes[i]); - } - } - if (tclass === "boolean") { - input = XsltForms_browser.createElement("input"); - input.type = "checkbox"; - if (inputid !== "") { - input.id = inputid; - } - cell.appendChild(input); - } else { - if(!input || this.itype !== input.type) { - input = XsltForms_browser.createElement(this.element.localName.toLowerCase() === "xforms-textarea" ? "textarea" : "input", cell); - if (this.element.localName.toLowerCase() === "xforms-secret") { - input.setAttribute("type", "password"); - } - } - if (inputid !== "") { - input.id = inputid; - } - this.initEvents(input, (this.itype === "input" || this.itype === "secret")); - if (tclass === "time") { - if (XsltForms_globals.htmlversion === "5" && (XsltForms_browser.isChrome || XsltForms_browser.isOpera || XsltForms_browser.isEdge)) { - input.type = "time"; - } - } else if (tclass === "date" || tclass === "datetime") { - if (XsltForms_globals.htmlversion === "5" && (XsltForms_browser.isChrome || XsltForms_browser.isOpera || XsltForms_browser.isSafari)) { - if (tclass === "date") { - input.type = "date"; - } else if (tclass === "datetime"){ - input.type = "datetime-local"; - } - } else { - this.calendarButton = XsltForms_browser.createElement("button", cell, XsltForms_browser.selectSingleNode("calendar.label", XsltForms_browser.config) ? XsltForms_browser.i18n.get("calendar.label") : "...", "xsltforms-aid-button"); - this.calendarButton.setAttribute("type", "button"); - this.initFocus(this.calendarButton); - } - } else if (tclass === "number"){ - if (XsltForms_globals.htmlversion === "5" && (XsltForms_browser.isChrome || XsltForms_browser.isOpera || XsltForms_browser.isSafari)) { - input.type = "number"; - if (typeof type.fractionDigits === "number") { - input.step = String(Math.pow(1, -parseInt(type.fractionDigits, 10))); - } else { - input.step = "any"; - } - } - input.setAttribute("xf-numeric", ""); - //input.style.textAlign = "right"; - } else { - input.removeAttribute("xf-numeric"); - //input.style.textAlign = "left"; - } - var max = type.getMaxLength(); - if (max) { - input.maxLength = max; - } else { - input.removeAttribute("maxLength"); - } - var tlength = type.getDisplayLength(); - if (tlength) { - input.size = tlength; - } else { - input.removeAttribute("size"); - } - } - } - this.input = input; - if (input && input.type === "secret") { - this.type = XsltForms_schema.getType("xsd_:string"); - this.initEvents(input, true); - } else if (input && input.nodeName.toLowerCase() === "textarea") { - this.type = type; - if (this.mediatype === "application/xhtml+xml" && type.rte) { - switch(type.rte.toLowerCase()) { - case "tinymce": - input.id = "xsltforms_" + String(this.element.xfIndex) + "_textarea"; - XsltForms_browser.debugConsole.write(input.id+": init="+XsltForms_globals.tinyMCEinit); - if (!XsltForms_globals.tinyMCEinit || XsltForms_globals.jslibraries["http://www.tinymce.com"].substr(0, 2) !== "3.") { - eval("initinfo = " + (type.appinfo ? type.appinfo.replace(/(\r\n|\n|\r)/gm, " ") : "{}")); - initinfo.mode = "none"; - initinfo.Xsltforms_usersetup = initinfo.setup || function() {}; - if (!XsltForms_globals.jslibraries["http://www.tinymce.com"] || XsltForms_globals.jslibraries["http://www.tinymce.com"].substr(0, 2) === "3.") { - initinfo.setup = function(ed) { - initinfo.Xsltforms_usersetup(ed); - ed.onKeyUp.add(function(ed) { - XsltForms_control.getXFElement(document.getElementById(ed.id)).valueChanged(ed.getContent() || ""); - }); - ed.onChange.add(function(ed) { - XsltForms_control.getXFElement(document.getElementById(ed.id)).valueChanged(ed.getContent() || ""); - }); - ed.onUndo.add(function(ed) { - XsltForms_control.getXFElement(document.getElementById(ed.id)).valueChanged(ed.getContent() || ""); - }); - ed.onRedo.add(function(ed) { - XsltForms_control.getXFElement(document.getElementById(ed.id)).valueChanged(ed.getContent() || ""); - }); - }; - } else { - initinfo.setup = function(ed) { - initinfo.Xsltforms_usersetup(ed); - ed.on("KeyUp", function() { - XsltForms_control.getXFElement(document.getElementById(this.id)).valueChanged(this.getContent() || ""); - }); - ed.on("Change", function(ed) { - XsltForms_control.getXFElement(document.getElementById(this.id)).valueChanged(ed.target.getContent() || ""); - }); - ed.on("Undo", function(ed) { - XsltForms_control.getXFElement(document.getElementById(this.id)).valueChanged(ed.target.getContent() || ""); - }); - ed.on("Redo", function(ed) { - XsltForms_control.getXFElement(document.getElementById(this.id)).valueChanged(ed.target.getContent() || ""); - }); - }; - initinfo.selector = "#" + input.id; - } - XsltForms_browser.debugConsole.write(input.id+": initinfo="+initinfo); - tinyMCE.init(initinfo); - XsltForms_globals.tinyMCEinit = true; - } - tinyMCE.execCommand("mceAddEditor", true, input.id); - //this.editor = new tinymce.Editor(input.id, initinfo, tinymce.EditorManager); - break; - case "ckeditor": - input.id = "xsltforms_" + String(this.element.xfIndex) + "_textarea"; - if (!CKEDITOR.replace) { - alert("CKEditor is not compatible with XHTML mode."); - } - initinfo = ""; - eval("initinfo = " + (type.appinfo ? type.appinfo.replace(/(\r\n|\n|\r)/gm, " ") : "{}")); - this.rte = CKEDITOR.replace(input.id, initinfo); - var eltRefresh = function(evt) { - var data = evt.editor.getData(); - if (data.substr(data.length - 1) === "\n") { - data = data.substr(0, data.length - 1); - } - var ctl = XsltForms_control.getXFElement(document.getElementById(evt.editor.name)); - XsltForms_browser.setBoolMeta(ctl.element.node, "unsafe", evt.editor.mode === "source"); - ctl.valueChanged(data || "", true); - }; - this.rte.on("change", eltRefresh); - this.rte.on("blur", eltRefresh); - this.rte.on("mode", eltRefresh); - } - } - this.initEvents(input, false); - } - this.initFocus(input, true); - this.input = input; + var cell = this.cell; + var input = cell.children[0]; + var tclass = type["class"]; + var initinfo = {}; + if (!input || type !== this.type) { + var inputid = input ? input.id : ""; + this.type = type; + if (tclass === "boolean" || !input || this.itype !== input.type) { + while (cell.firstChild) { + cell.removeChild(cell.firstChild); + } + } else { + while (cell.firstChild.nodeType === Fleur.Node.TEXT_NODE) { + cell.removeChild(cell.firstChild); + } + for (var i = cell.childNodes.length - 1; i >= 1; i--) { + cell.removeChild(cell.childNodes[i]); + } + } + if (tclass === "boolean") { + input = XsltForms_browser.createElement("input"); + input.type = "checkbox"; + if (inputid !== "") { + input.id = inputid; + } + cell.appendChild(input); + } else { + if(!input || this.itype !== input.type) { + input = XsltForms_browser.createElement(this.element.localName.toLowerCase() === "xforms-textarea" ? "textarea" : "input", cell); + if (this.element.localName.toLowerCase() === "xforms-secret") { + input.setAttribute("type", "password"); + } + } + if (inputid !== "") { + input.id = inputid; + } + this.initEvents(input, (this.itype === "input" || this.itype === "secret")); + if (tclass === "time") { + if (XsltForms_globals.htmlversion === "5" && (XsltForms_browser.isChrome || XsltForms_browser.isOpera || XsltForms_browser.isEdge)) { + input.type = "time"; + } + } else if (tclass === "date" || tclass === "datetime") { + if (XsltForms_globals.htmlversion === "5" && (XsltForms_browser.isChrome || XsltForms_browser.isOpera || XsltForms_browser.isSafari)) { + if (tclass === "date") { + input.type = "date"; + } else if (tclass === "datetime"){ + input.type = "datetime-local"; + } + } else { + this.calendarButton = XsltForms_browser.createElement("button", cell, XsltForms_browser.selectSingleNode("calendar.label", XsltForms_browser.config) ? XsltForms_browser.i18n.get("calendar.label") : "...", "xsltforms-aid-button"); + this.calendarButton.setAttribute("type", "button"); + this.initFocus(this.calendarButton); + } + } else if (tclass === "number"){ + if (XsltForms_globals.htmlversion === "5" && (XsltForms_browser.isChrome || XsltForms_browser.isOpera || XsltForms_browser.isSafari)) { + input.type = "number"; + if (typeof type.fractionDigits === "number") { + input.step = String(Math.pow(1, -parseInt(type.fractionDigits, 10))); + } else { + input.step = "any"; + } + } + input.setAttribute("xf-numeric", ""); + //input.style.textAlign = "right"; + } else { + input.removeAttribute("xf-numeric"); + //input.style.textAlign = "left"; + } + var max = type.getMaxLength(); + if (max) { + input.maxLength = max; + } else { + input.removeAttribute("maxLength"); + } + var tlength = type.getDisplayLength(); + if (tlength) { + input.size = tlength; + } else { + input.removeAttribute("size"); + } + } + } + for (const xattr in this.htmlAttrs) { + if (this.htmlAttrs.hasOwnProperty(xattr)) { + input.setAttribute(xattr, this.htmlAttrs[xattr]); + } + } + input.name = this.name; + this.input = input; + if (input && input.type === "secret") { + this.type = XsltForms_schema.getType("xsd_:string"); + this.initEvents(input, true); + } else if (input && input.nodeName.toLowerCase() === "textarea") { + this.type = type; + if (this.mediatype === "application/xhtml+xml" && type.rte) { + switch(type.rte.toLowerCase()) { + case "tinymce": + input.id = "xsltforms_" + String(this.element.xfIndex) + "_textarea"; + XsltForms_browser.debugConsole.write(input.id+": init="+XsltForms_globals.tinyMCEinit); + if (!XsltForms_globals.tinyMCEinit || XsltForms_globals.jslibraries["http://www.tinymce.com"].substr(0, 2) !== "3.") { + initinfo = type.appinfo ? eval("Object.create(" + type.appinfo.replace(/(\r\n|\n|\r)/gm, " ") + ")") : {}; + initinfo.mode = "none"; + initinfo.Xsltforms_usersetup = initinfo.setup || function() {}; + if (!XsltForms_globals.jslibraries["http://www.tinymce.com"] || XsltForms_globals.jslibraries["http://www.tinymce.com"].substr(0, 2) === "3.") { + initinfo.setup = function(ed) { + initinfo.Xsltforms_usersetup(ed); + ed.onKeyUp.add(function(ed) { + XsltForms_control.getXFElement(document.getElementById(ed.id)).valueChanged(ed.getContent() || ""); + }); + ed.onChange.add(function(ed) { + XsltForms_control.getXFElement(document.getElementById(ed.id)).valueChanged(ed.getContent() || ""); + }); + ed.onUndo.add(function(ed) { + XsltForms_control.getXFElement(document.getElementById(ed.id)).valueChanged(ed.getContent() || ""); + }); + ed.onRedo.add(function(ed) { + XsltForms_control.getXFElement(document.getElementById(ed.id)).valueChanged(ed.getContent() || ""); + }); + }; + } else { + initinfo.setup = function(ed) { + initinfo.Xsltforms_usersetup(ed); + ed.on("KeyUp", function() { + XsltForms_control.getXFElement(document.getElementById(this.id)).valueChanged(this.getContent() || ""); + }); + ed.on("Change", function(ed) { + XsltForms_control.getXFElement(document.getElementById(this.id)).valueChanged(ed.target.getContent() || ""); + }); + ed.on("Undo", function(ed) { + XsltForms_control.getXFElement(document.getElementById(this.id)).valueChanged(ed.target.getContent() || ""); + }); + ed.on("Redo", function(ed) { + XsltForms_control.getXFElement(document.getElementById(this.id)).valueChanged(ed.target.getContent() || ""); + }); + }; + initinfo.selector = "#" + input.id; + } + XsltForms_browser.debugConsole.write(input.id+": initinfo="+initinfo); + tinyMCE.init(initinfo); + XsltForms_globals.tinyMCEinit = true; + } + tinyMCE.execCommand("mceAddEditor", true, input.id); + //this.editor = new tinymce.Editor(input.id, initinfo, tinymce.EditorManager); + break; + case "ckeditor": + input.id = "xsltforms_" + String(this.element.xfIndex) + "_textarea"; + if (!CKEDITOR.replace) { + alert("CKEditor is not compatible with XHTML mode."); + } + initinfo = type.appinfo ? eval("Object.create(" + type.appinfo.replace(/(\r\n|\n|\r)/gm, " ") + ")") : {}; + this.rte = CKEDITOR.replace(input.id, initinfo); + var eltRefresh = function(evt) { + var data = evt.editor.getData(); + if (data.substr(data.length - 1) === "\n") { + data = data.substr(0, data.length - 1); + } + var ctl = XsltForms_control.getXFElement(document.getElementById(evt.editor.name)); + XsltForms_browser.setBoolMeta(ctl.element.node, "unsafe", evt.editor.mode === "source"); + ctl.valueChanged(data || "", true); + }; + this.rte.on("change", eltRefresh); + this.rte.on("blur", eltRefresh); + this.rte.on("mode", eltRefresh); + } + } + this.initEvents(input, false); + } + this.initFocus(input, true); + this.input = input; }; - + /** * * '''setValue''' method : sets the value of this input control according to its type */ XsltForms_input.prototype.setValue = function(value) { - var newvalue; - var node = this.element.node; - var type = node ? XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string") : XsltForms_schema.getType("xsd_:string"); - if (!this.input || type !== this.type) { - this.initBody(type); - this.changeReadonly(); - } -// XsltForms_browser.debugConsole.write(this.input.id+": setValue("+value+")"); -// if (this.type.rte && this.type.rte.toLowerCase() === "tinymce" && tinymce.get(this.input.id) === undefined) { -// XsltForms_browser.debugConsole.write(this.input.id+" is undefined"); -// } - if (type["class"] === "boolean") { - this.input.checked = value === "true"; - } else if (this.type.rte && this.type.rte.toLowerCase() === "tinymce" && tinymce.get(this.input.id)) { - //var v3 = !XsltForms_globals.jslibraries["http://www.tinymce.com"] || XsltForms_globals.jslibraries["http://www.tinymce.com"].substr(0, 2) === "3."; - try { - var editor = tinymce.get(this.input.id); - var prevalue = editor.getContent ? editor.getContent() : editor.contentDocument.body.innerHTML; - if (prevalue !== value) { - this.input.value = value || ""; - editor.setContent(value); - newvalue = editor.contentDocument ? editor.contentDocument.body.innerHTML : editor.getContent(); - this.input.value = newvalue || ""; - XsltForms_browser.debugConsole.write(this.input.id+": getContent() ="+newvalue); - XsltForms_browser.debugConsole.write(this.input.id+".value ="+this.input.value); - } - } catch (e) { - this.input.value = value; - } - } else if (this.type.rte && this.type.rte.toLowerCase() === "ckeditor" && this.rte) { - var data = this.rte.getData(); - if (data.substr(data.length - 1) === "\n") { - data = data.substr(0, data.length - 1); - } - if (data !== value) { - XsltForms_browser.debugConsole.write("value = '"+value+"'"); - XsltForms_browser.debugConsole.write(this.input.id+": getData() = '"+this.rte.getData()+"'"); - XsltForms_browser.debugConsole.write(this.input.id+".value = '"+this.input.value+"'"); - this.input.value = value || ""; - this.rte.setData(value); - //this.input.value = this.rte.getData() || ""; - } - } else if (this.input.type.substr(0, 4) === "date") { - if (this.input.value !== XsltForms_browser.getValue(node).substr(0, 15)) { - this.input.value = XsltForms_browser.getValue(node).substr(0, 15); - } - } else { - var inputvalue = this.input.value; - newvalue = value; - if (type.parse) { - if (inputvalue && inputvalue.length > 0) { - try { inputvalue = type.parse(inputvalue); } catch(e) { } - } - if (newvalue && newvalue.length > 0) { - try { newvalue = type.parse(newvalue); } catch(e) { } - } - } - if (this.input.type === "time" || this.input.type === "date" || this.input.type === "datetime-local") { - if (inputvalue !== newvalue) { // && this !== XsltForms_globals.focus) { - this.input.value = newvalue; - } - } else if (inputvalue !== value) { - this.input.value = value || ""; - } - } + var newvalue; + var node = this.element.node; + var type = node ? XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string") : XsltForms_schema.getType("xsd_:string"); + if (!this.input || type !== this.type) { + this.initBody(type); + this.changeReadonly(); + } +// XsltForms_browser.debugConsole.write(this.input.id+": setValue("+value+")"); +// if (this.type.rte && this.type.rte.toLowerCase() === "tinymce" && tinymce.get(this.input.id) === undefined) { +// XsltForms_browser.debugConsole.write(this.input.id+" is undefined"); +// } + if (type["class"] === "boolean") { + this.input.checked = value === "true"; + } else if (this.type.rte && this.type.rte.toLowerCase() === "tinymce" && tinymce.get(this.input.id)) { + //var v3 = !XsltForms_globals.jslibraries["http://www.tinymce.com"] || XsltForms_globals.jslibraries["http://www.tinymce.com"].substr(0, 2) === "3."; + try { + var editor = tinymce.get(this.input.id); + var prevalue = editor.getContent ? editor.getContent() : editor.contentDocument.body.innerHTML; + if (prevalue !== value) { + this.input.value = value || ""; + editor.setContent(value); + newvalue = editor.contentDocument ? editor.contentDocument.body.innerHTML : editor.getContent(); + this.input.value = newvalue || ""; + XsltForms_browser.debugConsole.write(this.input.id+": getContent() ="+newvalue); + XsltForms_browser.debugConsole.write(this.input.id+".value ="+this.input.value); + } + } catch (e) { + this.input.value = value; + } + } else if (this.type.rte && this.type.rte.toLowerCase() === "ckeditor" && this.rte) { + var data = this.rte.getData(); + if (data.substr(data.length - 1) === "\n") { + data = data.substr(0, data.length - 1); + } + if (data !== value) { + XsltForms_browser.debugConsole.write("value = '"+value+"'"); + XsltForms_browser.debugConsole.write(this.input.id+": getData() = '"+this.rte.getData()+"'"); + XsltForms_browser.debugConsole.write(this.input.id+".value = '"+this.input.value+"'"); + this.input.value = value || ""; + this.rte.setData(value); + //this.input.value = this.rte.getData() || ""; + } + } else if (this.input.type.substr(0, 4) === "date") { + if (this.input.value !== XsltForms_browser.getValue(node).substr(0, 15)) { + this.input.value = XsltForms_browser.getValue(node).substr(0, 15); + } + } else { + var inputvalue = this.input.value; + newvalue = value; + if (type.parse) { + if (inputvalue && inputvalue.length > 0) { + try { inputvalue = type.parse(inputvalue); } catch(e) { } + } + if (newvalue && newvalue.length > 0) { + try { newvalue = type.parse(newvalue); } catch(e) { } + } + } + if (this.input.type === "time" || this.input.type === "date" || this.input.type === "datetime-local") { + if (inputvalue !== newvalue) { // && this !== XsltForms_globals.focus) { + this.input.value = newvalue; + } + } else if (inputvalue !== value) { + this.input.value = value || ""; + } + } }; - + /** * * '''changeReadonly''' method : changes the read only state of this input control */ XsltForms_input.prototype.changeReadonly = function() { - var node = this.element.node; - var type = node ? XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string") : XsltForms_schema.getType("xsd_:string"); - if (this.input) { - if (type["class"] === "boolean") { - this.input.disabled = this.readonly; - } - this.input.readOnly = this.readonly; - if (this.calendarButton) { - this.calendarButton.style.display = this.readonly ? "none" : ""; - } - } + var node = this.element.node; + var type = node ? XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string") : XsltForms_schema.getType("xsd_:string"); + if (this.input) { + if (type["class"] === "boolean") { + this.input.disabled = this.readonly; + } + this.input.readOnly = this.readonly; + if (this.calendarButton) { + this.calendarButton.style.display = this.readonly ? "none" : ""; + } + } }; - + /** * * '''initEvents''' method : initializes the event management according to incremental capability */ XsltForms_input.prototype.initEvents = function(input, canActivate) { - var changeEventName = "keyup"; - if (XsltForms_browser.isEdge || XsltForms_browser.isIE11 || (XsltForms_globals.htmlversion === "5" && (XsltForms_browser.isChrome || XsltForms_browser.isOpera || XsltForms_browser.isSafari))) { - changeEventName = "input"; - } - if (this.inputmode) { - XsltForms_browser.events.attach(input, changeEventName, XsltForms_input.keyUpInputMode); - } - if (canActivate) { - XsltForms_browser.events.attach(input, "keydown", XsltForms_input.keyDownActivate); - XsltForms_browser.events.attach(input, "keypress", XsltForms_input.keyPressActivate); - if (this.incremental) { - XsltForms_browser.events.attach(input, changeEventName, XsltForms_input.keyUpIncrementalActivate); - //} else { - // XsltForms_browser.events.attach(input, changeEventName, XsltForms_input.keyUpActivate); - } - } else { - if (this.incremental) { - XsltForms_browser.events.attach(input, changeEventName, XsltForms_input.keyUpIncremental); - } - } + var changeEventName = "keyup"; + if (XsltForms_browser.isEdge || XsltForms_browser.isIE11 || (XsltForms_globals.htmlversion === "5" && (XsltForms_browser.isChrome || XsltForms_browser.isOpera || XsltForms_browser.isSafari))) { + changeEventName = "input"; + } + //changeEventName = "change"; + if (this.inputmode) { + XsltForms_browser.events.attach(input, changeEventName, XsltForms_input.keyUpInputMode); + } + if (canActivate) { + XsltForms_browser.events.attach(input, "keydown", XsltForms_input.keyDownActivate); + XsltForms_browser.events.attach(input, "keypress", XsltForms_input.keyPressActivate); + if (this.incremental) { + XsltForms_browser.events.attach(input, changeEventName, XsltForms_input.keyUpIncrementalActivate); + //} else { + // XsltForms_browser.events.attach(input, changeEventName, XsltForms_input.keyUpActivate); + } + } else { + if (this.incremental) { + XsltForms_browser.events.attach(input, changeEventName, XsltForms_input.keyUpIncremental); + XsltForms_browser.events.attach(input, "change", XsltForms_input.keyUpIncremental); + } + } }; - + /** * * '''blur''' method : manages the blur event when not in incremental mode * @callback */ XsltForms_input.prototype.blur = function(target) { - XsltForms_globals.focus = null; - var input = this.input; - var value; - if (!this.incremental) { - XsltForms_browser.assert(input, this.element.id); - if (input.type === "checkbox") { - value = input.checked ? "true" : "false"; - } else if (input.nodeName.toLowerCase() !== "textarea") { - value = input.value; - if (input.type === "time" && value && value.length === 5) { - value += ":00"; - } - } else if (this.type.rte && this.type.rte.toLowerCase() === "tinymce") { - value = tinyMCE.get(input.id).getContent(); - } else if (this.type.rte && this.type.rte.toLowerCase() === "ckeditor") { - value = this.rte.getData(); - if (value.substr(value.length - 1) === "\n") { - value = value.substr(0, value.length - 1); - } - } else { - value = input.value; - } - this.valueChanged(value); - } else { - var node = this.element.node; - value = input.value; - if (value && value.length > 0 && input.type !== "time" && input.type.substr(0, 4) !== "date" && XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string").format) { - try { input.value = XsltForms_browser.getValue(node, true); } catch(e) { } - } - if (this.timer) { - window.clearTimeout(this.timer); - this.timer = null; - this.valueChanged(value); - } - } + XsltForms_globals.focus = null; + var input = this.input; + var value; + if (!this.incremental) { + XsltForms_browser.assert(input, this.element.id); + if (input.type === "checkbox") { + value = input.checked ? "true" : "false"; + } else if (input.nodeName.toLowerCase() !== "textarea") { + value = input.value; + if (input.type === "time" && value && value.length === 5) { + value += ":00"; + } + } else if (this.type.rte && this.type.rte.toLowerCase() === "tinymce") { + value = tinyMCE.get(input.id).getContent(); + } else if (this.type.rte && this.type.rte.toLowerCase() === "ckeditor") { + value = this.rte.getData(); + if (value.substr(value.length - 1) === "\n") { + value = value.substr(0, value.length - 1); + } + } else { + value = input.value; + } + this.valueChanged(value); + } else { + var node = this.element.node; + value = input.value; + if (value && value.length > 0 && input.type !== "time" && input.type.substr(0, 4) !== "date" && XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string").format) { + try { input.value = XsltForms_browser.getValue(node, true); } catch(e) { } + } + if (this.timer) { + window.clearTimeout(this.timer); + this.timer = null; + this.valueChanged(value); + } + } }; - + /** * * '''click''' method : manages the click event according to the input control type */ XsltForms_input.prototype.click = function(target) { - if (target === this.aidButton) { - XsltForms_globals.openAction("XsltForms_input.prototype.click#1"); - XsltForms_xmlevents.dispatch(this, "ajx-aid"); - XsltForms_globals.closeAction("XsltForms_input.prototype.click#1"); - } else if (target === this.input && this.type["class"] === "boolean") { - XsltForms_globals.openAction("XsltForms_input.prototype.click#2"); - this.valueChanged(target.checked? "true" : "false"); - XsltForms_xmlevents.dispatch(this, "DOMActivate"); - XsltForms_globals.closeAction("XsltForms_input.prototype.click#2"); - } else if (target === this.calendarButton) { - XsltForms_calendar.show(target.previousSibling, this.type["class"] === "datetime"? XsltForms_calendar.SECONDS : XsltForms_calendar.ONLY_DATE); - } + if (target === this.aidButton) { + XsltForms_globals.openAction("XsltForms_input.prototype.click#1"); + XsltForms_xmlevents.dispatch(this, "ajx-aid"); + XsltForms_globals.closeAction("XsltForms_input.prototype.click#1"); + } else if (target === this.input && this.type["class"] === "boolean") { + XsltForms_globals.openAction("XsltForms_input.prototype.click#2"); + this.valueChanged(target.checked? "true" : "false"); + XsltForms_xmlevents.dispatch(this, "DOMActivate"); + XsltForms_globals.closeAction("XsltForms_input.prototype.click#2"); + } else if (target === this.calendarButton) { + XsltForms_calendar.show(target.previousSibling, this.type["class"] === "datetime"? XsltForms_calendar.SECONDS : XsltForms_calendar.ONLY_DATE); + } }; - + /** * * '''keyUpInputMode''' function : updates this input control value after key up */ XsltForms_input.keyUpInputMode = function() { - var xf = XsltForms_control.getXFElement(this); - this.value = xf.inputmode(this.value); + var xf = XsltForms_control.getXFElement(this); + this.value = xf.inputmode(this.value); }; - + /** * * '''keyDownActivate''' function : records the key code when down */ XsltForms_input.keyDownActivate = function(a) { - this.keyDownCode = a.keyCode; + this.keyDownCode = a.keyCode; }; - + /** * * '''keyPressActivate''' function : records the key code when pressed */ XsltForms_input.keyPressActivate = function(a) { -// console.log("keyPressActivate"); - var xf = XsltForms_control.getXFElement(this); - this.keyPressCode = a.keyCode; - if (a.keyCode === 13) { - XsltForms_globals.openAction("XsltForms_input.keyUpActivate"); - xf.valueChanged((this.type === "time" && this.value && this.value.length === 5 ? this.value + ":00" : this.value) || ""); - XsltForms_xmlevents.dispatch(xf, "DOMActivate"); - XsltForms_globals.closeAction("XsltForms_input.keyUpActivate"); - if (a.stopPropagation) { - a.stopPropagation(); - a.preventDefault(); - } else { - a.cancelBubble = true; - } - } +// console.log("keyPressActivate"); + var xf = XsltForms_control.getXFElement(this); + this.keyPressCode = a.keyCode; + if (a.keyCode === 13) { + XsltForms_globals.openAction("XsltForms_input.keyUpActivate"); + xf.valueChanged((this.type === "time" && this.value && this.value.length === 5 ? this.value + ":00" : this.value) || ""); + XsltForms_xmlevents.dispatch(xf, "DOMActivate"); + XsltForms_globals.closeAction("XsltForms_input.keyUpActivate"); + if (a.stopPropagation) { + a.stopPropagation(); + a.preventDefault(); + } else { + a.cancelBubble = true; + } + } }; - + /** * * '''keyUpActivate''' function : checks if Enter key was pressed to dispatch DOMActivate */ XsltForms_input.keyUpActivate = function(a) { - //console.log("keyUpActivate"); - //var xf = XsltForms_control.getXFElement(this); - //if (a.keyCode === 13 && (this.keyDownCode === 13 || this.keyPressCode === 13)) { - // XsltForms_globals.openAction("XsltForms_input.keyUpActivate"); - // xf.valueChanged((this.type === "time" && this.value && this.value.length === 5 ? this.value + ":00" : this.value) || ""); - // XsltForms_xmlevents.dispatch(xf, "DOMActivate"); - // XsltForms_globals.closeAction("XsltForms_input.keyUpActivate"); - //} - this.keyDownCode = this.keyPressCode = null; + //console.log("keyUpActivate"); + //var xf = XsltForms_control.getXFElement(this); + //if (a.keyCode === 13 && (this.keyDownCode === 13 || this.keyPressCode === 13)) { + // XsltForms_globals.openAction("XsltForms_input.keyUpActivate"); + // xf.valueChanged((this.type === "time" && this.value && this.value.length === 5 ? this.value + ":00" : this.value) || ""); + // XsltForms_xmlevents.dispatch(xf, "DOMActivate"); + // XsltForms_globals.closeAction("XsltForms_input.keyUpActivate"); + //} + this.keyDownCode = this.keyPressCode = null; }; - + /** * * '''keyUpIncrementalActivate''' function : checks if Enter key was pressed to dispatch DOMActivate in incremental mode */ XsltForms_input.keyUpIncrementalActivate = function(a) { - var xf = XsltForms_control.getXFElement(this); -// if (a.keyCode === 13 && (this.keyDownCode === 13 || this.keyPressCode === 13)) { -// XsltForms_globals.openAction("XsltForms_input.keyUpIncrementalActivate#1"); -// xf.valueChanged((this.type === "time" && this.value && this.value.length === 5 ? this.value + ":00" : this.value) || ""); -// XsltForms_xmlevents.dispatch(xf, "DOMActivate"); -// XsltForms_globals.closeAction("XsltForms_input.keyUpIncrementalActivate#1"); -// } else { - if (xf.delay && xf.delay > 0) { - if (xf.timer) { - window.clearTimeout(xf.timer); - } - var _self = this; - xf.timer = window.setTimeout( - function () { - XsltForms_globals.openAction('XsltForms_input.keyUpIncrementalActivate#2'); - xf.valueChanged((_self.type === "time" && _self.value && _self.value.length === 5 ? _self.value + ":00" : _self.value) || ""); - XsltForms_globals.closeAction('XsltForms_input.keyUpIncrementalActivate#2'); - }, xf.delay); - } else { - XsltForms_globals.openAction("XsltForms_input.keyUpIncrementalActivate#3"); - xf.valueChanged((this.type === "time" && this.value && this.value.length === 5 ? this.value + ":00" : this.value) || ""); - XsltForms_globals.closeAction("XsltForms_input.keyUpIncrementalActivate#3"); - } -// } - this.keyDownCode = this.keyPressCode = null; + var xf = XsltForms_control.getXFElement(this); +// if (a.keyCode === 13 && (this.keyDownCode === 13 || this.keyPressCode === 13)) { +// XsltForms_globals.openAction("XsltForms_input.keyUpIncrementalActivate#1"); +// xf.valueChanged((this.type === "time" && this.value && this.value.length === 5 ? this.value + ":00" : this.value) || ""); +// XsltForms_xmlevents.dispatch(xf, "DOMActivate"); +// XsltForms_globals.closeAction("XsltForms_input.keyUpIncrementalActivate#1"); +// } else { + if (xf.delay && xf.delay > 0) { + if (xf.timer) { + window.clearTimeout(xf.timer); + } + var _self = this; + xf.timer = window.setTimeout( + function () { + XsltForms_globals.openAction('XsltForms_input.keyUpIncrementalActivate#2'); + xf.valueChanged((_self.type === "time" && _self.value && _self.value.length === 5 ? _self.value + ":00" : _self.value) || ""); + XsltForms_globals.closeAction('XsltForms_input.keyUpIncrementalActivate#2'); + }, xf.delay); + } else { + XsltForms_globals.openAction("XsltForms_input.keyUpIncrementalActivate#3"); + xf.valueChanged((this.type === "time" && this.value && this.value.length === 5 ? this.value + ":00" : this.value) || ""); + XsltForms_globals.closeAction("XsltForms_input.keyUpIncrementalActivate#3"); + } +// } + this.keyDownCode = this.keyPressCode = null; }; - + /** * * '''inputActivate''' function : treats spinner input value changes * @callback */ XsltForms_input.inputActivate = function(a) { - var xf = XsltForms_control.getXFElement(this); - XsltForms_globals.openAction("XsltForms_input.inputActivate#1"); - xf.valueChanged(this.value || ""); - XsltForms_globals.closeAction("XsltForms_input.inputActivate#1"); + var xf = XsltForms_control.getXFElement(this); + XsltForms_globals.openAction("XsltForms_input.inputActivate#1"); + xf.valueChanged(this.value || ""); + XsltForms_globals.closeAction("XsltForms_input.inputActivate#1"); }; - + /** * * '''keyUpIncremental''' function : updates this input control value after key up in incremental mode */ XsltForms_input.keyUpIncremental = function() { - var xf = XsltForms_control.getXFElement(this); - if (xf.delay && xf.delay > 0) { - if (xf.timer) { - window.clearTimeout(xf.timer); - } - var _self = this; - xf.timer = window.setTimeout( - function () { - XsltForms_globals.openAction('XsltForms_input.keyUpIncremental#1'); - xf.valueChanged((_self.type === "time" && _self.value && _self.value.length === 5 ? _self.value + ":00" : _self.value) || ""); - XsltForms_globals.closeAction('XsltForms_input.keyUpIncremental#1'); - }, xf.delay); - } else { - XsltForms_globals.openAction("XsltForms_input.keyUpIncremental#2"); - xf.valueChanged((this.type === "time" && this.value && this.value.length === 5 ? this.value + ":00" : this.value) || ""); - XsltForms_globals.closeAction("XsltForms_input.keyUpIncremental#2"); - } + var xf = XsltForms_control.getXFElement(this); + if (xf.delay && xf.delay > 0) { + if (xf.timer) { + window.clearTimeout(xf.timer); + } + var _self = this; + xf.timer = window.setTimeout( + function () { + XsltForms_globals.openAction('XsltForms_input.keyUpIncremental#1'); + xf.valueChanged((_self.type === "time" && _self.value && _self.value.length === 5 ? _self.value + ":00" : _self.value) || ""); + XsltForms_globals.closeAction('XsltForms_input.keyUpIncremental#1'); + }, xf.delay); + } else { + XsltForms_globals.openAction("XsltForms_input.keyUpIncremental#2"); + xf.valueChanged((this.type === "time" && this.value && this.value.length === 5 ? this.value + ":00" : this.value) || ""); + XsltForms_globals.closeAction("XsltForms_input.keyUpIncremental#2"); + } }; - + /** * * '''InputMode''' functions set : specific check function for each possible input mode (lowerCase/upperCase/titleCase/digits) */ XsltForms_input.InputMode = { - lowerCase : function(value) { return value.toLowerCase(); }, - upperCase : function(value) { return value.toUpperCase(); }, - titleCase : function(value) { return value.charAt(0).toUpperCase() + value.substring(1).toLowerCase(); }, - digits : function(value) { - if (/^[0-9]*$/.exec(value)) { - return value; - } - alert("Character not valid"); - var digits = "1234567890"; - var newValue = ""; - for (var i = 0, len = value.length; i < len; i++) { - if (digits.indexOf(value.charAt(i)) !== -1) { - newValue += value.charAt(i); - } - } - return newValue; - } + lowerCase : function(value) { return value.toLowerCase(); }, + upperCase : function(value) { return value.toUpperCase(); }, + titleCase : function(value) { return value.charAt(0).toUpperCase() + value.substring(1).toLowerCase(); }, + digits : function(value) { + if (/^[0-9]*$/.exec(value)) { + return value; + } + alert("Character not valid"); + var digits = "1234567890"; + var newValue = ""; + for (var i = 0, len = value.length; i < len; i++) { + if (digits.indexOf(value.charAt(i)) !== -1) { + newValue += value.charAt(i); + } + } + return newValue; + } }; \ No newline at end of file diff --git a/src/js/xsltforms.js/controls/item.js b/src/js/xsltforms.js/controls/item.js index 6262512..74a670e 100644 --- a/src/js/xsltforms.js/controls/item.js +++ b/src/js/xsltforms.js/controls/item.js @@ -1,188 +1,186 @@ -/*eslint-env browser*/ -/*globals XsltForms_globals XsltForms_browser XsltForms_control XsltForms_element XsltForms_class XsltForms_subform*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module item * @description === "XsltForms_item" class === * Item Element Class * * constructor function : initializes specific properties and initializes focus and blur event management */ - + new XsltForms_class("XsltForms_item", "HTMLElement", "xforms-item", ""); function XsltForms_item(subform, elt, clone) { - var bindingL, bindingV, copyBinding; - XsltForms_globals.counters.item++; - this.init(subform, elt); - this.controlName = "item"; - if (bindingL || bindingV) { - this.hasBinding = true; - this.bindingL = bindingL; - this.bindingV = bindingV; - this.copyBinding = copyBinding; - //} else { - // XsltForms_browser.setClass(this.element, "xforms-disabled", false); - } - /* - var element = this.element; - if (element.nodeName.toLowerCase() !== "option") { - this.input = XsltForms_browser.isXhtml ? element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "input")[0] : element.getElementsByTagName("input")[0]; - this.input.name = XsltForms_control.getXFElement(this.element).element.id; - XsltForms_browser.events.attach(this.input, "focus", XsltForms_control.focusHandler); - XsltForms_browser.events.attach(this.input, "blur", XsltForms_control.blurHandler); - this.label = XsltForms_browser.isXhtml ? element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "label")[0] : element.getElementsByTagName("label")[0]; - } - */ + var bindingL, bindingV, copyBinding; + XsltForms_globals.counters.item++; + this.init(subform, elt); + this.controlName = "item"; + if (bindingL || bindingV) { + this.hasBinding = true; + this.bindingL = bindingL; + this.bindingV = bindingV; + this.copyBinding = copyBinding; + //} else { + // XsltForms_browser.setClass(this.element, "xforms-disabled", false); + } + /* + var element = this.element; + if (element.nodeName.toLowerCase() !== "option") { + this.input = XsltForms_browser.isXhtml ? element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "input")[0] : element.getElementsByTagName("input")[0]; + this.input.name = XsltForms_control.getXFElement(this.element).element.id; + XsltForms_browser.events.attach(this.input, "focus", XsltForms_control.focusHandler); + XsltForms_browser.events.attach(this.input, "blur", XsltForms_control.blurHandler); + this.label = XsltForms_browser.isXhtml ? element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "label")[0] : element.getElementsByTagName("label")[0]; + } + */ } XsltForms_item.prototype = new XsltForms_element(); - + /** * * '''clone''' method : creates a new item control with the given id */ XsltForms_item.prototype.clone = function(id) { - return new XsltForms_item(this.subform, id, this.bindingL, this.bindingV, this.copyBinding); + return new XsltForms_item(this.subform, id, this.bindingL, this.bindingV, this.copyBinding); }; - + /** * * '''dispose''' method : clears properties of this element and calls the parent dispose() method */ XsltForms_item.prototype.dispose = function() { - this.input = null; - this.label = null; - XsltForms_globals.counters.item--; - XsltForms_element.prototype.dispose.call(this); + this.input = null; + this.label = null; + XsltForms_globals.counters.item--; + XsltForms_element.prototype.dispose.call(this); }; - + /** * * '''build_''' method : specific build method according to label and value bindings */ XsltForms_item.prototype.build_ = function(ctx) { - var result, element = this.element; - var xf = element.parentNode.xfElement; - if (xf && xf.isRepeat) { - this.ctx = ctx = element.node; - } else { - element.node = ctx; - } - if (this.bindingL) { - result = this.evaluateBinding(this.bindingL, ctx); - if (Fleur.minimal) { - if (typeof result === "object") { - element.nodeL = result[0]; - element.valueL = null; - this.depsNodesRefresh.push(element.nodeL); - } else { - element.nodeL = null; - element.valueL = result; - } - } else { - if (result.nodeType !== Fleur.Node.TEXT_NODE) { - element.nodeL = result.head(); - element.valueL = null; - } else { - element.nodeL = null; - element.valueL = result.data; - } - } - } - if (this.bindingV) { - result = this.evaluateBinding(this.bindingV, ctx); - if (Fleur.minimal) { - if (typeof result === "object") { - element.nodeV = result[0]; - element.valueV = null; - this.depsNodesRefresh.push(element.nodeV); - } else { - element.nodeV = null; - element.valueV = result; - } - } else { - if (result.nodeType !== Fleur.Node.TEXT_NODE) { - element.nodeV = result.head(); - element.valueV = null; - } else { - element.nodeV = null; - element.valueV = result.data; - } - } - } - var nodeCopy = this.copyBinding ? this.evaluateBinding(this.copyBinding, ctx)[0] : null; - if (this.copyBinding && nodeCopy) { - element.parentNode.parentNode.parentNode.parentNode.xfElement.hasCopy = true; - this.depsNodesRefresh.push(nodeCopy); - try { - element.copy = XsltForms_browser.saveNode(nodeCopy, "application/xml"); - } catch(e3) { - } - } + var result, element = this.element; + var xf = element.parentNode.xfElement; + if (xf && xf.isRepeat) { + this.ctx = ctx = element.node; + } else { + element.node = ctx; + } + if (this.bindingL) { + result = this.evaluateBinding(this.bindingL, ctx); + if (Fleur.minimal) { + if (typeof result === "object") { + element.nodeL = result[0]; + element.valueL = null; + this.depsNodesRefresh.push(element.nodeL); + } else { + element.nodeL = null; + element.valueL = result; + } + } else { + if (result.nodeType !== Fleur.Node.TEXT_NODE) { + element.nodeL = result.head(); + element.valueL = null; + } else { + element.nodeL = null; + element.valueL = result.data; + } + } + } + if (this.bindingV) { + result = this.evaluateBinding(this.bindingV, ctx); + if (Fleur.minimal) { + if (typeof result === "object") { + element.nodeV = result[0]; + element.valueV = null; + this.depsNodesRefresh.push(element.nodeV); + } else { + element.nodeV = null; + element.valueV = result; + } + } else { + if (result.nodeType !== Fleur.Node.TEXT_NODE) { + element.nodeV = result.head(); + element.valueV = null; + } else { + element.nodeV = null; + element.valueV = result.data; + } + } + } + var nodeCopy = this.copyBinding ? this.evaluateBinding(this.copyBinding, ctx)[0] : null; + if (this.copyBinding && nodeCopy) { + element.parentNode.parentNode.parentNode.parentNode.xfElement.hasCopy = true; + this.depsNodesRefresh.push(nodeCopy); + try { + element.copy = XsltForms_browser.saveNode(nodeCopy, "application/xml"); + } catch(e3) { + } + } }; - + /** * * '''refresh''' method : refreshes the label and the value for this item control depending whether it has a rendering as option or not */ XsltForms_item.prototype.refresh = function() { - var element = this.element; - //XsltForms_browser.setClass(element, "xforms-disabled", false); - if (element.nodeName.toLowerCase() === "option") { - if (element.nodeL) { - try { - element.text = XsltForms_browser.getValue(element.nodeL, true); - } catch(e) { - } - } else if (element.valueL) { - element.text = element.valueL; - } - if (element.nodeV) { - try { - element.value = XsltForms_browser.getValue(element.nodeV); - } catch(e2) { - } - } else if (element.valueV) { - element.value = element.valueV; - } - } else { - if (element.nodeL) { - XsltForms_browser.setValue(this.label, XsltForms_browser.getValue(element.nodeL, true)); - } else if (element.valueL) { - XsltForms_browser.setValue(this.label, element.valueL); - } - if (element.nodeV) { - this.input.value = XsltForms_browser.getValue(element.nodeV); - } else if (element.valueV) { - this.input.value = element.valueV; - } else if (element.copy) { - this.input.value = this.input.copy = element.copy; - } - } + var element = this.element; + //XsltForms_browser.setClass(element, "xforms-disabled", false); + if (element.nodeName.toLowerCase() === "option") { + if (element.nodeL) { + try { + element.text = XsltForms_browser.getValue(element.nodeL, true); + } catch(e) { + } + } else if (element.valueL) { + element.text = element.valueL; + } + if (element.nodeV) { + try { + element.value = XsltForms_browser.getValue(element.nodeV); + } catch(e2) { + } + } else if (element.valueV) { + element.value = element.valueV; + } + } else { + if (element.nodeL) { + XsltForms_browser.setValue(this.label, XsltForms_browser.getValue(element.nodeL, true)); + } else if (element.valueL) { + XsltForms_browser.setValue(this.label, element.valueL); + } + if (element.nodeV) { + this.input.value = XsltForms_browser.getValue(element.nodeV); + } else if (element.valueV) { + this.input.value = element.valueV; + } else if (element.copy) { + this.input.value = this.input.copy = element.copy; + } + } }; - + /** * * '''click''' method : manages the click event according to the item control type */ XsltForms_item.prototype.click = function (target) { - var input = this.input; - if (input) { - var xf = XsltForms_control.getXFElement(this.element); - if (!xf.element.node.readonly && target === input) { - xf.itemClick(input.value); - } - } + var input = this.input; + if (input) { + var xf = XsltForms_control.getXFElement(this.element); + if (!xf.element.node.readonly && target === input) { + xf.itemClick(input.value); + } + } }; \ No newline at end of file diff --git a/src/js/xsltforms.js/controls/itemset.js b/src/js/xsltforms.js/controls/itemset.js index e5d73f3..83067cf 100644 --- a/src/js/xsltforms.js/controls/itemset.js +++ b/src/js/xsltforms.js/controls/itemset.js @@ -1,275 +1,273 @@ -/*eslint-env browser*/ -/*globals XsltForms_globals XsltForms_element XsltForms_idManager XsltForms_browser Fleur XsltForms_class XsltForms_subform XsltForms_binding XsltForms_classes XsltForms_repeat*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module itemset * @description === "XsltForms_itemset" class === * ItemSet Element Class * * constructor function : initializes specific properties */ - + new XsltForms_class("XsltForms_itemset", "HTMLElement", "xforms-itemset"); function XsltForms_itemset(subform, elt) { - var labelBinding, valueBinding, copyBinding; - XsltForms_globals.counters.itemset++; - this.init(subform, elt); - this.controlName = "itemset"; - this.nodesetBinding = new XsltForms_binding(subform, elt); - Array.prototype.slice.call(elt.children).forEach(function(n) { - switch(n.localName.toLowerCase()) { - case "xforms-label": - labelBinding = n; - break; - case "xforms-value": - valueBinding = n; - break; - case "xforms-copy": - copyBinding = n; - break; - } - }); - this.labelContent = labelBinding ? labelBinding.innerHTML : ""; - this.labelBinding = labelBinding && labelBinding.hasAttribute("xf-ref") ? new XsltForms_binding(subform, labelBinding) : null; - this.valueBinding = valueBinding ? new XsltForms_binding(subform, valueBinding) : null; - this.copyBinding = copyBinding ? new XsltForms_binding(subform, copyBinding) : null; - this.hasBinding = true; + var labelBinding, valueBinding, copyBinding; + XsltForms_globals.counters.itemset++; + this.init(subform, elt); + this.controlName = "itemset"; + this.nodesetBinding = new XsltForms_binding(subform, elt); + Array.prototype.slice.call(elt.children).forEach(function(n) { + switch(n.localName.toLowerCase()) { + case "xforms-label": + labelBinding = n; + break; + case "xforms-value": + valueBinding = n; + break; + case "xforms-copy": + copyBinding = n; + break; + } + }); + this.labelContent = labelBinding ? labelBinding.innerHTML : ""; + this.labelBinding = labelBinding && labelBinding.hasAttribute("xf-ref") ? new XsltForms_binding(subform, labelBinding) : null; + this.valueBinding = valueBinding ? new XsltForms_binding(subform, valueBinding) : null; + this.copyBinding = copyBinding ? new XsltForms_binding(subform, copyBinding) : null; + this.hasBinding = true; } XsltForms_itemset.prototype = new XsltForms_element(); - + /** * * '''build_''' method : specific build method with the corresponding clones creation */ XsltForms_itemset.prototype.build_ = function(ctx) { - if (this.element.getAttribute("cloned")) { - return; - } - this.nodes = this.evaluateBinding(this.nodesetBinding, ctx).toArray(); - var elt = this.element; - var xfelt = this; - if (this.nodes.length !== 0) { - this.element.setAttribute("xf-bound", ""); - } else { - this.element.removeAttribute("xf-bound"); - } - var subform = this.subform; - Array.prototype.slice.call(elt.querySelectorAll("xforms-item")).forEach(function(item) { - elt.removeChild(item); - }); - this.nodes.reverse().forEach(function(n) { - var ielt = document.createElement("xforms-item"); - var result, nodeLabel, nodeValue, nlabel, nvalue; - if (xfelt.labelBinding) { - result = xfelt.evaluateBinding(xfelt.labelBinding, n); - if (typeof result === "object") { - nodeLabel = result[0]; - xfelt.depsNodesRefresh.push(nodeLabel); - try { - nlabel = XsltForms_browser.getValue(nodeLabel, true); - } catch(e) { - } - } else { - nlabel = result; - } - } else { - nlabel = xfelt.labelContent; - } - result = xfelt.valueBinding ? xfelt.evaluateBinding(xfelt.valueBinding, n) : null; - if (xfelt.valueBinding && result) { - if (Fleur.minimal) { - if (typeof result === "object") { - nodeValue = result[0]; - xfelt.depsNodesRefresh.push(nodeValue); - try { - nvalue = XsltForms_browser.getValue(nodeValue); - } catch(e2) { - } - } else { - nvalue = result; - } - } else { - if (result.nodeType !== Fleur.Node.TEXT_NODE && result.head) { - nodeValue = result.head(); - xfelt.depsNodesRefresh.push(nodeValue); - try { - nvalue = XsltForms_browser.getValue(nodeValue); - } catch(e2) { - } - } else { - nvalue = result.data || result; - } - } - } - var nodeCopy = xfelt.copyBinding ? xfelt.evaluateBinding(xfelt.copyBinding, n).head() : null; - if (xfelt.copyBinding && nodeCopy) { - elt.parentNode.parentNode.xfElement.hasCopy = true; - xfelt.depsNodesRefresh.push(nodeCopy); - try { - nvalue = Fleur.Serializer.escapeXML(XsltForms_browser.saveNode(nodeCopy, "application/xml")); - } catch(e3) { - } - } - ielt.innerHTML = "" + nlabel + "" + nvalue + ""; - elt.insertBefore(ielt, elt.firstChild); - if (xfelt.labelBinding) { - XsltForms_classes["xforms-item"].classbinding(subform, ielt); - } else { - ielt.node = n; - XsltForms_repeat.initClone(subform, ielt); - } - }); - var xfparent = elt.parentNode.parentNode; - if (xfparent.localName.toLowerCase() === "xforms-body") { - xfparent = xfparent.parentNode; - } - var xfparentelement = xfparent.xfElement; - if (xfparentelement instanceof Array) { - xfparentelement = xfparentelement[0]; - } - xfparentelement.initBody(); - xfparentelement.setValue(xfparentelement.currentValue); - /* - var next = this.element; - var parentNode = next.parentNode; - var l = this.nodes.length; - var oldNode = next; - var listeners = next.listeners; - var cont = 1; - while (next) { - next = next.nextSibling; - if (next) { - if (next.nodeType === Fleur.Node.ELEMENT_NODE) { - if (next.getAttribute("cloned")) { - if (cont >= l) { - next.listeners = null; - parentNode.removeChild(next); - next = oldNode; - } else { - next.node = this.nodes[cont]; - this.refresh_(next, cont++); - oldNode = next; - } - } - } else { - var n = next.previousSibling; - next.parentNode.removeChild(next); - next = n; - } - } else { - for (var i = cont; i < l; i++) { - var node = this.element.cloneNode(true); - node.setAttribute("cloned", "true"); - if (node.id) { - XsltForms_idManager.cloneId(node); - } - node.node = this.nodes[i]; - parentNode.appendChild(node); - this.refresh_(node, i); - if (listeners && !XsltForms_browser.isIE) { - for (var j = 0, len = listeners.length; j < len; j++) { - listeners[j].clone(node); - } - } - } - break; - } - } - if (l > 0) { - this.element.node = this.nodes[0]; - this.refresh_(this.element, 0); - } else { - this.element.value = "\xA0"; - this.element.text = "\xA0"; - } - */ + if (this.element.getAttribute("cloned")) { + return; + } + this.nodes = this.evaluateBinding(this.nodesetBinding, ctx).toArray(); + var elt = this.element; + var xfelt = this; + if (this.nodes.length !== 0) { + this.element.setAttribute("xf-bound", ""); + } else { + this.element.removeAttribute("xf-bound"); + } + var subform = this.subform; + Array.prototype.slice.call(elt.querySelectorAll("xforms-item")).forEach(function(item) { + elt.removeChild(item); + }); + this.nodes.reverse().forEach(function(n) { + var ielt = document.createElement("xforms-item"); + var result, nodeLabel, nodeValue, nlabel, nvalue; + if (xfelt.labelBinding) { + result = xfelt.evaluateBinding(xfelt.labelBinding, n); + if (typeof result === "object") { + nodeLabel = result[0]; + xfelt.depsNodesRefresh.push(nodeLabel); + try { + nlabel = XsltForms_browser.getValue(nodeLabel, true); + } catch(e) { + } + } else { + nlabel = result; + } + } else { + nlabel = xfelt.labelContent; + } + result = xfelt.valueBinding ? xfelt.evaluateBinding(xfelt.valueBinding, n) : null; + if (xfelt.valueBinding && result) { + if (Fleur.minimal) { + if (typeof result === "object") { + nodeValue = result[0]; + xfelt.depsNodesRefresh.push(nodeValue); + try { + nvalue = XsltForms_browser.getValue(nodeValue); + } catch(e2) { + } + } else { + nvalue = result; + } + } else { + if (result.nodeType !== Fleur.Node.TEXT_NODE && result.head) { + nodeValue = result.head(); + xfelt.depsNodesRefresh.push(nodeValue); + try { + nvalue = XsltForms_browser.getValue(nodeValue); + } catch(e2) { + } + } else { + nvalue = result.data || result; + } + } + } + var nodeCopy = xfelt.copyBinding ? xfelt.evaluateBinding(xfelt.copyBinding, n).head() : null; + if (xfelt.copyBinding && nodeCopy) { + elt.parentNode.parentNode.xfElement.hasCopy = true; + xfelt.depsNodesRefresh.push(nodeCopy); + try { + nvalue = Fleur.Serializer.escapeXML(XsltForms_browser.saveNode(nodeCopy, "application/xml")); + } catch(e3) { + } + } + ielt.innerHTML = "" + nlabel + "" + nvalue + ""; + elt.insertBefore(ielt, elt.firstChild); + if (xfelt.labelBinding) { + XsltForms_classes["xforms-item"].classbinding(subform, ielt); + } else { + ielt.node = n; + XsltForms_repeat.initClone(subform, ielt); + } + }); + var xfparent = elt.parentNode.parentNode; + if (xfparent.localName.toLowerCase() === "xforms-body") { + xfparent = xfparent.parentNode; + } + var xfparentelement = xfparent.xfElement; + if (xfparentelement instanceof Array) { + xfparentelement = xfparentelement[0]; + } + xfparentelement.initBody(); + xfparentelement.setValue(xfparentelement.currentValue); + /* + var next = this.element; + var parentNode = next.parentNode; + var l = this.nodes.length; + var oldNode = next; + var listeners = next.listeners; + var cont = 1; + while (next) { + next = next.nextSibling; + if (next) { + if (next.nodeType === Fleur.Node.ELEMENT_NODE) { + if (next.getAttribute("cloned")) { + if (cont >= l) { + next.listeners = null; + parentNode.removeChild(next); + next = oldNode; + } else { + next.node = this.nodes[cont]; + this.refresh_(next, cont++); + oldNode = next; + } + } + } else { + var n = next.previousSibling; + next.parentNode.removeChild(next); + next = n; + } + } else { + for (var i = cont; i < l; i++) { + var node = this.element.cloneNode(true); + node.setAttribute("cloned", "true"); + if (node.id) { + XsltForms_idManager.cloneId(node); + } + node.node = this.nodes[i]; + parentNode.appendChild(node); + this.refresh_(node, i); + if (listeners && !XsltForms_browser.isIE) { + for (var j = 0, len = listeners.length; j < len; j++) { + listeners[j].clone(node); + } + } + } + break; + } + } + if (l > 0) { + this.element.node = this.nodes[0]; + this.refresh_(this.element, 0); + } else { + this.element.value = "\xA0"; + this.element.text = "\xA0"; + } + */ }; - + /** * * '''refresh''' method : sets "xforms-disabled" CSS class */ XsltForms_itemset.prototype.refresh = function() { /* - var parentNode = this.element.parentNode; - var i = 0; - while (parentNode.childNodes[i] !== this.element) { - i++; - } - for (var j = 0, len = this.nodes.length; j < len || j === 0; j++) { - XsltForms_browser.setClass(parentNode.childNodes[i+j], "xforms-disabled", this.nodes.length === 0); - } + var parentNode = this.element.parentNode; + var i = 0; + while (parentNode.childNodes[i] !== this.element) { + i++; + } + for (var j = 0, len = this.nodes.length; j < len || j === 0; j++) { + XsltForms_browser.setClass(parentNode.childNodes[i+j], "xforms-disabled", this.nodes.length === 0); + } */ }; - + /** * * '''clone''' method : creates a new itemset control with the given id */ XsltForms_itemset.prototype.clone = function(id) { - return new XsltForms_itemset(this.subform, id, this.nodesetBinding, this.labelBinding, this.valueBinding, this.copyBinding); + return new XsltForms_itemset(this.subform, id, this.nodesetBinding, this.labelBinding, this.valueBinding, this.copyBinding); }; - + /** * * '''dispose''' method : decrements the number of itemsets and calls the parent dispose() method */ XsltForms_itemset.prototype.dispose = function() { - XsltForms_globals.counters.itemset--; - XsltForms_element.prototype.dispose.call(this); + XsltForms_globals.counters.itemset--; + XsltForms_element.prototype.dispose.call(this); }; - + /** * * '''refresh_''' method : refreshes this ItemSet Control at a given position */ XsltForms_itemset.prototype.refresh_ = function(element, cont) { - var result, ctx = this.nodes[cont], nodeLabel, nodeValue; - result = this.evaluateBinding(this.labelBinding, ctx); - if (typeof result === "object") { - nodeLabel = result[0]; - this.depsNodesRefresh.push(nodeLabel); - try { - element.text = XsltForms_browser.getValue(nodeLabel, true); - } catch(e) { - } - } else { - element.text = result; - } - result = this.valueBinding ? this.evaluateBinding(this.valueBinding, ctx) : null; - if (this.valueBinding && result) { - if (typeof result === "object") { - nodeValue = result[0]; - this.depsNodesRefresh.push(nodeValue); - try { - element.value = XsltForms_browser.getValue(nodeValue); - } catch(e2) { - } - } else { - element.value = result; - } - } - var nodeCopy = this.copyBinding ? this.evaluateBinding(this.copyBinding, ctx)[0] : null; - if (this.copyBinding && nodeCopy) { - element.parentNode.parentNode.parentNode.xfElement.hasCopy = true; - this.depsNodesRefresh.push(nodeCopy); - try { - element.value = XsltForms_browser.saveNode(nodeCopy, "application/xml"); - element.setAttribute("xf-copy", ""); - } catch(e3) { - } - } + var result, ctx = this.nodes[cont], nodeLabel, nodeValue; + result = this.evaluateBinding(this.labelBinding, ctx); + if (typeof result === "object") { + nodeLabel = result[0]; + this.depsNodesRefresh.push(nodeLabel); + try { + element.text = XsltForms_browser.getValue(nodeLabel, true); + } catch(e) { + } + } else { + element.text = result; + } + result = this.valueBinding ? this.evaluateBinding(this.valueBinding, ctx) : null; + if (this.valueBinding && result) { + if (typeof result === "object") { + nodeValue = result[0]; + this.depsNodesRefresh.push(nodeValue); + try { + element.value = XsltForms_browser.getValue(nodeValue); + } catch(e2) { + } + } else { + element.value = result; + } + } + var nodeCopy = this.copyBinding ? this.evaluateBinding(this.copyBinding, ctx)[0] : null; + if (this.copyBinding && nodeCopy) { + element.parentNode.parentNode.parentNode.xfElement.hasCopy = true; + this.depsNodesRefresh.push(nodeCopy); + try { + element.value = XsltForms_browser.saveNode(nodeCopy, "application/xml"); + element.setAttribute("xf-copy", ""); + } catch(e3) { + } + } }; \ No newline at end of file diff --git a/src/js/xsltforms.js/controls/label.js b/src/js/xsltforms.js/controls/label.js index 86e7afa..a94a983 100644 --- a/src/js/xsltforms.js/controls/label.js +++ b/src/js/xsltforms.js/controls/label.js @@ -1,70 +1,68 @@ -/*eslint-env browser*/ -/*globals XsltForms_globals XsltForms_element XsltForms_browser XsltForms_subform XsltForms_binding XsltForms_class*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module label * @description === "XsltForms_label" class === * Label Element Class * * constructor function : initializes specific properties */ - + new XsltForms_class("XsltForms_label", "HTMLElement", "xforms-label"); function XsltForms_label(subform, elt) { - XsltForms_globals.counters.label++; - this.init(subform, elt); - this.controlName = "label"; - if (elt.getAttribute("xf-ref") || elt.getAttribute("xf-value") || elt.getAttribute("xf-bind")) { - this.hasBinding = true; - this.binding = new XsltForms_binding(subform, elt); - } + XsltForms_globals.counters.label++; + this.init(subform, elt); + this.controlName = "label"; + if (elt.getAttribute("xf-ref") || elt.getAttribute("xf-value") || elt.getAttribute("xf-bind")) { + this.hasBinding = true; + this.binding = new XsltForms_binding(subform, elt); + } } XsltForms_label.prototype = new XsltForms_element(); - + /** * * '''clone''' method : creates a new label element with the given id */ XsltForms_label.prototype.clone = function(id) { - return new XsltForms_label(this.subform, id, this.binding); + return new XsltForms_label(this.subform, id, this.binding); }; - + /** * * '''dispose''' method : decrements the number of labels and calls the parent dispose() method */ XsltForms_label.prototype.dispose = function() { - XsltForms_globals.counters.label--; - XsltForms_element.prototype.dispose.call(this); + XsltForms_globals.counters.label--; + XsltForms_element.prototype.dispose.call(this); }; - + /** * * '''build_''' method : specific build method */ XsltForms_label.prototype.build_ = function(ctx) { - var nodes = this.evaluateBinding(this.binding, ctx); - this.element.node = nodes.head(); - this.depsNodesRefresh.push(this.element.node); + var nodes = this.evaluateBinding(this.binding, ctx); + this.element.node = nodes.head(); + this.depsNodesRefresh.push(this.element.node); }; - + /** * * '''refresh''' method : refreshes this label element */ XsltForms_label.prototype.refresh = function() { - var node = this.element.node; - var value = node? XsltForms_browser.getValue(node, true) : ""; - XsltForms_browser.setValue(this.element.getAttributeNode("label") ? this.element.getAttributeNode("label") : this.element, value); + var node = this.element.node; + var value = node? XsltForms_browser.getValue(node, true) : ""; + XsltForms_browser.setValue(this.element.getAttributeNode("label") ? this.element.getAttributeNode("label") : this.element, value); }; \ No newline at end of file diff --git a/src/js/xsltforms.js/controls/output.js b/src/js/xsltforms.js/controls/output.js index e44d625..fe6fa2b 100644 --- a/src/js/xsltforms.js/controls/output.js +++ b/src/js/xsltforms.js/controls/output.js @@ -1,197 +1,195 @@ -/*eslint-env browser*/ -/*globals XsltForms_globals XsltForms_browser XsltForms_control XDocument XsltForms_subform XsltForms_binding XsltForms_class*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module output * @description === "XsltForms_output" class === * Output Control Class * * constructor function : initializes specific properties and initializes focus and blur event management */ - + new XsltForms_class("XsltForms_output", "HTMLElement", "xforms-output", ""); var XsltForms_output_svgtemplate = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); XsltForms_output_svgtemplate.innerHTML = ""; if (!XsltForms_output_svgtemplate.children) { - XsltForms_output_svgtemplate.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "tspan")); - XsltForms_output_svgtemplate.firstChild.setAttribute("xforms-name", "label"); - XsltForms_output_svgtemplate.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "tspan")); - XsltForms_output_svgtemplate.lastChild.setAttribute("xforms-name", "body"); + XsltForms_output_svgtemplate.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "tspan")); + XsltForms_output_svgtemplate.firstChild.setAttribute("xforms-name", "label"); + XsltForms_output_svgtemplate.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "tspan")); + XsltForms_output_svgtemplate.lastChild.setAttribute("xforms-name", "body"); } XsltForms_output_svgtemplate = Array.prototype.slice.call(XsltForms_output_svgtemplate.childNodes); XsltForms_browser.addLoadListener(new Function( - "Array.prototype.slice.call(document.querySelectorAll('*[xforms-name=\"output\"]')).forEach(function(elt) { if (!elt.xfElement) { XsltForms_class._applyTemplate(elt, XsltForms_output_svgtemplate); elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); elt.xfElement = new XsltForms_output(XsltForms_subform.subforms['xsltforms-mainform'], elt); } });" + "Array.prototype.slice.call(document.querySelectorAll('*[xforms-name=\"output\"]')).forEach(function(elt) { if (!elt.xfElement) { XsltForms_class._applyTemplate(elt, XsltForms_output_svgtemplate); elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); elt.xfElement = new XsltForms_output(XsltForms_subform.subforms['xsltforms-mainform'], elt); } });" )); -function XsltForms_output(subform, elt) { - XsltForms_globals.counters.output++; - this.init(subform, elt); - this.controlName = "output"; - var cells = this.element.children || this.element.childNodes; - for (var i = 0, l = cells.length; i < l; i++) { - if (cells[i].localName.toLowerCase() === "xforms-body" || cells[i].getAttribute("xforms-name") === "body") { - this.cell = cells[i]; - break; - } - } - this.binding = new XsltForms_binding(subform, elt); - this.hasBinding = true; //typeof binding !== "string"; - var mediatype; - Array.prototype.slice.call(elt.children || elt.childNodes).forEach(function(n) { - switch(n.localName.toLowerCase()) { - case "xforms-mediatype": - mediatype = n; - break; - } - }); - this.mediatype = mediatype ? mediatype.hasAttribute("xf-value") ? new XsltForms_binding(this.subform, mediatype) : mediatype.textContent : elt.getAttribute("xf-mediatype"); - this.complex = this.mediatype === "application/xhtml+xml" || this.mediatype === "text/html" || this.mediatype === "text/markdown"; - this.isOutput = true; - //if (this.binding) { - // if (this.binding.type) { - // XsltForms_browser.setClass(this.element, "xforms-disabled", false); - /* - } else if (typeof binding === "string") { - this.setValue(binding); - */ - // } - //} -} - -XsltForms_output.prototype = new XsltForms_control(); - +function XsltForms_output(subform, elt) { + XsltForms_globals.counters.output++; + this.init(subform, elt); + this.controlName = "output"; + var cells = this.element.children || this.element.childNodes; + for (var i = 0, l = cells.length; i < l; i++) { + if (cells[i].localName.toLowerCase() === "xforms-body" || cells[i].getAttribute("xforms-name") === "body") { + this.cell = cells[i]; + break; + } + } + this.binding = new XsltForms_binding(subform, elt); + this.hasBinding = true; //typeof binding !== "string"; + var mediatype; + Array.prototype.slice.call(elt.children || elt.childNodes).forEach(function(n) { + switch(n.localName.toLowerCase()) { + case "xforms-mediatype": + mediatype = n; + break; + } + }); + this.mediatype = mediatype ? mediatype.hasAttribute("xf-value") ? new XsltForms_binding(this.subform, mediatype) : mediatype.textContent : elt.getAttribute("xf-mediatype"); + this.complex = this.mediatype === "application/xhtml+xml" || this.mediatype === "text/html" || this.mediatype === "text/markdown"; + this.isOutput = true; + //if (this.binding) { + // if (this.binding.type) { + // XsltForms_browser.setClass(this.element, "xforms-disabled", false); + /* + } else if (typeof binding === "string") { + this.setValue(binding); + */ + // } + //} +} + +XsltForms_output.prototype = new XsltForms_control(); + - + /** * * '''clone''' method : creates a new output control with the given id */ - -XsltForms_output.prototype.clone = function(id) { - return new XsltForms_output(this.subform, id, this.valoff, this.binding, this.mediatype); -}; - - +XsltForms_output.prototype.clone = function(id) { + return new XsltForms_output(this.subform, id, this.valoff, this.binding, this.mediatype); +}; + + + /** * * '''dispose''' method : clears properties of this control and calls the parent dispose() method */ - -XsltForms_output.prototype.dispose = function() { - this.cell = null; - XsltForms_globals.counters.output--; - XsltForms_control.prototype.dispose.call(this); -}; - - +XsltForms_output.prototype.dispose = function() { + this.cell = null; + XsltForms_globals.counters.output--; + XsltForms_control.prototype.dispose.call(this); +}; + + + /** * * '''setValue''' method : sets the value of this output control */ - -XsltForms_output.prototype.setValue = function(value) { - var element = this.cell; - var mediatype = this.mediatype; - var i, li; - if (mediatype && mediatype.bind_evaluate) { - mediatype = XsltForms_globals.stringValue(mediatype.bind_evaluate(this.subform, this.boundnodes[0])); - } - if (!mediatype || mediatype.indexOf("image/") !== 0 || mediatype === "image/svg+xml") { - if (element.nodeName.toLowerCase() === "xforms-body" || element.nodeName.toLowerCase() === "tspan" || element.nodeName.toLowerCase() === "xforms-label") { - if (mediatype === "application/xhtml+xml" || mediatype === "text/html") { - while (element.firstChild) { - element.removeChild(element.firstChild); - } - if (value) { - element.innerHTML = value; - } - } else if (mediatype === "text/markdown") { - while (element.firstChild) { - element.removeChild(element.firstChild); - } - if (value) { - element.innerHTML = XsltForms_browser.md2string(value); - } - } else if (mediatype === "image/svg+xml") { - while (element.firstChild) { - element.removeChild(element.firstChild); - } - if (XsltForms_browser.isIE && !XsltForms_browser.isIE9) { - var xamlScript = XsltForms_browser.isXhtml ? document.createElementNS("http://www.w3.org/1999/xhtml", "script") : document.createElement("script"); - xamlScript.setAttribute("type", "text/xaml"); - xamlScript.setAttribute("id", this.element.id+"-xaml"); - xamlScript.text = XsltForms_browser.transformText(value, XsltForms_browser.ROOT + "svg2xaml.xsl", false, "width", element.currentStyle.width, "height", element.currentStyle.height); - element.appendChild(xamlScript); - var xamlObject = XsltForms_browser.isXhtml ? document.createElementNS("http://www.w3.org/1999/xhtml", "object") : document.createElement("object"); - xamlObject.setAttribute("width", element.currentStyle.width+"px"); - xamlObject.setAttribute("height", element.currentStyle.height+"px"); - xamlObject.setAttribute("type", "application/x-silverlight"); - xamlObject.setAttribute("style", "min-width: " + element.currentStyle.width+"px"); - //xamlObject.setAttribute("style", "min-width: " + xamlScript.text.substring(xamlScript.text.indexOf('"; - } -}; - +XsltForms_output.prototype.setValue = function(value) { + var element = this.cell; + var mediatype = this.mediatype; + var i, li; + if (mediatype && mediatype.bind_evaluate) { + mediatype = XsltForms_globals.stringValue(mediatype.bind_evaluate(this.subform, this.boundnodes[0])); + } + if (!mediatype || mediatype.indexOf("image/") !== 0 || mediatype === "image/svg+xml") { + if (element.nodeName.toLowerCase() === "xforms-body" || element.nodeName.toLowerCase() === "tspan" || element.nodeName.toLowerCase() === "xforms-label") { + if (mediatype === "application/xhtml+xml" || mediatype === "text/html") { + while (element.firstChild) { + element.removeChild(element.firstChild); + } + if (value) { + element.innerHTML = value; + } + } else if (mediatype === "text/markdown") { + while (element.firstChild) { + element.removeChild(element.firstChild); + } + if (value) { + element.innerHTML = XsltForms_browser.md2string(value); + } + } else if (mediatype === "image/svg+xml") { + while (element.firstChild) { + element.removeChild(element.firstChild); + } + if (XsltForms_browser.isIE && !XsltForms_browser.isIE9) { + var xamlScript = XsltForms_browser.isXhtml ? document.createElementNS("http://www.w3.org/1999/xhtml", "script") : document.createElement("script"); + xamlScript.setAttribute("type", "text/xaml"); + xamlScript.setAttribute("id", this.element.id+"-xaml"); + xamlScript.text = XsltForms_browser.transformText(value, XsltForms_browser.ROOT + "svg2xaml.xsl", false, "width", element.currentStyle.width, "height", element.currentStyle.height); + element.appendChild(xamlScript); + var xamlObject = XsltForms_browser.isXhtml ? document.createElementNS("http://www.w3.org/1999/xhtml", "object") : document.createElement("object"); + xamlObject.setAttribute("width", element.currentStyle.width+"px"); + xamlObject.setAttribute("height", element.currentStyle.height+"px"); + xamlObject.setAttribute("type", "application/x-silverlight"); + xamlObject.setAttribute("style", "min-width: " + element.currentStyle.width+"px"); + //xamlObject.setAttribute("style", "min-width: " + xamlScript.text.substring(xamlScript.text.indexOf('"; + } +}; + + /** * * '''getValue''' method : gets the value of this output control */ - -XsltForms_output.prototype.getValue = function(format) { - var element = this.cell; - if (element.nodeName.toLowerCase() === "span") { - return XsltForms_browser.getValue(element, format); - } - var value = element.src; - if (value && format && element.type.format) { - try { - value = element.type.format(value); - } catch(e) { - } - } - return value; + +XsltForms_output.prototype.getValue = function(format) { + var element = this.cell; + if (element.nodeName.toLowerCase() === "span") { + return XsltForms_browser.getValue(element, format); + } + var value = element.src; + if (value && format && element.type.format) { + try { + value = element.type.format(value); + } catch(e) { + } + } + return value; }; \ No newline at end of file diff --git a/src/js/xsltforms.js/controls/project.json b/src/js/xsltforms.js/controls/project.json index cb5d877..6ac408a 100644 --- a/src/js/xsltforms.js/controls/project.json +++ b/src/js/xsltforms.js/controls/project.json @@ -1,27 +1,27 @@ { - "Name":"controls.js", - "Description":"== XForms Controls Management ==\nEach control is stored as a Javascript object created by the XSLT transformation with the id of the corresponding (X)HTML element as a property.\nThe element class is the parent class for all action classes, having the control class as intermediate for most of them.", - "Components":[ - "element.js", - "control.js", - "var.js", - "tree.js", - "AVT.js", - "case.js", - "component.js", - "dialog.js", - "group.js", - "include.js", - "input.js", - "output.js", - "item.js", - "itemset.js", - "range.js", - "repeat.js", - "select.js", - "trigger.js", - "upload.js", - "label.js", - "Calendar.js" - ] + "Name":"controls.js", + "Description":"== XForms Controls Management ==\nEach control is stored as a Javascript object created by the XSLT transformation with the id of the corresponding (X)HTML element as a property.\nThe element class is the parent class for all action classes, having the control class as intermediate for most of them.", + "Components":[ + "element.js", + "control.js", + "var.js", + "tree.js", + "AVT.js", + "case.js", + "component.js", + "dialog.js", + "group.js", + "include.js", + "input.js", + "output.js", + "item.js", + "itemset.js", + "range.js", + "repeat.js", + "select.js", + "trigger.js", + "upload.js", + "label.js", + "Calendar.js" + ] } \ No newline at end of file diff --git a/src/js/xsltforms.js/controls/range.js b/src/js/xsltforms.js/controls/range.js index 4026e63..c4c9e73 100644 --- a/src/js/xsltforms.js/controls/range.js +++ b/src/js/xsltforms.js/controls/range.js @@ -1,225 +1,223 @@ -/*eslint-env browser*/ -/*globals XsltForms_globals XsltForms_browser Fleur XsltForms_schema XsltForms_control XsltForms_class XsltForms_binding*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module range * @description === "XsltForms_range" class === * Upload Control Class * * constructor function : initializes specific properties including aid button management */ - + new XsltForms_class("XsltForms_range", "HTMLElement", "xforms-range", ""); -function XsltForms_range(subform, elt) { - XsltForms_globals.counters.upload++; - this.init(subform, elt); - this.controlName = "range"; - this.binding = new XsltForms_binding(subform, elt); - this.incremental = elt.getAttribute("xf-incremental") !== "false"; - this.hasBinding = true; - this.start = parseFloat(elt.getAttribute("xf-start") || 0); - this.end = parseFloat(elt.getAttribute("xf-end") || 0); - this.step = parseFloat(elt.getAttribute("xf-step") || 1); - this.value = ""; - var cells = this.element.children; - for (var i = 0, l = cells.length; i < l; i++) { - var cname = cells[i].localName.toLowerCase(); - if (cname === "xforms-body") { - this.cell = cells[i]; - } else if (cname === "xforms-hint" && cells[i].getAttribute("xf-appearance") === "minimal") { - elt.setAttribute("title", cells[i].textContent); - } - } - this.initBody(); -} - -XsltForms_range.prototype = new XsltForms_control(); - - - +function XsltForms_range(subform, elt) { + XsltForms_globals.counters.upload++; + this.init(subform, elt); + this.controlName = "range"; + this.binding = new XsltForms_binding(subform, elt); + this.incremental = elt.getAttribute("xf-incremental") !== "false"; + this.hasBinding = true; + this.start = parseFloat(elt.getAttribute("xf-start") || 0); + this.end = parseFloat(elt.getAttribute("xf-end") || 0); + this.step = parseFloat(elt.getAttribute("xf-step") || 1); + this.value = ""; + var cells = this.element.children; + for (var i = 0, l = cells.length; i < l; i++) { + var cname = cells[i].localName.toLowerCase(); + if (cname === "xforms-body") { + this.cell = cells[i]; + } else if (cname === "xforms-hint" && cells[i].getAttribute("xf-appearance") === "minimal") { + elt.setAttribute("title", cells[i].textContent); + } + } + this.initBody(); +} + +XsltForms_range.prototype = new XsltForms_control(); + + + /** * * '''clone''' method : creates a new range with the given id */ - -XsltForms_range.prototype.clone = function(id) { - return new XsltForms_range(this.subform, id, this.valoff, this.binding, this.incremental, this.start, this.end, this.step, this.bolAidButton, true); -}; - - +XsltForms_range.prototype.clone = function(id) { + return new XsltForms_range(this.subform, id, this.valoff, this.binding, this.incremental, this.start, this.end, this.step, this.bolAidButton, true); +}; + + + /** * * '''dispose''' method : clears properties of this element and calls the parent dispose() method */ - -XsltForms_range.prototype.dispose = function() { - this.cell = null; - XsltForms_globals.counters.range--; - XsltForms_control.prototype.dispose.call(this); -}; - - + +XsltForms_range.prototype.dispose = function() { + this.cell = null; + XsltForms_globals.counters.range--; + XsltForms_control.prototype.dispose.call(this); +}; + + /** * * '''initBody''' method : initializes the input control body according to its type (password/textarea/boolean/date/datetime) */ XsltForms_range.railfocus = function(evt) { - var target = XsltForms_browser.events.getTarget(evt); - var parentNode = target; - while (parentNode && parentNode.nodeType === Fleur.Node.ELEMENT_NODE) { - var xf = parentNode.xfElement; - if (xf) { - alert("rail_focus "+xf.element.id); - break; - } - parentNode = parentNode.parentNode; - } + var target = XsltForms_browser.events.getTarget(evt); + var parentNode = target; + while (parentNode && parentNode.nodeType === Fleur.Node.ELEMENT_NODE) { + var xf = parentNode.xfElement; + if (xf) { + alert("rail_focus "+xf.element.id); + break; + } + parentNode = parentNode.parentNode; + } }; XsltForms_range.raildown = function(evt) { - var target = XsltForms_browser.events.getTarget(evt); - var parentNode = target; - while (parentNode && parentNode.nodeType === Fleur.Node.ELEMENT_NODE) { - var xf = parent.xfElement; - if (xf) { - var newPos = XsltForms_browser.getEventPos(evt).x + (window.pageLeft !== undefined ? window.pageLeft : (document.documentElement && document.documentElement.scrollLeft !== undefined) ? document.documentElement.scrollLeft : document.body.scrollLeft); - parentNode = xf.rail; - while (parentNode) { - newPos -= parentNode.offsetLeft; - parentNode = parentNode.offsetParent; - } - var node = xf.element.node; - var value = Math.round(newPos / xf.rail.clientWidth * (xf.end - xf.start) / xf.step) * xf.step + xf.start; - var dt = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string"); - if (dt.format) { - value = dt.format(value); - } - xf.setValue(value); - if (xf.incremental) { - XsltForms_globals.openAction("XsltForms_range#1"); - xf.valueChanged(String(xf.value)); - XsltForms_globals.closeAction("XsltForms_range#1"); - } - if (!document.activeElement || !document.activeElement !== xf.cursor) { - xf.cursor.focus(); - } - break; - } - parentNode = parentNode.parentNode; - } + var target = XsltForms_browser.events.getTarget(evt); + var parentNode = target; + while (parentNode && parentNode.nodeType === Fleur.Node.ELEMENT_NODE) { + var xf = parent.xfElement; + if (xf) { + var newPos = XsltForms_browser.getEventPos(evt).x + (window.pageLeft !== undefined ? window.pageLeft : (document.documentElement && document.documentElement.scrollLeft !== undefined) ? document.documentElement.scrollLeft : document.body.scrollLeft); + parentNode = xf.rail; + while (parentNode) { + newPos -= parentNode.offsetLeft; + parentNode = parentNode.offsetParent; + } + var node = xf.element.node; + var value = Math.round(newPos / xf.rail.clientWidth * (xf.end - xf.start) / xf.step) * xf.step + xf.start; + var dt = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string"); + if (dt.format) { + value = dt.format(value); + } + xf.setValue(value); + if (xf.incremental) { + XsltForms_globals.openAction("XsltForms_range#1"); + xf.valueChanged(String(xf.value)); + XsltForms_globals.closeAction("XsltForms_range#1"); + } + if (!document.activeElement || !document.activeElement !== xf.cursor) { + xf.cursor.focus(); + } + break; + } + parentNode = parentNode.parentNode; + } }; XsltForms_range.cursordown = function(evt) { - var target0 = XsltForms_browser.events.getTarget(evt); - var parentNode0 = target0; - while (parentNode0 && parentNode0.nodeType === Fleur.Node.ELEMENT_NODE) { - var xf0 = parentNode0.xfElement; - if (xf0) { - xf0.offset = XsltForms_browser.getEventPos(evt).x + (window.pageLeft !== undefined ? window.pageLeft : (document.documentElement && document.documentElement.scrollLeft !== undefined) ? document.documentElement.scrollLeft : document.body.scrollLeft); - parentNode0 = xf0.cursor; - while (parentNode0) { - xf0.offset -= parentNode0.offsetLeft; - parentNode0 = parentNode0.offsetParent; - } - document.onmousemove = function(evt) { - var target = XsltForms_browser.isIE ? document.activeElement : XsltForms_browser.events.getTarget(evt); - var parentNode = target; - while (parentNode && parentNode.nodeType === Fleur.Node.ELEMENT_NODE) { - var xf = parentNode.xfElement; - if (xf) { - var newPos = XsltForms_browser.getEventPos(evt).x - xf.offset + (window.pageLeft !== undefined ? window.pageLeft : (document.documentElement && document.documentElement.scrollLeft !== undefined) ? document.documentElement.scrollLeft : document.body.scrollLeft); - parentNode = xf.rail; - while (parentNode) { - newPos -= parentNode.offsetLeft; - parentNode = parentNode.offsetParent; - } - var node = xf.element.node; - var value = Math.round(newPos / xf.rail.clientWidth * (xf.end - xf.start) / xf.step) * xf.step + xf.start; - value = Math.min(Math.max(value, xf.start), xf.end); - var dt = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string"); - if (dt.format) { - value = dt.format(value); - } - xf.setValue(value); - if (xf.incremental) { - XsltForms_globals.openAction("XsltForms_range#2"); - xf.valueChanged(String(xf.value)); - XsltForms_globals.closeAction("XsltForms_range#2"); - } - if (!document.activeElement || !document.activeElement !== xf.cursor) { - xf.cursor.focus(); - } - break; - } - parentNode = parentNode.parentNode; - } - }; - document.onmouseup = function() { - document.onmousemove = null; - document.onmouseup = null; - }; - if (!document.activeElement || !document.activeElement !== xf0.cursor) { - xf0.cursor.focus(); - } - break; - } - parentNode0 = parentNode0.parentNode; - } - if (typeof evt.stopPropagation === "function") { - evt.stopPropagation(); - } - else if (typeof evt.cancelBubble !== "undefined") { - evt.cancelBubble = true; - } - if (evt.preventDefault) { - evt.preventDefault(); - } + var target0 = XsltForms_browser.events.getTarget(evt); + var parentNode0 = target0; + while (parentNode0 && parentNode0.nodeType === Fleur.Node.ELEMENT_NODE) { + var xf0 = parentNode0.xfElement; + if (xf0) { + xf0.offset = XsltForms_browser.getEventPos(evt).x + (window.pageLeft !== undefined ? window.pageLeft : (document.documentElement && document.documentElement.scrollLeft !== undefined) ? document.documentElement.scrollLeft : document.body.scrollLeft); + parentNode0 = xf0.cursor; + while (parentNode0) { + xf0.offset -= parentNode0.offsetLeft; + parentNode0 = parentNode0.offsetParent; + } + document.onmousemove = function(evt) { + var target = XsltForms_browser.isIE ? document.activeElement : XsltForms_browser.events.getTarget(evt); + var parentNode = target; + while (parentNode && parentNode.nodeType === Fleur.Node.ELEMENT_NODE) { + var xf = parentNode.xfElement; + if (xf) { + var newPos = XsltForms_browser.getEventPos(evt).x - xf.offset + (window.pageLeft !== undefined ? window.pageLeft : (document.documentElement && document.documentElement.scrollLeft !== undefined) ? document.documentElement.scrollLeft : document.body.scrollLeft); + parentNode = xf.rail; + while (parentNode) { + newPos -= parentNode.offsetLeft; + parentNode = parentNode.offsetParent; + } + var node = xf.element.node; + var value = Math.round(newPos / xf.rail.clientWidth * (xf.end - xf.start) / xf.step) * xf.step + xf.start; + value = Math.min(Math.max(value, xf.start), xf.end); + var dt = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string"); + if (dt.format) { + value = dt.format(value); + } + xf.setValue(value); + if (xf.incremental) { + XsltForms_globals.openAction("XsltForms_range#2"); + xf.valueChanged(String(xf.value)); + XsltForms_globals.closeAction("XsltForms_range#2"); + } + if (!document.activeElement || !document.activeElement !== xf.cursor) { + xf.cursor.focus(); + } + break; + } + parentNode = parentNode.parentNode; + } + }; + document.onmouseup = function() { + document.onmousemove = null; + document.onmouseup = null; + }; + if (!document.activeElement || !document.activeElement !== xf0.cursor) { + xf0.cursor.focus(); + } + break; + } + parentNode0 = parentNode0.parentNode; + } + if (typeof evt.stopPropagation === "function") { + evt.stopPropagation(); + } + else if (typeof evt.cancelBubble !== "undefined") { + evt.cancelBubble = true; + } + if (evt.preventDefault) { + evt.preventDefault(); + } }; XsltForms_range.prototype.initBody = function() { - if (this.cell.children.length === 0) { - this.cell.innerHTML = ''; - } - this.rail = this.cell.children[0]; - this.cursor = this.rail.children[0]; - this.outputvalue = this.cell.children[1]; - XsltForms_browser.events.attach(this.rail, "focus", XsltForms_range.railfocus); - XsltForms_browser.events.attach(this.rail, "mousedown", XsltForms_range.raildown); - XsltForms_browser.events.attach(this.cursor, "mousedown", XsltForms_range.cursordown); - this.initFocus(this.cell.children[0], true); + if (this.cell.children.length === 0) { + this.cell.innerHTML = ''; + } + this.rail = this.cell.children[0]; + this.cursor = this.rail.children[0]; + this.outputvalue = this.cell.children[1]; + XsltForms_browser.events.attach(this.rail, "focus", XsltForms_range.railfocus); + XsltForms_browser.events.attach(this.rail, "mousedown", XsltForms_range.raildown); + XsltForms_browser.events.attach(this.cursor, "mousedown", XsltForms_range.cursordown); + this.initFocus(this.cell.children[0], true); }; - - + + /** * * '''setValue''' method : sets the value of this input control according to its type */ - -XsltForms_range.prototype.setValue = function(value) { - this.outputvalue.innerHTML = value; - var node = this.element.node; - var f = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string").parse; - if (f) { - value = f(value); - } - if (this.value !== value) { - this.value = value; - this.cursor.style.left = Math.round(this.rail.clientWidth * (this.value - this.start) / (this.end - this.start)) + "px"; - } -}; - - - + +XsltForms_range.prototype.setValue = function(value) { + this.outputvalue.innerHTML = value; + var node = this.element.node; + var f = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string").parse; + if (f) { + value = f(value); + } + if (this.value !== value) { + this.value = value; + this.cursor.style.left = Math.round(this.rail.clientWidth * (this.value - this.start) / (this.end - this.start)) + "px"; + } +}; + + + /** * * '''blur''' method : manages the blur event when not in incremental mode * @callback */ - -XsltForms_range.prototype.blur = function(target) { - XsltForms_globals.focus = null; - if (!this.incremental) { - XsltForms_browser.assert(this.input, this.element.id); - this.valueChanged(this.value); - } + +XsltForms_range.prototype.blur = function(target) { + XsltForms_globals.focus = null; + if (!this.incremental) { + XsltForms_browser.assert(this.input, this.element.id); + this.valueChanged(this.value); + } }; \ No newline at end of file diff --git a/src/js/xsltforms.js/controls/repeat.js b/src/js/xsltforms.js/controls/repeat.js index 228f299..949230d 100644 --- a/src/js/xsltforms.js/controls/repeat.js +++ b/src/js/xsltforms.js/controls/repeat.js @@ -1,458 +1,454 @@ -/*eslint-env browser*/ -/*globals XsltForms_globals XsltForms_browser XsltForms_element Fleur XsltForms_idManager XsltForms_class XsltForms_subform XsltForms_binding XsltForms_classes XsltForms_collection XsltForms_avt*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module repeat * @description === "XsltForms_repeat" class === * Repeat Element Class * * constructor function : sets specific properties */ - + new XsltForms_class("XsltForms_repeat", "HTMLElement", "xforms-repeat"); XsltForms_browser.addLoadListener(new Function( - "Array.prototype.slice.call(document.querySelectorAll('*[xf-repeat-ref]')).forEach(function(elt) { if (!elt.xfElement) { elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); elt.xfElement = new XsltForms_repeat(XsltForms_subform.subforms['xsltforms-mainform'], elt); } });" + "Array.prototype.slice.call(document.querySelectorAll('*[xf-repeat-ref]')).forEach(function(elt) { if (!elt.xfElement) { elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); elt.xfElement = new XsltForms_repeat(XsltForms_subform.subforms['xsltforms-mainform'], elt); } });" )); XsltForms_browser.addLoadListener(new Function( - "Array.prototype.slice.call(document.querySelectorAll('*[xf-repeat-bind]')).forEach(function(elt) { if (!elt.xfElement) { elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); elt.xfElement = new XsltForms_repeat(XsltForms_subform.subforms['xsltforms-mainform'], elt); } });" + "Array.prototype.slice.call(document.querySelectorAll('*[xf-repeat-bind]')).forEach(function(elt) { if (!elt.xfElement) { elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); elt.xfElement = new XsltForms_repeat(XsltForms_subform.subforms['xsltforms-mainform'], elt); } });" )); XsltForms_browser.addLoadListener(new Function( - "Array.prototype.slice.call(document.querySelectorAll('*[data-xf-repeat-ref]')).forEach(function(elt) { if (!elt.xfElement) { elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); elt.xfElement = new XsltForms_repeat(XsltForms_subform.subforms['xsltforms-mainform'], elt); } });" + "Array.prototype.slice.call(document.querySelectorAll('*[data-xf-repeat-ref]')).forEach(function(elt) { if (!elt.xfElement) { elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); elt.xfElement = new XsltForms_repeat(XsltForms_subform.subforms['xsltforms-mainform'], elt); } });" )); XsltForms_browser.addLoadListener(new Function( - "Array.prototype.slice.call(document.querySelectorAll('*[data-xf-repeat-bind]')).forEach(function(elt) { if (!elt.xfElement) { elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); elt.xfElement = new XsltForms_repeat(XsltForms_subform.subforms['xsltforms-mainform'], elt); } });" + "Array.prototype.slice.call(document.querySelectorAll('*[data-xf-repeat-bind]')).forEach(function(elt) { if (!elt.xfElement) { elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); elt.xfElement = new XsltForms_repeat(XsltForms_subform.subforms['xsltforms-mainform'], elt); } });" )); XsltForms_browser.addLoadListener(new Function( - "Array.prototype.slice.call(document.querySelectorAll('*[xforms-name=\"repeat\"]')).forEach(function(elt) { if (!elt.xfElement) { elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); elt.xfElement = new XsltForms_repeat(XsltForms_subform.subforms['xsltforms-mainform'], elt); } });" + "Array.prototype.slice.call(document.querySelectorAll('*[xforms-name=\"repeat\"]')).forEach(function(elt) { if (!elt.xfElement) { elt.xfIndex = XsltForms_collection.length; XsltForms_collection.push(elt); elt.xfElement = new XsltForms_repeat(XsltForms_subform.subforms['xsltforms-mainform'], elt); } });" )); function XsltForms_repeat(subform, elt) { - this.init(subform, elt); - this.controlName = "repeat"; - this.index = 1; - this.isRepeat = true; - this.hasBinding = true; - if (elt.localName.toLowerCase() === "xforms-repeat" || elt.getAttribute("xforms-name") === "repeat") { - this.binding = elt.hasAttribute("xf-ref") || elt.hasAttribute("xf-bind") ? new XsltForms_binding(subform, elt) : null; - this.nbsiblings = 0; - //var el = this.element; - this.root = elt; - this.isItemset = false; - if ((!elt.firstChild.localName || elt.firstChild.localName.toLowerCase() !== "xforms-repeat-item") && (!elt.firstChild.getAttribute || elt.firstChild.getAttribute("xforms-name") !== "repeat-item")) { - var ritem; - if (elt.localName.toLowerCase() === "xforms-repeat") { - ritem = document.createElement("xforms-repeat-item"); - } else { - ritem = document.createElementNS(elt.namespaceURI, elt.localName); - ritem.setAttribute("xforms-name", "repeat-item"); - } - var cells = Array.prototype.slice.call(this.element.childNodes); - for (var i = 0, l = cells.length; i < l; i++) { - ritem.appendChild(cells[i]); - } - ritem.varScope = elt.varScope; - elt.varScope = null; - elt.appendChild(ritem); - } - } else { - if (elt.hasAttribute("xf-repeat-ref") || elt.hasAttribute("xf-repeat-bind")) { - this.binding = new XsltForms_binding(subform, elt, "xf-repeat-ref"); - } else if (elt.hasAttribute("data-xf-repeat-ref") || elt.hasAttribute("data-xf-repeat-bind")) { - this.binding = new XsltForms_binding(subform, elt, "data-xf-repeat-ref"); - } else { - this.binding = null; - } - this.nbsiblings = 0; - this.root = elt; - } + this.init(subform, elt); + this.controlName = "repeat"; + this.index = 1; + this.isRepeat = true; + this.hasBinding = true; + if (elt.localName.toLowerCase() === "xforms-repeat" || elt.getAttribute("xforms-name") === "repeat") { + this.binding = elt.hasAttribute("xf-ref") || elt.hasAttribute("xf-bind") ? new XsltForms_binding(subform, elt) : null; + this.nbsiblings = 0; + //var el = this.element; + this.root = elt; + this.isItemset = false; + if ((!elt.firstChild.localName || elt.firstChild.localName.toLowerCase() !== "xforms-repeat-item") && (!elt.firstChild.getAttribute || elt.firstChild.getAttribute("xforms-name") !== "repeat-item")) { + var ritem; + if (elt.localName.toLowerCase() === "xforms-repeat") { + ritem = document.createElement("xforms-repeat-item"); + } else { + ritem = document.createElementNS(elt.namespaceURI, elt.localName); + ritem.setAttribute("xforms-name", "repeat-item"); + } + var cells = Array.prototype.slice.call(this.element.childNodes); + for (var i = 0, l = cells.length; i < l; i++) { + ritem.appendChild(cells[i]); + } + elt.appendChild(ritem); + } + } else { + if (elt.hasAttribute("xf-repeat-ref") || elt.hasAttribute("xf-repeat-bind")) { + this.binding = new XsltForms_binding(subform, elt, "xf-repeat-ref"); + } else if (elt.hasAttribute("data-xf-repeat-ref") || elt.hasAttribute("data-xf-repeat-bind")) { + this.binding = new XsltForms_binding(subform, elt, "data-xf-repeat-ref"); + } else { + this.binding = null; + } + this.nbsiblings = 0; + this.root = elt; + } } XsltForms_repeat.prototype = new XsltForms_element(); - + /** * * '''dispose''' method : clears properties of this element and calls the parent dispose() method */ XsltForms_repeat.prototype.dispose = function() { - this.root = null; - XsltForms_globals.counters.repeat--; - XsltForms_element.prototype.dispose.call(this); + this.root = null; + XsltForms_globals.counters.repeat--; + XsltForms_element.prototype.dispose.call(this); }; - + /** * * '''setIndex''' method : sets the current index for this repeat element */ XsltForms_repeat.prototype.setIndex = function(index) { - if (this.nodes.length === 0) { - this.index = 0; - } else if (this.index !== index) { - var node = this.nodes[index - 1]; - if (node) { - XsltForms_globals.openAction("XsltForms_repeat.prototype.setIndex"); - this.index = index; - this.element.node = node; - XsltForms_globals.addChange(this); - XsltForms_globals.addChange(document.getElementById(XsltForms_browser.getDocMeta(node.ownerDocument, "model")).xfElement); - XsltForms_globals.closeAction("XsltForms_repeat.prototype.setIndex"); - } - } + if (this.nodes.length === 0) { + this.index = 0; + } else if (this.index !== index) { + var node = this.nodes[index - 1]; + if (node) { + XsltForms_globals.openAction("XsltForms_repeat.prototype.setIndex"); + this.index = index; + this.element.node = node; + XsltForms_globals.addChange(this); + XsltForms_globals.addChange(document.getElementById(XsltForms_browser.getDocMeta(node.ownerDocument, "model")).xfElement); + XsltForms_globals.closeAction("XsltForms_repeat.prototype.setIndex"); + } + } }; - + /** * * '''deleteNode''' method : deletes the given node within this repeat element and makes sure that the current index is still valid */ XsltForms_repeat.prototype.deleteNode = function(node) { - var newNodes = []; - var nodes = this.nodes; - for (var i = 0, len = nodes.length; i < len; i++) { - if (node !== nodes[i]) { - newNodes.push(nodes[i]); - } - } - this.nodes = newNodes; - this.setIndex(this.index === nodes.length? this.index - 1 : this.index); + var newNodes = []; + var nodes = this.nodes; + for (var i = 0, len = nodes.length; i < len; i++) { + if (node !== nodes[i]) { + newNodes.push(nodes[i]); + } + } + this.nodes = newNodes; + this.setIndex(this.index === nodes.length? this.index - 1 : this.index); }; - + /** * * '''insertNode''' method : inserts the given node after another given node within this repeat element and updates the current index */ XsltForms_repeat.prototype.insertNode = function(node, nodeAfter) { - var i, len, nodes = this.nodes; - if (nodeAfter) { - var repeatAfter = null; - for (i = 0, len = nodes.length; i < len && repeatAfter === null; i++) { - repeatAfter = nodeAfter; - while (repeatAfter !== null && repeatAfter !== nodes[i]) { - repeatAfter = repeatAfter.nextSibling; - } - } - } - if (repeatAfter) { - var newNodes = []; - var index = 1; - for (i = 0, len = nodes.length; i < len; i++) { - if (repeatAfter === nodes[i]) { - newNodes.push(node); - index = i + 1; - } - newNodes.push(nodes[i]); - } - this.nodes = newNodes; - this.setIndex(index); - } else { - nodes.push(node); - this.setIndex(nodes.length); - } + var i, len, nodes = this.nodes; + if (nodeAfter) { + var repeatAfter = null; + for (i = 0, len = nodes.length; i < len && repeatAfter === null; i++) { + repeatAfter = nodeAfter; + while (repeatAfter !== null && repeatAfter !== nodes[i]) { + repeatAfter = repeatAfter.nextSibling; + } + } + } + if (repeatAfter) { + var newNodes = []; + var index = 1; + for (i = 0, len = nodes.length; i < len; i++) { + if (repeatAfter === nodes[i]) { + newNodes.push(node); + index = i + 1; + } + newNodes.push(nodes[i]); + } + this.nodes = newNodes; + this.setIndex(index); + } else { + nodes.push(node); + this.setIndex(nodes.length); + } }; - + /** * * '''build_''' method : recreates every nodes within this repeat control and sets the current index at 1 */ XsltForms_repeat.prototype.build_ = function(ctx) { - var nodes0 = this.evaluateBinding(this.binding, ctx); - var nodes = []; - var r0, r, l, child; - if (nodes0.isSingle()) { - nodes[0] = nodes0; - } else { - for (let n = 0, ln = nodes0.childNodes.length; n < ln; n++) { - if (!XsltForms_browser.getBoolMeta(nodes0.childNodes[n], "notrelevant")) { - nodes.push(nodes0.childNodes[n]); - } - } - } - var inputids = {ids: {}, fors: {}}; - this.nodes = nodes; - let n = nodes.length; - if (this.nbsiblings === 0) { - r = this.root; - while (r.firstChild.nodeType === Fleur.Node.TEXT_NODE) { - r.removeChild(r.firstChild); - } - r0 = r.children ? r.children[0] : r.childNodes[0]; - XsltForms_repeat.forceOldId(r0); - l = r.children ? r.children.length : r.childNodes.length; - for (var i = l; i < n; i++) { - child = r0.cloneNode(true); - Array.prototype.slice.call(child.querySelectorAll(".cke")).forEach(function(n) { n.parentNode.removeChild(n); }); - r.appendChild(child); - XsltForms_repeat.initClone(this.subform, child, inputids); - } - for (var j = n; j < l && r.childNodes.length > 1; j++) { - XsltForms_globals.dispose(r.lastChild); - r.removeChild(r.lastChild); - } - for (var k = 0; k < n; k++) { - XsltForms_browser.setMeta(nodes[k], "repeat", String(this.element.xfIndex)); - if (r.children) { - r.children[k].node = nodes[k]; - } else { - r.childNodes[k].node = nodes[k]; - } - } - } else { - r0 = this.root; - XsltForms_repeat.forceOldId(r0); - r = r0.parentNode; - var cc = r.firstChild; - var i0 = 0; - while (cc) { - if (cc === r0) { - break; - } - i0++; - cc = cc.nextSibling; - } - l = 1; - var rl = r.childNodes[i0 + this.nbsiblings]; - while (rl && (rl.id === this.element.id || rl.attributes.oldid.value === this.element.id)) { - l++; - rl = r.childNodes[i0 + l*this.nbsiblings]; - } - for (var ib = l; ib < n; ib++) { - child = r0.cloneNode(true); - Array.prototype.slice.call(child.querySelectorAll(".cke")).forEach(function(n) { n.parentNode.removeChild(n); }); - r.insertBefore(child, rl); - XsltForms_repeat.initClone(this.subform, child, inputids); - delete child.xfElement; - var r0s = r0.nextSibling; - for (var isb = 1; isb < this.nbsiblings; isb++, r0s = r0s.nextSibling) { - child = r0s.cloneNode(true); - r.insertBefore(child, rl); - XsltForms_repeat.initClone(this.subform, child, inputids); - } - } - for (var jb = n; jb < l; jb++) { - var rj = r.childNodes[i0 + (n+1)*this.nbsiblings]; - if (!(rj && (rj.id === this.element.id || rj.attributes.oldid.value === this.element.id))) { - break; - } - for (var jsb = 0; jsb < this.nbsiblings; jsb++) { - XsltForms_globals.dispose(r.children[i0 + n*this.nbsiblings]); - r.removeChild(r.children[i0 + n*this.nbsiblings]); - } - } - for (var kb = 0; kb < n; kb++) { - XsltForms_browser.setMeta(nodes[kb], "repeat", String(this.element.xfIndex)); - if (r.children) { - r.children[i0 + kb*this.nbsiblings].node = nodes[kb]; - } else { - r.childNodes[i0 + kb*this.nbsiblings].node = nodes[kb]; - } - } - } - for (var ii = 0; ii < n; ii++) { - if (this.element.node === nodes[ii]) { - if (this.index !== ii + 1) { - this.index = ii + 1; - XsltForms_globals.addChange(this); - XsltForms_globals.addChange(this.element.node.ownerDocument.model); - } - return; - } - } - this.element.node = nodes[0]; - if (this.element.node) { - if (this.index !== 1) { - this.index = 1; - XsltForms_globals.addChange(this); - XsltForms_globals.addChange(this.element.node.ownerDocument.model); - } - } else { - this.index = 0; - if (XsltForms_globals.ready) { - XsltForms_globals.addChange(this); - } - } + var nodes0 = this.evaluateBinding(this.binding, ctx); + var nodes = []; + var r0, r, l, child; + if (nodes0.isSingle()) { + nodes[0] = nodes0; + } else { + for (let n = 0, ln = nodes0.childNodes.length; n < ln; n++) { + if (!XsltForms_browser.getBoolMeta(nodes0.childNodes[n], "notrelevant")) { + nodes.push(nodes0.childNodes[n]); + } + } + } + var inputids = {ids: {}, fors: {}}; + this.nodes = nodes; + let n = nodes.length; + if (this.nbsiblings === 0) { + r = this.root; + while (r.firstChild.nodeType === Fleur.Node.TEXT_NODE) { + r.removeChild(r.firstChild); + } + r0 = r.children ? r.children[0] : r.childNodes[0]; + XsltForms_repeat.forceOldId(r0); + l = r.children ? r.children.length : r.childNodes.length; + for (var i = l; i < n; i++) { + child = r0.cloneNode(true); + Array.prototype.slice.call(child.querySelectorAll(".cke")).forEach(function(n) { n.parentNode.removeChild(n); }); + r.appendChild(child); + XsltForms_repeat.initClone(this.subform, child, inputids); + } + for (var j = n; j < l && r.childNodes.length > 1; j++) { + XsltForms_globals.dispose(r.lastChild); + r.removeChild(r.lastChild); + } + for (var k = 0; k < n; k++) { + XsltForms_browser.setMeta(nodes[k], "repeat", String(this.element.xfIndex)); + if (r.children) { + r.children[k].node = nodes[k]; + } else { + r.childNodes[k].node = nodes[k]; + } + } + } else { + r0 = this.root; + XsltForms_repeat.forceOldId(r0); + r = r0.parentNode; + var cc = r.firstChild; + var i0 = 0; + while (cc) { + if (cc === r0) { + break; + } + i0++; + cc = cc.nextSibling; + } + l = 1; + var rl = r.childNodes[i0 + this.nbsiblings]; + while (rl && (rl.id === this.element.id || rl.attributes.oldid.value === this.element.id)) { + l++; + rl = r.childNodes[i0 + l*this.nbsiblings]; + } + for (var ib = l; ib < n; ib++) { + child = r0.cloneNode(true); + Array.prototype.slice.call(child.querySelectorAll(".cke")).forEach(function(n) { n.parentNode.removeChild(n); }); + r.insertBefore(child, rl); + XsltForms_repeat.initClone(this.subform, child, inputids); + delete child.xfElement; + var r0s = r0.nextSibling; + for (var isb = 1; isb < this.nbsiblings; isb++, r0s = r0s.nextSibling) { + child = r0s.cloneNode(true); + r.insertBefore(child, rl); + XsltForms_repeat.initClone(this.subform, child, inputids); + } + } + for (var jb = n; jb < l; jb++) { + var rj = r.childNodes[i0 + (n+1)*this.nbsiblings]; + if (!(rj && (rj.id === this.element.id || rj.attributes.oldid.value === this.element.id))) { + break; + } + for (var jsb = 0; jsb < this.nbsiblings; jsb++) { + XsltForms_globals.dispose(r.children[i0 + n*this.nbsiblings]); + r.removeChild(r.children[i0 + n*this.nbsiblings]); + } + } + for (var kb = 0; kb < n; kb++) { + XsltForms_browser.setMeta(nodes[kb], "repeat", String(this.element.xfIndex)); + if (r.children) { + r.children[i0 + kb*this.nbsiblings].node = nodes[kb]; + } else { + r.childNodes[i0 + kb*this.nbsiblings].node = nodes[kb]; + } + } + } + for (var ii = 0; ii < n; ii++) { + if (this.element.node === nodes[ii]) { + if (this.index !== ii + 1) { + this.index = ii + 1; + XsltForms_globals.addChange(this); + XsltForms_globals.addChange(this.element.node.ownerDocument.model); + } + return; + } + } + this.element.node = nodes[0]; + if (this.element.node) { + if (this.index !== 1) { + this.index = 1; + XsltForms_globals.addChange(this); + XsltForms_globals.addChange(this.element.node.ownerDocument.model); + } + } else { + this.index = 0; + if (XsltForms_globals.ready) { + XsltForms_globals.addChange(this); + } + } }; - + /** * * '''refresh''' method : refreshes this repeat element and the child elements if it is not an ItemSet */ XsltForms_repeat.prototype.refresh = function(selected) { - var empty = this.nodes.length === 0; - //if (this.nbsiblings !== 0) { - // var n0 = this.element; - // for (var i0 = 0, l0 = this.nodes.length; i0 < l0; i0++) { - // XsltForms_browser.setClass(n0, "xforms-disabled", empty); - // for (var i1 = 0, l1 = this.nbsiblings; i1 < l1; i1++) { - // n0 = n0.nextSibling; - // } - // } - //} - //XsltForms_browser.setClass(this.element, "xforms-disabled", empty); - if (!empty) { - this.element.setAttribute("xf-bound", ""); - } else { - this.element.removeAttribute("xf-bound"); - } - if (!empty && !this.isItemset) { - if (this.nbsiblings === 0) { - var childs = this.root.children || this.root.childNodes; - for (var i = 0, len = childs.length; i < len; i++) { - var sel = selected && (this.index === i + 1); - childs[i].selected = sel; - //XsltForms_browser.setClass(childs[i], "xforms-repeat-item-selected", sel); - childs[i].setAttribute("xf-selected", String(sel)); - } - } - } + var empty = this.nodes.length === 0; + //if (this.nbsiblings !== 0) { + // var n0 = this.element; + // for (var i0 = 0, l0 = this.nodes.length; i0 < l0; i0++) { + // XsltForms_browser.setClass(n0, "xforms-disabled", empty); + // for (var i1 = 0, l1 = this.nbsiblings; i1 < l1; i1++) { + // n0 = n0.nextSibling; + // } + // } + //} + //XsltForms_browser.setClass(this.element, "xforms-disabled", empty); + if (!empty) { + this.element.setAttribute("xf-bound", ""); + } else { + this.element.removeAttribute("xf-bound"); + } + if (!empty && !this.isItemset) { + if (this.nbsiblings === 0) { + var childs = this.root.children || this.root.childNodes; + for (var i = 0, len = childs.length; i < len; i++) { + var sel = selected && (this.index === i + 1); + childs[i].selected = sel; + //XsltForms_browser.setClass(childs[i], "xforms-repeat-item-selected", sel); + childs[i].setAttribute("xf-selected", String(sel)); + } + } + } }; - + /** * * '''clone''' method : creates a new repeat element with the given id */ XsltForms_repeat.prototype.clone = function(id) { - return new XsltForms_repeat(this.subform, id, this.nbsiblings, this.binding, true); + return new XsltForms_repeat(this.subform, id, this.nbsiblings, this.binding, true); }; - + /** * * '''initClone''' function : initializes a clone for the given id */ XsltForms_repeat.initClone = function(subform, element, inputids) { - if ("LABEL" === element.nodeName.toUpperCase() && element.getAttribute("for") !== "") { - if (inputids.ids[element.getAttribute("for")]) { - element.setAttribute("for", inputids.ids[element.getAttribute("for")]); - } else { - inputids.fors[element.getAttribute("for")] = element; - } - } - var id = element.id; - if (id) { - XsltForms_idManager.cloneId(element); - if ("INPUT" === element.nodeName.toUpperCase()) { - if (inputids.fors[id]) { - inputids.fors[id].setAttribute("for", element.id); - delete inputids.ids[id]; - } else { - inputids.ids[id] = element.id; - } - } - var oldid = element.getAttribute("oldid"); - var original = document.getElementById(oldid); - if (!original) { - original = XsltForms_globals.idalt[oldid]; - } - } - var ename = element.nodeName.toLowerCase(); - var xfclass = XsltForms_classes[ename]; - if (xfclass || (element.nodeType === Fleur.Node.ELEMENT_NODE && element.hasAttribute("xf-avt"))) { - element.xfElement = null; - } - if (xfclass) { - xfclass.classbinding(subform, element); - } - if (element.nodeType === Fleur.Node.ELEMENT_NODE && element.hasAttribute("xforms-name") && XsltForms_classes["xforms-" + element.getAttribute("xforms-name")]) { - element.xfElement = eval("new " + XsltForms_classes["xforms-" + element.getAttribute("xforms-name")].className + "(subform, element)"); - element.xfIndex = XsltForms_collection.length; - XsltForms_collection.push(element); - } - if (element.nodeType === Fleur.Node.ELEMENT_NODE && (element.hasAttribute("xf-repeat-ref") || element.hasAttribute("xf-repeat-bind"))) { - element.xfElement = new XsltForms_repeat(subform, element); - element.xfIndex = XsltForms_collection.length; - XsltForms_collection.push(element); - } - if (element.nodeType === Fleur.Node.ELEMENT_NODE && element.hasAttribute("xf-avt")) { - element.xfIndex = XsltForms_collection.length; - XsltForms_collection.push(element); - Array.prototype.slice.call(element.attributes).filter(function(a) {return a.nodeName.startsWith('xf-template-');}).forEach(function(a) { new XsltForms_avt(subform, element, a.nodeName.substr(12)); }); - } - var parentXF = element.parentNode.xfElement; - if (parentXF && parentXF.isComponent && parentXF.valueElement === element) { - if (parentXF.evaljs) { - eval(parentXF.subjs); - parentXF.evaljs = false; - } - return; - } - //var oldinputids = {ids: inputids.ids.slice(0), fors: inputids.fors.slice(0)}; - var next = element.firstChild; - while (next) { - var child = next; - next = next.nextSibling; - if (child.id && child.getAttribute("cloned")) { - element.removeChild(child); - } else { - XsltForms_repeat.initClone(subform, child, inputids); - } - } + if ("LABEL" === element.nodeName.toUpperCase() && element.getAttribute("for") !== "") { + if (inputids.ids[element.getAttribute("for")]) { + element.setAttribute("for", inputids.ids[element.getAttribute("for")]); + } else { + inputids.fors[element.getAttribute("for")] = element; + } + } + var id = element.id; + if (id) { + XsltForms_idManager.cloneId(element); + if ("INPUT" === element.nodeName.toUpperCase()) { + if (inputids.fors[id]) { + inputids.fors[id].setAttribute("for", element.id); + delete inputids.ids[id]; + } else { + inputids.ids[id] = element.id; + } + } + var oldid = element.getAttribute("oldid"); + var original = document.getElementById(oldid); + if (!original) { + original = XsltForms_globals.idalt[oldid]; + } + } + var ename = element.nodeName.toLowerCase(); + var xfclass = XsltForms_classes[ename]; + if (xfclass || (element.nodeType === Fleur.Node.ELEMENT_NODE && element.hasAttribute("xf-avt"))) { + element.xfElement = null; + } + if (xfclass) { + xfclass.classbinding(subform, element); + } + if (element.nodeType === Fleur.Node.ELEMENT_NODE && element.hasAttribute("xforms-name") && XsltForms_classes["xforms-" + element.getAttribute("xforms-name")]) { + element.xfElement = eval("new " + XsltForms_classes["xforms-" + element.getAttribute("xforms-name")].className + "(subform, element)"); + element.xfIndex = XsltForms_collection.length; + XsltForms_collection.push(element); + } + if (element.nodeType === Fleur.Node.ELEMENT_NODE && (element.hasAttribute("xf-repeat-ref") || element.hasAttribute("xf-repeat-bind"))) { + element.xfElement = new XsltForms_repeat(subform, element); + element.xfIndex = XsltForms_collection.length; + XsltForms_collection.push(element); + } + if (element.nodeType === Fleur.Node.ELEMENT_NODE && element.hasAttribute("xf-avt")) { + element.xfIndex = XsltForms_collection.length; + XsltForms_collection.push(element); + Array.prototype.slice.call(element.attributes).filter(function(a) {return a.nodeName.startsWith('xf-template-');}).forEach(function(a) { new XsltForms_avt(subform, element, a.nodeName.substr(12)); }); + } + var parentXF = element.parentNode.xfElement; + if (parentXF && parentXF.isComponent && parentXF.valueElement === element) { + if (parentXF.evaljs) { + eval(parentXF.subjs); + parentXF.evaljs = false; + } + return; + } + //var oldinputids = {ids: inputids.ids.slice(0), fors: inputids.fors.slice(0)}; + var next = element.firstChild; + while (next) { + var child = next; + next = next.nextSibling; + if (child.id && child.getAttribute("cloned")) { + element.removeChild(child); + } else { + XsltForms_repeat.initClone(subform, child, inputids); + } + } }; - + /** * * '''forceOldId''' function : allows this element to have oldid attributes based on id attributes */ XsltForms_repeat.forceOldId = function(element) { - var id = element.id; - if (id) { - if (id.substr(0, 8) === "clonedId") { - return; - } - element.setAttribute("oldid", id); - } - var next = element.firstChild; - while (next) { - var child = next; - next = next.nextSibling; - XsltForms_repeat.forceOldId(child); - } + var id = element.id; + if (id) { + if (id.substr(0, 8) === "clonedId") { + return; + } + element.setAttribute("oldid", id); + } + var next = element.firstChild; + while (next) { + var child = next; + next = next.nextSibling; + XsltForms_repeat.forceOldId(child); + } }; - + /** * * '''selectItem''' function : set the current index at the given element within a repeat element */ XsltForms_repeat.selectItem = function(element) { - var par = element.parentNode; - if (par) { - var repeat = par.xfElement? par : par.parentNode; - if (repeat.xfElement) { - var childs = par.children; - XsltForms_browser.assert(repeat.xfElement, element.nodeName + " - " + repeat.nodeName); - for (var i = 0, len = childs.length; i < len; i++) { - if (childs[i] === element) { - repeat.xfElement.setIndex(i + 1); - break; - } - } - } else { - var n = element; - var d = 1; - while (n && !n.xfElement) { - n = n.previousSibling; - d++; - } - if (n && n.xfElement && n.xfElement.nbsiblings > 0) { - n.xfElement.setIndex(d / n.xfElement.nbsiblings); - } - } - } + var par = element.parentNode; + if (par) { + var repeat = par.xfElement? par : par.parentNode; + if (repeat.xfElement) { + var childs = par.children; + XsltForms_browser.assert(repeat.xfElement, element.nodeName + " - " + repeat.nodeName); + for (var i = 0, len = childs.length; i < len; i++) { + if (childs[i] === element) { + repeat.xfElement.setIndex(i + 1); + break; + } + } + } else { + var n = element; + var d = 1; + while (n && !n.xfElement) { + n = n.previousSibling; + d++; + } + if (n && n.xfElement && n.xfElement.nbsiblings > 0) { + n.xfElement.setIndex(d / n.xfElement.nbsiblings); + } + } + } }; \ No newline at end of file diff --git a/src/js/xsltforms.js/controls/select.js b/src/js/xsltforms.js/controls/select.js index 3136236..0237d3e 100644 --- a/src/js/xsltforms.js/controls/select.js +++ b/src/js/xsltforms.js/controls/select.js @@ -1,542 +1,540 @@ -/*eslint-env browser*/ -/*globals XsltForms_globals XsltForms_browser XsltForms_control XsltForms_schema XsltForms_xmlevents XsltForms_class XsltForms_subform XsltForms_binding XsltForms_collection*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module select * @description === "XsltForms_select" class === * Select/Select1 Control Class * * constructor function : initializes specific properties and initializes focus and change event management */ - + new XsltForms_class("XsltForms_select", "HTMLElement", "xforms-select", ""); new XsltForms_class("XsltForms_select", "HTMLElement", "xforms-select1", ""); function XsltForms_select(subform, elt, clone) { - this.inputname = "xsltforms-select-" + String(XsltForms_globals.counters.select++); - this.init(subform, elt); - this.controlName = elt.localName.substr(7); - this.binding = new XsltForms_binding(subform, elt); - this.min = elt.getAttribute("xf-min"); - this.min = this.min ? Math.max(Number(this.min), 1) : 1; - this.max = elt.getAttribute("xf-max"); - this.max = this.max ? Math.max(Number(this.max), this.min) : elt.localName.toLowerCase() === "xforms-select1" ? 1 : null; - this.inputtype = this.max === 1 ? "radio" : "checkbox"; - this.full = elt.getAttribute("xf-appearance") === "full"; - this.compact = elt.getAttribute("xf-appearance") === "compact"; - this.open = elt.getAttribute("xf-selection") === "open"; - this.incremental = elt.getAttribute("xf-incremental") !== "false"; - var cells = Array.prototype.slice.call(this.element.children); - var cname; - for (var i = 0, l = cells.length; i < l; i++) { - cname = cells[i].localName.toLowerCase(); - if (cname === "xforms-body") { - this.cell = cells[i]; - } else if (cname === "xforms-hint" && cells[i].getAttribute("xf-appearance") === "minimal") { - elt.setAttribute("title", cells[i].textContent); - } - } - for (i = 0, l = cells.length; i < l; i++) { - cname = cells[i].localName.toLowerCase(); - if (cname === "xforms-item" || cname === "xforms-itemset" || cname === "xforms-choices") { - this.cell.appendChild(cells[i]); - } - } - this.isClone = clone; - this.hasBinding = true; - this.outRange = false; + this.inputname = "xsltforms-select-" + String(XsltForms_globals.counters.select++); + this.init(subform, elt); + this.controlName = elt.localName.substr(7); + this.binding = new XsltForms_binding(subform, elt); + this.min = elt.getAttribute("xf-min"); + this.min = this.min ? Math.max(Number(this.min), 1) : 1; + this.max = elt.getAttribute("xf-max"); + this.max = this.max ? Math.max(Number(this.max), this.min) : elt.localName.toLowerCase() === "xforms-select1" ? 1 : null; + this.inputtype = this.max === 1 ? "radio" : "checkbox"; + this.full = elt.getAttribute("xf-appearance") === "full"; + this.compact = elt.getAttribute("xf-appearance") === "compact"; + this.open = elt.getAttribute("xf-selection") === "open"; + this.incremental = elt.getAttribute("xf-incremental") !== "false"; + var cells = Array.prototype.slice.call(this.element.children); + var cname; + for (var i = 0, l = cells.length; i < l; i++) { + cname = cells[i].localName.toLowerCase(); + if (cname === "xforms-body") { + this.cell = cells[i]; + } else if (cname === "xforms-hint" && cells[i].getAttribute("xf-appearance") === "minimal") { + elt.setAttribute("title", cells[i].textContent); + } + } + for (i = 0, l = cells.length; i < l; i++) { + cname = cells[i].localName.toLowerCase(); + if (cname === "xforms-item" || cname === "xforms-itemset" || cname === "xforms-choices") { + this.cell.appendChild(cells[i]); + } + } + this.isClone = clone; + this.hasBinding = true; + this.outRange = false; } XsltForms_select.prototype = new XsltForms_control(); - + /** * * '''clone''' method : creates a new select/select1 control with the given id */ XsltForms_select.prototype.clone = function(id) { - return new XsltForms_select(this.subform, id, this.min, this.max, this.full, this.binding, this.open, this.incremental, true); + return new XsltForms_select(this.subform, id, this.min, this.max, this.full, this.binding, this.open, this.incremental, true); }; - + /** * * '''dispose''' method : clears properties of this select/select1 control and calls the parent dispose() method */ XsltForms_select.prototype.dispose = function() { - this.select = null; - this.selectedOptions = null; - XsltForms_globals.counters.select--; - XsltForms_control.prototype.dispose.call(this); + this.select = null; + this.selectedOptions = null; + XsltForms_globals.counters.select--; + XsltForms_control.prototype.dispose.call(this); }; - + /** * * '''focusFirst''' method : sets focus to the first item in this select/select1 control */ XsltForms_select.prototype.focusFirst = function() { - var input = XsltForms_browser.isXhtml ? this.element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "input")[0] : this.element.getElementsByTagName("input")[0]; - input.focus(); - if (XsltForms_browser.isOpera) { - input.focus(); - } + var input = XsltForms_browser.isXhtml ? this.element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "input")[0] : this.element.getElementsByTagName("input")[0]; + input.focus(); + if (XsltForms_browser.isOpera) { + input.focus(); + } }; XsltForms_select.initChild = { - "xforms-item": function(child) { - var ilabel, ivalue, icopy; - Array.prototype.slice.call(child.children).forEach(function(subitem) { - switch (subitem.localName.toLowerCase()) { - case "xforms-value": - ivalue = subitem.textContent.replace(/>/g, ">").replace(/' + ilabel + ''; - }, - "xforms-itemset": function(child) { - return Array.prototype.slice.call(child.children).map(function(item) { - var f = XsltForms_select.initChild[item.localName.toLowerCase()]; - return f ? f(item) : ""; - }, "").join(""); - }, - "xforms-choices": function(child) { - var gchildren = Array.prototype.slice.call(child.children); - var glabel = gchildren.filter(function(n) { return n.localName.toLowerCase() === "xforms-label";}); - var alabel = glabel.length !== 0 ? ' label="' + glabel[0].textContent + '"' : ""; - return "" + gchildren.map(function(item) { - var f = XsltForms_select.initChild[item.localName.toLowerCase()]; - return f ? f(item) : ""; - }, "").join("") + ""; - } + "xforms-item": function(child) { + var ilabel, ivalue, icopy; + Array.prototype.slice.call(child.children).forEach(function(subitem) { + switch (subitem.localName.toLowerCase()) { + case "xforms-value": + ivalue = subitem.textContent.replace(/>/g, ">").replace(/' + ilabel + ''; + }, + "xforms-itemset": function(child) { + return Array.prototype.slice.call(child.children).map(function(item) { + var f = XsltForms_select.initChild[item.localName.toLowerCase()]; + return f ? f(item) : ""; + }, "").join(""); + }, + "xforms-choices": function(child) { + var gchildren = Array.prototype.slice.call(child.children); + var glabel = gchildren.filter(function(n) { return n.localName.toLowerCase() === "xforms-label";}); + var alabel = glabel.length !== 0 ? ' label="' + glabel[0].textContent + '"' : ""; + return "" + gchildren.map(function(item) { + var f = XsltForms_select.initChild[item.localName.toLowerCase()]; + return f ? f(item) : ""; + }, "").join("") + ""; + } }; XsltForms_select.initChildFull = { - "xforms-item": function(child, thisselect) { - var ibody, ivalue, icopy; - Array.prototype.slice.call(child.children).forEach(function(subitem) { - switch (subitem.localName.toLowerCase()) { - case "xforms-body": - ibody = subitem; - break; - case "xforms-value": - ivalue = subitem.textContent.replace(/>/g, ">").replace(/'; - //child.setAttribute("xf-appearance", "full"); - //XsltForms_browser.setClass(child, "xforms-appearance-full", true); - child.xfElement.input = ibody.children[0]; - XsltForms_browser.events.attach(ibody.children[0], "focus", XsltForms_control.focusHandler); - XsltForms_browser.events.attach(ibody.children[0], "blur", XsltForms_control.blurHandler); - }, - "xforms-itemset": function(child, thisselect) { - Array.prototype.slice.call(child.children).map(function(item) { - var f = XsltForms_select.initChildFull[item.localName.toLowerCase()]; - if (f) { - f(item, thisselect); - } - }); - }, - "xforms-choices": function(child, thisselect) { - Array.prototype.slice.call(child.children).map(function(item) { - var f = XsltForms_select.initChildFull[item.localName.toLowerCase()]; - if (f) { - f(item, thisselect); - } - }); - //child.setAttribute("xf-appearance", "full"); - } + "xforms-item": function(child, thisselect) { + var ibody, ivalue, icopy; + Array.prototype.slice.call(child.children).forEach(function(subitem) { + switch (subitem.localName.toLowerCase()) { + case "xforms-body": + ibody = subitem; + break; + case "xforms-value": + ivalue = subitem.textContent.replace(/>/g, ">").replace(/'; + //child.setAttribute("xf-appearance", "full"); + //XsltForms_browser.setClass(child, "xforms-appearance-full", true); + child.xfElement.input = ibody.children[0]; + XsltForms_browser.events.attach(ibody.children[0], "focus", XsltForms_control.focusHandler); + XsltForms_browser.events.attach(ibody.children[0], "blur", XsltForms_control.blurHandler); + }, + "xforms-itemset": function(child, thisselect) { + Array.prototype.slice.call(child.children).map(function(item) { + var f = XsltForms_select.initChildFull[item.localName.toLowerCase()]; + if (f) { + f(item, thisselect); + } + }); + }, + "xforms-choices": function(child, thisselect) { + Array.prototype.slice.call(child.children).map(function(item) { + var f = XsltForms_select.initChildFull[item.localName.toLowerCase()]; + if (f) { + f(item, thisselect); + } + }); + //child.setAttribute("xf-appearance", "full"); + } }; - + /** * * '''initBody''' method : initializes the select control body */ XsltForms_select.prototype.initBody = function() { - var cell = this.cell; - var thisselect = this; - if (this.full) { - //XsltForms_browser.setClass(this.element, "xforms-appearance-full", true); - Array.prototype.slice.call(cell.children).forEach(function(child) { - var f = XsltForms_select.initChildFull[child.localName.toLowerCase()]; - return f ? f(child, thisselect) : ""; - }); - } else { - var select; - if (cell.lastChild.localName.toLowerCase() === "select") { - select = cell.lastChild; - } else { - select = document.createElement("select"); - if (!this.max || this.max > this.min + 1) { - select.setAttribute("multiple", ""); - } - if (this.compact) { - select.setAttribute("size", "4"); - } - cell.appendChild(select); - } - var v = select.value; - var options = (select.value === "\xA0" ? '' : "") + Array.prototype.slice.call(cell.children).map(function(child) { - var f = XsltForms_select.initChild[child.localName.toLowerCase()]; - return f ? f(child) : ""; - }).join(""); - select.innerHTML = options; - Array.prototype.slice.call(select.querySelectorAll("*")).forEach(function(elt){ - if (elt.hasAttribute("xf-index")) { - var ls = XsltForms_collection[elt.getAttribute("xf-index")].listeners; - if (ls) { - ls.forEach(function(l) { - l.clone(elt); - }); - } - elt.removeAttribute("xf-index"); - } - /* - if (elt.hasAttribute ("value")) { - elt.setAttribute("value", elt.getAttribute("value").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, '"').replace(/&apos/g, "'")); - } - */ - }); - select.value = v; - var datalist; - if (!this.open) { - this.select = select; - this.datalist = this.select; - } else { - this.select = select; - this.datalist = datalist; - } - this.initFocus(this.select); - if (this.incremental) { - XsltForms_browser.events.attach(this.select, "change", XsltForms_select.incrementalChange); - XsltForms_browser.events.attach(this.select, "keyup", XsltForms_select.incrementalChangeKeyup); - } else { - XsltForms_browser.events.attach(this.select, "change", XsltForms_select.normalChange); - } - } - this.bodyOK = true; + var cell = this.cell; + var thisselect = this; + if (this.full) { + //XsltForms_browser.setClass(this.element, "xforms-appearance-full", true); + Array.prototype.slice.call(cell.children).forEach(function(child) { + var f = XsltForms_select.initChildFull[child.localName.toLowerCase()]; + return f ? f(child, thisselect) : ""; + }); + } else { + var select; + if (cell.lastChild.localName.toLowerCase() === "select") { + select = cell.lastChild; + } else { + select = document.createElement("select"); + if (!this.max || this.max > this.min + 1) { + select.setAttribute("multiple", ""); + } + if (this.compact) { + select.setAttribute("size", "4"); + } + cell.appendChild(select); + } + var v = select.value; + var options = (select.value === "\xA0" ? '' : "") + Array.prototype.slice.call(cell.children).map(function(child) { + var f = XsltForms_select.initChild[child.localName.toLowerCase()]; + return f ? f(child) : ""; + }).join(""); + select.innerHTML = options; + Array.prototype.slice.call(select.querySelectorAll("*")).forEach(function(elt){ + if (elt.hasAttribute("xf-index")) { + var ls = XsltForms_collection[elt.getAttribute("xf-index")].listeners; + if (ls) { + ls.forEach(function(l) { + l.clone(elt); + }); + } + elt.removeAttribute("xf-index"); + } + /* + if (elt.hasAttribute ("value")) { + elt.setAttribute("value", elt.getAttribute("value").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, '"').replace(/&apos/g, "'")); + } + */ + }); + select.value = v; + var datalist; + if (!this.open) { + this.select = select; + this.datalist = this.select; + } else { + this.select = select; + this.datalist = datalist; + } + this.initFocus(this.select); + if (this.incremental) { + XsltForms_browser.events.attach(this.select, "change", XsltForms_select.incrementalChange); + XsltForms_browser.events.attach(this.select, "keyup", XsltForms_select.incrementalChangeKeyup); + } else { + XsltForms_browser.events.attach(this.select, "change", XsltForms_select.normalChange); + } + } + this.bodyOK = true; }; - + /** * * '''setValue''' method : searches for the given value and checks it if found or dispatches the "xforms-in-range" event */ XsltForms_select.prototype.setValue = function(value) { - var optvalue, empty; - if (!this.bodyOK) { - this.initBody(); - } - if (this.select && this.datalist.options.length === 1 && this.datalist.options[0] && this.datalist.options[0].value === "\xA0") { - this.currentValue = null; - } - if (!this.full && (!value || value === "")) { - this.selectedOptions = []; - if (this.datalist.options[0] && this.datalist.options[0].value !== "\xA0") { - empty = XsltForms_browser.isXhtml ? document.createElementNS("http://www.w3.org/1999/xhtml", "option") : document.createElement("option"); - empty.value = "\xA0"; - empty.text = "\xA0"; - empty.id = ""; - if (this.datalist.children[0]) { - this.datalist.insertBefore(empty, this.datalist.children[0]); - } else { - this.datalist.appendChild(empty); - } - this.datalist.selectedIndex = 0; - } - } else { - if (!this.full && this.min === 0 && this.datalist.options[0] && this.datalist.options[0].value !== "\xA0") { - empty = XsltForms_browser.isXhtml ? document.createElementNS("http://www.w3.org/1999/xhtml", "option") : document.createElement("option"); - empty.value = "\xA0"; - empty.text = "\xA0"; - empty.id = ""; - if (this.datalist.children[0]) { - this.datalist.insertBefore(empty, this.datalist.children[0]); - } else { - this.datalist.appendChild(empty); - } - } - if (!this.full && this.datalist.firstChild && this.datalist.firstChild.value === "\xA0" && !(this.min === 0 && this.max === 1)) { - //this.select.removeChild(this.select.firstChild); - this.datalist.remove(0); - } - var vals = value ? value instanceof Array ? value : (this.max !== 1? value.split(XsltForms_globals.valuesSeparator) : [value]) : [""]; - var list = this.full ? (XsltForms_browser.isXhtml ? this.element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "input") : this.element.getElementsByTagName("input")) : this.datalist.options; - var well = true; - var schtyp = XsltForms_schema.getType(this.element.node ? XsltForms_browser.getType(this.element.node) || "xsd_:string" : "xsd_:string"); - for (var i = 0, len = vals.length; well && i < len; i++) { - var val = vals[i]; - var found = false; - for (var j = 0, len1 = list.length; !found && j < len1; j++) { - optvalue = list[j].value; - if (schtyp.format) { - try { optvalue = schtyp.format(optvalue); } catch(e) { } - } - if (optvalue === val) { - found = true; - } - } - well = found; - } - if (well || (this.max !== 1 && !value)) { - if (this.outRange) { - this.outRange = false; - XsltForms_xmlevents.dispatch(this, "xforms-in-range"); - } - } else if ((this.max === 1 || value) && !this.outRange) { - this.outRange = true; - XsltForms_xmlevents.dispatch(this, "xforms-out-of-range"); - } - vals = this.max !== 1? vals : [vals[0]]; - var item; - if (this.full) { - for (var n = 0, len2 = list.length; n < len2; n++) { - item = list[n]; - item.checked = item.value !== "" ? XsltForms_browser.inArray(item.value, vals) : false; - } - } else { - this.selectedOptions = []; - for (var k = 0, len3 = list.length; k < len3; k++) { - item = list[k]; - optvalue = item.value; - if (schtyp.format) { - try { optvalue = schtyp.format(optvalue); } catch(e) { } - } - var b = XsltForms_browser.inArray(optvalue, vals); - if (b) { - this.selectedOptions.push(item); - } - try { - item.selected = b; - } catch(e) { - } - } - } - } + var optvalue, empty; + if (!this.bodyOK) { + this.initBody(); + } + if (this.select && this.datalist.options.length === 1 && this.datalist.options[0] && this.datalist.options[0].value === "\xA0") { + this.currentValue = null; + } + if (!this.full && (!value || value === "")) { + this.selectedOptions = []; + if (this.datalist.options[0] && this.datalist.options[0].value !== "\xA0") { + empty = XsltForms_browser.isXhtml ? document.createElementNS("http://www.w3.org/1999/xhtml", "option") : document.createElement("option"); + empty.value = "\xA0"; + empty.text = "\xA0"; + empty.id = ""; + if (this.datalist.children[0]) { + this.datalist.insertBefore(empty, this.datalist.children[0]); + } else { + this.datalist.appendChild(empty); + } + this.datalist.selectedIndex = 0; + } + } else { + if (!this.full && this.min === 0 && this.datalist.options[0] && this.datalist.options[0].value !== "\xA0") { + empty = XsltForms_browser.isXhtml ? document.createElementNS("http://www.w3.org/1999/xhtml", "option") : document.createElement("option"); + empty.value = "\xA0"; + empty.text = "\xA0"; + empty.id = ""; + if (this.datalist.children[0]) { + this.datalist.insertBefore(empty, this.datalist.children[0]); + } else { + this.datalist.appendChild(empty); + } + } + if (!this.full && this.datalist.firstChild && this.datalist.firstChild.value === "\xA0" && !(this.min === 0 && this.max === 1)) { + //this.select.removeChild(this.select.firstChild); + this.datalist.remove(0); + } + var vals = value ? value instanceof Array ? value : (this.max !== 1? value.split(XsltForms_globals.valuesSeparator) : [value]) : [""]; + var list = this.full ? (XsltForms_browser.isXhtml ? this.element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "input") : this.element.getElementsByTagName("input")) : this.datalist.options; + var well = true; + var schtyp = XsltForms_schema.getType(this.element.node ? XsltForms_browser.getType(this.element.node) || "xsd_:string" : "xsd_:string"); + for (var i = 0, len = vals.length; well && i < len; i++) { + var val = vals[i]; + var found = false; + for (var j = 0, len1 = list.length; !found && j < len1; j++) { + optvalue = list[j].value; + if (schtyp.format) { + try { optvalue = schtyp.format(optvalue); } catch(e) { } + } + if (optvalue === val) { + found = true; + } + } + well = found; + } + if (well || (this.max !== 1 && !value)) { + if (this.outRange) { + this.outRange = false; + XsltForms_xmlevents.dispatch(this, "xforms-in-range"); + } + } else if ((this.max === 1 || value) && !this.outRange) { + this.outRange = true; + XsltForms_xmlevents.dispatch(this, "xforms-out-of-range"); + } + vals = this.max !== 1? vals : [vals[0]]; + var item; + if (this.full) { + for (var n = 0, len2 = list.length; n < len2; n++) { + item = list[n]; + item.checked = item.value !== "" ? XsltForms_browser.inArray(item.value, vals) : false; + } + } else { + this.selectedOptions = []; + for (var k = 0, len3 = list.length; k < len3; k++) { + item = list[k]; + optvalue = item.value; + if (schtyp.format) { + try { optvalue = schtyp.format(optvalue); } catch(e) { } + } + var b = XsltForms_browser.inArray(optvalue, vals); + if (b) { + this.selectedOptions.push(item); + } + try { + item.selected = b; + } catch(e) { + } + } + } + } }; - + /** * * '''changeReadonly''' method : changes the read only state of this select/select1 control */ XsltForms_select.prototype.changeReadonly = function() { - if (this.full) { - var list = XsltForms_browser.isXhtml ? this.element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "input") : this.element.getElementsByTagName("input"); - for (var i = 0, len = list.length; i < len; i++) { - list[i].disabled = this.readonly; - } - } else { - if (!XsltForms_browser.dialog.knownSelect(this.select) && this.select) { - this.select.disabled = this.readonly; - } - } + if (this.full) { + var list = XsltForms_browser.isXhtml ? this.element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "input") : this.element.getElementsByTagName("input"); + for (var i = 0, len = list.length; i < len; i++) { + list[i].disabled = this.readonly; + } + } else { + if (!XsltForms_browser.dialog.knownSelect(this.select) && this.select) { + this.select.disabled = this.readonly; + } + } }; - + /** * * '''itemClick''' method : dispatches "xforms-select" and "xforms-deselect" events */ XsltForms_select.prototype.itemClick = function(value) { - var inputs = XsltForms_browser.isXhtml ? this.element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "input") : this.element.getElementsByTagName("input"); - var input; - XsltForms_globals.openAction("XsltForms_select.prototype.itemClick"); - var newValue = ""; - if (this.max !== 1) { - for (var i = 0, len = inputs.length; i < len; i++) { - input = inputs[i]; - if (input.hasAttribute("xf-copy") && newValue === "") { - newValue = []; - } - if (input.value === value) { - XsltForms_xmlevents.dispatch(input.parentNode, input.checked? "xforms-select" : "xforms-deselect"); - } - if (input.checked) { - if (input.hasAttribute("xf-copy")) { - newValue.push(input.value); - } else { - newValue = (newValue !== "" ? newValue + XsltForms_globals.valuesSeparator : "") + input.value; - } - } - } - } else { - var old = this.value; - var schtyp = XsltForms_schema.getType(XsltForms_browser.getType(this.element.node) || "xsd_:string"); - if (!old) { - old = XsltForms_browser.getValue(this.element.node); - if (schtyp.format) { - try { old = schtyp.format(old); } catch(e) { } - } - } - var inputSelected = null; - if (old === value && this.min !== 0) { - XsltForms_globals.closeAction("XsltForms_select.prototype.itemClick"); - return; - } - for (var j = 0, len1 = inputs.length; j < len1; j++) { - input = inputs[j]; - var input_controlvalue = input.value; - if (schtyp.format) { - try { input_controlvalue = schtyp.format(input_controlvalue); } catch(e) { } - } - input.checked = input_controlvalue === value; - if (input_controlvalue === old) { - if (input.checked && this.min === 0) { - input.checked = false; - newValue = input.hasAttribute("xf-copy") ? [] : ""; - } - XsltForms_xmlevents.dispatch(input.parentNode, "xforms-deselect"); - } else if (input_controlvalue === value) { - inputSelected = input; - newValue = input.hasAttribute("xf-copy") ? [value] : value; - } - } - if (inputSelected) { - XsltForms_xmlevents.dispatch(inputSelected.parentNode, "xforms-select"); - } - } - value = newValue; - if (this.incremental) { - this.valueChanged(this.value = value || ""); - } else { - this.value = value || ""; - } - XsltForms_globals.closeAction("XsltForms_select.prototype.itemClick"); + var inputs = XsltForms_browser.isXhtml ? this.element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "input") : this.element.getElementsByTagName("input"); + var input; + XsltForms_globals.openAction("XsltForms_select.prototype.itemClick"); + var newValue = ""; + if (this.max !== 1) { + for (var i = 0, len = inputs.length; i < len; i++) { + input = inputs[i]; + if (input.hasAttribute("xf-copy") && newValue === "") { + newValue = []; + } + if (input.value === value) { + XsltForms_xmlevents.dispatch(input.parentNode, input.checked? "xforms-select" : "xforms-deselect"); + } + if (input.checked) { + if (input.hasAttribute("xf-copy")) { + newValue.push(input.value); + } else { + newValue = (newValue !== "" ? newValue + XsltForms_globals.valuesSeparator : "") + input.value; + } + } + } + } else { + var old = this.value; + var schtyp = XsltForms_schema.getType(XsltForms_browser.getType(this.element.node) || "xsd_:string"); + if (!old) { + old = XsltForms_browser.getValue(this.element.node); + if (schtyp.format) { + try { old = schtyp.format(old); } catch(e) { } + } + } + var inputSelected = null; + if (old === value && this.min !== 0) { + XsltForms_globals.closeAction("XsltForms_select.prototype.itemClick"); + return; + } + for (var j = 0, len1 = inputs.length; j < len1; j++) { + input = inputs[j]; + var input_controlvalue = input.value; + if (schtyp.format) { + try { input_controlvalue = schtyp.format(input_controlvalue); } catch(e) { } + } + input.checked = input_controlvalue === value; + if (input_controlvalue === old) { + if (input.checked && this.min === 0) { + input.checked = false; + newValue = input.hasAttribute("xf-copy") ? [] : ""; + } + XsltForms_xmlevents.dispatch(input.parentNode, "xforms-deselect"); + } else if (input_controlvalue === value) { + inputSelected = input; + newValue = input.hasAttribute("xf-copy") ? [value] : value; + } + } + if (inputSelected) { + XsltForms_xmlevents.dispatch(inputSelected.parentNode, "xforms-select"); + } + } + value = newValue; + if (this.incremental) { + this.valueChanged(this.value = value || ""); + } else { + this.value = value || ""; + } + XsltForms_globals.closeAction("XsltForms_select.prototype.itemClick"); }; - + /** * * '''blur''' method : blur event management * @callback */ XsltForms_select.prototype.blur = function(evt) { - if (this.value) { - XsltForms_globals.openAction("XsltForms_select.prototype.blur"); - this.valueChanged(this.value); - XsltForms_globals.closeAction("XsltForms_select.prototype.blur"); - this.value = null; - } + if (this.value) { + XsltForms_globals.openAction("XsltForms_select.prototype.blur"); + this.valueChanged(this.value); + XsltForms_globals.closeAction("XsltForms_select.prototype.blur"); + this.value = null; + } }; - + /** * * '''normalChange''' function : handler for normal mode on change dispatching "xforms-select" and "xforms-deselect" events * @callback */ XsltForms_select.normalChange = function(evt) { - var xf = XsltForms_control.getXFElement(this); - var news = []; - var value = ""; - var copy = []; - var old = xf.getSelected(); - var opts = this.options; - XsltForms_globals.openAction("XsltForms_select.normalChange"); - for (var i = 0, len = old.length; i < len; i++) { - if (old[i].selected) { - news.push(old[i]); - } else { - XsltForms_xmlevents.dispatch(old[i], "xforms-deselect"); - } - } - var opt; - for (var j = 0, len1 = opts.length; j < len1; j++) { - opt = opts[j]; - if (opt.selected) { - if (opt.hasAttribute("xf-copy")) { - copy.push(opt.value); - } else if (opt.value !== "\xA0") { - value = value? value + XsltForms_globals.valuesSeparator + opt.value : opt.value; - } - } - } - for (var k = 0, len2 = opts.length; k < len2; k++) { - opt = opts[k]; - if (opt.selected && opt.value !== "\xA0") { - if (!XsltForms_browser.inArray(opt, news)) { - news.push(opt); - XsltForms_xmlevents.dispatch(opt, "xforms-select"); - } - } - } - if (copy.length === 0) { - xf.value = value; - var schtyp = XsltForms_schema.getType(XsltForms_browser.getType(xf.element.node) || "xsd_:string"); - if (schtyp.format) { - try { xf.value = schtyp.format(value); } catch(e) { } - } - } else { - xf.value = copy; - } - xf.selectedOptions = news; - XsltForms_globals.closeAction("XsltForms_select.normalChange"); + var xf = XsltForms_control.getXFElement(this); + var news = []; + var value = ""; + var copy = []; + var old = xf.getSelected(); + var opts = this.options; + XsltForms_globals.openAction("XsltForms_select.normalChange"); + for (var i = 0, len = old.length; i < len; i++) { + if (old[i].selected) { + news.push(old[i]); + } else { + XsltForms_xmlevents.dispatch(old[i], "xforms-deselect"); + } + } + var opt; + for (var j = 0, len1 = opts.length; j < len1; j++) { + opt = opts[j]; + if (opt.selected) { + if (opt.hasAttribute("xf-copy")) { + copy.push(opt.value); + } else if (opt.value !== "\xA0") { + value = value? value + XsltForms_globals.valuesSeparator + opt.value : opt.value; + } + } + } + for (var k = 0, len2 = opts.length; k < len2; k++) { + opt = opts[k]; + if (opt.selected && opt.value !== "\xA0") { + if (!XsltForms_browser.inArray(opt, news)) { + news.push(opt); + XsltForms_xmlevents.dispatch(opt, "xforms-select"); + } + } + } + if (copy.length === 0) { + xf.value = value; + var schtyp = XsltForms_schema.getType(XsltForms_browser.getType(xf.element.node) || "xsd_:string"); + if (schtyp.format) { + try { xf.value = schtyp.format(value); } catch(e) { } + } + } else { + xf.value = copy; + } + xf.selectedOptions = news; + XsltForms_globals.closeAction("XsltForms_select.normalChange"); }; - + /** * * '''incrementalChange''' function : handler for incremental mode on change calling normal mode handler */ XsltForms_select.incrementalChange = function(evt) { - var xf = XsltForms_control.getXFElement(this); - XsltForms_globals.openAction("XsltForms_select.incrementalChange"); - XsltForms_select.normalChange.call(this, evt); - xf.valueChanged(xf.value); - XsltForms_globals.closeAction("XsltForms_select.incrementalChange"); + var xf = XsltForms_control.getXFElement(this); + XsltForms_globals.openAction("XsltForms_select.incrementalChange"); + XsltForms_select.normalChange.call(this, evt); + xf.valueChanged(xf.value); + XsltForms_globals.closeAction("XsltForms_select.incrementalChange"); }; - + /** * * '''incrementalChangeKeyup''' function : handler for incremental mode from keyboard on change calling normal mode handler */ XsltForms_select.incrementalChangeKeyup = function(evt) { - if (evt.keyCode !== 9 && evt.keyCode !== 17) { - var xf = XsltForms_control.getXFElement(this); - XsltForms_globals.openAction("XsltForms_select.incrementalChangeKeyup"); - XsltForms_select.normalChange.call(this, evt); - xf.valueChanged(xf.value); - XsltForms_globals.closeAction("XsltForms_select.incrementalChangeKeyup"); - } + if (evt.keyCode !== 9 && evt.keyCode !== 17) { + var xf = XsltForms_control.getXFElement(this); + XsltForms_globals.openAction("XsltForms_select.incrementalChangeKeyup"); + XsltForms_select.normalChange.call(this, evt); + xf.valueChanged(xf.value); + XsltForms_globals.closeAction("XsltForms_select.incrementalChangeKeyup"); + } }; - + /** * * '''getSelected''' method : collects selected options for this select/select1 control */ XsltForms_select.prototype.getSelected = function() { - var s = this.selectedOptions; - if (!s || s.length === 0) { - s = []; - var opts = this.select.options; - for (var i = 0, len = opts.length; i < len; i++) { - if (opts[i].selected) { - s.push(opts[i]); - } - } - } - return s; + var s = this.selectedOptions; + if (!s || s.length === 0) { + s = []; + var opts = this.select.options; + for (var i = 0, len = opts.length; i < len; i++) { + if (opts[i].selected) { + s.push(opts[i]); + } + } + } + return s; }; \ No newline at end of file diff --git a/src/js/xsltforms.js/controls/tree.js b/src/js/xsltforms.js/controls/tree.js index b8f68d2..1f79833 100644 --- a/src/js/xsltforms.js/controls/tree.js +++ b/src/js/xsltforms.js/controls/tree.js @@ -1,115 +1,113 @@ -/*eslint-env browser*/ -/*globals XsltForms_browser XsltForms_element XsltForms_globals XsltForms_repeat Fleur XsltForms_class*/ -"use strict"; -/** - * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. - * @module tree - * @description - */ - -new XsltForms_class("XsltForms_tree", "HTMLElement", "xforms-tree"); - +"use strict"; +/** + * @author Alain Couthures + * @license LGPL - See file 'LICENSE.md' in this project. + * @module tree + * @description + */ + +new XsltForms_class("XsltForms_tree", "HTMLElement", "xforms-tree"); + function XsltForms_tree(subform, id, binding) { - this.init(subform, id); - this.binding = binding; - this.hasBinding = true; - this.root = XsltForms_browser.isXhtml ? this.element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "ul")[0] : this.element.getElementsByTagName("ul")[0]; - this.label = this.root.firstChild.cloneNode(true); + this.init(subform, id); + this.binding = binding; + this.hasBinding = true; + this.root = XsltForms_browser.isXhtml ? this.element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "ul")[0] : this.element.getElementsByTagName("ul")[0]; + this.label = this.root.firstChild.cloneNode(true); } -XsltForms_tree.prototype = new XsltForms_element(); +XsltForms_tree.prototype = new XsltForms_element(); XsltForms_tree.prototype.dispose = function() { - this.root = null; - this.selected = null; - XsltForms_element.prototype.dispose.call(this); + this.root = null; + this.selected = null; + XsltForms_element.prototype.dispose.call(this); }; XsltForms_tree.prototype.build_ = function(ctx) { - var node = this.evaluateBinding(this.binding, ctx)[0]; - if (node) { - var nodes = []; - this.buildTree(this.root, 0, node, nodes); - if (!this.selected || !XsltForms_browser.inArray(this.selected, nodes)) { - this.select(this.root.firstChild); - } - } + var node = this.evaluateBinding(this.binding, ctx)[0]; + if (node) { + var nodes = []; + this.buildTree(this.root, 0, node, nodes); + if (!this.selected || !XsltForms_browser.inArray(this.selected, nodes)) { + this.select(this.root.firstChild); + } + } }; XsltForms_tree.prototype.select = function(item) { - var changed = true; - var init = !!this.selected; - if (init) { - if (this.selected === item) { - changed = false; - } else { - XsltForms_browser.setClass(this.selected, "xforms-tree-item-selected", false); - XsltForms_browser.setClass(this.selected.childNodes[1], "xforms-tree-item-label-selected", false); - } - } - if (changed) { - this.element.node = item.node; - this.selected = item; - XsltForms_browser.setClass(item, "xforms-tree-item-selected", true); - XsltForms_browser.setClass(item.childNodes[1], "xforms-tree-item-label-selected", true); - XsltForms_globals.openAction(); - XsltForms_globals.addChange(this); - XsltForms_globals.addChange(document.getElementById(XsltForms_browser.getDocMeta(item.node.ownerDocument, "model")).xfElement); - XsltForms_globals.closeAction(); - } + var changed = true; + var init = !!this.selected; + if (init) { + if (this.selected === item) { + changed = false; + } else { + XsltForms_browser.setClass(this.selected, "xforms-tree-item-selected", false); + XsltForms_browser.setClass(this.selected.childNodes[1], "xforms-tree-item-label-selected", false); + } + } + if (changed) { + this.element.node = item.node; + this.selected = item; + XsltForms_browser.setClass(item, "xforms-tree-item-selected", true); + XsltForms_browser.setClass(item.childNodes[1], "xforms-tree-item-label-selected", true); + XsltForms_globals.openAction(); + XsltForms_globals.addChange(this); + XsltForms_globals.addChange(document.getElementById(XsltForms_browser.getDocMeta(item.node.ownerDocument, "model")).xfElement); + XsltForms_globals.closeAction(); + } }; XsltForms_tree.prototype.click = function(target) { - if (target.className === "xforms-tree-item-button") { - var ul = target.nextSibling.nextSibling; - if (ul) { - ul.style.display = ul.style.display !== "none"? "none" : "block"; - } - } else if (XsltForms_browser.hasClass(target, "xforms-tree-item-label")) { - this.select(target.parentNode); - } + if (target.className === "xforms-tree-item-button") { + var ul = target.nextSibling.nextSibling; + if (ul) { + ul.style.display = ul.style.display !== "none"? "none" : "block"; + } + } else if (XsltForms_browser.hasClass(target, "xforms-tree-item-label")) { + this.select(target.parentNode); + } }; XsltForms_tree.prototype.buildTree = function(parentNode, index, node, nodes) { - var li = null; - var ul = null; - var childs = node.childNodes; - var nochild = childs.length === 0; - nodes.push(node); - if (parentNode.childNodes.length < index + 1) { - li = this.label.cloneNode(true); - parentNode.appendChild(li); - XsltForms_repeat.initClone(li); - } else { - li = parentNode.childNodes[index]; - var last = li.lastChild; - if (last.nodeName.toLowerCase() === "ul") { - ul = last; - if (nochild) { - XsltForms_globals.dispose(ul); - li.removeChild(ul); - } - } - } - li.node = node; - XsltForms_browser.setClass(li, "xforms-tree-item-fork", !nochild); - XsltForms_browser.setClass(li, "xforms-tree-item-leaf", nochild); - for (var i = 0, len = childs.length; i < len; i++) { - var child = childs[i]; - if (child.nodeType === Fleur.Node.ELEMENT_NODE) { - if (!ul) { - ul = XsltForms_browser.createElement("ul", li); - } - this.buildTree(ul, i, child, nodes); - } - } - if (ul) { - for (var j = ul.childNodes.length, len1 = childs.length; j > len1; j--) { - XsltForms_globals.dispose(ul.lastChild); - ul.removeChild(ul.lastChild); - } - } + var li = null; + var ul = null; + var childs = node.childNodes; + var nochild = childs.length === 0; + nodes.push(node); + if (parentNode.childNodes.length < index + 1) { + li = this.label.cloneNode(true); + parentNode.appendChild(li); + XsltForms_repeat.initClone(li); + } else { + li = parentNode.childNodes[index]; + var last = li.lastChild; + if (last.nodeName.toLowerCase() === "ul") { + ul = last; + if (nochild) { + XsltForms_globals.dispose(ul); + li.removeChild(ul); + } + } + } + li.node = node; + XsltForms_browser.setClass(li, "xforms-tree-item-fork", !nochild); + XsltForms_browser.setClass(li, "xforms-tree-item-leaf", nochild); + for (var i = 0, len = childs.length; i < len; i++) { + var child = childs[i]; + if (child.nodeType === Fleur.Node.ELEMENT_NODE) { + if (!ul) { + ul = XsltForms_browser.createElement("ul", li); + } + this.buildTree(ul, i, child, nodes); + } + } + if (ul) { + for (var j = ul.childNodes.length, len1 = childs.length; j > len1; j--) { + XsltForms_globals.dispose(ul.lastChild); + ul.removeChild(ul.lastChild); + } + } }; XsltForms_tree.prototype.refresh = function() { diff --git a/src/js/xsltforms.js/controls/trigger.js b/src/js/xsltforms.js/controls/trigger.js index e70e8c8..8c42022 100644 --- a/src/js/xsltforms.js/controls/trigger.js +++ b/src/js/xsltforms.js/controls/trigger.js @@ -1,166 +1,164 @@ -/*eslint-env browser*/ -/*globals XsltForms_globals XsltForms_browser XsltForms_control XsltForms_element XsltForms_xmlevents XsltForms_class XsltForms_subform XsltForms_binding XsltForms_collection*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module trigger * @description === "XsltForms_trigger" class === * Trigger Control Class * * constructor function : initializes specific properties and initializes focus event management */ - + new XsltForms_class("XsltForms_trigger", "HTMLElement", "xforms-trigger", ""); new XsltForms_class("XsltForms_trigger", "HTMLElement", "xforms-submit", ""); -function XsltForms_trigger(subform, elt) { - this.init(subform, elt); - switch(elt.localName.toLowerCase()) { - case "xforms-trigger": - this.binding = elt.hasAttribute("xf-ref") || elt.hasAttribute("xf-bind") ? new XsltForms_binding(subform, elt) : null; - break; - case "xforms-submit": - var send = document.createElement("xforms-send"); - send.setAttribute("ev-event", "DOMActivate"); - if (elt.hasAttribute("xf-submission")) { - send.setAttribute("xf-submission", elt.getAttribute("xf-submission")); - } - elt.appendChild(send); - XsltForms_classes["xforms-dispatch"].classbinding(subform, send); - break; - } - var appearance = elt.getAttribute("xf-appearance"); - this.appearance = appearance? appearance : "full"; - XsltForms_globals.counters.trigger++; - this.controlName = "trigger"; - this.hasBinding = Boolean(this.binding); - var cells = Array.prototype.slice.call(this.element.children); - for (var i = 0, l = cells.length; i < l; i++) { - var cname = cells[i].localName.toLowerCase(); - if (cname === "xforms-body") { - this.cell = cells[i]; - } else if (cname === "xforms-hint" && cells[i].getAttribute("xf-appearance") === "minimal") { - elt.setAttribute("title", cells[i].textContent); - } - } - //if(!this.hasBinding) { - // XsltForms_browser.setClass(this.element, "xforms-disabled", false); - //} - this.isTrigger = true; - this.initBody(); - //var anchor = XsltForms_browser.isXhtml ? this.element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "a")[0] : this.element.getElementsByTagName("a")[0]; - //if (anchor !== null && typeof anchor !== "undefined") { - // if (!anchor.hasAttribute("href")) { - // anchor.setAttribute("href", "#/"); - // } - //} - //var button = XsltForms_browser.isXhtml ? (this.element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "a")[0] || this.element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "button")[0]) : (this.element.getElementsByTagName("a")[0] || this.element.getElementsByTagName("button")[0]); - //this.input = button; - //this.initFocus(button); -} - -XsltForms_trigger.prototype = new XsltForms_control(); - - +function XsltForms_trigger(subform, elt) { + this.init(subform, elt); + switch(elt.localName.toLowerCase()) { + case "xforms-trigger": + this.binding = elt.hasAttribute("xf-ref") || elt.hasAttribute("xf-bind") ? new XsltForms_binding(subform, elt) : null; + break; + case "xforms-submit": + var send = document.createElement("xforms-send"); + send.setAttribute("ev-event", "DOMActivate"); + if (elt.hasAttribute("xf-submission")) { + send.setAttribute("xf-submission", elt.getAttribute("xf-submission")); + } + elt.appendChild(send); + XsltForms_classes["xforms-dispatch"].classbinding(subform, send); + break; + } + var appearance = elt.getAttribute("xf-appearance"); + this.appearance = appearance? appearance : "full"; + XsltForms_globals.counters.trigger++; + this.controlName = "trigger"; + this.hasBinding = Boolean(this.binding); + var cells = Array.prototype.slice.call(this.element.children); + for (var i = 0, l = cells.length; i < l; i++) { + var cname = cells[i].localName.toLowerCase(); + if (cname === "xforms-body") { + this.cell = cells[i]; + } else if (cname === "xforms-hint" && cells[i].getAttribute("xf-appearance") === "minimal") { + elt.setAttribute("title", cells[i].textContent); + } + } + //if(!this.hasBinding) { + // XsltForms_browser.setClass(this.element, "xforms-disabled", false); + //} + this.isTrigger = true; + this.initBody(); + //var anchor = XsltForms_browser.isXhtml ? this.element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "a")[0] : this.element.getElementsByTagName("a")[0]; + //if (anchor !== null && typeof anchor !== "undefined") { + // if (!anchor.hasAttribute("href")) { + // anchor.setAttribute("href", "#/"); + // } + //} + //var button = XsltForms_browser.isXhtml ? (this.element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "a")[0] || this.element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "button")[0]) : (this.element.getElementsByTagName("a")[0] || this.element.getElementsByTagName("button")[0]); + //this.input = button; + //this.initFocus(button); +} + +XsltForms_trigger.prototype = new XsltForms_control(); + + /** * * '''initBody''' method : initializes the select control body */ XsltForms_trigger.prototype.initBody = function() { - var cells = Array.prototype.slice.call(this.element.children); - var i, l, cname; - switch(this.appearance) { - case "full": - case "compact": - //XsltForms_browser.setClass(this.element, "xforms-appearance-full", true); - if (this.cell.children.length === 0 || this.cell.children[0].nodeName.toUpperCase() !== "BUTTON") { - this.cell.innerHTML = ''; - this.input = this.cell.children[0]; - for (i = 0, l = cells.length; i < l; i++) { - cname = cells[i].localName.toLowerCase(); - if (cname === "xforms-label") { - this.input.appendChild(cells[i]); - break; - } - } - } else { - this.input = this.cell.children[0]; - } - break; - case "minimal": - if (this.cell.children.length === 0 || this.cell.children[0].nodeName.toUpperCase() !== "A") { - this.cell.innerHTML = ''; - this.input = this.cell.children[0]; - for (i = 0, l = cells.length; i < l; i++) { - cname = cells[i].localName.toLowerCase(); - if (cname === "xforms-label") { - this.input.appendChild(cells[i]); - break; - } - } - } else { - this.input = this.cell.children[0]; - } - break; - } - this.initFocus(this.input); -}; - - + var cells = Array.prototype.slice.call(this.element.children); + var i, l, cname; + switch(this.appearance) { + case "full": + case "compact": + //XsltForms_browser.setClass(this.element, "xforms-appearance-full", true); + if (this.cell.children.length === 0 || this.cell.children[0].nodeName.toUpperCase() !== "BUTTON") { + this.cell.innerHTML = ''; + this.input = this.cell.children[0]; + for (i = 0, l = cells.length; i < l; i++) { + cname = cells[i].localName.toLowerCase(); + if (cname === "xforms-label") { + this.input.appendChild(cells[i]); + break; + } + } + } else { + this.input = this.cell.children[0]; + } + break; + case "minimal": + if (this.cell.children.length === 0 || this.cell.children[0].nodeName.toUpperCase() !== "A") { + this.cell.innerHTML = ''; + this.input = this.cell.children[0]; + for (i = 0, l = cells.length; i < l; i++) { + cname = cells[i].localName.toLowerCase(); + if (cname === "xforms-label") { + this.input.appendChild(cells[i]); + break; + } + } + } else { + this.input = this.cell.children[0]; + } + break; + } + this.initFocus(this.input); +}; + + /** * * '''setValue''' method : empty */ - -XsltForms_trigger.prototype.setValue = function() {}; - - +XsltForms_trigger.prototype.setValue = function() {}; + + + /** * * '''changeReadonly''' method : changes the read only state of this input control */ - -XsltForms_trigger.prototype.changeReadonly = function() { - this.input.disabled = this.readonly; -}; - - +XsltForms_trigger.prototype.changeReadonly = function() { + this.input.disabled = this.readonly; +}; + + + /** * * '''clone''' method : creates a new trigger control with the given id */ - -XsltForms_trigger.prototype.clone = function(id) { - return new XsltForms_trigger(this.subform, id, this.binding, true); -}; - - +XsltForms_trigger.prototype.clone = function(id) { + return new XsltForms_trigger(this.subform, id, this.binding, true); +}; + + + /** * * '''dispose''' method : decrements the number of triggers and calls the parent dispose() method */ - -XsltForms_trigger.prototype.dispose = function() { - XsltForms_globals.counters.trigger--; - XsltForms_element.prototype.dispose.call(this); -}; - - - + +XsltForms_trigger.prototype.dispose = function() { + XsltForms_globals.counters.trigger--; + XsltForms_element.prototype.dispose.call(this); +}; + + + /** * * '''click''' method : dispatches a "DOMActivate" event * @callback */ - -XsltForms_trigger.prototype.click = function(target, evcontext) { - XsltForms_globals.openAction("XsltForms_trigger.prototype.click"); - XsltForms_xmlevents.dispatch(this, "DOMActivate", null, null, null, null, evcontext); - XsltForms_globals.closeAction("XsltForms_trigger.prototype.click"); -}; - - - + +XsltForms_trigger.prototype.click = function(target, evcontext) { + XsltForms_globals.openAction("XsltForms_trigger.prototype.click"); + XsltForms_xmlevents.dispatch(this, "DOMActivate", null, null, null, null, evcontext); + XsltForms_globals.closeAction("XsltForms_trigger.prototype.click"); +}; + + + /** * * '''blur''' method : empty */ - + XsltForms_trigger.prototype.blur = function() {}; \ No newline at end of file diff --git a/src/js/xsltforms.js/controls/upload.js b/src/js/xsltforms.js/controls/upload.js index 1655ee1..b8b3209 100644 --- a/src/js/xsltforms.js/controls/upload.js +++ b/src/js/xsltforms.js/controls/upload.js @@ -1,9 +1,7 @@ -/*eslint-env browser, jquery*/ -/*globals XsltForms_globals XsltForms_browser XsltForms_control XsltForms_schema plupload XsltForms_xmlevents XsltForms_class XsltForms_subform XsltForms_binding*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module upload * @description === "XsltForms_upload" class === * Upload Control Class @@ -172,8 +170,7 @@ XsltForms_upload.prototype.setValue = function(value) { } if (this.resource && typeof plupload !== "undefined") { if (!this.uploader) { - var upsettings = {}; - eval("upsettings = " + (this.type.appinfo ? this.type.appinfo.replace(/(\r\n|\n|\r)/gm, " ") : "{}")); + var upsettings = eval(this.type.appinfo ? this.type.appinfo.replace(/(\r\n|\n|\r)/gm, " ") : "{}"); upsettings.url = "dummy"; upsettings.init = { PostInit: function() { diff --git a/src/js/xsltforms.js/controls/var.js b/src/js/xsltforms.js/controls/var.js index aa20b58..a2e88f0 100644 --- a/src/js/xsltforms.js/controls/var.js +++ b/src/js/xsltforms.js/controls/var.js @@ -1,70 +1,63 @@ -/*eslint-env browser*/ -/*globals XsltForms_globals XsltForms_control XsltForms_class XsltForms_subform XsltForms_binding XsltForms_xpath*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module var * @description === "XsltForms_var" class === * Var Control Class * * constructor function : initializes specific properties and initializes scope */ - + new XsltForms_class("XsltForms_var", "HTMLElement", "xforms-var"); -function XsltForms_var(subform, elt) { - XsltForms_globals.counters.xvar++; - this.init(subform, elt); - if (!this.element.parentNode.varScope) { - this.element.parentNode.varScope = {}; - } - var vname = elt.getAttribute("xf-name"); - this.element.parentNode.varScope[vname] = this; - this.name = vname; - if (elt.parentNode.localName.toLowerCase() === "xforms-action") { - this.controlName = "action-var"; - this.hasBinding = false; - this.value = XsltForms_xpath.create(this.subform, elt.getAttribute("xf-value")); - } else { - this.controlName = "var"; - this.hasBinding = true; - this.binding = new XsltForms_binding(subform, elt); - this.isOutput = true; - } -} - -XsltForms_var.prototype = new XsltForms_control(); - +function XsltForms_var(subform, elt) { + XsltForms_globals.counters.xvar++; + this.init(subform, elt); + this.name = elt.getAttribute("xf-name"); + if (elt.parentNode.localName.toLowerCase() === "xforms-action") { + this.controlName = "action-var"; + this.hasBinding = false; + this.value = XsltForms_xpath.create(this.subform, elt.getAttribute("xf-value")); + } else { + this.controlName = "var"; + this.hasBinding = true; + this.binding = new XsltForms_binding(subform, elt); + this.isOutput = true; + } +} - +XsltForms_var.prototype = new XsltForms_control(); + + + /** * * '''clone''' method : creates a new var control with the given id */ - -XsltForms_var.prototype.clone = function(id) { - return new XsltForms_var(this.subform, id, this.name, this.binding); -}; - - +XsltForms_var.prototype.clone = function(id) { + return new XsltForms_var(this.subform, id, this.name, this.binding); +}; + + + /** * * '''dispose''' method : clears properties of this control and calls the parent dispose() method */ - -XsltForms_var.prototype.dispose = function() { - XsltForms_globals.counters.xvar--; - XsltForms_control.prototype.dispose.call(this); + +XsltForms_var.prototype.dispose = function() { + XsltForms_globals.counters.xvar--; + XsltForms_control.prototype.dispose.call(this); }; - + /** * * '''execute''' method : evaluates the var value when within an action */ XsltForms_var.prototype.execute = function(element, ctx, evt) { - if (!ctx) { - ctx = element.node || (XsltForms_globals.defaultModel.getInstanceDocument() ? XsltForms_globals.defaultModel.getInstanceDocument().documentElement : null); - } - this.boundnodes = this.value.xpath_evaluate(ctx); + if (!ctx) { + ctx = element.node || (XsltForms_globals.defaultModel.getInstanceDocument() ? XsltForms_globals.defaultModel.getInstanceDocument().documentElement : null); + } + this.boundnodes = this.value.xpath_evaluate(ctx); }; \ No newline at end of file diff --git a/src/js/xsltforms.js/coreelts/CoreElement.js b/src/js/xsltforms.js/coreelts/CoreElement.js index d276a82..6772026 100644 --- a/src/js/xsltforms.js/coreelts/CoreElement.js +++ b/src/js/xsltforms.js/coreelts/CoreElement.js @@ -1,49 +1,47 @@ -/*eslint-env browser*/ -/*globals XsltForms_browser */ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module CoreElement * @description === "XsltForms_coreElement" class === * Parent class for each Model component class */ - -function XsltForms_coreElement() { -} - + +function XsltForms_coreElement() { +} - + + /** * * '''init''' method : creates a "span" element under the "head" element to store this object */ - -XsltForms_coreElement.prototype.init = function(subform, elt) { - this.subforms = []; - this.subforms[subform] = true; - this.nbsubforms = 1; - this.subform = subform; - this.element = elt; - /* - parentElt = parentElt? parentElt.element : XsltForms_browser.isXhtml ? document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "head")[0]: document.getElementsByTagName("head")[0]; - this.element = XsltForms_browser.createElement("span", parentElt, null, className); - this.element.id = id; - this.element.xfElement = this; - */ -}; -XsltForms_coreElement.prototype.build = function() {}; +XsltForms_coreElement.prototype.init = function(subform, elt) { + this.subforms = []; + this.subforms[subform] = true; + this.nbsubforms = 1; + this.subform = subform; + this.element = elt; + /* + parentElt = parentElt? parentElt.element : XsltForms_browser.isXhtml ? document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "head")[0]: document.getElementsByTagName("head")[0]; + this.element = XsltForms_browser.createElement("span", parentElt, null, className); + this.element.id = id; + this.element.xfElement = this; + */ +}; + +XsltForms_coreElement.prototype.build = function() {}; - + /** * * '''dispose''' method : clears the properties of this object */ - + XsltForms_coreElement.prototype.dispose = function() { - if (this.element) { - this.element.xfElement = null; - this.element.parentNode.removeChild(this.element); - } - this.element = null; - this.model = null; + if (this.element) { + this.element.xfElement = null; + this.element.parentNode.removeChild(this.element); + } + this.element = null; + this.model = null; }; \ No newline at end of file diff --git a/src/js/xsltforms.js/coreelts/bind.js b/src/js/xsltforms.js/coreelts/bind.js index 6583ad0..b2b4f89 100644 --- a/src/js/xsltforms.js/coreelts/bind.js +++ b/src/js/xsltforms.js/coreelts/bind.js @@ -1,164 +1,164 @@ -/*eslint-env browser*/ -/*globals XsltForms_globals XsltForms_schema XsltForms_binding XsltForms_element XsltForms_coreElement XsltForms_browser XsltForms_exprContext XsltForms_class XsltForms_subform XsltForms_element_depsId:true XsltForms_xpath XsltForms_MIPBinding XsltForms_mipbinding Fleur*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module bind * @description === "XsltForms_bind" class === * Model Binding Class * * constructor function : resolve all the properties and attach this object to the model */ - + new XsltForms_class("XsltForms_bind", "HTMLElement", "xforms-bind"); function XsltForms_bind(subform, elt) { - //if (document.getElementById(id)) { - // return; - //} - var parentBind = elt.parentNode.xfElement; - var model = parentBind.model || parentBind; - var type = elt.getAttribute("xf-type"); - if (type === "xsd:ID") { - XsltForms_globals.IDstr = elt.getAttribute("xf-ref").split('/').pop(); - } - this.init(subform, elt); - this.model = model; - this.type = type ? XsltForms_schema.getType(type) : null; - if (!elt.hasAttribute("xf-ref")) { - elt.setAttribute("xf-ref", "."); - } - this.nodeset = elt.getAttribute("xf-ref"); - this.readonly = elt.hasAttribute("xf-readonly") ? new XsltForms_mipbinding(subform, elt, "xf-readonly", "xsd:boolean", model) : null; - this.required = elt.hasAttribute("xf-required") ? new XsltForms_mipbinding(subform, elt, "xf-required", "xsd:boolean", model) : null; - this.relevant = elt.hasAttribute("xf-relevant") ? new XsltForms_mipbinding(subform, elt, "xf-relevant", "xsd:boolean", model) : null; - this.calculate = elt.hasAttribute("xf-calculate") ? new XsltForms_mipbinding(subform, elt, "xf-calculate", "xsd:string", model) : null; - this.constraint = elt.hasAttribute("xf-constraint") ? new XsltForms_mipbinding(subform, elt, "xf-constraint", "xsd:boolean", model) : null; - this.changed = elt.hasAttribute("xf-changed") ? new XsltForms_mipbinding(subform, elt, "xf-changed", "xsd:string", model) : null; - this.meta = {}; - var metas = this.meta; - Array.prototype.slice.call(elt.attributes).forEach(function(attr) { - if (attr.nodeName.startsWith("meta-")) { - metas[attr.nodeName.substr(5)] = new XsltForms_mipbinding(subform, elt, attr.nodeName, "xsd:anyAtomicType", model); - } - }); - this.depsNodes = []; - this.depsElements = []; - this.nodes = []; - this.binds = []; - this.binding = new XsltForms_binding(subform, elt); - parentBind.addBind(this); - subform.binds.push(this); - this.depsId = XsltForms_element_depsId++; + //if (document.getElementById(id)) { + // return; + //} + var parentBind = elt.parentNode.xfElement; + var model = parentBind.model || parentBind; + var type = elt.getAttribute("xf-type"); + if (type === "xsd:ID") { + XsltForms_globals.IDstr = elt.getAttribute("xf-ref").split('/').pop(); + } + this.init(subform, elt); + this.model = model; + this.type = type ? XsltForms_schema.getType(type) : null; + if (!elt.hasAttribute("xf-ref")) { + elt.setAttribute("xf-ref", "."); + } + this.nodeset = elt.getAttribute("xf-ref"); + this.readonly = elt.hasAttribute("xf-readonly") ? new XsltForms_mipbinding(subform, elt, "xf-readonly", "xsd:boolean", model) : null; + this.required = elt.hasAttribute("xf-required") ? new XsltForms_mipbinding(subform, elt, "xf-required", "xsd:boolean", model) : null; + this.relevant = elt.hasAttribute("xf-relevant") ? new XsltForms_mipbinding(subform, elt, "xf-relevant", "xsd:boolean", model) : null; + this.calculate = elt.hasAttribute("xf-calculate") ? new XsltForms_mipbinding(subform, elt, "xf-calculate", "xsd:string", model) : null; + this.constraint = elt.hasAttribute("xf-constraint") ? new XsltForms_mipbinding(subform, elt, "xf-constraint", "xsd:boolean", model) : null; + this.changed = elt.hasAttribute("xf-changed") ? new XsltForms_mipbinding(subform, elt, "xf-changed", "xsd:string", model) : null; + this.meta = {}; + var metas = this.meta; + Array.prototype.slice.call(elt.attributes).forEach(function(attr) { + if (attr.nodeName.startsWith("meta-")) { + metas[attr.nodeName.substr(5)] = new XsltForms_mipbinding(subform, elt, attr.nodeName, "xsd:anyAtomicType", model); + } + }); + this.depsNodes = []; + this.depsElements = []; + this.nodes = []; + this.binds = []; + this.binding = new XsltForms_binding(subform, elt); + parentBind.addBind(this); + subform.binds.push(this); + this.depsId = XsltForms_element_depsId++; } XsltForms_bind.prototype = new XsltForms_coreElement(); XsltForms_bind.prototype.addBind = function(bind) { - this.binds.push(bind); + this.binds.push(bind); }; XsltForms_bind.prototype.clear = function() { - this.depsNodes.length = 0; - this.depsElements.length = 0; - this.nodes.length = 0; - XsltForms_browser.forEach(this.binds, "clear"); + this.depsNodes.length = 0; + this.depsElements.length = 0; + this.nodes.length = 0; + XsltForms_browser.forEach(this.binds, "clear"); }; - + /** * * '''refresh''' method : completely evaluates and refreshes this binding */ XsltForms_bind.prototype.refresh = function(ctx, index) { - if (!index) { - for (var i = 0, len = this.depsNodes.length; i < len; i++) { - XsltForms_browser.rmValueMeta(this.depsNodes[i], "depfor", this.depsId); - } - this.clear(); - } - ctx = ctx || (this.model ? this.model.getInstanceDocument() ? this.model.getInstanceDocument().documentElement : null : null); - XsltForms_browser.copyArray(this.binding.bind_evaluate(this.subform, ctx, {}, this.depsNodes, this.depsId, this.depsElements).toArray(), this.nodes); - var el = this.element; - for (var i2 = 0, len2 = this.nodes.length; i2 < len2; i2++) { - var node = this.nodes[i2]; - var bindids = XsltForms_browser.getMeta(node, "bind"); - if (!bindids) { - XsltForms_browser.setMeta(node, "bind", String(this.element.xfIndex)); - } else { - var bindids2 = " " + bindids + " "; - if (bindids2.indexOf(" " + this.element.xfIndex + " ") === -1) { - XsltForms_browser.setMeta(node, "bind", bindids + " " + this.element.xfIndex); - } - } - if (this.type) { - if (XsltForms_browser.getMeta(node, "schemaType")) { - XsltForms_globals.error(el, "xforms-binding-exception", "Type especified in xsi:type attribute"); - } else { - var typename = this.type.name; - var ns = this.type.nsuri; - var ns_li = Fleur.XPathNSResolver_default.uri.lastIndexOf(ns); - if (ns_li !== -1) { - typename = Fleur.XPathNSResolver_default.pf[ns_li] + ":" + typename; - } - XsltForms_browser.setType(node, typename); - } - } - for (var j = 0, len1 = el.children.length; j < len1; j++) { - if (el.children[j].xfElement && el.children[j].xfElement.refresh) { - el.children[j].xfElement.refresh(node, i2); - } - } - } + if (!index) { + for (var i = 0, len = this.depsNodes.length; i < len; i++) { + XsltForms_browser.rmValueMeta(this.depsNodes[i], "depfor", this.depsId); + } + this.clear(); + } + ctx = ctx || (this.model ? this.model.getInstanceDocument() ? this.model.getInstanceDocument().documentElement : null : null); + XsltForms_browser.copyArray(this.binding.bind_evaluate(this.subform, ctx, {}, this.depsNodes, this.depsId, this.depsElements).toArray(), this.nodes); + var el = this.element; + for (var i2 = 0, len2 = this.nodes.length; i2 < len2; i2++) { + var node = this.nodes[i2]; + var bindids = XsltForms_browser.getMeta(node, "bind"); + if (!bindids) { + XsltForms_browser.setMeta(node, "bind", String(this.element.xfIndex)); + } else { + var bindids2 = " " + bindids + " "; + if (bindids2.indexOf(" " + this.element.xfIndex + " ") === -1) { + XsltForms_browser.setMeta(node, "bind", bindids + " " + this.element.xfIndex); + } + } + if (this.type) { + if (XsltForms_browser.getMeta(node, "schemaType")) { + XsltForms_globals.error(el, "xforms-binding-exception", "Type especified in xsi:type attribute"); + } else { + var typename = this.type.name; + var ns = this.type.nsuri; + var ns_li = Fleur.XPathNSResolver_default.uri.lastIndexOf(ns); + if (ns_li !== -1) { + typename = Fleur.XPathNSResolver_default.pf[ns_li] + ":" + typename; + } + XsltForms_browser.setType(node, typename); + } + } + for (var j = 0, len1 = el.children.length; j < len1; j++) { + if (el.children[j].xfElement && el.children[j].xfElement.refresh) { + el.children[j].xfElement.refresh(node, i2); + } + } + } }; - + /** * * '''recalculate''' method : just recalculates this binding */ XsltForms_bind.prototype.recalculate = function() { - var el = this.element; - if (this.calculate) { - for (var i = 0, len = this.nodes.length; i < len; i++) { - var node = this.nodes[i]; - var ctx = new XsltForms_exprContext(this.subform, node, i + 1, this.nodes); - var value = XsltForms_globals.stringValue(this.calculate.evaluate(ctx, node)); - value = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string").normalize(value); - XsltForms_browser.setValue(node, value); - this.model.addChange(node); - XsltForms_browser.debugConsole.write("Calculate " + node.nodeName + " " + value); - } - } - for (var j = 0, len1 = el.children.length; j < len1; j++) { - if (el.children[j].xfElement) { - el.children[j].xfElement.recalculate(); - } - } + var el = this.element; + if (this.calculate) { + for (var i = 0, len = this.nodes.length; i < len; i++) { + var node = this.nodes[i]; + var ctx = new XsltForms_exprContext(this.subform, node, i + 1, this.nodes); + var value = XsltForms_globals.stringValue(this.calculate.evaluate(ctx, node)); + value = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string").normalize(value); + if ((node.nodeValue || node.textContent) !== value) { + XsltForms_browser.setValue(node, value); + this.model.addChange(node); + } + XsltForms_browser.debugConsole.write("Calculate " + node.nodeName + " " + value); + } + } + for (var j = 0, len1 = el.children.length; j < len1; j++) { + if (el.children[j].xfElement) { + el.children[j].xfElement.recalculate(); + } + } }; - + /** * * '''propagate''' method : propagate change to component content */ XsltForms_bind.prototype.propagate = function() { - var el = this.element; - if (this.changed) { - for (var i = 0, len = this.nodes.length; i < len; i++) { - var node = this.nodes[i]; - var ctx = new XsltForms_exprContext(this.subform, node, i + 1, this.nodes); - var value = XsltForms_globals.stringValue(this.changed.evaluate(ctx, node)); - value = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string").normalize(value); - XsltForms_browser.setValue(node, value); - //this.model.addChange(node); - XsltForms_browser.debugConsole.write("Propagate " + node.nodeName + " " + value); - } - } - for (var j = 0, len1 = el.children.length; j < len1; j++) { - if (el.children[j].xfElement) { - el.children[j].xfElement.propagate(); - } - } + var el = this.element; + if (this.changed) { + for (var i = 0, len = this.nodes.length; i < len; i++) { + var node = this.nodes[i]; + var ctx = new XsltForms_exprContext(this.subform, node, i + 1, this.nodes); + var value = XsltForms_globals.stringValue(this.changed.evaluate(ctx, node)); + value = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string").normalize(value); + XsltForms_browser.setValue(node, value); + //this.model.addChange(node); + XsltForms_browser.debugConsole.write("Propagate " + node.nodeName + " " + value); + } + } + for (var j = 0, len1 = el.children.length; j < len1; j++) { + if (el.children[j].xfElement) { + el.children[j].xfElement.propagate(); + } + } }; \ No newline at end of file diff --git a/src/js/xsltforms.js/coreelts/form.js b/src/js/xsltforms.js/coreelts/form.js new file mode 100644 index 0000000..537b67f --- /dev/null +++ b/src/js/xsltforms.js/coreelts/form.js @@ -0,0 +1,61 @@ +"use strict"; +/** + * @author Alain Couthures + * @license LGPL - See file 'LICENSE.md' in this project. + * @module model + * @description === "XsltForms_form" class === + * * constructor function : specifically gets the associated schemas + */ + +new XsltForms_class("XsltForms_form", "HTMLElement", "xforms-form"); + +function XsltForms_form(subform, elt) { + Array.prototype.slice.call(elt.attributes).forEach(function(n) { + if (n.nodeName.substr(0, 6) === "xmlns:" || n.nodeName.substr(0, 6) === "xmlns-") { + Fleur.XPathNSResolver_default.pf.push(n.nodeName.substr(6)); + Fleur.XPathNSResolver_default.uri.push(n.nodeValue); + } else if (n.localName === "xmlns" && n.prefix) { + Fleur.XPathNSResolver_default.pf.push(n.prefix.toLowerCase()); + Fleur.XPathNSResolver_default.uri.push(n.namespaceURI); + } else if (n.prefix && n.prefix !== "") { + Fleur.XPathNSResolver_default.pf.push(n.prefix.toLowerCase()); + Fleur.XPathNSResolver_default.uri.push(n.namespaceURI); + } + }); + this.init(subform, elt); + let xmodelconfig, xdialog, xbody; + const contents = []; + Array.prototype.slice.call(elt.children).forEach(function(n) { + switch(n.localName.toLowerCase()) { + case "xforms-model": + xmodelconfig = n; + break; + case "xforms-dialog": + xdialog = n; + break; + case "xforms-body": + xbody = n; + break; + default: + contents.push(n); + } + }); + if (!xdialog) { + const xcons = document.createElement("xforms-dialog"); + xcons.setAttribute("id", "xsltforms-console"); + elt.appendChild(xcons); + const stap = document.createElement("xforms-dialog"); + stap.setAttribute("id", "xsltforms-status-panel"); + elt.appendChild(stap); + } + if (!xbody) { + const frm = document.createElement("form"); + contents.forEach(n => frm.appendChild(n)); + const xbo = document.createElement("xforms-body"); + xbo.appendChild(frm); + elt.appendChild(xbo); + } + XsltForms_globals.formelt = elt.querySelector("form"); +} + +XsltForms_form.prototype = new XsltForms_coreElement(); diff --git a/src/js/xsltforms.js/coreelts/instance.js b/src/js/xsltforms.js/coreelts/instance.js index e9c54e0..fac5729 100644 --- a/src/js/xsltforms.js/coreelts/instance.js +++ b/src/js/xsltforms.js/coreelts/instance.js @@ -1,5 +1,3 @@ -/*eslint-env browser*/ -/*globals XsltForms_browser unescape XsltForms_coreElement XsltForms_globals XsltForms_browser_BinaryToArray_ByteStr_Last XsltForms_browser_BinaryToArray_ByteStr Fleur XsltForms_schema XsltForms_exprContext XsltForms_xmlevents zip_inflate zip_deflate XsltForms_class XsltForms_subform XsltForms_collection*/ "use strict"; /** * @author Alain Couthures @@ -9,1093 +7,1102 @@ * Instance Class * * constructor function : stores the properties of this instance and attaches it to a model */ - + new XsltForms_class("XsltForms_instance", "HTMLElement", "xforms-instance"); function XsltForms_instance(subform, elt) { - if (XsltForms_globals.formSource) { - this.instanceSource = elt.outerHTML; - if (subform.instances.length === 0) { - this.sourceStart = XsltForms_globals.formSource.indexOf(this.instanceSource); - } else { - this.sourceStart = XsltForms_globals.formSource.indexOf(this.instanceSource, subform.instances[subform.instances.length - 1].sourceStart + subform.instances[subform.instances.length - 1].instanceSource.length); - } - this.dataSource = elt.children[0] ? elt.children[0].textContent : ""; - } - if (!elt.id && !document.getElementById(subform.id + "-instance-default")) { - elt.id = subform.id + "-instance-default"; - } - var model = elt.parentNode.xfElement; - var srcDoc = elt.children[0] ? elt.children[0].textContent : ""; - srcDoc = srcDoc.replace(/(<|<)\\\/script(>|>)/g, "<\/script>"); - if (srcDoc === "") { - elt.innerHTML = ""; - } - if (!Fleur.DOMParse) { - this.init(subform, elt); - this.readonly = elt.getAttribute("xf-readonly"); - var mediatype = elt.getAttribute("xf-mediatype") || "application/xml"; - var lines = mediatype.split(";"); - this.mediatype = lines[0]; - for (var i = 1, len = lines.length; i < len; i++) { - var vals = lines[i].split("="); - switch (vals[0].replace(/^\s+/g,'').replace(/\s+$/g,'')) { - case "header": - this.header = vals[1].replace(/^\s+/g,'').replace(/\s+$/g,'') === "present"; - break; - case "separator": - this.separator = (decodeURI ? decodeURI : unescape)(vals[1].replace(/^\s+/g,'').replace(/\s+$/g,'')); - break; - case "charset": - this.charset = vals[1].replace(/^\s+/g,'').replace(/\s+$/g,''); - break; - } - } - this.src = XsltForms_browser.unescape(elt.getAttribute("xf-src") || (elt.children.length !== 0 ? null : elt.getAttribute("xf-resource"))); - var newmediatype = this.mediatype; - if (newmediatype.substr(newmediatype.length - 4) === "/xml" || newmediatype.substr(newmediatype.length - 4) === "/xsl" || newmediatype.substr(newmediatype.length - 4) === "+xml") { - newmediatype = "application/xml"; - } - switch(newmediatype) { - case "application/xml": - this.srcDoc = srcDoc.trim(); - if (this.srcDoc.substring(0, 1) === "&") { - this.srcDoc = XsltForms_browser.unescape(this.srcDoc); - } - break; - case "text/json": - case "application/json": - case "application/javascript": - if (srcDoc) { - var json; - eval("json = " + srcDoc); - this.srcDoc = XsltForms_browser.json2xml("", json, true, false); - } else { - this.srcDoc = ""; - } - break; - case "text/csv": - this.srcDoc = XsltForms_browser.csv2xml(srcDoc, this.separator, this.header); - break; - case "text/vcard": - this.srcDoc = XsltForms_browser.vcard2xcard(srcDoc); - break; - case "application/zip": - case "application/vnd.openxmlformats-officedocument.wordprocessingml.document": - case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": - this.srcDoc = ""; - break; - default: - alert("Unsupported mediatype '" + elt.getAttribute("mediatype") + "' for instance #" + elt.id); - return; - } - this.model = model; - this.doc = XsltForms_browser.createXMLDocument(""); - XsltForms_browser.setDocMeta(this.doc, "instance", elt.id); - XsltForms_browser.setDocMeta(this.doc, "model", model.element.id); - model.addInstance(this); - subform.instances.push(this); - } else { - this.init(subform, elt); - this.readonly = elt.getAttribute("xf-readonly"); - this.mediatype = elt.getAttribute("xf-mediatype"); - this.src = XsltForms_browser.unescape(elt.getAttribute("xf-src")); - this.srcDoc = srcDoc.replace(/^\s+|\s+$/gm,''); - this.model = model; - this.doc = XsltForms_browser.createXMLDocument(""); - XsltForms_browser.setDocMeta(this.doc, "instance", elt.id); - XsltForms_browser.setDocMeta(this.doc, "model", model.element.id); - model.addInstance(this); - subform.instances.push(this); - } + let srcDoc = ""; + if (elt.children[0]) { + srcDoc = elt.children[0].innerHTML; + if (srcDoc.trim() === "") { + srcDoc = elt.children[0].outerHTML; + srcDoc = srcDoc.substring(srcDoc.indexOf(">") + 1); + srcDoc = srcDoc.substring(0, srcDoc.length - 9); + } + } + if (XsltForms_globals.formSource) { + this.instanceSource = elt.outerHTML; + if (subform.instances.length === 0) { + this.sourceStart = XsltForms_globals.formSource.indexOf(this.instanceSource); + } else { + this.sourceStart = XsltForms_globals.formSource.indexOf(this.instanceSource, subform.instances[subform.instances.length - 1].sourceStart + subform.instances[subform.instances.length - 1].instanceSource.length); + } + this.dataSource = srcDoc; + } + if (!elt.id && !document.getElementById(subform.id + "-instance-default")) { + elt.id = subform.id + "-instance-default"; + } + var model = elt.parentNode.xfElement; + srcDoc = srcDoc.replace(/(<|<)\\\/script(>|>)/g, "<\/script>"); + if (srcDoc === "") { + elt.innerHTML = ""; + } + this.modified = false; + if (!Fleur.DOMParse) { + this.init(subform, elt); + this.readonly = elt.getAttribute("xf-readonly"); + var mediatype = elt.getAttribute("xf-mediatype") || "application/xml"; + var lines = mediatype.split(";"); + this.mediatype = lines[0]; + for (var i = 1, len = lines.length; i < len; i++) { + var vals = lines[i].split("="); + switch (vals[0].replace(/^\s+/g,'').replace(/\s+$/g,'')) { + case "header": + this.header = vals[1].replace(/^\s+/g,'').replace(/\s+$/g,'') === "present"; + break; + case "separator": + this.separator = (decodeURI ? decodeURI : unescape)(vals[1].replace(/^\s+/g,'').replace(/\s+$/g,'')); + break; + case "charset": + this.charset = vals[1].replace(/^\s+/g,'').replace(/\s+$/g,''); + break; + } + } + this.src = XsltForms_browser.unescape(elt.getAttribute("xf-src") || (elt.children.length !== 0 ? null : elt.getAttribute("xf-resource"))); + var newmediatype = this.mediatype; + if (newmediatype.substr(newmediatype.length - 4) === "/xml" || newmediatype.substr(newmediatype.length - 4) === "/xsl" || newmediatype.substr(newmediatype.length - 4) === "+xml") { + newmediatype = "application/xml"; + } + switch(newmediatype) { + case "application/xml": + this.srcDoc = srcDoc.trim(); + if (this.srcDoc.substring(0, 1) === "&") { + this.srcDoc = XsltForms_browser.unescape(this.srcDoc); + } + break; + case "text/json": + case "application/json": + case "application/javascript": + if (srcDoc) { + var json = eval(srcDoc); + this.srcDoc = XsltForms_browser.json2xml("", json, true, false); + } else { + this.srcDoc = ""; + } + break; + case "text/csv": + this.srcDoc = XsltForms_browser.csv2xml(srcDoc, this.separator, this.header); + break; + case "text/vcard": + this.srcDoc = XsltForms_browser.vcard2xcard(srcDoc); + break; + case "application/zip": + case "application/vnd.openxmlformats-officedocument.wordprocessingml.document": + case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": + this.srcDoc = ""; + break; + default: + alert("Unsupported mediatype '" + elt.getAttribute("mediatype") + "' for instance #" + elt.id); + return; + } + this.model = model; + this.doc = XsltForms_browser.createXMLDocument(""); + XsltForms_browser.setDocMeta(this.doc, "instance", elt.id); + XsltForms_browser.setDocMeta(this.doc, "model", model.element.id); + model.addInstance(this); + subform.instances.push(this); + } else { + this.init(subform, elt); + this.readonly = elt.getAttribute("xf-readonly"); + this.mediatype = elt.getAttribute("xf-mediatype"); + this.src = XsltForms_browser.unescape(elt.getAttribute("xf-src")); + this.srcDoc = srcDoc.replace(/^\s+|\s+$/gm,''); + this.model = model; + this.doc = XsltForms_browser.createXMLDocument(""); + XsltForms_browser.setDocMeta(this.doc, "instance", elt.id); + XsltForms_browser.setDocMeta(this.doc, "model", model.element.id); + model.addInstance(this); + subform.instances.push(this); + } } XsltForms_instance.prototype = new XsltForms_coreElement(); - + /** * * '''create''' method : checks if this instance has not already been created */ XsltForms_instance.create = function(subform, id, model, readonly, mediatype, src, srcDoc) { - var instelt = document.getElementById(id); - if (instelt && instelt.xfElement) { - instelt.xfElement.subforms[subform] = true; - instelt.xfElement.nbsubforms++; - subform.instances.push(instelt.xfElement); - return instelt.xfElement; - } - return new XsltForms_instance(subform, id, model, readonly, mediatype, src, srcDoc); + var instelt = document.getElementById(id); + if (instelt && instelt.xfElement) { + instelt.xfElement.subforms[subform] = true; + instelt.xfElement.nbsubforms++; + subform.instances.push(instelt.xfElement); + return instelt.xfElement; + } + return new XsltForms_instance(subform, id, model, readonly, mediatype, src, srcDoc); }; - + /** * * '''dispose''' method : clears the properties and recycles the associated nodes */ XsltForms_instance.prototype.dispose = function(subform) { - if (subform && this.nbsubforms !== 1) { - this.subforms[subform] = null; - this.nbsubforms--; - return; - } - XsltForms_coreElement.prototype.dispose.call(this); + if (subform && this.nbsubforms !== 1) { + this.subforms[subform] = null; + this.nbsubforms--; + return; + } + XsltForms_coreElement.prototype.dispose.call(this); }; - + /** * * '''construct''' method : loads the source of this instance locally or remotely */ XsltForms_instance.prototype.construct = function(subform) { - var ser; - if (!XsltForms_globals.ready || (subform && !subform.ready && this.nbsubforms === 1)) { - if (this.src) { - if (this.src.substring(0, 8) === "local://") { - try { - if (typeof(localStorage) === 'undefined') { - throw new Error({ message: "local:// not supported" }); - } - this.setDoc(window.localStorage.getItem(this.src.substr(8))); - } catch(e) { - XsltForms_globals.error(this.element, "xforms-link-exception", "Fatal error loading " + this.src, e.toString()); - } - } else if (this.src.substr(0, 9) === "opener://") { - try { - ser = window.opener.XsltForms_globals.xmlrequest('get', this.src.substr(9)); - this.setDoc(ser); - } catch (e) { - XsltForms_globals.error(this.element, "xforms-link-exception", "Fatal error loading " + this.src, e.toString()); - } - } else { - if (this.src.substr(0, 11) === "javascript:") { - try { - eval("ser = (" + this.src.substr(11) + ");"); - this.setDoc(ser); - } catch (e) { - XsltForms_globals.error(this.element, "xforms-link-exception", "Error evaluating the following Javascript expression: "+this.src.substr(11)); - } - } else { - var cross = false; - if (this.src.match(/^[a-zA-Z0-9+\.\-]+:\/\//)) { - var domain = /^([a-zA-Z0-9+\.\-]+:\/\/[^\/]*)/; - var sdom = domain.exec(this.src); - var ldom = domain.exec(document.location.href); - cross = sdom[0] !== ldom[0]; - } - if (cross && this.mediatype === "application/javascript") { - this.setDoc(''); - XsltForms_browser.jsoninstobj = this; - var scriptelt = XsltForms_browser.isXhtml ? document.createElementNS("http://www.w3.org/1999/xhtml", "script") : document.createElement("script"); - scriptelt.setAttribute("src", this.src+((this.src.indexOf("?") === -1) ? "?" : "&")+"callback=XsltForms_browser.jsoninst"); - scriptelt.setAttribute("id", "jsoninst"); - scriptelt.setAttribute("type", "text/javascript"); - var body = XsltForms_browser.isXhtml ? document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "body")[0] : document.getElementsByTagName("body")[0]; - body.insertBefore(scriptelt, body.firstChild); - } else { - try { - var req = XsltForms_browser.openRequest("GET", this.src, false); - XsltForms_browser.debugConsole.write("Loading " + this.src); - if ((this.mediatype === "application/zip" || this.mediatype === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" )&& req.overrideMimeType) { - req.overrideMimeType('text/plain; charset=x-user-defined'); - } else if (this.mediatype === "text/csv") { - req.overrideMimeType('text/csv'); - } else if (this.mediatype === "text/json" || this.mediatype === "application/json") { - req.overrideMimeType('application/json; charset=x-user-defined'); - } - req.send(null); - if (req.status !== 0 && (req.status < 200 || req.status >= 300)) { - throw new Error({ message: "Request error: " + req.status }); - } - this.setDocFromReq(req); - } catch(e) { - XsltForms_globals.error(this.element, "xforms-link-exception", "Fatal error loading " + this.src, e.toString()); - } - } - } - } - } else { - this.setDoc(this.srcDoc); - } - } + var ser; + if (!XsltForms_globals.ready || (subform && !subform.ready && this.nbsubforms === 1)) { + if (this.src) { + if (this.src.substring(0, 8) === "local://") { + try { + if (typeof(localStorage) === 'undefined') { + throw new Error({ message: "local:// not supported" }); + } + this.setDoc(window.localStorage.getItem(this.src.substr(8))); + } catch(e) { + XsltForms_globals.error(this.element, "xforms-link-exception", "Fatal error loading " + this.src, e.toString()); + } + } else if (this.src.substr(0, 9) === "opener://") { + try { + ser = window.opener.XsltForms_globals.xmlrequest('get', this.src.substr(9)); + this.setDoc(ser); + } catch (e) { + XsltForms_globals.error(this.element, "xforms-link-exception", "Fatal error loading " + this.src, e.toString()); + } + } else { + if (this.src.substr(0, 11) === "javascript:") { + try { + ser = eval(this.src.substr(11)); + this.setDoc(ser); + } catch (e) { + XsltForms_globals.error(this.element, "xforms-link-exception", "Error evaluating the following Javascript expression: "+this.src.substr(11)); + } + } else { + var cross = false; + if (this.src.match(/^[a-zA-Z0-9+\.\-]+:\/\//)) { + var domain = /^([a-zA-Z0-9+\.\-]+:\/\/[^\/]*)/; + var sdom = domain.exec(this.src); + var ldom = domain.exec(document.location.href); + cross = sdom[0] !== ldom[0]; + } + if (cross && this.mediatype === "application/javascript") { + this.setDoc(''); + XsltForms_browser.jsoninstobj = this; + var scriptelt = XsltForms_browser.isXhtml ? document.createElementNS("http://www.w3.org/1999/xhtml", "script") : document.createElement("script"); + scriptelt.setAttribute("src", this.src+((this.src.indexOf("?") === -1) ? "?" : "&")+"callback=XsltForms_browser.jsoninst"); + scriptelt.setAttribute("id", "jsoninst"); + scriptelt.setAttribute("type", "text/javascript"); + var body = XsltForms_browser.isXhtml ? document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "body")[0] : document.getElementsByTagName("body")[0]; + body.insertBefore(scriptelt, body.firstChild); + } else { + try { + var req = XsltForms_browser.openRequest("GET", this.src, false); + XsltForms_browser.debugConsole.write("Loading " + this.src); + if ((this.mediatype === "application/zip" || this.mediatype === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" )&& req.overrideMimeType) { + req.overrideMimeType('text/plain; charset=x-user-defined'); + } else if (this.mediatype === "text/csv") { + req.overrideMimeType('text/csv'); + } else if (this.mediatype === "text/json" || this.mediatype === "application/json") { + req.overrideMimeType('application/json; charset=x-user-defined'); + } + req.send(null); + if (req.status !== 0 && (req.status < 200 || req.status >= 300)) { + throw new Error({ message: "Request error: " + req.status }); + } + this.setDocFromReq(req); + } catch(e) { + XsltForms_globals.error(this.element, "xforms-link-exception", "Fatal error loading " + this.src, e.toString()); + } + } + } + } + } else { + this.setDoc(this.srcDoc); + } + } }; - + /** * * '''reset''' method : simply restores the initial copy of this instance */ XsltForms_instance.prototype.reset = function() { - this.setDoc(this.oldDoc, true); + this.setDoc(this.oldDoc, true); }; - + /** * * '''store''' method : clones the document of this instance */ XsltForms_instance.prototype.store = function(isReset) { - if (this.oldDoc && !isReset) { - this.oldDoc = null; - } - this.oldDoc = XsltForms_browser.saveDoc(this.doc, this.mediatype); + if (this.oldDoc && !isReset) { + this.oldDoc = null; + } + this.oldDoc = XsltForms_browser.saveDoc(this.doc, this.mediatype); }; - + /** * * '''setDoc''' method : sets a document for this instance */ if (!Fleur.DOMParser) { - XsltForms_instance.prototype.setDoc = function(xml, isReset, preserveOld) { - var instid = XsltForms_browser.getDocMeta(this.doc, "instance"); - var modid = XsltForms_browser.getDocMeta(this.doc, "model"); - XsltForms_browser.loadDoc(this.doc, xml); - XsltForms_browser.setDocMeta(this.doc, "instance", instid); - XsltForms_browser.setDocMeta(this.doc, "model", modid); - if (!preserveOld) { - this.store(isReset); - } - if (instid === XsltForms_browser.idPf + "instance-config") { - XsltForms_browser.config = this.doc.documentElement; - XsltForms_globals.htmlversion = XsltForms_browser.i18n.get("html"); - } - }; + XsltForms_instance.prototype.setDoc = function(xml, isReset, preserveOld) { + var instid = XsltForms_browser.getDocMeta(this.doc, "instance"); + var modid = XsltForms_browser.getDocMeta(this.doc, "model"); + XsltForms_browser.loadDoc(this.doc, xml); + this.modified = false; + XsltForms_browser.setDocMeta(this.doc, "instance", instid); + XsltForms_browser.setDocMeta(this.doc, "model", modid); + if (!preserveOld) { + this.store(isReset); + } + if (instid === XsltForms_browser.idPf + "instance-config") { + XsltForms_browser.config = this.doc.documentElement; + XsltForms_globals.htmlversion = XsltForms_browser.i18n.get("html"); + } + }; } else { - XsltForms_instance.prototype.setDoc = function(srcDoc, isReset, preserveOld) { - var instid = XsltForms_browser.getDocMeta(this.doc, "instance"); - var modid = XsltForms_browser.getDocMeta(this.doc, "model"); - XsltForms_browser.loadDoc(this.doc, srcDoc, this.mediatype); - XsltForms_browser.setDocMeta(this.doc, "instance", instid); - XsltForms_browser.setDocMeta(this.doc, "model", modid); - if (!preserveOld) { - this.store(isReset); - } - if (instid === XsltForms_browser.idPf + "instance-config") { - XsltForms_browser.config = this.doc.documentElement; - XsltForms_globals.htmlversion = XsltForms_browser.i18n.get("html"); - } - }; + XsltForms_instance.prototype.setDoc = function(srcDoc, isReset, preserveOld) { + var instid = XsltForms_browser.getDocMeta(this.doc, "instance"); + var modid = XsltForms_browser.getDocMeta(this.doc, "model"); + XsltForms_browser.loadDoc(this.doc, srcDoc, this.mediatype); + this.modified = false; + XsltForms_browser.setDocMeta(this.doc, "instance", instid); + XsltForms_browser.setDocMeta(this.doc, "model", modid); + if (!preserveOld) { + this.store(isReset); + } + if (instid === XsltForms_browser.idPf + "instance-config") { + XsltForms_browser.config = this.doc.documentElement; + XsltForms_globals.htmlversion = XsltForms_browser.i18n.get("html"); + } + }; } - + /** * * '''setDocFromReq''' method : sets a document for this instance from a request */ if (!Fleur.DOMParser) { - XsltForms_instance.prototype.setDocFromReq = function(req, isReset, preserveOld) { - var srcDoc = req.responseText; - var mediatype = req.getResponseHeader('Content-Type') ? req.getResponseHeader('Content-Type') : this.mediatype; - var lines = mediatype.split(";"); - var i0, len; - this.mediatype = lines[0]; - for (i0 = 1, len = lines.length; i0 < len; i0++) { - var vals = lines[i0].split("="); - switch (vals[0].replace(/^\s+/g,'').replace(/\s+$/g,'')) { - case "header": - this.header = vals[1].replace(/^\s+/g,'').replace(/\s+$/g,'') === "present"; - break; - case "separator": - this.separator = (decodeURI ? decodeURI : unescape)(vals[1].replace(/^\s+/g,'').replace(/\s+$/g,'')); - break; - case "charset": - this.charset = vals[1].replace(/^\s+/g,'').replace(/\s+$/g,''); - break; - } - } - if (XsltForms_browser.isChrome && this.mediatype === "text/plain") { - switch(this.src.substr(this.src.indexOf("."))) { - case ".xlsx": - this.mediatype = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; - break; - case ".docx": - this.mediatype = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; - break; - case ".csv": - this.mediatype = "text/csv"; - break; - } - } - var newmediatype = this.mediatype; - if (newmediatype.substr(newmediatype.length - 4) === "/xml" || newmediatype.substr(newmediatype.length - 4) === "/xsl" || newmediatype.substr(newmediatype.length - 4) === "+xml") { - newmediatype = "application/xml"; - } - switch(newmediatype) { - case "text/json": - case "application/json": - var json; - eval("json = " + srcDoc); - srcDoc = XsltForms_browser.json2xml("", json, true, false); - break; - case "text/csv": - if (XsltForms_browser.isIE) { - var convertResponseBodyToText = function (binary) { - if (!XsltForms_browser.byteMapping) { - var byteMapping = {}; - for (var i = 0; i < 256; i++) { - for (var j = 0; j < 256; j++) { - byteMapping[String.fromCharCode(i + j * 256)] = String.fromCharCode(i) + String.fromCharCode(j); - } - } - XsltForms_browser.byteMapping = byteMapping; - } - var rawBytes = XsltForms_browser_BinaryToArray_ByteStr(binary); - var lastChr = XsltForms_browser_BinaryToArray_ByteStr_Last(binary); - return rawBytes.replace(/[\s\S]/g, function (match) { return XsltForms_browser.byteMapping[match]; }) + lastChr; - }; - srcDoc = XsltForms_browser.csv2xml(convertResponseBodyToText(req.responseBody), this.separator, this.header); - } else { - srcDoc = XsltForms_browser.csv2xml(srcDoc, this.separator, this.header); - } - break; - case "text/vcard": - srcDoc = XsltForms_browser.vcard2xcard(srcDoc); - break; - case "application/x-zip-compressed": - case "application/zip": - case "application/vnd.openxmlformats-officedocument.wordprocessingml.document": - case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": - var arch; - if (XsltForms_browser.isIE) { - var convertResponseBodyToTextb = function (binary) { - if (!XsltForms_browser.byteMapping) { - var byteMapping = {}; - for (var i = 0; i < 256; i++) { - for (var j = 0; j < 256; j++) { - byteMapping[String.fromCharCode(i + j * 256)] = String.fromCharCode(i) + String.fromCharCode(j); - } - } - XsltForms_browser.byteMapping = byteMapping; - } - var rawBytes = XsltForms_browser_BinaryToArray_ByteStr(binary); - var lastChr = XsltForms_browser_BinaryToArray_ByteStr_Last(binary); - return rawBytes.replace(/[\s\S]/g, function (match) { return XsltForms_browser.byteMapping[match]; }) + lastChr; - }; - arch = XsltForms_browser.zip2xml(convertResponseBodyToTextb(req.responseBody), this.mediatype, this.element.id, this.model.element.id); - } else { - arch = XsltForms_browser.zip2xml(srcDoc, this.mediatype, this.element.id, this.model.element.id); - } - srcDoc = arch.srcDoc; - delete arch.srcDoc; - this.archive = arch; - break; - case "application/xml": - break; - default: - alert("Unsupported mediatype '" + this.mediatype + "' for instance #" + this.element.id); - return; - } - this.setDoc(srcDoc, isReset, preserveOld); - }; + XsltForms_instance.prototype.setDocFromReq = function(req, isReset, preserveOld) { + var srcDoc = req.responseText; + var mediatype = req.getResponseHeader('Content-Type') ? req.getResponseHeader('Content-Type') : this.mediatype; + var lines = mediatype.split(";"); + var i0, len; + this.mediatype = lines[0]; + for (i0 = 1, len = lines.length; i0 < len; i0++) { + var vals = lines[i0].split("="); + switch (vals[0].replace(/^\s+/g,'').replace(/\s+$/g,'')) { + case "header": + this.header = vals[1].replace(/^\s+/g,'').replace(/\s+$/g,'') === "present"; + break; + case "separator": + this.separator = (decodeURI ? decodeURI : unescape)(vals[1].replace(/^\s+/g,'').replace(/\s+$/g,'')); + break; + case "charset": + this.charset = vals[1].replace(/^\s+/g,'').replace(/\s+$/g,''); + break; + } + } + if (XsltForms_browser.isChrome && this.mediatype === "text/plain") { + switch(this.src.substr(this.src.indexOf("."))) { + case ".xlsx": + this.mediatype = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; + break; + case ".docx": + this.mediatype = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; + break; + case ".csv": + this.mediatype = "text/csv"; + break; + } + } + var newmediatype = this.mediatype; + if (newmediatype.substr(newmediatype.length - 4) === "/xml" || newmediatype.substr(newmediatype.length - 4) === "/xsl" || newmediatype.substr(newmediatype.length - 4) === "+xml") { + newmediatype = "application/xml"; + } + switch(newmediatype) { + case "text/json": + case "application/json": + var json = eval(srcDoc); + srcDoc = XsltForms_browser.json2xml("", json, true, false); + break; + case "text/csv": + if (XsltForms_browser.isIE) { + var convertResponseBodyToText = function (binary) { + if (!XsltForms_browser.byteMapping) { + var byteMapping = {}; + for (var i = 0; i < 256; i++) { + for (var j = 0; j < 256; j++) { + byteMapping[String.fromCharCode(i + j * 256)] = String.fromCharCode(i) + String.fromCharCode(j); + } + } + XsltForms_browser.byteMapping = byteMapping; + } + var rawBytes = XsltForms_browser_BinaryToArray_ByteStr(binary); + var lastChr = XsltForms_browser_BinaryToArray_ByteStr_Last(binary); + return rawBytes.replace(/[\s\S]/g, function (match) { return XsltForms_browser.byteMapping[match]; }) + lastChr; + }; + srcDoc = XsltForms_browser.csv2xml(convertResponseBodyToText(req.responseBody), this.separator, this.header); + } else { + srcDoc = XsltForms_browser.csv2xml(srcDoc, this.separator, this.header); + } + break; + case "text/vcard": + srcDoc = XsltForms_browser.vcard2xcard(srcDoc); + break; + case "application/x-zip-compressed": + case "application/zip": + case "application/vnd.openxmlformats-officedocument.wordprocessingml.document": + case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": + var arch; + if (XsltForms_browser.isIE) { + var convertResponseBodyToTextb = function (binary) { + if (!XsltForms_browser.byteMapping) { + var byteMapping = {}; + for (var i = 0; i < 256; i++) { + for (var j = 0; j < 256; j++) { + byteMapping[String.fromCharCode(i + j * 256)] = String.fromCharCode(i) + String.fromCharCode(j); + } + } + XsltForms_browser.byteMapping = byteMapping; + } + var rawBytes = XsltForms_browser_BinaryToArray_ByteStr(binary); + var lastChr = XsltForms_browser_BinaryToArray_ByteStr_Last(binary); + return rawBytes.replace(/[\s\S]/g, function (match) { return XsltForms_browser.byteMapping[match]; }) + lastChr; + }; + arch = XsltForms_browser.zip2xml(convertResponseBodyToTextb(req.responseBody), this.mediatype, this.element.id, this.model.element.id); + } else { + arch = XsltForms_browser.zip2xml(srcDoc, this.mediatype, this.element.id, this.model.element.id); + } + srcDoc = arch.srcDoc; + delete arch.srcDoc; + this.archive = arch; + break; + case "application/xml": + break; + default: + alert("Unsupported mediatype '" + this.mediatype + "' for instance #" + this.element.id); + return; + } + this.setDoc(srcDoc, isReset, preserveOld); + }; } else { - XsltForms_instance.prototype.setDocFromReq = function(req, isReset, preserveOld) { - var srcDoc = req.responseText; - if (XsltForms_browser.isChrome && this.mediatype === "text/plain") { - switch(this.src.substr(this.src.indexOf("."))) { - case ".xlsx": - this.mediatype = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; - break; - case ".docx": - this.mediatype = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; - break; - case ".csv": - this.mediatype = "text/csv"; - break; - } - } - this.mediatype = req.getResponseHeader('Content-Type') ? req.getResponseHeader('Content-Type') : this.mediatype; - this.setDoc(srcDoc, isReset, preserveOld); - }; + XsltForms_instance.prototype.setDocFromReq = function(req, isReset, preserveOld) { + var srcDoc = req.responseText; + if (XsltForms_browser.isChrome && this.mediatype === "text/plain") { + switch(this.src.substr(this.src.indexOf("."))) { + case ".xlsx": + this.mediatype = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; + break; + case ".docx": + this.mediatype = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; + break; + case ".csv": + this.mediatype = "text/csv"; + break; + } + } + this.mediatype = req.getResponseHeader('Content-Type') ? req.getResponseHeader('Content-Type') : this.mediatype; + this.setDoc(srcDoc, isReset, preserveOld); + }; } - + /** * * '''revalidate''' method : recursively revalidates each node of this instance according to readonly and relevant attributes */ XsltForms_instance.prototype.revalidate = function() { - if (!this.readonly && this.doc.documentElement) { - this.validation_(this.doc.documentElement); - } + if (!this.readonly && this.doc.documentElement) { + this.validation_(this.doc.documentElement); + } }; XsltForms_instance.prototype.validation_ = function(node, readonly, notrelevant) { - if (!readonly) { - readonly = false; - } - if (!notrelevant) { - notrelevant = false; - } - this.validate_(node, readonly, notrelevant); - readonly = XsltForms_browser.getBoolMeta(node, "readonly"); - notrelevant = XsltForms_browser.getBoolMeta(node, "notrelevant"); - var atts = node.attributes || []; - if (atts) { - var atts2 = []; - for (var i = 0, len = atts.length; i < len; i++) { - if (atts[i].nodeName.substr(0,10) !== "xsltforms_" && atts[i].nodeName.substr(0,5) !== "xmlns") { - atts2[atts2.length] = atts[i]; - } - } - for (var i2 = 0, len2 = atts2.length; i2 < len2; i2++) { - this.validation_(atts2[i2], readonly, notrelevant); - } - } - if (node.childNodes) { - for (var j = 0, len1 = node.childNodes.length; j < len1; j++) { - var child = node.childNodes[j]; - if (child.nodeType === Fleur.Node.ELEMENT_NODE) { - this.validation_(child, readonly, notrelevant); - } - } - } + if (!readonly) { + readonly = false; + } + if (!notrelevant) { + notrelevant = false; + } + this.validate_(node, readonly, notrelevant); + readonly = XsltForms_browser.getBoolMeta(node, "readonly"); + notrelevant = XsltForms_browser.getBoolMeta(node, "notrelevant"); + var atts = node.attributes || []; + if (atts) { + var atts2 = []; + for (var i = 0, len = atts.length; i < len; i++) { + if (atts[i].nodeName.substr(0,10) !== "xsltforms_" && atts[i].nodeName.substr(0,5) !== "xmlns") { + atts2[atts2.length] = atts[i]; + } + } + for (var i2 = 0, len2 = atts2.length; i2 < len2; i2++) { + this.validation_(atts2[i2], readonly, notrelevant); + } + } + if (node.childNodes) { + for (var j = 0, len1 = node.childNodes.length; j < len1; j++) { + var child = node.childNodes[j]; + if (child.nodeType === Fleur.Node.ELEMENT_NODE) { + this.validation_(child, readonly, notrelevant); + } + } + } }; XsltForms_instance.prototype.validate_ = function(node, readonly, notrelevant) { - var bindids = XsltForms_browser.getMeta(node, "bind"); - var value = XsltForms_globals.xmlValue(node); - var schtyp = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string"); - if (bindids) { - var binds = bindids.split(" "); - var relevantfound = false; - var readonlyfound = false; - for (var i = 0, len = binds.length; i < len; i++) { - var bind = XsltForms_collection[binds[i]].xfElement; - var nodes = bind.nodes; - var i2 = 0; - for (var len2 = nodes.length; i2 < len2; i2++) { - if (nodes[i2] === node) { - break; - } - } - for (var j = 0, len3 = bind.depsNodes.length; j < len3; j++) { - XsltForms_browser.rmValueMeta(bind.depsNodes[j], "depfor", bind.depsId); - } - bind.depsNodes.length = 0; - var ctx = new XsltForms_exprContext(this.subform, node, i2, nodes, null, null, null, [], bind.depsId); - if (bind.required) { - this.setProperty_(node, "required", bind.required.evaluate(ctx, node)); - } - if (notrelevant || !relevantfound || bind.relevant) { - this.setProperty_(node, "notrelevant", notrelevant || !(bind.relevant? bind.relevant.evaluate(ctx, node) : true)); - relevantfound = relevantfound || bind.relevant; - } - if (readonly || !readonlyfound || bind.readonly) { - this.setProperty_(node, "readonly", readonly || (bind.readonly? bind.readonly.evaluate(ctx, node) : bind.calculate ? true : false)); - readonlyfound = readonlyfound || bind.readonly; - } - this.setProperty_(node, "invalid", - !XsltForms_browser.getBoolMeta(node, "notrelevant") && !(!(XsltForms_browser.getBoolMeta(node, "required") && (!value || value === "")) && - (XsltForms_browser.getNil(node) ? value === "" : !schtyp || schtyp.validate(value) && !XsltForms_browser.getBoolMeta(node, "unsafe")) && - (!bind.constraint || bind.constraint.evaluate(ctx, node)))); - var inst = this; - Object.entries(bind.meta).forEach(function(m) { - var valueb = String(m[1].evaluate(ctx, node)); - if (XsltForms_browser.getMeta(node, "meta-" + m[0]) !== valueb) { - XsltForms_browser.setMeta(node, "meta-" + m[0], valueb); - inst.model.addChange(node); - } - }); - XsltForms_browser.copyArray(ctx.depsNodes, bind.depsNodes); - } - } else { - this.setProperty_(node, "notrelevant", notrelevant); - this.setProperty_(node, "readonly", readonly); - this.setProperty_(node, "invalid", schtyp && (!schtyp.validate(value) || XsltForms_browser.getBoolMeta(node, "unsafe"))); - } + var bindids = XsltForms_browser.getMeta(node, "bind"); + var value = XsltForms_globals.xmlValue(node); + var schtyp = XsltForms_schema.getType(XsltForms_browser.getType(node) || "xsd_:string"); + if (bindids) { + var binds = bindids.split(" "); + var relevantfound = false; + var readonlyfound = false; + for (var i = 0, len = binds.length; i < len; i++) { + var bind = XsltForms_collection[binds[i]].xfElement; + var nodes = bind.nodes; + var i2 = 0; + for (var len2 = nodes.length; i2 < len2; i2++) { + if (nodes[i2] === node) { + break; + } + } + for (var j = 0, len3 = bind.depsNodes.length; j < len3; j++) { + XsltForms_browser.rmValueMeta(bind.depsNodes[j], "depfor", bind.depsId); + } + bind.depsNodes.length = 0; + var ctx = new XsltForms_exprContext(this.subform, node, i2, nodes, null, null, null, [], bind.depsId); + if (bind.required) { + this.setProperty_(node, "required", bind.required.evaluate(ctx, node)); + } + if (notrelevant || !relevantfound || bind.relevant) { + this.setProperty_(node, "notrelevant", notrelevant || !(bind.relevant? bind.relevant.evaluate(ctx, node) : true)); + relevantfound = relevantfound || bind.relevant; + } + if (readonly || !readonlyfound || bind.readonly) { + this.setProperty_(node, "readonly", readonly || (bind.readonly? bind.readonly.evaluate(ctx, node) : bind.calculate ? true : false)); + readonlyfound = readonlyfound || bind.readonly; + } + this.setProperty_(node, "invalid", + !XsltForms_browser.getBoolMeta(node, "notrelevant") && !(!(XsltForms_browser.getBoolMeta(node, "required") && (!value || value === "")) && + (XsltForms_browser.getNil(node) ? value === "" : !schtyp || schtyp.validate(value) && !XsltForms_browser.getBoolMeta(node, "unsafe")) && + (!bind.constraint || bind.constraint.evaluate(ctx, node)))); + var inst = this; + Object.entries(bind.meta).forEach(function(m) { + var valueb = String(m[1].evaluate(ctx, node)); + if (XsltForms_browser.getMeta(node, "meta-" + m[0]) !== valueb) { + XsltForms_browser.setMeta(node, "meta-" + m[0], valueb); + inst.model.addChange(node); + } + }); + XsltForms_browser.copyArray(ctx.depsNodes, bind.depsNodes); + } + } else { + this.setProperty_(node, "notrelevant", notrelevant); + this.setProperty_(node, "readonly", readonly); + this.setProperty_(node, "invalid", schtyp && (!schtyp.validate(value) || XsltForms_browser.getBoolMeta(node, "unsafe"))); + } }; XsltForms_instance.prototype.setProperty_ = function (node, property, value) { - if (XsltForms_browser.getBoolMeta(node, property) !== value) { - XsltForms_browser.setBoolMeta(node, property, value); - this.model.addChange(node); - } + if (XsltForms_browser.getBoolMeta(node, property) !== value) { + XsltForms_browser.setBoolMeta(node, property, value); + this.model.addChange(node); + } }; - + /** * * '''json2xml''' function : converts json to xml notation */ XsltForms_browser.json2xmlreg = new RegExp("^[A-Za-z_\xC0-\xD6\xD8-\xF6\xF8-\xFF][A-Za-z_\xC0-\xD6\xD8-\xF6\xF8-\xFF\-\.0-9\xB7]*$"); XsltForms_browser.json2xml = function(eltname, json, root, inarray) { - var fullname = ""; - if (eltname === "________" || !(json instanceof Array) && eltname !== "" && !XsltForms_browser.json2xmlreg.test(eltname)) { - fullname = " exml:fullname=\"" + XsltForms_browser.escape(eltname) + "\""; - eltname = "________"; - } - var ret = root ? "" : ""; - if (json instanceof Array) { - if (inarray) { - ret += ""; - } - if (json.length === 0) { - ret += "<" + (eltname === "" ? "exml:anonymous" : eltname) + fullname + " exsi:maxOccurs=\"unbounded\" xsi:nil=\"true\"/>"; - } else { - for (var i = 0, len = json.length; i < len; i++) { - ret += XsltForms_browser.json2xml(eltname === "" ? "exml:anonymous" : eltname, json[i], false, true); - } - } - if (inarray) { - ret += ""; - } - } else { - var xsdtype = ""; - switch(typeof(json)) { - case "string": - xsdtype = " xsi:type=\"xsd:string\""; - break; - case "number": - xsdtype = " xsi:type=\"xsd:double\""; - break; - case "boolean": - xsdtype = " xsi:type=\"xsd:boolean\""; - break; - case "object": - if (json instanceof Date) { - xsdtype = " xsi:type=\"xsd:dateTime\""; - } - break; - } - if (eltname === "") { - if (root && xsdtype !== "") { - ret = ret.substr(0, ret.length - 1) + xsdtype + ">"; - } - } else { - ret += "<"+eltname+fullname+(inarray?" exsi:maxOccurs=\"unbounded\"":"")+xsdtype+">"; - } - if (typeof(json) === "object" && !(json instanceof Date)) { - for (var m in json) { - if (json.hasOwnProperty(m)) { - ret += XsltForms_browser.json2xml(m, json[m], false, false); - } - } - } else { - if (json instanceof Date) { - ret += json.getFullYear() + "-"; - ret += (json.getMonth() < 9 ? "0" : "") + (json.getMonth()+1) + "-"; - ret += (json.getDate() < 10 ? "0" : "") + json.getDate() + "T"; - ret += (json.getHours() < 10 ? "0" : "") + json.getHours() + ":"; - ret += (json.getMinutes() < 10 ? "0" : "") + json.getMinutes() + ":"; - ret += (json.getSeconds() < 10 ? "0" : "") + json.getSeconds() + "Z"; - } else { - ret += XsltForms_browser.escape(json); - } - } - ret += eltname === "" ? "" : ""; - } - ret += root ? "" : ""; - return ret; + var fullname = ""; + if (eltname === "________" || !(json instanceof Array) && eltname !== "" && !XsltForms_browser.json2xmlreg.test(eltname)) { + fullname = " exml:fullname=\"" + XsltForms_browser.escape(eltname) + "\""; + eltname = "________"; + } + var ret = root ? "" : ""; + if (json instanceof Array) { + if (inarray) { + ret += ""; + } + if (json.length === 0) { + ret += "<" + (eltname === "" ? "exml:anonymous" : eltname) + fullname + " exsi:maxOccurs=\"unbounded\" xsi:nil=\"true\"/>"; + } else { + for (var i = 0, len = json.length; i < len; i++) { + ret += XsltForms_browser.json2xml(eltname === "" ? "exml:anonymous" : eltname, json[i], false, true); + } + } + if (inarray) { + ret += ""; + } + } else { + var xsdtype = ""; + switch(typeof(json)) { + case "string": + xsdtype = " xsi:type=\"xsd:string\""; + break; + case "number": + xsdtype = " xsi:type=\"xsd:double\""; + break; + case "boolean": + xsdtype = " xsi:type=\"xsd:boolean\""; + break; + case "object": + if (json instanceof Date) { + xsdtype = " xsi:type=\"xsd:dateTime\""; + } + break; + } + if (eltname === "") { + if (root && xsdtype !== "") { + ret = ret.substr(0, ret.length - 1) + xsdtype + ">"; + } + } else { + ret += "<"+eltname+fullname+(inarray?" exsi:maxOccurs=\"unbounded\"":"")+xsdtype+">"; + } + if (typeof(json) === "object" && !(json instanceof Date)) { + for (var m in json) { + if (json.hasOwnProperty(m)) { + ret += XsltForms_browser.json2xml(m, json[m], false, false); + } + } + } else { + if (json instanceof Date) { + ret += json.getFullYear() + "-"; + ret += (json.getMonth() < 9 ? "0" : "") + (json.getMonth()+1) + "-"; + ret += (json.getDate() < 10 ? "0" : "") + json.getDate() + "T"; + ret += (json.getHours() < 10 ? "0" : "") + json.getHours() + ":"; + ret += (json.getMinutes() < 10 ? "0" : "") + json.getMinutes() + ":"; + ret += (json.getSeconds() < 10 ? "0" : "") + json.getSeconds() + "Z"; + } else { + ret += XsltForms_browser.escape(json); + } + } + ret += eltname === "" ? "" : ""; + } + ret += root ? "" : ""; + return ret; }; - + /** * * '''xml2json''' function : converts xml to json notation */ XsltForms_browser.node2json = function(node, comma) { - var xsdtype, inarray, att, lname, s = "", i, l, lc, t; - if (node.nodeType !== Fleur.Node.ELEMENT_NODE) { - return ""; - } - lname = node.localName ? node.localName : node.baseName; - if (node.getAttributeNS) { - xsdtype = node.getAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "type"); - inarray = node.getAttributeNS("http://www.agencexml.com/exi", "maxOccurs") === "unbounded"; - if (lname === "________") { - lname = node.getAttributeNS("http://www.agencexml.com/exml", "fullname"); - } - } else { - att = node.selectSingleNode("@*[local-name()='type' and namespace-uri()='http://www.w3.org/2001/XMLSchema-instance']"); - xsdtype = att ? att.value : ""; - att = node.selectSingleNode("@*[local-name()='maxOccurs' and namespace-uri()='http://www.agencexml.com/exi']"); - inarray = att ? att.value === "unbounded" : false; - if (lname === "________") { - att = node.selectSingleNode("@*[local-name()='fullname' and namespace-uri()='http://www.agencexml.com/exml']"); - lname = att ? att.value : ""; - } - } - s = ""; - if (lname !== "anonymous" || node.namespaceURI !== "http://www.agencexml.com/exml") { - s += lname + ":"; - } - if (inarray) { - s = "["; - lc = 0; - for (i = 0, l = node.childNodes.length; i < l; i++) { - if (node.childNodes[i].nodeType === Fleur.Node.ELEMENT_NODE) { - lc = i; - } - } - for (i = 0; i <= lc; i++) { - s += XsltForms_browser.node2json(node.childNodes[i], (i === lc ? "" : ",")); - } - return s + "]" + comma; - } - t = node.text || node.textContent; - switch (xsdtype) { - case "xsd:string": - return s + '"' + XsltForms_browser.escapeJS(t) + '"' + comma; - case "xsd:double": - case "xsd:boolean": - return s + t + comma; - case "xsd:dateTime": - return s + 'new Date("' + t + '")' + comma; - default: - s += "{"; - lc = 0; - for (i = 0, l = node.childNodes.length; i < l; i++) { - if (node.childNodes[i].nodeType === Fleur.Node.ELEMENT_NODE) { - lc = i; - } - } - for (i = 0; i <= lc; i++) { - s += XsltForms_browser.node2json(node.childNodes[i], (i === lc ? "" : ",")); - } - return s + "}" + comma; - } + var xsdtype, inarray, att, lname, s = "", i, l, lc, t; + if (node.nodeType !== Fleur.Node.ELEMENT_NODE) { + return ""; + } + lname = node.localName ? node.localName : node.baseName; + if (node.getAttributeNS) { + xsdtype = node.getAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "type"); + inarray = node.getAttributeNS("http://www.agencexml.com/exi", "maxOccurs") === "unbounded"; + if (lname === "________") { + lname = node.getAttributeNS("http://www.agencexml.com/exml", "fullname"); + } + } else { + att = node.selectSingleNode("@*[local-name()='type' and namespace-uri()='http://www.w3.org/2001/XMLSchema-instance']"); + xsdtype = att ? att.value : ""; + att = node.selectSingleNode("@*[local-name()='maxOccurs' and namespace-uri()='http://www.agencexml.com/exi']"); + inarray = att ? att.value === "unbounded" : false; + if (lname === "________") { + att = node.selectSingleNode("@*[local-name()='fullname' and namespace-uri()='http://www.agencexml.com/exml']"); + lname = att ? att.value : ""; + } + } + s = ""; + if (lname !== "anonymous" || node.namespaceURI !== "http://www.agencexml.com/exml") { + s += lname + ":"; + } + if (inarray) { + s = "["; + lc = 0; + for (i = 0, l = node.childNodes.length; i < l; i++) { + if (node.childNodes[i].nodeType === Fleur.Node.ELEMENT_NODE) { + lc = i; + } + } + for (i = 0; i <= lc; i++) { + s += XsltForms_browser.node2json(node.childNodes[i], (i === lc ? "" : ",")); + } + return s + "]" + comma; + } + t = node.text || node.textContent; + switch (xsdtype) { + case "xsd:string": + return s + '"' + XsltForms_browser.escapeJS(t) + '"' + comma; + case "xsd:double": + case "xsd:boolean": + return s + t + comma; + case "xsd:dateTime": + return s + 'new Date("' + t + '")' + comma; + default: + s += "{"; + lc = 0; + for (i = 0, l = node.childNodes.length; i < l; i++) { + if (node.childNodes[i].nodeType === Fleur.Node.ELEMENT_NODE) { + lc = i; + } + } + for (i = 0; i <= lc; i++) { + s += XsltForms_browser.node2json(node.childNodes[i], (i === lc ? "" : ",")); + } + return s + "}" + comma; + } }; XsltForms_browser.xml2json = function(s) { - var d = XsltForms_browser.createXMLDocument(s); - return XsltForms_browser.node2json(d.documentElement, ""); + var d = XsltForms_browser.createXMLDocument(s); + return XsltForms_browser.node2json(d.documentElement, ""); }; - + /** * * '''jsoninst''' function : replaces instance data from json content */ var jsoninst = function(json) { - XsltForms_browser.jsoninstobj.submission.pending = false; - XsltForms_browser.dialog.hide("xsltforms-status-panel", false); - XsltForms_browser.jsoninstobj.instance.setDoc(XsltForms_browser.json2xml("", json, true, false)); - XsltForms_globals.addChange(XsltForms_browser.jsoninstobj.instance.model); - XsltForms_xmlevents.dispatch(XsltForms_browser.jsoninstobj.instance.model, "xforms-rebuild"); - XsltForms_globals.refresh(); - document.body.removeChild(document.getElementById("jsoninst")); + XsltForms_browser.jsoninstobj.submission.pending = false; + XsltForms_browser.dialog.hide("xsltforms-status-panel", false); + XsltForms_browser.jsoninstobj.instance.setDoc(XsltForms_browser.json2xml("", json, true, false)); + XsltForms_globals.addChange(XsltForms_browser.jsoninstobj.instance.model); + XsltForms_xmlevents.dispatch(XsltForms_browser.jsoninstobj.instance.model, "xforms-rebuild"); + XsltForms_globals.refresh(); + document.body.removeChild(document.getElementById("jsoninst")); }; - + /** * * '''vcard2xcard''' function : converts vcard to xcard notation */ XsltForms_browser.vcard2xcard_data = { - state: 0, - version: "4.0", - reg_date: /^(\d{8}|\d{4}-\d\d|--\d\d(\d\d)?|---\d\d)$/, - reg_time: /^(\d\d(\d\d(\d\d)?)?|-\d\d(\d\d?)|--\d\d)(Z|[+\-]\d\d(\d\d)?)?$/, - reg_date_time: /^(\d{8}|--\d{4}|---\d\d)T\d\d(\d\d(\d\d)?)?(Z|[+\-]\d\d(\d\d)?)?$/, - reg_uri: /^(([^:\/?#]+):)?(\/\/([^\/\?#]*))?([^\?#]*)(\?([^#]*))?(#([^\:#\[\]\@\!\$\&\\'\(\)\*\+\,\;\=]*))?$/, - reg_utc_offset: /^[+\-]\d\d(\d\d)?$/ + state: 0, + version: "4.0", + reg_date: /^(\d{8}|\d{4}-\d\d|--\d\d(\d\d)?|---\d\d)$/, + reg_time: /^(\d\d(\d\d(\d\d)?)?|-\d\d(\d\d?)|--\d\d)(Z|[+\-]\d\d(\d\d)?)?$/, + reg_date_time: /^(\d{8}|--\d{4}|---\d\d)T\d\d(\d\d(\d\d)?)?(Z|[+\-]\d\d(\d\d)?)?$/, + reg_uri: /^(([^:\/?#]+):)?(\/\/([^\/\?#]*))?([^\?#]*)(\?([^#]*))?(#([^\:#\[\]\@\!\$\&\\'\(\)\*\+\,\;\=]*))?$/, + reg_utc_offset: /^[+\-]\d\d(\d\d)?$/ }; XsltForms_browser.vcard2xcard_escape = function(s) { - return s.replace(/&/gm,"&").replace(//gm,">").replace(/\\;/gm,";"); + return s.replace(/&/gm,"&").replace(//gm,">").replace(/\\;/gm,";"); }; XsltForms_browser.vcard2xcard_param = { - "PREF": {fparam: function(value) {return "" + value + "";}}, - "TYPE": {fparam: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}} + "PREF": {fparam: function(value) {return "" + value + "";}}, + "TYPE": {fparam: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}} }; XsltForms_browser.vcard2xcard_prop = { - "BEGIN": {state: 0, fvalue: function(value) {XsltForms_browser.vcard2xcard_data.state = 1; return value.toUpperCase() === "VCARD" ? "" : "<'Invalid directive: BEGIN:" + value + "'>";}}, - "END": {state: 1, fvalue: function(value) {XsltForms_browser.vcard2xcard_data.state = 0; return value.toUpperCase() === "VCARD" ? "" : "<'Invalid directive: END:" + value + "'>";}}, - "SOURCE": {state: 1, tag: "source", fvalue: function(value) {return "" + value + "";}}, - "KIND": {state: 1, tag: "kind", fvalue: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, - "XML": {state: 1, fvalue: function(value) {return value;}}, - "FN": {state: 1, tag: "fn", fvalue: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, - "N": {state: 1, tag: "n", fvalue: function(value) {var n = value.split(";"); return "" + XsltForms_browser.vcard2xcard_escape(n[0]) + "" + XsltForms_browser.vcard2xcard_escape(n[1]) + "" + XsltForms_browser.vcard2xcard_escape(n[2]) + "" + XsltForms_browser.vcard2xcard_escape(n[3]) + "" + XsltForms_browser.vcard2xcard_escape(n[4]) + "";}}, - "NICKNAME": {state: 1, tag: "nickname", fvalue: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, - "PHOTO": {state: 1, tag: "photo", fvalue: function(value) {return "" + value + "";}}, - "BDAY": {state: 1, tag: "bday", fvalue: function(value) {return (XsltForms_browser.vcard2xcard_data.reg_date_time.test(value) ? "" + value + "" : XsltForms_browser.vcard2xcard_data.reg_date.test(value) ? "" + value + "" : XsltForms_browser.vcard2xcard_data.reg_time.test(value) ? "" : "" + XsltForms_browser.vcard2xcard_escape(value) + "");}}, - "ANNIVERSARY": {state: 1, tag: "anniversary", fvalue: function(value) {return (XsltForms_browser.vcard2xcard_data.reg_date_time.test(value) ? "" + value + "" : XsltForms_browser.vcard2xcard_data.reg_date.test(value) ? "" + value + "" : XsltForms_browser.vcard2xcard_data.reg_time.test(value) ? "" : "" + XsltForms_browser.vcard2xcard_escape(value) + "");}}, - "GENDER": {state: 1, tag: "gender", fvalue: function(value) {var gender = value.split(";"); return "" + gender[0] + "" + (value.indexOf(";") !== -1 ? "" + XsltForms_browser.vcard2xcard_escape(gender[1]) + "": "");}}, - "ADR": {state: 1, tag: "adr", fvalue: function(value) {var adr = value.split(";"); return "" + XsltForms_browser.vcard2xcard_escape(adr[0]) + "" + XsltForms_browser.vcard2xcard_escape(adr[1]) + "" + XsltForms_browser.vcard2xcard_escape(adr[2]) + "" + XsltForms_browser.vcard2xcard_escape(adr[3]) + "" + XsltForms_browser.vcard2xcard_escape(adr[4]) + "" + XsltForms_browser.vcard2xcard_escape(adr[5]) + "" + XsltForms_browser.vcard2xcard_escape(adr[6]) + "";}}, - "TEL": {state: 1, tag: "tel", fvalue: function(value) {return (XsltForms_browser.vcard2xcard_data.reg_uri.test(value) ? "" + value + "" : "" + XsltForms_browser.vcard2xcard_escape(value) + "");}}, - "EMAIL": {state: 1, tag: "email", fvalue: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, - "IMPP": {state: 1, tag: "impp", fvalue: function(value) {return "" + value + "";}}, - "LANG": {state: 1, tag: "lang", fvalue: function(value) {return "" + value + "";}}, - "TZ": {state: 1, tag: "tz", fvalue: function(value) {return XsltForms_browser.vcard2xcard_data.reg_uri.test(value) ? "" + value + "" : XsltForms_browser.vcard2xcard_data.reg_utc_offset.test(value) ? "" + value + "" : "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, - "GEO": {state: 1, tag: "geo", fvalue: function(value) {return "" + value + "";}}, - "TITLE": {state: 1, tag: "title", fvalue: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, - "ROLE": {state: 1, tag: "role", fvalue: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, - "LOGO": {state: 1, tag: "logo", fvalue: function(value) {return "" + value + "";}}, - "ORG": {state: 1, tag: "org", fvalue: function(value) {var orgs = value.split(";"); var s = ""; for (var i = 0, len = orgs.length; i < len; i++) { s += "" + XsltForms_browser.vcard2xcard_escape(orgs[i]) + "";} return s;}}, - "MEMBER": {state: 1, tag: "member", fvalue: function(value) {return "" + value + "";}}, - "RELATED": {state: 1, tag: "related", fvalue: function(value) {return XsltForms_browser.vcard2xcard_data.reg_uri.test(value) ? "" + value + "" : "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, - "CATEGORIES": {state: 1, tag: "categories", fvalue: function(value) {var cats = value.split(";"); var s = ""; for (var i = 0, len = cats.length; i < len; i++) { s += "" + XsltForms_browser.vcard2xcard_escape(cats[i]) + "";} return s;}}, - "NOTE": {state: 1, tag: "note", fvalue: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, - "X-LOTUS-BRIEFCASE": {state: 1, tag: "x-lotus-briefcase", fvalue: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, - "PRODID": {state: 1, tag: "prodid", fvalue: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, - "REV": {state: 1, tag: "rev", fvalue: function(value) {return "" + value + "";}}, - "SOUND": {state: 1, tag: "sound", fvalue: function(value) {return "" + value + "";}}, - "UID": {state: 1, tag: "uid", fvalue: function(value) {return "" + value + "";}}, - "CLIENTPIDMAP":{state: 1, tag: "clientpidmap", fvalue: function(value) {var cmap = value.split(";"); return "" + cmap[0] + "" + cmap[1] + "";}}, - "URL": {state: 1, tag: "url", fvalue: function(value) {return "" + value + "";}}, - "VERSION": {state: 1, fvalue: function(value) {XsltForms_browser.vcard2xcard_data.version = value; return "";}}, - "KEY": {state: 1, tag: "key", fvalue: function(value) {return XsltForms_browser.vcard2xcard_data.reg_uri.test(value) ? "" + value + "" : "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, - "FBURL": {state: 1, tag: "fburl", fvalue: function(value) {return "" + value + "";}}, - "CALADRURI": {state: 1, tag: "caladruri", fvalue: function(value) {return "" + value + "";}}, - "CALURI": {state: 1, tag: "caluri", fvalue: function(value) {return "" + value + "";}} + "BEGIN": {state: 0, fvalue: function(value) {XsltForms_browser.vcard2xcard_data.state = 1; return value.toUpperCase() === "VCARD" ? "" : "<'Invalid directive: BEGIN:" + value + "'>";}}, + "END": {state: 1, fvalue: function(value) {XsltForms_browser.vcard2xcard_data.state = 0; return value.toUpperCase() === "VCARD" ? "" : "<'Invalid directive: END:" + value + "'>";}}, + "SOURCE": {state: 1, tag: "source", fvalue: function(value) {return "" + value + "";}}, + "KIND": {state: 1, tag: "kind", fvalue: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, + "XML": {state: 1, fvalue: function(value) {return value;}}, + "FN": {state: 1, tag: "fn", fvalue: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, + "N": {state: 1, tag: "n", fvalue: function(value) {var n = value.split(";"); return "" + XsltForms_browser.vcard2xcard_escape(n[0]) + "" + XsltForms_browser.vcard2xcard_escape(n[1]) + "" + XsltForms_browser.vcard2xcard_escape(n[2]) + "" + XsltForms_browser.vcard2xcard_escape(n[3]) + "" + XsltForms_browser.vcard2xcard_escape(n[4]) + "";}}, + "NICKNAME": {state: 1, tag: "nickname", fvalue: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, + "PHOTO": {state: 1, tag: "photo", fvalue: function(value) {return "" + value + "";}}, + "BDAY": {state: 1, tag: "bday", fvalue: function(value) {return (XsltForms_browser.vcard2xcard_data.reg_date_time.test(value) ? "" + value + "" : XsltForms_browser.vcard2xcard_data.reg_date.test(value) ? "" + value + "" : XsltForms_browser.vcard2xcard_data.reg_time.test(value) ? "" : "" + XsltForms_browser.vcard2xcard_escape(value) + "");}}, + "ANNIVERSARY": {state: 1, tag: "anniversary", fvalue: function(value) {return (XsltForms_browser.vcard2xcard_data.reg_date_time.test(value) ? "" + value + "" : XsltForms_browser.vcard2xcard_data.reg_date.test(value) ? "" + value + "" : XsltForms_browser.vcard2xcard_data.reg_time.test(value) ? "" : "" + XsltForms_browser.vcard2xcard_escape(value) + "");}}, + "GENDER": {state: 1, tag: "gender", fvalue: function(value) {var gender = value.split(";"); return "" + gender[0] + "" + (value.indexOf(";") !== -1 ? "" + XsltForms_browser.vcard2xcard_escape(gender[1]) + "": "");}}, + "ADR": {state: 1, tag: "adr", fvalue: function(value) {var adr = value.split(";"); return "" + XsltForms_browser.vcard2xcard_escape(adr[0]) + "" + XsltForms_browser.vcard2xcard_escape(adr[1]) + "" + XsltForms_browser.vcard2xcard_escape(adr[2]) + "" + XsltForms_browser.vcard2xcard_escape(adr[3]) + "" + XsltForms_browser.vcard2xcard_escape(adr[4]) + "" + XsltForms_browser.vcard2xcard_escape(adr[5]) + "" + XsltForms_browser.vcard2xcard_escape(adr[6]) + "";}}, + "TEL": {state: 1, tag: "tel", fvalue: function(value) {return (XsltForms_browser.vcard2xcard_data.reg_uri.test(value) ? "" + value + "" : "" + XsltForms_browser.vcard2xcard_escape(value) + "");}}, + "EMAIL": {state: 1, tag: "email", fvalue: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, + "IMPP": {state: 1, tag: "impp", fvalue: function(value) {return "" + value + "";}}, + "LANG": {state: 1, tag: "lang", fvalue: function(value) {return "" + value + "";}}, + "TZ": {state: 1, tag: "tz", fvalue: function(value) {return XsltForms_browser.vcard2xcard_data.reg_uri.test(value) ? "" + value + "" : XsltForms_browser.vcard2xcard_data.reg_utc_offset.test(value) ? "" + value + "" : "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, + "GEO": {state: 1, tag: "geo", fvalue: function(value) {return "" + value + "";}}, + "TITLE": {state: 1, tag: "title", fvalue: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, + "ROLE": {state: 1, tag: "role", fvalue: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, + "LOGO": {state: 1, tag: "logo", fvalue: function(value) {return "" + value + "";}}, + "ORG": {state: 1, tag: "org", fvalue: function(value) {var orgs = value.split(";"); var s = ""; for (var i = 0, len = orgs.length; i < len; i++) { s += "" + XsltForms_browser.vcard2xcard_escape(orgs[i]) + "";} return s;}}, + "MEMBER": {state: 1, tag: "member", fvalue: function(value) {return "" + value + "";}}, + "RELATED": {state: 1, tag: "related", fvalue: function(value) {return XsltForms_browser.vcard2xcard_data.reg_uri.test(value) ? "" + value + "" : "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, + "CATEGORIES": {state: 1, tag: "categories", fvalue: function(value) {var cats = value.split(";"); var s = ""; for (var i = 0, len = cats.length; i < len; i++) { s += "" + XsltForms_browser.vcard2xcard_escape(cats[i]) + "";} return s;}}, + "NOTE": {state: 1, tag: "note", fvalue: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, + "X-LOTUS-BRIEFCASE": {state: 1, tag: "x-lotus-briefcase", fvalue: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, + "PRODID": {state: 1, tag: "prodid", fvalue: function(value) {return "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, + "REV": {state: 1, tag: "rev", fvalue: function(value) {return "" + value + "";}}, + "SOUND": {state: 1, tag: "sound", fvalue: function(value) {return "" + value + "";}}, + "UID": {state: 1, tag: "uid", fvalue: function(value) {return "" + value + "";}}, + "CLIENTPIDMAP":{state: 1, tag: "clientpidmap", fvalue: function(value) {var cmap = value.split(";"); return "" + cmap[0] + "" + cmap[1] + "";}}, + "URL": {state: 1, tag: "url", fvalue: function(value) {return "" + value + "";}}, + "VERSION": {state: 1, fvalue: function(value) {XsltForms_browser.vcard2xcard_data.version = value; return "";}}, + "KEY": {state: 1, tag: "key", fvalue: function(value) {return XsltForms_browser.vcard2xcard_data.reg_uri.test(value) ? "" + value + "" : "" + XsltForms_browser.vcard2xcard_escape(value) + "";}}, + "FBURL": {state: 1, tag: "fburl", fvalue: function(value) {return "" + value + "";}}, + "CALADRURI": {state: 1, tag: "caladruri", fvalue: function(value) {return "" + value + "";}}, + "CALURI": {state: 1, tag: "caluri", fvalue: function(value) {return "" + value + "";}} }; XsltForms_browser.vcard2xcard = function(v) { - var s = ''; - var vcards = v.replace(/(\r\n|\n|\r) /gm,"").replace(/^\s+/,"").replace(/\s+$/,"").split("\n"); - for (var i = 0, len = vcards.length; i < len; i++) { - var sep = vcards[i].indexOf(":"); - var before = vcards[i].substring(0, sep); - var after = vcards[i].substring(sep + 1); - var propnames = before.split(";"); - var p = XsltForms_browser.vcard2xcard_prop[propnames[0]]; - if (p && p.state === XsltForms_browser.vcard2xcard_data.state) { - var val = after.replace(/\\n/gm,"\n").replace(/\\,/gm,","); - if (p.tag) { - s += "<" + p.tag + ">"; - } - if (propnames.length > 1) { - s += ""; - propnames.shift(); - for (var j = 0, len2 = propnames.length; j < len2;) { - var par = propnames[j].split("="); - var parname = par[0]; - var parobj = XsltForms_browser.vcard2xcard_param[parname]; - if (parobj) { - s += "<" + parname.toLowerCase() + ">"; - while (par[0] === parname) { - s += parobj.fparam(par[1]); - j++; - if (j < len2) { - par = propnames[j].split("="); - } else { - break; - } - } - s += ""; - } else { - j++; - } - } - s += ""; - } - s += p.fvalue(val); - if (p.tag) { - s += ""; - } - } - } - return s + ""; + var s = ''; + var vcards = v.replace(/(\r\n|\n|\r) /gm,"").replace(/^\s+/,"").replace(/\s+$/,"").split("\n"); + for (var i = 0, len = vcards.length; i < len; i++) { + var sep = vcards[i].indexOf(":"); + var before = vcards[i].substring(0, sep); + var after = vcards[i].substring(sep + 1); + var propnames = before.split(";"); + var p = XsltForms_browser.vcard2xcard_prop[propnames[0]]; + if (p && p.state === XsltForms_browser.vcard2xcard_data.state) { + var val = after.replace(/\\n/gm,"\n").replace(/\\,/gm,","); + if (p.tag) { + s += "<" + p.tag + ">"; + } + if (propnames.length > 1) { + s += ""; + propnames.shift(); + for (var j = 0, len2 = propnames.length; j < len2;) { + var par = propnames[j].split("="); + var parname = par[0]; + var parobj = XsltForms_browser.vcard2xcard_param[parname]; + if (parobj) { + s += "<" + parname.toLowerCase() + ">"; + while (par[0] === parname) { + s += parobj.fparam(par[1]); + j++; + if (j < len2) { + par = propnames[j].split("="); + } else { + break; + } + } + s += ""; + } else { + j++; + } + } + s += ""; + } + s += p.fvalue(val); + if (p.tag) { + s += ""; + } + } + } + return s + ""; }; XsltForms_browser.xml2csv = function(s, sep) { - var d = XsltForms_browser.createXMLDocument(s); - var n0 = d.documentElement.firstChild; - while (n0 && n0.nodeType !== Fleur.Node.ELEMENT_NODE) { - n0 = n0.nextSibling; - } - var h = n0.cloneNode(true); - d.documentElement.insertBefore(h, n0); - var n = h; - var r = ""; - sep = sep || ","; - var seps = sep.split(" "); - var fsep = seps[0]; - var decsep = seps[1]; - while (n) { - if (n.nodeType === Fleur.Node.ELEMENT_NODE) { - var m = n.firstChild; - var l = ""; - while (m) { - if (m.nodeType === Fleur.Node.ELEMENT_NODE) { - var v = n === h ? m.getAttribute("fullname") || m.localName : m.text !== undefined ? m.text : m.textContent; - if (v.indexOf("\n") !== -1 || v.indexOf(fsep) !== -1) { - v = '"' + v.replace(/"/gm, '""') + '"'; - } else if (decsep && v.match(/^[\-+]?([0-9]+(\.[0-9]*)?|\.[0-9]+)$/)) { - v = v.replace(/\./, decsep); - } - l += fsep + v; - } - m = m.nextSibling; - } - r += l.substr(1) + "\n"; - } - n = n.nextSibling; - } - return r; + var d = XsltForms_browser.createXMLDocument(s); + var n0 = d.documentElement.firstChild; + while (n0 && n0.nodeType !== Fleur.Node.ELEMENT_NODE) { + n0 = n0.nextSibling; + } + var h = n0.cloneNode(true); + d.documentElement.insertBefore(h, n0); + var n = h; + var r = ""; + sep = sep || ","; + var seps = sep.split(" "); + var fsep = seps[0]; + var decsep = seps[1]; + while (n) { + if (n.nodeType === Fleur.Node.ELEMENT_NODE) { + var m = n.firstChild; + var l = ""; + while (m) { + if (m.nodeType === Fleur.Node.ELEMENT_NODE) { + var v = n === h ? m.getAttribute("fullname") || m.localName : m.text !== undefined ? m.text : m.textContent; + if (v.indexOf("\n") !== -1 || v.indexOf(fsep) !== -1) { + v = '"' + v.replace(/"/gm, '""') + '"'; + } else if (decsep && v.match(/^[\-+]?([0-9]+(\.[0-9]*)?|\.[0-9]+)$/)) { + v = v.replace(/\./, decsep); + } + l += fsep + v; + } + m = m.nextSibling; + } + r += l.substr(1) + "\n"; + } + n = n.nextSibling; + } + return r; }; XsltForms_browser.csv2xml = function(s, sep, head) { - var r = ""; - s = s.replace(/\r\n/g,"\n").replace(/\r/g,"\n"); - if (s.substr(s.length - 1, 1) !== "\n") { - s += "\n"; - } - var headers = []; - var first = head; - var col = 0; - var rowcat = ""; - var row = ""; - for (var i = 0, l = s.length; i < l; ) { - var v = ""; - if (s.substr(i, 1) === '"') { - i++; - do { - if (s.substr(i, 1) !== '"') { - v += s.substr(i, 1); - i++; - } else { - if (s.substr(i, 2) === '""') { - v += '"'; - i += 2; - } else { - i++; - break; - } - } - } while (i < l); - } else { - while (s.substr(i, sep.length) !== sep && s.substr(i, 1) !== "\n") { - v += s.substr(i, 1); - i++; - } - } - if (first) { - headers.push(v); - } else { - rowcat += v; - row += "<" + (head ? headers[col] : "exml:anonymous") + ">" + XsltForms_browser.escape(v) + ""; - } - if (s.substr(i, 1) === "\n") { - if (!first && rowcat !== "") { - r += "" + row + ""; - } - first = false; - col = 0; - row = ""; - rowcat = ""; - } else { - col++; - } - i++; - } - return r + ""; + var r = ""; + s = s.replace(/\r\n/g,"\n").replace(/\r/g,"\n"); + if (s.substr(s.length - 1, 1) !== "\n") { + s += "\n"; + } + var headers = []; + var first = head; + var col = 0; + var rowcat = ""; + var row = ""; + for (var i = 0, l = s.length; i < l; ) { + var v = ""; + if (s.substr(i, 1) === '"') { + i++; + do { + if (s.substr(i, 1) !== '"') { + v += s.substr(i, 1); + i++; + } else { + if (s.substr(i, 2) === '""') { + v += '"'; + i += 2; + } else { + i++; + break; + } + } + } while (i < l); + } else { + while (s.substr(i, sep.length) !== sep && s.substr(i, 1) !== "\n") { + v += s.substr(i, 1); + i++; + } + } + if (first) { + headers.push(v); + } else { + rowcat += v; + row += "<" + (head ? headers[col] : "exml:anonymous") + ">" + XsltForms_browser.escape(v) + ""; + } + if (s.substr(i, 1) === "\n") { + if (!first && rowcat !== "") { + r += "" + row + ""; + } + first = false; + col = 0; + row = ""; + rowcat = ""; + } else { + col++; + } + i++; + } + return r + ""; }; XsltForms_browser.xsltsharedsrc = ''; -XsltForms_browser.xsltsharedsrc += ' '; -XsltForms_browser.xsltsharedsrc += ' '; -XsltForms_browser.xsltsharedsrc += ' '; -XsltForms_browser.xsltsharedsrc += ' '; +XsltForms_browser.xsltsharedsrc += ' '; +XsltForms_browser.xsltsharedsrc += ' '; +XsltForms_browser.xsltsharedsrc += ' '; +XsltForms_browser.xsltsharedsrc += ' '; XsltForms_browser.xsltsharedsrc += ''; XsltForms_browser.xsltinlinesrc = ''; -XsltForms_browser.xsltinlinesrc += ' '; -XsltForms_browser.xsltinlinesrc += ' '; -XsltForms_browser.xsltinlinesrc += ' '; -XsltForms_browser.xsltinlinesrc += ' '; -XsltForms_browser.xsltinlinesrc += ' inlineStr'; -XsltForms_browser.xsltinlinesrc += ' '; -XsltForms_browser.xsltinlinesrc += ' '; -XsltForms_browser.xsltinlinesrc += ' '; -XsltForms_browser.xsltinlinesrc += ' '; -XsltForms_browser.xsltinlinesrc += ' '; -XsltForms_browser.xsltinlinesrc += ' '; -XsltForms_browser.xsltinlinesrc += ' '; -XsltForms_browser.xsltinlinesrc += ' '; -XsltForms_browser.xsltinlinesrc += ' '; -XsltForms_browser.xsltinlinesrc += ' '; -XsltForms_browser.xsltinlinesrc += ' '; +XsltForms_browser.xsltinlinesrc += ' '; +XsltForms_browser.xsltinlinesrc += ' '; +XsltForms_browser.xsltinlinesrc += ' '; +XsltForms_browser.xsltinlinesrc += ' '; +XsltForms_browser.xsltinlinesrc += ' inlineStr'; +XsltForms_browser.xsltinlinesrc += ' '; +XsltForms_browser.xsltinlinesrc += ' '; +XsltForms_browser.xsltinlinesrc += ' '; +XsltForms_browser.xsltinlinesrc += ' '; +XsltForms_browser.xsltinlinesrc += ' '; +XsltForms_browser.xsltinlinesrc += ' '; +XsltForms_browser.xsltinlinesrc += ' '; +XsltForms_browser.xsltinlinesrc += ' '; +XsltForms_browser.xsltinlinesrc += ' '; +XsltForms_browser.xsltinlinesrc += ' '; +XsltForms_browser.xsltinlinesrc += ' '; XsltForms_browser.xsltinlinesrc += ''; XsltForms_browser.zip2xml = function(z, mediatype, instid, modid) { - var arch = {}; - var f; - var r = ""; - var offset = z.lastIndexOf("PK\x05\x06")+16; - var r2 = function(z, offset) { - return ((z.charCodeAt(offset+1) & 0xFF)<< 8) | z.charCodeAt(offset) & 0xFF; - }; - var r4 = function(z, offset) { - return ((((((z.charCodeAt(offset+3) & 0xFF)<< 8) | z.charCodeAt(offset+2) & 0xFF)<< 8) | z.charCodeAt(offset+1) & 0xFF)<< 8) | z.charCodeAt(offset) & 0xFF; - }; - offset = r4(z, offset); - while (z.charCodeAt(offset) === 80 && z.charCodeAt(offset+1) === 75 && z.charCodeAt(offset+2) === 1 && z.charCodeAt(offset+3) === 2) { - f = {}; - offset += 4; - f.versionMadeBy = r2(z, offset); - offset += 2; - f.versionNeeded = r2(z, offset); - offset += 2; - f.bitFlag = r2(z, offset); - offset += 2; - f.compressionMethod = r2(z, offset); - offset += 2; - f.date = r4(z, offset); - offset += 4; - f.crc32 = r4(z, offset); - offset += 4; - f.compressedSize = r4(z, offset); - offset += 4; - f.uncompressedSize = r4(z, offset); - offset += 4; - f.fileNameLength = r2(z, offset); - offset += 2; - f.extraFieldsLength = r2(z, offset); - offset += 2; - f.fileCommentLength = r2(z, offset); - offset += 2; - f.diskNumber = r2(z, offset); - offset += 2; - f.internalFileAttributes = r2(z, offset); - offset += 2; - f.externalFileAttributes = r4(z, offset); - offset += 4; - f.localHeaderOffset = r4(z, offset); - offset += 4; - var fileName = z.substr(offset, f.fileNameLength); - offset += f.fileNameLength; - f.extraFields = z.substr(offset, f.extraFieldsLength); - offset += f.extraFieldsLength; - f.fileComment = z.substr(offset, f.fileCommentLength); - offset += f.fileCommentLength; - //f.dir = f.externalFileAttributes & 0x00000010 ? true : false; - var loffset = f.localHeaderOffset + 28; - f.lextraFieldsLength = r2(z, loffset); - loffset += 2 + f.fileNameLength; - f.lextraFields = z.substr(loffset, f.lextraFieldsLength); - loffset += f.lextraFieldsLength; - f.compressedFileData = z.substr(loffset, f.compressedSize); - if (mediatype === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" && (fileName.substr(fileName.length - 4) === ".xml" || fileName.substr(fileName.length - 5) === ".rels")) { - f.doc = XsltForms_browser.createXMLDocument(""); - XsltForms_browser.loadDoc(f.doc, XsltForms_browser.utf8decode(zip_inflate(f.compressedFileData))); - XsltForms_browser.setDocMeta(f.doc, "instance", instid); - XsltForms_browser.setDocMeta(f.doc, "model", modid); - } - r += ''; - arch[fileName] = f; - } - r += ""; - if (mediatype === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" && arch.hasOwnProperty("xl/sharedStrings.xml")) { - var shared = XsltForms_browser.transformText(XsltForms_browser.saveDoc(arch["xl/sharedStrings.xml"].doc, "application/xml"), XsltForms_browser.xsltsharedsrc, true) + "|"; - for (var fn in arch) { - if (arch.hasOwnProperty(fn)) { - f = arch[fn]; - if (f.doc && (f.doc.documentElement.localName ? f.doc.documentElement.localName : f.doc.documentElement.baseName) === "worksheet") { - var inlineStr = XsltForms_browser.transformText(XsltForms_browser.saveDoc(f.doc, "application/xml"), XsltForms_browser.xsltinlinesrc, true, "shared", shared); - XsltForms_browser.loadDoc(f.doc, inlineStr); - XsltForms_browser.setDocMeta(f.doc, "instance", instid); - XsltForms_browser.setDocMeta(f.doc, "model", modid); - } - } - } - } - arch.srcDoc = r; - return arch; + var arch = {}; + var f; + var r = ""; + var offset = z.lastIndexOf("PK\x05\x06")+16; + var r2 = function(z, offset) { + return ((z.charCodeAt(offset+1) & 0xFF)<< 8) | z.charCodeAt(offset) & 0xFF; + }; + var r4 = function(z, offset) { + return ((((((z.charCodeAt(offset+3) & 0xFF)<< 8) | z.charCodeAt(offset+2) & 0xFF)<< 8) | z.charCodeAt(offset+1) & 0xFF)<< 8) | z.charCodeAt(offset) & 0xFF; + }; + offset = r4(z, offset); + while (z.charCodeAt(offset) === 80 && z.charCodeAt(offset+1) === 75 && z.charCodeAt(offset+2) === 1 && z.charCodeAt(offset+3) === 2) { + f = {}; + offset += 4; + f.versionMadeBy = r2(z, offset); + offset += 2; + f.versionNeeded = r2(z, offset); + offset += 2; + f.bitFlag = r2(z, offset); + offset += 2; + f.compressionMethod = r2(z, offset); + offset += 2; + f.date = r4(z, offset); + offset += 4; + f.crc32 = r4(z, offset); + offset += 4; + f.compressedSize = r4(z, offset); + offset += 4; + f.uncompressedSize = r4(z, offset); + offset += 4; + f.fileNameLength = r2(z, offset); + offset += 2; + f.extraFieldsLength = r2(z, offset); + offset += 2; + f.fileCommentLength = r2(z, offset); + offset += 2; + f.diskNumber = r2(z, offset); + offset += 2; + f.internalFileAttributes = r2(z, offset); + offset += 2; + f.externalFileAttributes = r4(z, offset); + offset += 4; + f.localHeaderOffset = r4(z, offset); + offset += 4; + var fileName = z.substr(offset, f.fileNameLength); + offset += f.fileNameLength; + f.extraFields = z.substr(offset, f.extraFieldsLength); + offset += f.extraFieldsLength; + f.fileComment = z.substr(offset, f.fileCommentLength); + offset += f.fileCommentLength; + //f.dir = f.externalFileAttributes & 0x00000010 ? true : false; + var loffset = f.localHeaderOffset + 28; + f.lextraFieldsLength = r2(z, loffset); + loffset += 2 + f.fileNameLength; + f.lextraFields = z.substr(loffset, f.lextraFieldsLength); + loffset += f.lextraFieldsLength; + f.compressedFileData = z.substr(loffset, f.compressedSize); + if (mediatype === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" && (fileName.substr(fileName.length - 4) === ".xml" || fileName.substr(fileName.length - 5) === ".rels")) { + f.doc = XsltForms_browser.createXMLDocument(""); + XsltForms_browser.loadDoc(f.doc, XsltForms_browser.utf8decode(zip_inflate(f.compressedFileData))); + XsltForms_browser.setDocMeta(f.doc, "instance", instid); + XsltForms_browser.setDocMeta(f.doc, "model", modid); + } + r += ''; + arch[fileName] = f; + } + r += ""; + if (mediatype === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" && arch.hasOwnProperty("xl/sharedStrings.xml")) { + var shared = XsltForms_browser.transformText(XsltForms_browser.saveDoc(arch["xl/sharedStrings.xml"].doc, "application/xml"), XsltForms_browser.xsltsharedsrc, true) + "|"; + for (var fn in arch) { + if (arch.hasOwnProperty(fn)) { + f = arch[fn]; + if (f.doc && (f.doc.documentElement.localName ? f.doc.documentElement.localName : f.doc.documentElement.baseName) === "worksheet") { + var inlineStr = XsltForms_browser.transformText(XsltForms_browser.saveDoc(f.doc, "application/xml"), XsltForms_browser.xsltinlinesrc, true, "shared", shared); + XsltForms_browser.loadDoc(f.doc, inlineStr); + XsltForms_browser.setDocMeta(f.doc, "instance", instid); + XsltForms_browser.setDocMeta(f.doc, "model", modid); + } + } + } + } + arch.srcDoc = r; + return arch; }; XsltForms_browser.xml2zip = function(arch, mediatype) { - var z = ""; - var fn, f; - var fcount = 0; - var w2 = function(v) { - return String.fromCharCode(v & 0xFF) + String.fromCharCode((v >>> 8) & 0xFF); - }; - var w4 = function(v) { - return String.fromCharCode(v & 0xFF) + String.fromCharCode((v >>> 8) & 0xFF) + String.fromCharCode((v >>> 16) & 0xFF) + String.fromCharCode((v >>> 24) & 0xFF); - }; - for (fn in arch) { - if (arch.hasOwnProperty(fn)) { - f = arch[fn]; - f.localHeaderOffset = z.length; - if (f.doc) { - var ser = XsltForms_browser.utf8encode(XsltForms_browser.saveDoc(f.doc, "application/xml")); - if (mediatype.indexOf("application/vnd.openxmlformats-officedocument.") === 0) { - var x14ac = ser.indexOf(' xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"'); - var rattr = f.doc.documentElement.attributes; - for (var ri = 0, li = rattr.length; ri < li; ri++) { - if (rattr[ri].localName === "Ignorable" && rattr[ri].namespaceURI === "http://schemas.openxmlformats.org/markup-compatibility/2006") { - if (x14ac === -1 || x14ac > ser.indexOf("Ignorable")) { - ser = ser.substr(0, ser.indexOf(" ")) + ' xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"' + ser.substr(ser.indexOf(" ")); - break; - } - } - } - } - ser = '\r\n' + ser; - f.crc32 = XsltForms_browser.crc32(ser); - f.uncompressedSize = ser.length; - f.compressedFileData = zip_deflate(ser); - f.compressedSize = f.compressedFileData.length; - } - z += "PK\x03\x04"; - z += w2(f.versionNeeded); - z += w2(f.bitFlag); - z += w2(f.compressionMethod); - z += w4(f.date); - z += w4(f.crc32); - z += w4(f.compressedSize); - z += w4(f.uncompressedSize); - z += w2(f.fileNameLength); - z += w2(f.lextraFieldsLength); - z += fn; - z += f.lextraFields; - z += f.compressedFileData; - fcount++; - } - } - var diroffset = z.length; - for (fn in arch) { - if (arch.hasOwnProperty(fn)) { - f = arch[fn]; - z += "PK\x01\x02"; - z += w2(f.versionMadeBy); - z += w2(f.versionNeeded); - z += w2(f.bitFlag); - z += w2(f.compressionMethod); - z += w4(f.date); - z += w4(f.crc32); - z += w4(f.compressedSize); - z += w4(f.uncompressedSize); - z += w2(f.fileNameLength); - z += w2(f.extraFieldsLength); - z += w2(f.fileCommentLength); - z += w2(f.diskNumber); - z += w2(f.internalFileAttributes); - z += w4(f.externalFileAttributes); - z += w4(f.localHeaderOffset); - z += fn; - z += f.extraFields; - z += f.fileComment; - } - } - var endoffset = z.length; - z += "PK\x05\x06"; - z += w2(0); - z += w2(0); - z += w2(fcount); - z += w2(fcount); - z += w4(endoffset - diroffset); - z += w4(diroffset); - var comment = "generated by XSLTForms - http://www.agencexml.com"; - z += w2(comment.length); - z += comment; - var data = []; - for( var di = 0, dl = z.length; di < dl; di++) { - data.push(z.charCodeAt(di) & 0xff); - } - try { - var z2 = new Uint8Array(data); - return z2.buffer; - } catch (e) { - return XsltForms_browser.StringToBinary(z); - } + var z = ""; + var fn, f; + var fcount = 0; + var w2 = function(v) { + return String.fromCharCode(v & 0xFF) + String.fromCharCode((v >>> 8) & 0xFF); + }; + var w4 = function(v) { + return String.fromCharCode(v & 0xFF) + String.fromCharCode((v >>> 8) & 0xFF) + String.fromCharCode((v >>> 16) & 0xFF) + String.fromCharCode((v >>> 24) & 0xFF); + }; + for (fn in arch) { + if (arch.hasOwnProperty(fn)) { + f = arch[fn]; + f.localHeaderOffset = z.length; + if (f.doc) { + var ser = XsltForms_browser.utf8encode(XsltForms_browser.saveDoc(f.doc, "application/xml")); + if (mediatype.indexOf("application/vnd.openxmlformats-officedocument.") === 0) { + var x14ac = ser.indexOf(' xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"'); + var rattr = f.doc.documentElement.attributes; + for (var ri = 0, li = rattr.length; ri < li; ri++) { + if (rattr[ri].localName === "Ignorable" && rattr[ri].namespaceURI === "http://schemas.openxmlformats.org/markup-compatibility/2006") { + if (x14ac === -1 || x14ac > ser.indexOf("Ignorable")) { + ser = ser.substr(0, ser.indexOf(" ")) + ' xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"' + ser.substr(ser.indexOf(" ")); + break; + } + } + } + } + ser = '\r\n' + ser; + f.crc32 = XsltForms_browser.crc32(ser); + f.uncompressedSize = ser.length; + f.compressedFileData = zip_deflate(ser); + f.compressedSize = f.compressedFileData.length; + } + z += "PK\x03\x04"; + z += w2(f.versionNeeded); + z += w2(f.bitFlag); + z += w2(f.compressionMethod); + z += w4(f.date); + z += w4(f.crc32); + z += w4(f.compressedSize); + z += w4(f.uncompressedSize); + z += w2(f.fileNameLength); + z += w2(f.lextraFieldsLength); + z += fn; + z += f.lextraFields; + z += f.compressedFileData; + fcount++; + } + } + var diroffset = z.length; + for (fn in arch) { + if (arch.hasOwnProperty(fn)) { + f = arch[fn]; + z += "PK\x01\x02"; + z += w2(f.versionMadeBy); + z += w2(f.versionNeeded); + z += w2(f.bitFlag); + z += w2(f.compressionMethod); + z += w4(f.date); + z += w4(f.crc32); + z += w4(f.compressedSize); + z += w4(f.uncompressedSize); + z += w2(f.fileNameLength); + z += w2(f.extraFieldsLength); + z += w2(f.fileCommentLength); + z += w2(f.diskNumber); + z += w2(f.internalFileAttributes); + z += w4(f.externalFileAttributes); + z += w4(f.localHeaderOffset); + z += fn; + z += f.extraFields; + z += f.fileComment; + } + } + var endoffset = z.length; + z += "PK\x05\x06"; + z += w2(0); + z += w2(0); + z += w2(fcount); + z += w2(fcount); + z += w4(endoffset - diroffset); + z += w4(diroffset); + var comment = "generated by XSLTForms - http://www.agencexml.com"; + z += w2(comment.length); + z += comment; + var data = []; + for( var di = 0, dl = z.length; di < dl; di++) { + data.push(z.charCodeAt(di) & 0xff); + } + try { + var z2 = new Uint8Array(data); + return z2.buffer; + } catch (e) { + return XsltForms_browser.StringToBinary(z); + } }; \ No newline at end of file diff --git a/src/js/xsltforms.js/coreelts/itext.js b/src/js/xsltforms.js/coreelts/itext.js index 296f57f..96dc946 100644 --- a/src/js/xsltforms.js/coreelts/itext.js +++ b/src/js/xsltforms.js/coreelts/itext.js @@ -1,21 +1,19 @@ -/*eslint-env browser*/ -/*globals XsltForms_class XsltForms_coreElement*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module itext * @description === "XsltForms_itext" class === * Itext Element Class * * constructor function : sets specific properties */ - + new XsltForms_class("XsltForms_itext", "HTMLElement", "xforms-itext"); - + function XsltForms_itext(subform, elt) { - elt.parentNode.xfElement.itext = { - defaultlang: elt.children[0].getAttribute("xf-lang") - }; + elt.parentNode.xfElement.itext = { + defaultlang: elt.children[0].getAttribute("xf-lang") + }; } XsltForms_itext.prototype = new XsltForms_coreElement(); diff --git a/src/js/xsltforms.js/coreelts/model.js b/src/js/xsltforms.js/coreelts/model.js index 6e202fd..e424eae 100644 --- a/src/js/xsltforms.js/coreelts/model.js +++ b/src/js/xsltforms.js/coreelts/model.js @@ -1,9 +1,7 @@ -/*eslint-env browser*/ -/*globals XsltForms_globals XsltForms_xmlevents XsltForms_schema XsltForms_coreElement XsltForms_xpathCoreFunctions Fleur XsltForms_browser XsltForms_subform XsltForms_class XsltForms_schemadocs*/ "use strict"; /** * @author Alain Couthures - * @licence LGPL - See file 'LICENSE.md' in this project. + * @license LGPL - See file 'LICENSE.md' in this project. * @module model * @description === "XsltForms_model" class === * * constructor function : specifically gets the associated schemas @@ -11,365 +9,366 @@ Array.prototype.slice.call(document.documentElement.attributes).forEach(function(n) { - if (n.nodeName.substr(0, 6) === "xmlns:" || n.nodeName.substr(0, 6) === "xmlns-") { - Fleur.XPathNSResolver_default.pf.push(n.nodeName.substr(6)); - Fleur.XPathNSResolver_default.uri.push(n.nodeValue); - } else if (n.localName === "xmlns" && n.prefix) { - Fleur.XPathNSResolver_default.pf.push(n.prefix.toLowerCase()); - Fleur.XPathNSResolver_default.uri.push(n.namespaceURI); - } else if (n.prefix && n.prefix !== "") { - Fleur.XPathNSResolver_default.pf.push(n.prefix.toLowerCase()); - Fleur.XPathNSResolver_default.uri.push(n.namespaceURI); - } + if (n.nodeName.substr(0, 6) === "xmlns:" || n.nodeName.substr(0, 6) === "xmlns-") { + Fleur.XPathNSResolver_default.pf.push(n.nodeName.substr(6)); + Fleur.XPathNSResolver_default.uri.push(n.nodeValue); + } else if (n.localName === "xmlns" && n.prefix) { + Fleur.XPathNSResolver_default.pf.push(n.prefix.toLowerCase()); + Fleur.XPathNSResolver_default.uri.push(n.namespaceURI); + } else if (n.prefix && n.prefix !== "") { + Fleur.XPathNSResolver_default.pf.push(n.prefix.toLowerCase()); + Fleur.XPathNSResolver_default.uri.push(n.namespaceURI); + } }); Array.prototype.slice.call(document.querySelectorAll("script[data-uri]")).forEach(function(n) { - XsltForms_globals.jslibraries[n.getAttribute("data-uri")] = n.getAttribute("data-version"); + XsltForms_globals.jslibraries[n.getAttribute("data-uri")] = n.getAttribute("data-version"); }); new XsltForms_class("XsltForms_model", "HTMLElement", "xforms-model"); function XsltForms_model(subform, elt) { - if (!elt.id && !document.getElementById(subform.id + "-model-default")) { - elt.id = subform.id + "-model-default"; - } - var children = elt.children; - for (var i = 0, l = children.length; i < l; i++) { - if (children[i].localName.toLowerCase() === "xforms-instance") { - break; - } - } - if (i === l) { - var definst = document.createElement("xforms-instance"); - definst.innerHTML = '