/ or #
character.
Historically, 'prefix' is referred to as 'namespace' reflecting RDF/XML history.
For display, use localname(java.lang.String) and namespace(java.lang.String).
These pragmatic follow Turtle (e.g. localname allows a plain trailing dot)
but does not escape any characters.
These operations are for display (c.f. Object.toString() and do not guarantee a round-trip;
namespace+localname may not be the exact input IRI.
A URI is split never split before the last / or #, if present.
See splitpoint(java.lang.String) for more details.
The functions
namespaceTTL(java.lang.String) and localnameTTL(java.lang.String)
provide a strict Turtle split, if possible;
the local name is escaped if necessary.
namespaceTTL(java.lang.String) can be used to build a set of prefix mappings.
The functions namespaceXML(java.lang.String) and localnameXML(java.lang.String)
apply the rules for XML qnames.
This code forms the machinery behind Node.getLocalName()
Node.getNameSpace() for URI Nodes following the XML rules.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringCalculate a localname - do not escape PN_LOCAL_ESC.static StringlocalnameTTL(String string) Calculate a localname - enforce legal Turtle escapes for localnames (rule PN_LOCAL_ESC), A final '.' is escaped.static StringlocalnameXML(String string) Localname, according to XML 1.0 qname rules.static StringReturn the 'namespace' (prefix) for a URI string.static StringnamespaceTTL(String string) Return the 'namespace' (prefix) for a URI string, legal for Turtle and goes withlocalnameTTL(java.lang.String).static StringnamespaceXML(String string) Namespace, according to XML 1.0 qname rules.static intsplitpoint(String uri) Find the URI split point, return the index into the string that is the first character of a legal Turtle local name.static intSplit point, according to XML 1.0 qname rules.static intsplitXML10(String string) Deprecated.Retained as a record of previous split handling.
-
Constructor Details
-
SplitIRI
public SplitIRI()
-
-
Method Details
-
namespace
Return the 'namespace' (prefix) for a URI string. Use withlocalname(java.lang.String). Return the input string if there is no splitpoint. -
localname
Calculate a localname - do not escape PN_LOCAL_ESC. This is not guaranteed to be legal Turtle. Use withnamespace(java.lang.String)Return an empty string if there is no split point. -
namespaceTTL
Return the 'namespace' (prefix) for a URI string, legal for Turtle and goes withlocalnameTTL(java.lang.String). This operation does not guaratee that the argument has a legal localname. -
localnameTTL
Calculate a localname - enforce legal Turtle escapes for localnames (rule PN_LOCAL_ESC), A final '.' is escaped. Return "" for "no split". Use withnamespaceTTL(java.lang.String) -
splitpoint
Find the URI split point, return the index into the string that is the first character of a legal Turtle local name.This is a pragmatic choice, not just finding the maximal point. For example, with escaping '/' can be included but that means
http://example/path/abccould split to givehttp://example/andpath/abc.Split URN's after ':'.
This function does not enforce the Turtle rule that the final character can not be '.'.
- Parameters:
uri- URI string- Returns:
- The split point, or -1 for "not found".
-
splitXML
Split point, according to XML 1.0 qname rules. This is the longest XML 1.0 NCName at the end of the uri. Return a split at the end of the string if there is no match (e.g. the URI string ends in '/' or '#'). -
splitXML10
Deprecated.Retained as a record of previous split handling.splitXML with local stricter XML 1.0 rules (only single Java characters) -
namespaceXML
Namespace, according to XML 1.0 qname rules. Use withlocalnameXML(java.lang.String). -
localnameXML
Localname, according to XML 1.0 qname rules.
-