Changeset 2840
- Timestamp:
- 04/26/13 12:33:26 (11 years ago)
- Location:
- SRUClient/trunk/src/main/java/eu/clarin/sru/client
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUSimpleClient.java
r2466 r2840 576 576 577 577 // explainResponse/diagnostics 578 final List<SRUDiagnostic> diagnostics = parseDiagnostics(reader); 578 final List<SRUDiagnostic> diagnostics = 579 parseDiagnostics(reader, strictMode); 579 580 if (diagnostics != null) { 580 581 handler.onDiagnostics(diagnostics); … … 725 726 726 727 // scanResponse/diagnostics 727 final List<SRUDiagnostic> diagnostics = parseDiagnostics(reader); 728 final List<SRUDiagnostic> diagnostics = 729 parseDiagnostics(reader, strictMode); 728 730 if (diagnostics != null) { 729 731 handler.onDiagnostics(diagnostics); … … 872 874 873 875 if (SRU_DIAGNOSTIC_RECORD_SCHEMA.equals(schema)) { 874 surrogate = parseDiagnostic(recordReader, true); 876 surrogate = parseDiagnostic(recordReader, 877 true, strictMode); 875 878 } else { 876 879 SRURecordDataParser parser = findParser(schema); … … 1024 1027 1025 1028 // searchRetrieveResponse/diagnostics 1026 final List<SRUDiagnostic> diagnostics = parseDiagnostics(reader); 1029 final List<SRUDiagnostic> diagnostics = 1030 parseDiagnostics(reader, strictMode); 1027 1031 if (diagnostics != null) { 1028 1032 handler.onDiagnostics(diagnostics); … … 1067 1071 1068 1072 private static List<SRUDiagnostic> parseDiagnostics( 1069 SRUXMLStreamReader reader ) throws XMLStreamException,1070 SRUClientException {1073 SRUXMLStreamReader reader, boolean strictMode) 1074 throws XMLStreamException, SRUClientException { 1071 1075 if (reader.readStart(SRU_NS, "diagnostics", false)) { 1072 1076 List<SRUDiagnostic> diagnostics = null; … … 1074 1078 SRUDiagnostic diagnostic = null; 1075 1079 while ((diagnostic = parseDiagnostic(reader, 1076 (diagnostics == null) )) != null) {1080 (diagnostics == null), strictMode)) != null) { 1077 1081 if (diagnostics == null) { 1078 1082 diagnostics = new ArrayList<SRUDiagnostic>(); … … 1089 1093 1090 1094 private static SRUDiagnostic parseDiagnostic(SRUXMLStreamReader reader, 1091 boolean required) throws XMLStreamException, SRUClientException { 1095 boolean required, boolean stictMode) throws XMLStreamException, 1096 SRUClientException { 1092 1097 if (reader.readStart(SRU_DIAGNOSIC_NS, "diagnostic", required)) { 1093 1098 … … 1096 1101 1097 1102 // diagnostic/details 1098 String details = 1099 reader.readContent(SRU_DIAGNOSIC_NS, "details", false); 1103 String details = reader.readContent(SRU_DIAGNOSIC_NS, "details", 1104 false, stictMode); 1105 if ((details != null) && details.isEmpty()) { 1106 details = null; 1107 logger.warn("omitting empty element <details> " + 1108 "within element <diagnostic>"); 1109 } 1100 1110 1101 1111 // diagnostic/message 1102 String message = 1103 reader.readContent(SRU_DIAGNOSIC_NS, "message", false); 1112 String message = reader.readContent(SRU_DIAGNOSIC_NS, "message", 1113 false, stictMode); 1114 if ((message != null) && message.isEmpty()) { 1115 message = null; 1116 logger.warn("omitting empty element <message> " + 1117 "within element <diagnostic>"); 1118 } 1104 1119 1105 1120 reader.readEnd(SRU_DIAGNOSIC_NS, "diagnostic"); -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUXMLStreamReader.java
r2466 r2840 515 515 String readContent(String namespaceURI, String localName, boolean required) 516 516 throws XMLStreamException { 517 return readContent(namespaceURI, localName, required, true); 518 } 519 520 521 String readContent(String namespaceURI, String localName, boolean required, 522 boolean contentRequired) throws XMLStreamException { 517 523 String result = null; 518 524 if (readStart(namespaceURI, localName, required)) { 519 525 try { 520 result = readString(true); 526 result = readString(contentRequired); 527 if (!contentRequired && (result == null)) { 528 result = ""; 529 } 521 530 } catch (XMLStreamException e) { 522 531 StringBuilder sb = new StringBuilder();
Note: See TracChangeset
for help on using the changeset viewer.