For question number 1, the signature is misleading: while it looks like valueOf()
is defined by OWL2Datatype
, it is actually defined for Enum
- all java enumerations get it, and the string that will work for its argument is "XSD_STRING"
, i.e., the actual name of the variable in the enumeration.
For question number 2, the problem is that xsd is a well known namespace abbreviation but it's still arbitrary - in order to translate to the full IRI for the datatype you would need a ShortFormProvider to reverse the mapping. I can see that this would be a useful function to have but I'm not sure that it is offered at the moment. I'll raise an issue for it.
This has been added to the OWLAPI and now there are two methods to do what you need, illustrated in this test:
@Test
public void shouldParseXSDSTRING() {
// given
OWLDataFactory df = OWLManager.getOWLDataFactory();
String s = "xsd:string";
// when
XSDVocabulary v = XSDVocabulary.parseShortName(s);
// then
assertEquals(XSDVocabulary.STRING, v);
assertEquals(OWL2Datatype.XSD_STRING.getDatatype(df),
df.getOWLDatatype(v.getIRI()));
}
So, one way is through OWL2Datatype and an OWLDataFactory:
OWLDatatype string = OWL2Datatype.XSD_STRING.getDatatype(df)
And another is with XSDVocabulary and an OWLDataFactory:
OWLDatatype string = df.getOWLDatatype(XSDVocabulary.parseShortName("xsd:string"));