Git Product home page Git Product logo

Comments (3)

rvesse avatar rvesse commented on June 1, 2024

Historically Resource.getLocalName() uses RDF/XML specific local name rules, which early versions of other syntaxes also used to follow. As RDF/XML has become less and less prevalent other formats relaxed those rules to allow for a wider range of characters in the local name portion of their prefixed name syntaxes but given Jena's long history early parts of the API like Model and Resource have not really changed in that regard.

There are other ways to present URIs e.g. PrefixMapping.shortForm() or PrefixMap.abbreviate() that should be used if you want more generic URI shortening and these will use more modern rules about what is allowed in the local name portion of URIs

Or you could look at the NodeFormatter API if you plan to generate a lot of shortened URIs in your outputs

from jena.

afs avatar afs commented on June 1, 2024

See SplitIRI for split algorithms -- there are splits for RDF/XML, Turtle and a basic /,# split.

The javadoc for Resource.getLocalName refers to SplitIRI.

Changing Resource.getLocalName would impact existing applications and Jena has tended to be conservative in that regard. It encourages people to upgrade their use of Jena for general good security health.

New Resource.splitLocalName/splitNamespace operations could be done that call SplitIRI.

Contributions welcome!

from jena.

davidcockbill avatar davidcockbill commented on June 1, 2024

Thanks for the quick replies.

That'll teach me for looking at decompiled code in the debugger rather than the actual sources!

As Andy says the actual source does mention this:

  /** Returns the localname of this resource within its namespace if it is a URI else null.
   * <p>
   * Note: XML requires QNames to start with a letter, not a digit,
   * and this method reflects that restriction.
   * <p>
   * See functions in {@code SplitIRI} for other split algorithms.
   * @return The localname of this property within its namespace.
   */

I'lll investigate using either PrefixMapping or SplitIRI.

When I have a free moment I'll consider creating a PR for those new methods, depending on my success!

from jena.

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.