docs: private void validateResource(List<ValidationMessage> errors, Element resource, Element element, StructureDefinition profile, IdStatus idstatus, NodeStack stack) throws FHIRException, FHIRException {
  		assert stack != null;
  		assert resource != null;
  
  		// getting going - either we got a profile, or not.
  		boolean ok = true;
  		if (ok) {
  			String resourceName = element.getType();
  			if (profile == null) {
  				long t = System.nanoTime();
  				profile = context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + resourceName);
  				sdTime = sdTime + (System.nanoTime() - t);
  				ok = rule(errors, IssueType.INVALID, element.line(), element.col(), stack.addToLiteralPath(resourceName), profile != null, "No profile found for resource type '" + resourceName + "'");
  			} else {
  				String type = profile.getKind() == StructureDefinitionKind.LOGICAL ? profile.getId() : profile.hasBaseType() && profile.getDerivation() == TypeDerivationRule.CONSTRAINT ? profile.getBaseType() : profile.getName();
  				// special case: we have a bundle, and the profile is not for a bundle. We'll try the first entry instead 
  				if (!type.equals(resourceName) && resourceName.equals("Bundle")) {
  					Element first = getFirstEntry(element);
  					if (first != null && first.getType().equals(type)) {
  						element = first;
  						resourceName = element.getType();
  						idstatus = IdStatus.OPTIONAL; // why?
  					}
  				}
  				ok = rule(errors, IssueType.INVALID, -1, -1, stack.getLiteralPath(), type.equals(resourceName),
  						"Specified profile type was '" + type + "', but found type '" + resourceName + "'");
  			}
  		}
  
  		if (ok) {
  			if (idstatus == IdStatus.REQUIRED && (element.getNamedChild("id") == null))
  				rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), false, "Resource requires an id, but none is present");
  			else if (idstatus == IdStatus.PROHIBITED && (element.getNamedChild("id") != null))
  				rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), false, "Resource has an id, but none is allowed");
  			start(errors, resource, element, profile, stack); // root is both definition and type
  		}
  	}