Closed moissinac closed 4 years ago
Your example does not follow the N3 syntax for escaping characters (\/
is not allowed I think according to https://www.w3.org/TeamSubmission/n3/#escaping)
@moissinac just reiterating your issue to be clear:
The string:
<http://gv.eu/myuri> <http://gv.eu/hasScript> """
<script>function euCookieComplianceLoadScripts() {var scriptTag = document.createElement("script");scriptTag.src = "\/themes\/custom\/pmp\/javascripts\/google-analytics.js";document.body.appendChild(scriptTag);}</script>
""".
Is indeed invalid N3 and the master branch version (5.0.0-dev) rdflib parser correctly fails to parse it with the message you quote above.
As @JervenBolleman says, you can't escape "/" using "\" in N3 so to make your N3 code valid, just replace "\/" with "/":
<http://gv.eu/myuri> <http://gv.eu/hasScript> """<script>function euCookieComplianceLoadScripts() {var scriptTag = document.createElement("script");scriptTag.src = "/themes/custom/pmp/javascripts/google-analytics.js";document.body.appendChild(scriptTag);}</script>""".
Then rdflib will parse it and you can print out the triple getting:
(
rdflib.term.URIRef('http://gv.eu/myuri'),
rdflib.term.URIRef('http://gv.eu/hasScript'),
rdflib.term.Literal('<script>function euCookieComplianceLoadScripts() {var scriptTag = document.createElement("script");scriptTag.src = "/themes/custom/pmp/javascripts/google-analytics.js";document.body.appendChild(scriptTag);}</script>')
)
So I'm going to close this as it's not an rdflib problem to fix.
Also, for future Issues, please include quoted code or RDF in backtick "`" so it renders nicely, as I've done in this reply!
Hello
I have a text file (test.n3) with the following content: http://gv.eu/myuri http://gv.eu/hasScript """
""".
When doing gexpo = rdflib.Graph() gexpo.parse(source="test.n3", format="n3") I get an error: ... File "C:\outils\Python\Python36\lib\site-packages\rdflib\plugins\parsers\notation3.py", line 1615, in BadSyntax raise BadSyntax(self._thisDoc, self.lines, argstr, i, msg) rdflib.plugins.parsers.notation3.BadSyntax: at line 3 of <>: Bad syntax (bad escape) at ^ in: "...b'riptTag = document.createElement("script");scriptTag.src = "'^b'\/themes\/custom\/pmp\/javascripts\/google-analytics.js";doc'..."
and I doesn't find how to manage the problem (solution or workaround) Thank's for any help