} else {
throw new XPathFunctionException("Unexpected argument type: "+args.get(0).getClass());
}
String localName = null, namespaceUri = null, prefix = null;
if (args.get(1) instanceof QNameValue) {
QNameValue qNameValue = (QNameValue) args.get(1);
namespaceUri = qNameValue.getNamespaceURI();
localName = qNameValue.getLocalName();
prefix = qNameValue.getPrefix();
} else if (args.get(1) instanceof List) {
List elmts = (List) args.get(1);
if (elmts.size() != 1) throw new XPathFunctionException(
new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
"The bpws:rename function MUST be passed a single " +
"element node."));
Element nameElmt = (Element) elmts.get(0);
namespaceUri = nameElmt.getNamespaceURI();
localName = nameElmt.getLocalName();
prefix = nameElmt.getPrefix();
} else if (args.get(1) instanceof NodeWrapper) {
Element nameElmt = (Element) ((NodeWrapper) args.get(1)).getUnderlyingNode();
namespaceUri = nameElmt.getNamespaceURI();
localName = nameElmt.getLocalName();
prefix = nameElmt.getPrefix();
} else if (args.get(1) instanceof Element) {
Element nameElmt = (Element) args.get(1);
namespaceUri = nameElmt.getNamespaceURI();
localName = nameElmt.getLocalName();
prefix = nameElmt.getPrefix();
} else if (args.get(1) instanceof String) {
String qName = (String) args.get(1);
if (qName.contains(":")) {
int index = qName.indexOf(":");
prefix = qName.substring(0, index);
localName = qName.substring(index + 1);
} else {
localName = qName;
}
} else if (args.get(1) instanceof QName) {
QName qName = (QName) args.get(1);
namespaceUri = qName.getNamespaceURI();
localName = qName.getLocalPart();
prefix = qName.getPrefix();
} else {
throw new XPathFunctionException("Unexpected argument type: "+args.get(1).getClass());
}
if (namespaceUri == null) {
namespaceUri = targetElmt.lookupNamespaceURI(prefix);
}
elementQName = new QName(namespaceUri, localName, prefix);
if (args.size() > 2) {
if (args.get(2) instanceof QNameValue) {
QNameValue qNameValue = (QNameValue) args.get(2);
namespaceUri = qNameValue.getNamespaceURI();
localName = qNameValue.getLocalName();
prefix = qNameValue.getPrefix();
} else if (args.get(2) instanceof NodeWrapper) {
Element nameElmt = (Element) ((NodeWrapper) args.get(2)).getUnderlyingNode();
namespaceUri = nameElmt.getNamespaceURI();
localName = nameElmt.getLocalName();
prefix = nameElmt.getPrefix();