I am executing the following XQuery code on BaseX 7.9 and the result is false even when I know it is a file (the dots are an abbreviation).
file:is-file("C:\Users\...\books2.xml")
According to http://docs.basex.org/wiki/File_Module#file:is-file I should be receiving true.
Related
Consider the following code:
In Utils.py:
#keyword
def get_compound_dictionary():
"""
https://docs.python.org/3/library/copy.html
An example compound dictionary
"""
return {'key1': 'value1', 'deep_dict': {'key2': 'value2'}}
In collection-library-tests.robot
*** Settings ***
Documentation A test suite utilizing all collection library keywords
Library Collections
Library Utils.py
# To run:
# robot --pythonpath Resources --noncritical failure-expected -d Results/ Tests/collection-
library-tests.robot
*** Test Cases ***
Use "Copy Dictionary" : Shallow Copy
${compound_python_dictionary} = get compound dictionary
&{shallow_copy} = Copy Dictionary ${compound_python_dictionary} deepcopy=False
# if we modify the contained objects (i.e. deep_dict) through the shallow_copy,
# the original compound_python_dictionary will see the changes in the contained objects
Set To Dictionary ${shallow_copy}[deep_dict] key2=modified
Log ${shallow_copy}
Log ${compound_python_dictionary}
Should Be Equal ${compound_python_dictionary}[deep_dict][key2] modified # fails, why?
The goal is stated in the test case as:
if we modify the contained objects (i.e. deep_dict) through the shallow_copy,
the original compound_python_dictionary will see the changes in the contained objects
Expected Result
Should Be Equal ${compound_python_dictionary}[deep_dict][key2] modified # passes
Observed Result
Note that I am using Robot FW version: Robot Framework 3.1.2 (Python
3.7.4 on linux)
Acc.to the documentation about Copy Dictionary:
The deepcopy argument controls should the returned dictionary be a
shallow or deep copy. By default returns a shallow copy, but that can be
changed by giving deepcopy a true value (see Boolean arguments). This > is a new option in Robot Framework 3.1.2. Earlier versions always
returned shallow copies.
Acc.to the documentation about Boolean Arguments:
Some keywords accept arguments that are handled as Boolean values true or false. If such an argument is given as a string, it is considered false if it is an empty string or equal to FALSE, NONE, NO, OFF or 0, case-insensitively. Other strings are considered true regardless their value.
Note also that i tried also deepcopy=${False}, which yielded the same observed result.
The problem is not with the RF keyword (it very seldom is, they have extensive UT), but with the way you call it, namely this argument:
deepcopy=False
You may be thinking you are passing a boolean value, but in fact you are passing the string "False".
Inside the keyword's implementation there is this branching:
if deepcopy:
return copy.deepcopy(dictionary)
, and as a non-empty string evaluates to True, you are in fact getting a deep copy.
This is the way to pass a real False:
deepcopy=${False}
I have just started diving into NLP and want to use hunspell in order to perform tokenization. However, until now I was not able to use hunspell properly, since it returns "false" everytime I use the function "hunspell_check".
I installed hunspell serveral times and checked, whether dictionaries are actually present (they are). Also, I tried different functions of hunspell (like "hunspell()"), but they do not work either. Interestingly, I cannot find an error message of any kind.
> hunspell_check("work")
[1] FALSE
> dictionary(lang = "en_US")
<hunspell dictionary>
affix: C:\Users\NilsKlähn\Documents\R\win-library\3.6\hunspell\dict\en_US.aff
dictionary: C:\Users\NilsKlähn\Documents\R\win-library\3.6\hunspell\dict\en_US.dic
encoding: ISO8859-1
wordchars: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ
added: 0 custom words
I expect the function hunspell_check("work") to return true, instead of false, since it is spelled correctly. The dictionary seems to be alright though.
Using XQuery 3.1 (under eXistDB 4.4), I have a function which returns a serialized output of 710 delimited rows like these:
MS609-0001~ok~0001~1r~Deposition~De_Manso_Sanctarum_Puellarum_1~self~1245-05-27~Arnald_Garnier_MSP-AU~self
MS609-0002~ok~0002~1r~Deposition~De_Manso_Sanctarum_Puellarum_1~MS609-0001~1245-05-27~Guilhem_de_Rosengue_MSP-AU~MS609-0001
MS609-0003~ok~0003~1r~Deposition~De_Manso_Sanctarum_Puellarum_1~MS609-0001~1245-05-27~Hugo_de_Mamiros_MSP-AU~MS609-0001
I get the above serialized results in another function that should store it in the directory /db/apps/deheresi/documents as a flatfile depositions.txt
let $x := schedule:deposition-textfile()
return xmldb:store(concat($globalvar:URIdb,"documents"), "deposition.txt", $x)
But when I execute the xmldb:store action, it returns an error:
Description: err:XPTY0004 checking function parameter 3
in call xmldb:store(untyped-value-check[xs:string,
concat("/db/apps/deheresi/", "documents")], "depositions.txt", $x):
XPTY0004: The actual cardinality for parameter 3 does not
match the cardinality declared in the function's signature:
xmldb:store($collection-uri as xs:string,
$resource-name as xs:string?,
$contents as item()) xs:string?.
Expected cardinality: exactly one, got 710.
How do I get these serialized results into the text file?
Thanks in advance.
UPDATE: I tried wrapping the serialized output in <result> and that fixes the problem of cardinality, BUT it writes the <result> element to the file as plain text:
<result>MS609-0001~ok~0001~1r~Deposition~De_Manso_Sanctarum_Puellarum_1~self~1245-05-27~Arnald_Garnier_MSP-AU~self
MS609-0002~ok~0002~1r~Deposition~De_Manso_Sanctarum_Puellarum_1~MS609-0001~1245-05-27~Guilhem_de_Rosengue_MSP-AU~MS609-0001
MS609-0003~ok~0003~1r~Deposition~De_Manso_Sanctarum_Puellarum_1~MS609-0001~1245-05-27~Hugo_de_Mamiros_MSP-AU~MS609-0001</result>
Even if I add:
declare option exist:serialize "method=text";
The error message seems quite clear. The return type of schedule:deposition-textfile() is not acceptable to xmldb:store(). You want a single string, not 710.
Either change the return type of your function, or search the xQuery function documentation for xmldb:store to find a suitable alternative for your returntype.
I don't know the function you are calling, but perhaps you should use string-join() to combine the 710 strings into one, with a newline separator.
This a ROBLOX lua script, lua 5.1 with features that have been modified, removed, or added, Anyone with lua 5.1 knowledge, will help greatly.
My issue is that when I try to obfuscate this script:
_G.findchild = function (instance, name)
for _, child in pairs(instance:GetChildren()) do
if child.Name == name then
return true
elseif _==#instance:GetChildren() then
return false
end
end
end
print(_G.findchild(game,"Workspace"))
It doesn't wait for the function to complete in the print, and it just prints nothing (nil), not false or true
Here is the encryption script (note I commented out the io.write lines, roblox removed this library)
https://pastebin.com/TcHTBf3C
Any help would be appreciated!
Using BaseX 8.6 the following use of the serialize function with a map as the second argument works fine:
serialize(<root><foo><bar>test</bar></foo></root>, map { 'indent' : 'yes'})
and outputs the indented code
<root>
<foo>
<bar>test</bar>
</foo>
</root>
However, when I try to run the same code with Saxon 9.7 or AltovaXML Spy they don't compile the query and complain about map { 'indent' : 'yes'} not being a boolean value but a string. https://www.w3.org/TR/xpath-functions-31/#func-serialize defines
indent xs:boolean? true() means "yes", false() means "no"
so I am not quite sure whether that allows only a boolean and is meant to explain its meaning in relation to the serialization values of yes/no or whether it also means using yes or no is allowed.
In BaseX, the map argument was added before it was integrated in the XQFO 3.1 specification. Back then, the most obvious choice was to use the syntax for output declarations in the query prolog (in which only strings can be used for values of serialization parameters). – The new official syntax will be made available in a future version of BaseX.