diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/HTMLClientLogger.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/HTMLClientLogger.java index 88cf249d8..4096a5dc0 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/HTMLClientLogger.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/HTMLClientLogger.java @@ -67,8 +67,11 @@ public class HTMLClientLogger extends BaseLogger implements ToolingClientLogger file.println("

#"+id+"

"); file.println("
");
     file.println(method+" "+url+" HTTP/1.0");
-    for (String s : headers)  
-      file.println(Utilities.escapeXml(s));
+    if (headers != null) {
+      for (String s : headers) {  
+        file.println(Utilities.escapeXml(s));
+      }
+    }
     if (body != null) {
       file.println("");
       try {
diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java
index 727df9029..54785abcb 100644
--- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java
+++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java
@@ -543,17 +543,19 @@ public class Element extends Base {
   }
 
   public Element getNamedChild(String name) {
-	  if (children == null)
-  		return null;
-	  Element result = null;
-	  for (Element child : children) {
-	  	if (child.getName().equals(name) || (child.getName().length() >  child.fhirType().length() && child.getName().substring(0, child.getName().length() - child.fhirType().length()).equals(name) && child.getProperty().getDefinition().isChoice())) {
-	  		if (result == null)
-	  			result = child;
-	  		else 
-	  			throw new Error("Attempt to read a single element when there is more than one present ("+name+")");
-	  	}
-	  }
+    if (children == null)
+      return null;
+    Element result = null;
+    for (Element child : children) {
+      if (child.getName() != null && name != null && child.getProperty() != null && child.getProperty().getDefinition() != null && child.fhirType() != null) {
+        if (child.getName().equals(name) || (child.getName().length() >  child.fhirType().length() && child.getName().substring(0, child.getName().length() - child.fhirType().length()).equals(name) && child.getProperty().getDefinition().isChoice())) {
+          if (result == null)
+            result = child;
+          else 
+            throw new Error("Attempt to read a single element when there is more than one present ("+name+")");
+        }
+      }
+    }
 	  return result;
 	}
 
diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Manager.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Manager.java
index 513ba88fc..658789419 100644
--- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Manager.java
+++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Manager.java
@@ -79,6 +79,7 @@ public class Manager {
       return null;
     }
 
+    
   }
   
   public static Element parse(IWorkerContext context, InputStream source, FhirFormat inputFormat) throws FHIRFormatError, DefinitionException, IOException, FHIRException {
diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/ParserBase.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/ParserBase.java
index 646322653..a0b12d919 100644
--- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/ParserBase.java
+++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/ParserBase.java
@@ -114,7 +114,7 @@ public abstract class ParserBase {
 	      if(name.equals(sd.getType()) && (ns == null || ns.equals(FormatUtilities.FHIR_NS)) && !ToolingExtensions.hasExtension(sd, "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace"))
 	        return sd;
 	      String sns = ToolingExtensions.readStringExtension(sd, "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace");
-	      if (name.equals(sd.getType()) && ns != null && ns.equals(sns))
+	      if ((name.equals(sd.getType()) || name.equals(sd.getName())) ) && ns != null && ns.equals(sns))
 	        return sd;
 	    }
 	  }
@@ -122,7 +122,7 @@ public abstract class ParserBase {
 	  return null;
   }
 
-	protected StructureDefinition getDefinition(int line, int col, String name) throws FHIRFormatError {
+  protected StructureDefinition getDefinition(int line, int col, String name) throws FHIRFormatError {
     if (name == null) {
       logError(line, col, name, IssueType.STRUCTURE, context.formatMessage(I18nConstants.THIS_CANNOT_BE_PARSED_AS_A_FHIR_OBJECT_NO_NAME), IssueSeverity.FATAL);
       return null;
diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java
index aaf2bf313..a4a14c2bf 100644
--- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java
+++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java
@@ -5170,7 +5170,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
       ok = rule(errors, IssueType.INVALID, element.line(), element.col(), stack.addToLiteralPath(resourceName), defn != null, I18nConstants.VALIDATION_VAL_PROFILE_NODEFINITION, resourceName);
     }
 
-    String type = defn.getKind() == StructureDefinitionKind.LOGICAL ? defn.getId() : defn.getType();
+    String type = defn.getKind() == StructureDefinitionKind.LOGICAL ? defn.getName() : defn.getType();
     // 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)) {
       NodeStack first = getFirstEntry(stack);