*/
public static XMPPath expandXPath(String schemaNS, String path) throws XMPException
{
if (schemaNS == null || path == null)
{
throw new XMPException("Parameter must not be null", XMPError.BADPARAM);
}
XMPPath expandedXPath = new XMPPath();
PathPosition pos = new PathPosition();
pos.path = path;
// Pull out the first component and do some special processing on it: add the schema
// namespace prefix and and see if it is an alias. The start must be a "qualName".
parseRootNode(schemaNS, pos, expandedXPath);
// Now continue to process the rest of the XMPPath string.
while (pos.stepEnd < path.length())
{
pos.stepBegin = pos.stepEnd;
skipPathDelimiter(path, pos);
pos.stepEnd = pos.stepBegin;
XMPPathSegment segment;
if (path.charAt(pos.stepBegin) != '[')
{
// A struct field or qualifier.
segment = parseStructSegment(pos);
}
else
{
// One of the array forms.
segment = parseIndexSegment(pos);
}
if (segment.getKind() == XMPPath.STRUCT_FIELD_STEP)
{
if (segment.getName().charAt(0) == '@')
{
segment.setName("?" + segment.getName().substring(1));
if (!"?xml:lang".equals(segment.getName()))
{
throw new XMPException("Only xml:lang allowed with '@'",
XMPError.BADXPATH);
}
}
if (segment.getName().charAt(0) == '?')
{
pos.nameStart++;
segment.setKind(XMPPath.QUALIFIER_STEP);
}
verifyQualName(pos.path.substring(pos.nameStart, pos.nameEnd));
}
else if (segment.getKind() == XMPPath.FIELD_SELECTOR_STEP)
{
if (segment.getName().charAt(1) == '@')
{
segment.setName("[?" + segment.getName().substring(2));
if (!segment.getName().startsWith("[?xml:lang="))
{
throw new XMPException("Only xml:lang allowed with '@'",
XMPError.BADXPATH);
}
}
if (segment.getName().charAt(1) == '?')