// Do some basic checks on the URI and name. Try to lookup the URI. See if the name is
// qualified.
if (schemaNS == null || schemaNS.length() == 0)
{
throw new XMPException(
"Schema namespace URI is required", XMPError.BADSCHEMA);
}
if ((rootProp.charAt(0) == '?') || (rootProp.charAt(0) == '@'))
{
throw new XMPException("Top level name must not be a qualifier", XMPError.BADXPATH);
}
if (rootProp.indexOf('/') >= 0 || rootProp.indexOf('[') >= 0)
{
throw new XMPException("Top level name must be simple", XMPError.BADXPATH);
}
String prefix = XMPMetaFactory.getSchemaRegistry().getNamespacePrefix(schemaNS);
if (prefix == null)
{
throw new XMPException("Unregistered schema namespace URI", XMPError.BADSCHEMA);
}
// Verify the various URI and prefix combinations. Initialize the
// expanded XMPPath.
int colonPos = rootProp.indexOf(':');
if (colonPos < 0)
{
// The propName is unqualified, use the schemaURI and associated
// prefix.
verifySimpleXMLName(rootProp); // Verify the part before any colon
return prefix + rootProp;
}
else
{
// The propName is qualified. Make sure the prefix is legit. Use the associated URI and
// qualified name.
// Verify the part before any colon
verifySimpleXMLName(rootProp.substring(0, colonPos));
verifySimpleXMLName(rootProp.substring(colonPos));
prefix = rootProp.substring(0, colonPos + 1);
String regPrefix = XMPMetaFactory.getSchemaRegistry().getNamespacePrefix(schemaNS);
if (regPrefix == null)
{
throw new XMPException("Unknown schema namespace prefix", XMPError.BADSCHEMA);
}
if (!prefix.equals(regPrefix))
{
throw new XMPException("Schema namespace URI and prefix mismatch",
XMPError.BADSCHEMA);
}
return rootProp;
}