Revision 1409
Added by Jing Tao almost 22 years ago
src/edu/ucsb/nceas/metacat/MetaCatServlet.java | ||
---|---|---|
122 | 122 |
private static final String ERROR = "<error>"; |
123 | 123 |
private static final String ERRORCLOSE = "</error>"; |
124 | 124 |
public static final String SCHEMALOCATIONKEYWORD = "xsi:schemaLocation"; |
125 |
public static final String EML2KEYWORD ="<eml:eml"; |
|
125 | 126 |
|
126 | 127 |
/** |
127 | 128 |
* Initialize the servlet by creating appropriate database connections |
... | ... | |
1378 | 1379 |
} |
1379 | 1380 |
else if (needSchemaValidation(doctext[0])) |
1380 | 1381 |
{ |
1381 |
// set schema base validation parser |
|
1382 |
String rule = DocumentImpl.SCHEMA; |
|
1383 |
documentWrapper = new DocumentImplWrapper(rule, true); |
|
1382 |
// for eml2 |
|
1383 |
if (needEml2Validation(doctext[0])) |
|
1384 |
{ |
|
1385 |
// set eml2 base validation parser |
|
1386 |
String rule = DocumentImpl.EML2; |
|
1387 |
documentWrapper = new DocumentImplWrapper(rule, true); |
|
1388 |
} |
|
1389 |
else |
|
1390 |
{ |
|
1391 |
// set schema base validation parser |
|
1392 |
String rule = DocumentImpl.SCHEMA; |
|
1393 |
documentWrapper = new DocumentImplWrapper(rule, true); |
|
1394 |
} |
|
1384 | 1395 |
} |
1385 | 1396 |
else |
1386 | 1397 |
{ |
... | ... | |
1552 | 1563 |
|
1553 | 1564 |
} |
1554 | 1565 |
|
1566 |
/* check if the xml string contains key words to specify schema loocation*/ |
|
1567 |
private boolean needEml2Validation(String xml) |
|
1568 |
{ |
|
1569 |
boolean needEml2Validate =false; |
|
1570 |
if (xml == null) |
|
1571 |
{ |
|
1572 |
MetaCatUtil.debugMessage("Validation for schema is " + |
|
1573 |
needEml2Validate, 10); |
|
1574 |
return needEml2Validate; |
|
1575 |
} |
|
1576 |
else if (xml.indexOf(EML2KEYWORD) != -1) |
|
1577 |
{ |
|
1578 |
// if contains schema location key word, should be validate |
|
1579 |
needEml2Validate = true; |
|
1580 |
} |
|
1581 |
|
|
1582 |
MetaCatUtil.debugMessage("Validation for schema is " + |
|
1583 |
needEml2Validate, 10); |
|
1584 |
return needEml2Validate; |
|
1585 |
|
|
1586 |
} |
|
1587 |
|
|
1555 | 1588 |
// DELETE SECTION |
1556 | 1589 |
/** |
1557 | 1590 |
* Handle the database delete request and delete an XML document |
Also available in: Unified diff
Set a condition to for setting eml2 parser.