for (int i=0; i<components.length; i++) {
ItemType it = components[i].getItemType(th);
if (it instanceof NodeTest) {
int possibleNodeKinds = ((NodeTest)it).getNodeKindMask();
if (possibleNodeKinds == 1<<Type.ATTRIBUTE) {
XPathException de = new XPathException("Cannot create an attribute node whose parent is a document node");
de.setErrorCode(isXSLT ? "XTDE0420" : "XPTY0004");
de.setLocator(components[i]);
throw de;
} else if (possibleNodeKinds == 1<<Type.NAMESPACE) {
XPathException de = new XPathException("Cannot create a namespace node whose parent is a document node");
de.setErrorCode(isXSLT ? "XTDE0420" : "XQTY0024");
de.setLocator(components[i]);
throw de;
}
if (possibleNodeKinds == 1<<Type.ELEMENT) {
elementCount++;
if (elementCount > 1 &&
(validation==Validation.STRICT || validation==Validation.LAX || type!=null)) {
XPathException de = new XPathException("A valid document must have only one child element");
if (isXSLT) {
de.setErrorCode("XTTE1550");
} else {
de.setErrorCode("XQDY0061");
}
de.setLocator(components[i]);
throw de;
}
if (validation==Validation.STRICT && components[i] instanceof FixedElement) {
SchemaDeclaration decl = env.getConfiguration().getElementDeclaration(
((FixedElement)components[i]).getNameCode(null) & NamePool.FP_MASK);