how to parse json-ld file with rdflib.parse() or load() - json-ld

I am new to json-ld and rdflib usage. I have json-ld file with #context and #graph sections inside.
I want to use rdflib open to load this graph.
When I try using parse() method, with format='n3', I am getting error
BadSyntax: at line 5 of <>:
Bad syntax (expected '.' or '}' or ']' at end of statement) at ^ in:
If I give format='json-ld', it says No plugin registered for (json-ld, )
If I don't give any format parameter then it says,
SAXParseException: file:composition.json-ld:1:0: not well-formed (invalid token)
rdflib.Graph().load('composition.json-ld')
Error SAXParseException: not well-formed (invalid token)
rdflib.Graph().load('composition.json-ld', format='json-ld')
Error PluginException: No plugin registered for (json-ld, <class 'rdflib.parser.Parser'>)
f= open('filename.json-ld', 'rb')
rdflib.Graph().parse(data=f.read(), format='json-ld') ==> Error PluginException: No plugin registered for (json-ld, <class 'rdflib.parser.Parser'>)
I checked json-ld file in json-ld playground. It is correct.
Am I missing something in syntax for parsing here?

Did you install the JSON-LD plugin? If not, do a
pip install rdflib-jsonld

Related

Solr Data Config Error, Open quote is expected for attribute "driver"

I have a postgres data-config file.
<dataConfig>
<dataSource driver=”org.postgresql.Driver” url=”jdbc:postgresql://127.0.0.1:5432/mydb” user=”user” password=”pw” />
...
</dataConfig>
But when I run it, it shows error
Data Config problem: Open quote is expected for attribute "driver" associated with an element type "dataSource".
What's the problem here. is driver information that I put wrong?
Your quotes are wrong.
” and " are not the same kind of quotes (see the different presentation). Only " is a valid double quote in an XML file (and in most/all programming contexts).
The examples in your config file seems to have been mangled by a blog or a text editor on the way.

Getting an error in output when passing dynamic variable in ElFileBody in Gatling 3.0.3

I am using Gatling 3.0.3 and Java home is set to Jdk9. I am getting an error when running my script using 'ElFileBody' and I am passing a dynamic variable Session_ID in the ElFileBody .txt file. Below is my code
.exec(http("TEAMXPRESS_INIT")
.post("/WEBXPAPIT/api/Common/wxRequestHandlerJSON")
.headers(headers_7)
.body(ElFileBody("bodies/resources/TeamXPLoginUnSchShift_0021_request.txt")).sJson
.check( jsonPath( "$" ).saveAs( "TEAMXP_INIT_RESPONSE_DATA" ) )
.check(status.in(200))
.check(jsonPath("$.pcResult").is("OK")))
bodies/resources/TeamXPLoginUnSchShift_0021_request.txt file is
{"pcwxSessionID":"${Session_ID)","pcServiceName":"TeamXpressInit","pcContextString":"{\"ttContext\":[{\"contextName\":\"pcToken\",\"contextValue\":null,\"contextGroup\":\"PARAM\",\"contextOperator\":\"\",\"contextType\":\"\"},{\"contextName\":\"pcPlatform\",\"contextValue\":null,\"contextGroup\":\"PARAM\",\"contextOperator\":\"\",\"contextType\":\"\"}]}","piClientVersion":"20190414001","pcIODataSetString":""}
Error I am getting is
Caused by: java.util.concurrent.CompletionException: io.gatling.core.session.el.ElParserException: Failed to parse {"pcwxSessionID":"${Session_ID)","pcServiceName":"TeamXpressInit","pcContextString":"{\"ttContext\":[{\"contextName\":\"pcToken\",\"contextValue\":null,\"contextGroup\":\"PARAM\",\"contextOperator\":\"\",\"contextType\":\"\"},{\"contextName\":\"pcPlatform\",\"contextValue\":null,\"contextGroup\":\"PARAM\",\"contextOperator\":\"\",\"contextType\":\"\"}]}","piClientVersion":"20190414001","pcIODataSetString":""} with error ''}' expected but ')' found'
at com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalLoadingCache.lambda$new$0(BoundedLocalCache.java:3373)
at com.github.benmanes.caffeine.cache.BoundedLocalCache.lambda$doComputeIfAbsent$14(BoundedLocalCache.java:2039)
at java.base/java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1922)
at com.github.benmanes.caffeine.cache.BoundedLocalCache.doComputeIfAbsent(BoundedLocalCache.java:2037)
at com.github.benmanes.caffeine.cache.BoundedLocalCache.computeIfAbsent(BoundedLocalCache.java:2020)
at com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:112)
at com.github.benmanes.caffeine.cache.LocalLoadingCache.get(LocalLoadingCache.java:67)
at io.gatling.core.body.ElFileBodies.asBytesSeq(ElFileBodies.scala:71)
at io.gatling.core.body.ElFileBody$.apply(Body.scala:34)
at teamXPLogin.TeamXPLoginUnSchShift.<init>(TeamXPLoginUnSchShift.scala:86)
What wrong am I doing here. If I pass the post request body manually using StringBody method then it works fine. Please help.
I figured out the silly mistake I have done. Instead of passing dynamic variable ${Session_ID} like this, I have passed ${Session_ID).

