GithubHelp home page GithubHelp logo

Comments (11)

VladimirAlexiev avatar VladimirAlexiev commented on June 9, 2024 1

@enridaga Yes!

Note: It's not the whatwg namespace, but the xhtml namespace.
Actually I've renamed them in my script, see the comments below as to where they appear:

prefix x:     <http://www.w3.org/1999/xhtml#>              # raw data prefix in HTML->RDF, prepended to any other prefix, eg x:gml:featurecollection, x:plu:indicationreference, x:nilreason, x:xsi:nil
prefix html:  <https://html.spec.whatwg.org/#>             # html:innerHTML, html:innerText

from sparql.anything.

enridaga avatar enridaga commented on June 9, 2024

I mean the complete XML structure with sub-elements, not just its text content

Interesting use case, unfortunately, this can't be done with the XML triplifier. Maybe you can try to pretend it's HTML, I think that triplifier should have an innerHTML property that in principle should return the GML code. See the documentation for details and let us know if it solves your problem.

from sparql.anything.

VladimirAlexiev avatar VladimirAlexiev commented on June 9, 2024

@enridaga It kind of works, but not quite. See test files at https://gist.github.com/VladimirAlexiev/318ab4924c756ead618ebdded6428509 and compare

  • sparql-anything-test-xml.ttl
  • sparql-anything-test-html.ttl

I use these prefixes:

prefix x:     <http://www.w3.org/1999/xhtml#>              # raw data prefix in HTML->RDF, prepended to any other prefix, eg x:gml:featurecollection, x:plu:indicationreference, x:nilreason, x:xsi:nil
prefix html:  <https://html.spec.whatwg.org/#>             # html:innerHTML, html:innerText
prefix xlink: <http://www.w3.org/1999/xlink#>
prefix gml:   <http://www.opengis.net/gml/3.2#>
prefix plu:   <http://inspire.ec.europa.eu/schemas/plu/4.0#>
prefix xyz:   <http://sparql.xyz/facade-x/data/>           # raw prefix in XML->RDF data
prefix fx:    <http://sparql.xyz/facade-x/ns/>             # fx:properties in SERVICE call, fx:root in output
prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#># each XML element becomes rdf:type
prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#>      # rdfs:member
prefix xsd:   <http://www.w3.org/2001/XMLSchema#>
prefix xsi:   <http://www.w3.org/2001/XMLSchema-instance#> # xsi:nil "true": filter out such elements. xsi:schemaLocation

Problems:

  • all elements are lowercased: both inside innerHTML and in RDF
  • all elements in RDF are prepended the x: prefix, eg x:gml:featurecollection, x:plu:indicationreference, x:xsi:nil
    (the originals are gml:FeatureCollection, plu:indicationReference, xsi:nil`

I guess I can live with this, but the script will be completely non-portable between XML and HTML input...

from sparql.anything.

enridaga avatar enridaga commented on June 9, 2024

I guess I can live with this, but the script will be completely non-portable between XML and HTML input...

Of course, this is a hack, XML is different from HTML.

We can open issues to support the case better, when using the HTML triplifier with XML content. To summarise, these seems to be the problems:

[ ] xmlns is not considered a ns prefix, and the default whatwg namespace is prepended
[ ] element names are lowercased, while in XML tags are case sensitive

from sparql.anything.

enridaga avatar enridaga commented on June 9, 2024

@enridaga Yes!

Note: It's not the whatwg namespace, but the xhtml namespace. Actually I've renamed them in my script, see the comments below as to where they appear:

prefix x:     <http://www.w3.org/1999/xhtml#>              # raw data prefix in HTML->RDF, prepended to any other prefix, eg x:gml:featurecollection, x:plu:indicationreference, x:nilreason, x:xsi:nil
prefix html:  <https://html.spec.whatwg.org/#>             # html:innerHTML, html:innerText

My suspicion is that this depends on the fact that the HTML parser (beatifulsoup) does not handle prefixes. Will investigate.

from sparql.anything.

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.