Git Product home page Git Product logo

Comments (16)

grtjn avatar grtjn commented on August 21, 2024

from ml-lodlive.

tpiros avatar tpiros commented on August 21, 2024

@grtjn I thought ml-lodelive-ng uses dbpedia and not an internal ML endpoint.

from ml-lodlive.

grtjn avatar grtjn commented on August 21, 2024

It packages two pre-defined configs, one for dbpedia, one for marklogic..

from ml-lodlive.

tpiros avatar tpiros commented on August 21, 2024

but I guess it presumes that you're running on the same port? I have an app running on port 3000 trying to access ML on a different host.

from ml-lodlive.

grtjn avatar grtjn commented on August 21, 2024

The profile factory in ml-lodlive-ng gives you a plain json config. You can patch it with straight js. You could also just compare the ml profile with what you are currently using. Just to see where it differs from the one in this project or what you were using yourself..

from ml-lodlive.

tpiros avatar tpiros commented on August 21, 2024

Yes, this is the relevant bit:

MarkLogicProfile.connection = {
          // http matches all http requests, so this will be the only connection settings used
          'http:': {
            endpoint: '/v1/graphs/sparql',
            accepts: 'application/sparql-results+json',
            description: {
              en: 'MarkLogic LodLive'
            }
          }
        };

This is what I have:

var MyProfileObject = {};
      MyProfileObject.endpoints = {};

      MyProfileObject.connection = {
        'http:': {  
          endpoint: 'http://192.168.56.200:8060/lodlive.xqy',
          accepts: 'application/sparql-results+json'
        }
      };

Since I'm not running my app from the same machine where ML is, according to the documentation I need this lodlive.xqy file:

"This can be loaded into MarkLogic as RDF triples and can the be exposed via a standard REST application in MarkLogic. If accessing this REST endpoint from a different host or port it will be necessary to install the lodlive.xqy module at the root of the /modules directory for that REST server. Additionally, update your lodlive profile so that the lodlive.xqy url is used as the base."

from ml-lodlive.

tpiros avatar tpiros commented on August 21, 2024

I of course also have this added to the config:

MyProfileObject.endpoints = {
        all: '',
        jsonp: true
      };

from ml-lodlive.

grtjn avatar grtjn commented on August 21, 2024

I think the statement you need lodlive.xqy is wrong. Just prefix /v1/etc with host and port you need for you app..

from ml-lodlive.

tpiros avatar tpiros commented on August 21, 2024

I have done that. In that case the error changes to:

REST-UNSUPPORTEDPARAM: (err:FOER0000) Endpoint does not support query parameter: invalid parameters: _, callback for request

This is due to the fact that I am executing a JSONP request (because I am on different hosts)

from ml-lodlive.

grtjn avatar grtjn commented on August 21, 2024

Yeah, dont think v1 sparql supports jsonp. Can you live without that? 😁

from ml-lodlive.

tpiros avatar tpiros commented on August 21, 2024

Nope 😢 I need JSONP support. The problem is in the lodlive.xqy file somewhere ... but since XQY is not my strong suite I can't really figure it out. I have managed to update the code so that it no longer throws the error mentioned in the subject to be the following:

xquery version "1.0-ml";

import module namespace semmod = "http://marklogic.com/rest-api/models/semantics"
    at "/MarkLogic/rest-api/models/semantics-model.xqy";
import module namespace eput = "http://marklogic.com/rest-api/lib/endpoint-util"
    at "/MarkLogic/rest-api/lib/endpoint-util.xqy";

declare option xdmp:mapping "false";

let $params  := map:map()
let $_ := for $i in xdmp:get-request-field-names() return map:put($params, $i, xdmp:get-request-field($i))
let $headers := eput:get-request-headers()

let $result := semmod:sparql-query($headers,$params,map:get($params, "query"))
let $response := semmod:results-payload($headers,$params,$result, ())
let $_ := xdmp:set-response-content-type($response[1])

return (
  if (map:get($params, "callback")) then fn:concat(map:get($params, "callback"), "(") else (),
  $response[2],
  if (map:get($params, "callback")) then ")" else ()

  )

But this now throws the error of:

XDMP-NONMIXEDCOMPLEXCONT: fn:data(<html xmlns="http://www.w3.org/1999/xhtml"><head><title>SPARQL results</title></head>...</html>) -- Node has complex type with non-mixed complex content

Which has lead me to the actual implementation of semantics-model.xqy and I managed to track this back to 2 things: 1) the accepts header is not being sent propertly, 2) the data that gets returned is just not correct. But this is where my XQY knowledge has depleted and I'm totally stuck

from ml-lodlive.

grtjn avatar grtjn commented on August 21, 2024

I'm on mobile unfortunately. Send me a mail on my work address as a reminder, i might have a spare moment tomorrow.

Why are you stuck with jsonp? Never needed it myself.. 😉

from ml-lodlive.

tpiros avatar tpiros commented on August 21, 2024

I am running a Node.js app from where I would like to display a LodLive graph 😄

from ml-lodlive.

tpiros avatar tpiros commented on August 21, 2024

I just had an idea, I'll try to proxy my request ... 😄

from ml-lodlive.

grtjn avatar grtjn commented on August 21, 2024

Did proxying help?

from ml-lodlive.

tpiros avatar tpiros commented on August 21, 2024

@grtjn - yes it did help. Thanks. But I'd still like to see a working version of this lodlive.xqy :)

from ml-lodlive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.