Parse error while rendering the pdf file in angularjs app

When I try to access the pdf file which is public using the angular-pdf-viewer I got the following error message on console.
Error: [$parse:syntax] Syntax Error: Token ':' is an unexpected token at column 5 of the expression [http://pucdocket.s3.amazonaws.com/VA/PUE-2010-00039/122913.pdf] starting at [://pucdocket.s3.amazonaws.com/VA/PUE-2010-00039/122913.pdf].
here is my pdf directive for rendering the pdf file:
<pdf-viewer delegate-handle="my-pdf-container" url="http://pucdocket.s3.amazonaws.com/VA/PUE-2010-00039/122913.pdf" scale="1" show-toolbar="true" ></pdf-viewer>
could anyone help on this issue?
all the samples seems to be suggesting define url on scope and reference it. But you may try the following, which stringifys the url
<pdf-viewer delegate-handle="my-pdf-container" url="'http://pucdocket.s3.amazonaws.com/VA/PUE-2010-00039/122913.pdf'" scale="1" show-toolbar="true" ></pdf-viewer>

Parse error: syntax error, unexpected 'image' (T_STRING) in eval line

I`m trying to create a page that read the metadata of an image and allow user to edit it and save it to the same image.
After searching the internet I have found exiftool as the solution but I can make it work only as a command line not as a library in the page.
I have this code:
eval('$metadata=' . exiftool.exe -php -q $imagePath);
foreach ($metadata[0] as $key => $value) {
if ($metadata[0][$key]!=$_POST[$key]){
if ($_POST[$key]=="") $_POST[$key]=" "; //if metadata is not set, than create an empty metadata
eval('$metadata=' . exiftool.exe "-$key=$_POST[$key]" $imagePath);
}
}
and I`m getting this error:
Parse error: syntax error, unexpected 'image' (T_STRING) in E:\xampp\htdocs\imgdata\index.php(30) : eval()'d code on line 1
I tried to replace the ` with other like " and ' but no luck.
What do I miss?
Any better idea on how to do it?
Thanks
I had the same problem, but using Centos OS, and found a solution here:
'command not found' error when using subprocess in apache
Might not work for Windows but worth a look. Basically the answer suggests specifying the full exiftool path rather than simply exiftool.exe.
If that doesn't help then have a look for errors in the Apache Error Log File.

How to get right attribute which contain "&" through libxml2

When I try to get the attribute of URL in a test XML:
<Test> <Item URL="http://127.0.0.1?a=1&b=2"/>
</Test>
After I call: attr=xmlGetProp(cur, BAD_CAST "URL");
The libxml2 give a message: Entity: line 1: parser error : EntityRef: expecting ';'
and return value of attr is "http://127.0.0.1?a=1=2"
How can I get the completion attribution of URL? Thanks
You cannot get the “correct” URL here because the XML file is not well-formed. the & should have been written as &. You have to ask the creator of the XML file to create a syntactically valid, well-formed XML file.
XML is not created by just putting strings together, they also have to be encoded properly.

Resources