diff --git a/tools/extensions/XPathStd.pm b/tools/extensions/XPathStd.pm new file mode 100644 index 0000000000000000000000000000000000000000..3ef29832eee497b4384b25bd160dcd992e88ec1b --- /dev/null +++ b/tools/extensions/XPathStd.pm @@ -0,0 +1,234 @@ +package XPathStd; +use Exporter; +our @ISA= qw( Exporter ); +our @EXPORT_OK = qw( functions ); +our @EXPORT = qw( functions ); + +@functions = ( + "abs", + "acos", + "add-dayTimeDurations", + "add-dayTimeDuration-to-date", + "add-dayTimeDuration-to-dateTime", + "add-dayTimeDuration-to-time", + "add-yearMonthDurations", + "add-yearMonthDuration-to-date", + "add-yearMonthDuration-to-dateTime", + "adjust-dateTime-to-timezone", + "adjust-date-to-timezone", + "adjust-time-to-timezone", + "analyze-string", + "asin", + "atan", + "atan2", + "available-environment-variables", + "avg", + "base64Binary-equal", + "base-uri", + "boolean", + "boolean-equal", + "boolean-greater-than", + "boolean-less-than", + "ceiling", + "codepoint-equal", + "codepoints-to-string", + "collection", + "compare", + "concat", + "concatenate", + "contains", + "cos", + "count", + "current-date", + "current-dateTime", + "current-time", + "data", + "date-equal", + "date-greater-than", + "date-less-than", + "dateTime", + "dateTime-equal", + "dateTime-greater-than", + "dateTime-less-than", + "day-from-date", + "day-from-dateTime", + "days-from-duration", + "dayTimeDuration-greater-than", + "dayTimeDuration-less-than", + "deep-equal", + "default-collation", + "distinct-values", + "divide-dayTimeDuration", + "divide-dayTimeDuration-by-dayTimeDuration", + "divide-yearMonthDuration", + "divide-yearMonthDuration-by-yearMonthDuration", + "doc", + "doc-available", + "document-uri", + "duration-equal", + "element-with-id", + "empty", + "encode-for-uri", + "ends-with", + "environment-variable", + "error", + "escape-html-uri", + "exactly-one", + "except", + "exists", + "exp", + "exp10", + "false", + "filter", + "floor", + "fold-left", + "fold-right", + "for-each", + "for-each-pair", + "format-date", + "format-dateTime", + "format-integer", + "format-number", + "format-time", + "function-arity", + "function-lookup", + "function-name", + "gDay-equal", + "generate-id", + "gMonthDay-equal", + "gMonth-equal", + "gYear-equal", + "gYearMonth-equal", + "has-children", + "head", + "hexBinary-equal", + "hours-from-dateTime", + "hours-from-duration", + "hours-from-time", + "id", + "idref", + "implicit-timezone", + "index-of", + "innermost", + "in-scope-prefixes", + "insert-before", + "intersect", + "iri-to-uri", + "is-same-node", + "lang", + "last", + "local-name", + "local-name-from-QName", + "log", + "log10", + "lower-case", + "matches", + "max", + "min", + "minutes-from-dateTime", + "minutes-from-duration", + "minutes-from-time", + "month-from-date", + "month-from-dateTime", + "months-from-duration", + "multiply-dayTimeDuration", + "multiply-yearMonthDuration", + "name", + "namespace-uri", + "namespace-uri-for-prefix", + "namespace-uri-from-QName", + "nilled", + "node-after", + "node-before", + "node-name", + "normalize-space", + "normalize-unicode", + "not", + "NOTATION-equal", + "number", + "numeric-add", + "numeric-divide", + "numeric-equal", + "numeric-greater-than", + "numeric-integer-divide", + "numeric-less-than", + "numeric-mod", + "numeric-multiply", + "numeric-subtract", + "numeric-unary-minus", + "numeric-unary-plus", + "one-or-more", + "outermost", + "parse-xml", + "parse-xml-fragment", + "path", + "pi", + "position", + "pow", + "prefix-from-QName", + "QName", + "QName-equal", + "remove", + "replace", + "resolve-QName", + "resolve-uri", + "reverse", + "root", + "round", + "round-half-to-even", + "seconds-from-dateTime", + "seconds-from-duration", + "seconds-from-time", + "serialize", + "sin", + "sqrt", + "starts-with", + "static-base-uri", + "string", + "string-join", + "string-length", + "string-to-codepoints", + "subsequence", + "substring", + "substring-after", + "substring-before", + "subtract-dates", + "subtract-dateTimes", + "subtract-dayTimeDuration-from-date", + "subtract-dayTimeDuration-from-dateTime", + "subtract-dayTimeDuration-from-time", + "subtract-dayTimeDurations", + "subtract-times", + "subtract-yearMonthDuration-from-date", + "subtract-yearMonthDuration-from-dateTime", + "subtract-yearMonthDurations", + "sum", + "tail", + "tan", + "time-equal", + "time-greater-than", + "time-less-than", + "timezone-from-date", + "timezone-from-dateTime", + "timezone-from-time", + "to", + "tokenize", + "trace", + "translate", + "true", + "union", + "unordered", + "unparsed-text", + "unparsed-text-available", + "unparsed-text-lines", + "upper-case", + "uri-collection", + "year-from-date", + "year-from-dateTime", + "yearMonthDuration-greater-than", + "yearMonthDuration-less-than", + "years-from-duration", + "zero-or-one" +); + +1; diff --git a/tools/extensions/countfuns.pl b/tools/extensions/countfuns.pl index b33a72abb2d8d54ea7ccabde4b07548aaf1be3fa..cee42d0f79ae4f3acac3a0665696fb663049ac25 100755 --- a/tools/extensions/countfuns.pl +++ b/tools/extensions/countfuns.pl @@ -1,232 +1,6 @@ #!/usr/bin/perl -# Standard XPATH functions -@stdfuns = ( - "abs", - "acos", - "add-dayTimeDurations", - "add-dayTimeDuration-to-date", - "add-dayTimeDuration-to-dateTime", - "add-dayTimeDuration-to-time", - "add-yearMonthDurations", - "add-yearMonthDuration-to-date", - "add-yearMonthDuration-to-dateTime", - "adjust-dateTime-to-timezone", - "adjust-date-to-timezone", - "adjust-time-to-timezone", - "analyze-string", - "asin", - "atan", - "atan2", - "available-environment-variables", - "avg", - "base64Binary-equal", - "base-uri", - "boolean", - "boolean-equal", - "boolean-greater-than", - "boolean-less-than", - "ceiling", - "codepoint-equal", - "codepoints-to-string", - "collection", - "compare", - "concat", - "concatenate", - "contains", - "cos", - "count", - "current-date", - "current-dateTime", - "current-time", - "data", - "date-equal", - "date-greater-than", - "date-less-than", - "dateTime", - "dateTime-equal", - "dateTime-greater-than", - "dateTime-less-than", - "day-from-date", - "day-from-dateTime", - "days-from-duration", - "dayTimeDuration-greater-than", - "dayTimeDuration-less-than", - "deep-equal", - "default-collation", - "distinct-values", - "divide-dayTimeDuration", - "divide-dayTimeDuration-by-dayTimeDuration", - "divide-yearMonthDuration", - "divide-yearMonthDuration-by-yearMonthDuration", - "doc", - "doc-available", - "document-uri", - "duration-equal", - "element-with-id", - "empty", - "encode-for-uri", - "ends-with", - "environment-variable", - "error", - "escape-html-uri", - "exactly-one", - "except", - "exists", - "exp", - "exp10", - "false", - "filter", - "floor", - "fold-left", - "fold-right", - "for-each", - "for-each-pair", - "format-date", - "format-dateTime", - "format-integer", - "format-number", - "format-time", - "function-arity", - "function-lookup", - "function-name", - "gDay-equal", - "generate-id", - "gMonthDay-equal", - "gMonth-equal", - "gYear-equal", - "gYearMonth-equal", - "has-children", - "head", - "hexBinary-equal", - "hours-from-dateTime", - "hours-from-duration", - "hours-from-time", - "id", - "idref", - "implicit-timezone", - "index-of", - "innermost", - "in-scope-prefixes", - "insert-before", - "intersect", - "iri-to-uri", - "is-same-node", - "lang", - "last", - "local-name", - "local-name-from-QName", - "log", - "log10", - "lower-case", - "matches", - "max", - "min", - "minutes-from-dateTime", - "minutes-from-duration", - "minutes-from-time", - "month-from-date", - "month-from-dateTime", - "months-from-duration", - "multiply-dayTimeDuration", - "multiply-yearMonthDuration", - "name", - "namespace-uri", - "namespace-uri-for-prefix", - "namespace-uri-from-QName", - "nilled", - "node-after", - "node-before", - "node-name", - "normalize-space", - "normalize-unicode", - "not", - "NOTATION-equal", - "number", - "numeric-add", - "numeric-divide", - "numeric-equal", - "numeric-greater-than", - "numeric-integer-divide", - "numeric-less-than", - "numeric-mod", - "numeric-multiply", - "numeric-subtract", - "numeric-unary-minus", - "numeric-unary-plus", - "one-or-more", - "outermost", - "parse-xml", - "parse-xml-fragment", - "path", - "pi", - "position", - "pow", - "prefix-from-QName", - "QName", - "QName-equal", - "remove", - "replace", - "resolve-QName", - "resolve-uri", - "reverse", - "root", - "round", - "round-half-to-even", - "seconds-from-dateTime", - "seconds-from-duration", - "seconds-from-time", - "serialize", - "sin", - "sqrt", - "starts-with", - "static-base-uri", - "string", - "string-join", - "string-length", - "string-to-codepoints", - "subsequence", - "substring", - "substring-after", - "substring-before", - "subtract-dates", - "subtract-dateTimes", - "subtract-dayTimeDuration-from-date", - "subtract-dayTimeDuration-from-dateTime", - "subtract-dayTimeDuration-from-time", - "subtract-dayTimeDurations", - "subtract-times", - "subtract-yearMonthDuration-from-date", - "subtract-yearMonthDuration-from-dateTime", - "subtract-yearMonthDurations", - "sum", - "tail", - "tan", - "time-equal", - "time-greater-than", - "time-less-than", - "timezone-from-date", - "timezone-from-dateTime", - "timezone-from-time", - "to", - "tokenize", - "trace", - "translate", - "true", - "union", - "unordered", - "unparsed-text", - "unparsed-text-available", - "unparsed-text-lines", - "upper-case", - "uri-collection", - "year-from-date", - "year-from-dateTime", - "yearMonthDuration-greater-than", - "yearMonthDuration-less-than", - "years-from-duration", - "zero-or-one" -); +require "./XPathStd.pm"; unless (@ARGV) { print < $table{$a} } keys %table) { "* $n functions (out of $nbfuns) needed to cover 70% of occurrences.\n"; } printf DAT "$n $table{$fname} %.2f\n", 100*$sofar/$total; - if (grep { $fname eq $_ } @stdfuns) { + if (grep { $fname eq $_ } @XPathStd::functions) { $sofar_std+=$table{$fname}; printf STD "$n $table{$fname} %.2f\n",100*$sofar_std/$total; } else { diff --git a/tools/extensions/nonstandard.pl b/tools/extensions/nonstandard.pl index 8846c0a851941b85c1613904cc4a2b851c0e9da2..a33a07e79f2eaf504b8f9b282a564dccb339175d 100755 --- a/tools/extensions/nonstandard.pl +++ b/tools/extensions/nonstandard.pl @@ -1,5 +1,7 @@ #!/usr/bin/perl +require "./XPathStd.pm"; + die "Usage: $0 \n" unless @ARGV; @files = @ARGV; @@ -209,235 +211,8 @@ foreach (@unsupported) { $query = "$query)"; $nonsupportedquery = "ast//xqx:functionName[$query]"; -@functions = ( - "abs", - "acos", - "add-dayTimeDurations", - "add-dayTimeDuration-to-date", - "add-dayTimeDuration-to-dateTime", - "add-dayTimeDuration-to-time", - "add-yearMonthDurations", - "add-yearMonthDuration-to-date", - "add-yearMonthDuration-to-dateTime", - "adjust-dateTime-to-timezone", - "adjust-date-to-timezone", - "adjust-time-to-timezone", - "analyze-string", - "asin", - "atan", - "atan2", - "available-environment-variables", - "avg", - "base64Binary-equal", - "base-uri", - "boolean", - "boolean-equal", - "boolean-greater-than", - "boolean-less-than", - "ceiling", - "codepoint-equal", - "codepoints-to-string", - "collection", - "compare", - "concat", - "concatenate", - "contains", - "cos", - "count", - "current-date", - "current-dateTime", - "current-time", - "data", - "date-equal", - "date-greater-than", - "date-less-than", - "dateTime", - "dateTime-equal", - "dateTime-greater-than", - "dateTime-less-than", - "day-from-date", - "day-from-dateTime", - "days-from-duration", - "dayTimeDuration-greater-than", - "dayTimeDuration-less-than", - "deep-equal", - "default-collation", - "distinct-values", - "divide-dayTimeDuration", - "divide-dayTimeDuration-by-dayTimeDuration", - "divide-yearMonthDuration", - "divide-yearMonthDuration-by-yearMonthDuration", - "doc", - "doc-available", - "document-uri", - "duration-equal", - "element-with-id", - "empty", - "encode-for-uri", - "ends-with", - "environment-variable", - "error", - "escape-html-uri", - "exactly-one", - "except", - "exists", - "exp", - "exp10", - "false", - "filter", - "floor", - "fold-left", - "fold-right", - "for-each", - "for-each-pair", - "format-date", - "format-dateTime", - "format-integer", - "format-number", - "format-time", - "function-arity", - "function-lookup", - "function-name", - "gDay-equal", - "generate-id", - "gMonthDay-equal", - "gMonth-equal", - "gYear-equal", - "gYearMonth-equal", - "has-children", - "head", - "hexBinary-equal", - "hours-from-dateTime", - "hours-from-duration", - "hours-from-time", - "id", - "idref", - "implicit-timezone", - "index-of", - "innermost", - "in-scope-prefixes", - "insert-before", - "intersect", - "iri-to-uri", - "is-same-node", - "lang", - "last", - "local-name", - "local-name-from-QName", - "log", - "log10", - "lower-case", - "matches", - "max", - "min", - "minutes-from-dateTime", - "minutes-from-duration", - "minutes-from-time", - "month-from-date", - "month-from-dateTime", - "months-from-duration", - "multiply-dayTimeDuration", - "multiply-yearMonthDuration", - "name", - "namespace-uri", - "namespace-uri-for-prefix", - "namespace-uri-from-QName", - "nilled", - "node-after", - "node-before", - "node-name", - "normalize-space", - "normalize-unicode", - "not", - "NOTATION-equal", - "number", - "numeric-add", - "numeric-divide", - "numeric-equal", - "numeric-greater-than", - "numeric-integer-divide", - "numeric-less-than", - "numeric-mod", - "numeric-multiply", - "numeric-subtract", - "numeric-unary-minus", - "numeric-unary-plus", - "one-or-more", - "outermost", - "parse-xml", - "parse-xml-fragment", - "path", - "pi", - "position", - "pow", - "prefix-from-QName", - "QName", - "QName-equal", - "remove", - "replace", - "resolve-QName", - "resolve-uri", - "reverse", - "root", - "round", - "round-half-to-even", - "seconds-from-dateTime", - "seconds-from-duration", - "seconds-from-time", - "serialize", - "sin", - "sqrt", - "starts-with", - "static-base-uri", - "string", - "string-join", - "string-length", - "string-to-codepoints", - "subsequence", - "substring", - "substring-after", - "substring-before", - "subtract-dates", - "subtract-dateTimes", - "subtract-dayTimeDuration-from-date", - "subtract-dayTimeDuration-from-dateTime", - "subtract-dayTimeDuration-from-time", - "subtract-dayTimeDurations", - "subtract-times", - "subtract-yearMonthDuration-from-date", - "subtract-yearMonthDuration-from-dateTime", - "subtract-yearMonthDurations", - "sum", - "tail", - "tan", - "time-equal", - "time-greater-than", - "time-less-than", - "timezone-from-date", - "timezone-from-dateTime", - "timezone-from-time", - "to", - "tokenize", - "trace", - "translate", - "true", - "union", - "unordered", - "unparsed-text", - "unparsed-text-available", - "unparsed-text-lines", - "upper-case", - "uri-collection", - "year-from-date", - "year-from-dateTime", - "yearMonthDuration-greater-than", - "yearMonthDuration-less-than", - "years-from-duration", - "zero-or-one" -); - $query = '(@xqx:prefix != \'fn\') or (true()'; -foreach (@functions) { +foreach (@XPathStd::functions) { $query = "$query and text() != '$_'"; } $query = "$query)";