for (Item pair : prefixes)
{
if ( !pair.isList() || pair.getList().size() != 2 )
BuilderLib.broken(pair, "Not a prefix/IRI pair") ;
Item prefixItem = pair.getList().get(0) ;
Item iriItem = pair.getList().get(1) ;
// Maybe a Node (fake prefixed name) or a Symbol, depending on parser set up.
String prefix = null ;
// -- Prefix as symbol
if ( prefixItem.isSymbol() )
prefix = prefixItem.getSymbol() ;
// -- Prefix as Node
// if ( prefixItem.isNode())
// {
// Node n = prefixItem.getNode() ;
// if ( ! n.isURI() )
// BuilderBase.broken(pair, "Prefix part is not a prefixed name: "+pair) ;
//
// prefix = n.getURI();
// // It will look like :x:
//
// if ( ! prefix.startsWith(":") )
// BuilderBase.broken(pair, "Prefix part is not a prefix name: "+pair) ;
// prefix = prefix.substring(1) ;
// }
if ( prefix == null )
BuilderLib.broken(pair, "Prefix part not recognized: "+prefixItem) ;
if ( ! prefix.endsWith(":") )
BuilderLib.broken(pair, "Prefix part does not end with a ':': "+pair) ;
prefix = prefix.substring(0, prefix.length()-1) ;
if ( StrUtils.contains(prefix, ":") )
BuilderLib.broken(pair, "Prefix itself contains a ':' : "+pair) ;
// -- /Prefix
Node iriNode = iriItem.getNode() ;
if ( iriNode == null || ! iriNode.isURI() )
BuilderLib.broken(pair, "Not an IRI: "+iriItem) ;
String iri = iriNode.getURI();