Revision 1804
Added by Jing Tao over 21 years ago
src/edu/ucsb/nceas/metacat/DocumentImpl.java | ||
---|---|---|
94 | 94 |
MetaCatUtil.getOption("eml2namespace"); |
95 | 95 |
// "eml://ecoinformatics.org/eml-2.0.0"; |
96 | 96 |
|
97 |
|
|
97 |
public static final String DOCNAME = "docname"; |
|
98 |
public static final String PUBLICID = "publicid"; |
|
99 |
public static final String SYSTEMID = "systemid"; |
|
98 | 100 |
static final int ALL = 1; |
99 | 101 |
static final int WRITE = 2; |
100 | 102 |
static final int READ = 4; |
... | ... | |
853 | 855 |
{ |
854 | 856 |
// flag for process eml2 |
855 | 857 |
boolean proccessEml2 = false; |
858 |
boolean storedDTD = false;//flag to inidate publicid or system |
|
859 |
// id stored in db or not |
|
860 |
boolean firstElement = true; |
|
861 |
String dbDocName = null; |
|
862 |
String dbPublicID = null; |
|
863 |
String dbSystemID = null; |
|
864 |
|
|
856 | 865 |
if (doctype != null && doctype.equals(EMLNAMESPACE)) |
857 | 866 |
{ |
858 | 867 |
proccessEml2 = true; |
... | ... | |
940 | 949 |
|
941 | 950 |
// Handle the DOCUMENT node |
942 | 951 |
if (currentNode.nodetype.equals("DOCUMENT")) { |
943 |
out.println("<?xml version=\"1.0\"?>"); |
|
944 |
if (docname != null && validateType != null && validateType.equals(DTD)) |
|
945 |
{ |
|
946 |
if ((doctype != null) && (system_id != null)) |
|
947 |
{ |
|
948 |
|
|
949 |
out.println("<!DOCTYPE " + docname + " PUBLIC \"" + doctype + |
|
950 |
"\" \"" + system_id + "\">"); |
|
951 |
} |
|
952 |
else |
|
953 |
{ |
|
954 |
|
|
955 |
out.println("<!DOCTYPE " + docname + ">"); |
|
956 |
} |
|
957 |
} |
|
952 |
out.print("<?xml version=\"1.0\"?>"); |
|
953 |
|
|
958 | 954 |
|
959 | 955 |
// Handle the ELEMENT nodes |
960 | 956 |
} else if (currentNode.nodetype.equals("ELEMENT")) { |
... | ... | |
965 | 961 |
out.print(">"); |
966 | 962 |
} |
967 | 963 |
} |
964 |
|
|
965 |
// if publicid or system is not stored into db send it out by default |
|
966 |
if ( !storedDTD & firstElement ) |
|
967 |
{ |
|
968 |
if (docname != null && validateType != null && validateType.equals(DTD)) |
|
969 |
{ |
|
970 |
if ((doctype != null) && (system_id != null)) |
|
971 |
{ |
|
972 |
|
|
973 |
out.print("<!DOCTYPE " + docname + " PUBLIC \"" + doctype + |
|
974 |
"\" \"" + system_id + "\">"); |
|
975 |
} |
|
976 |
else |
|
977 |
{ |
|
978 |
|
|
979 |
out.print("<!DOCTYPE " + docname + ">"); |
|
980 |
} |
|
981 |
} |
|
982 |
} |
|
983 |
firstElement = false; |
|
968 | 984 |
openElements.push(currentNode); |
969 | 985 |
util.debugMessage("\n PUSHED: " + currentNode.nodename, 50); |
970 | 986 |
previousNodeWasElement = true; |
... | ... | |
1054 | 1070 |
out.print("<?" + currentNode.nodename + " " + |
1055 | 1071 |
currentNode.nodedata + "?>"); |
1056 | 1072 |
previousNodeWasElement = false; |
1057 |
|
|
1073 |
// Handle the DTD nodes (docname, publicid, systemid) |
|
1074 |
} else if (currentNode.nodetype.equals(DTD)) { |
|
1075 |
storedDTD = true; |
|
1076 |
if (currentNode.getNodeName().equals(DOCNAME)) |
|
1077 |
{ |
|
1078 |
dbDocName = currentNode.getNodeData(); |
|
1079 |
} |
|
1080 |
if (currentNode.getNodeName().equals(PUBLICID)) |
|
1081 |
{ |
|
1082 |
dbPublicID = currentNode.getNodeData(); |
|
1083 |
} |
|
1084 |
if (currentNode.getNodeName().equals(SYSTEMID)) |
|
1085 |
{ |
|
1086 |
dbSystemID = currentNode.getNodeData(); |
|
1087 |
// send out <!doctype .../> |
|
1088 |
if (dbDocName != null ) |
|
1089 |
{ |
|
1090 |
if ((dbPublicID!= null) && (dbSystemID != null)) |
|
1091 |
{ |
|
1092 |
|
|
1093 |
out.print("<!DOCTYPE " + dbDocName+" PUBLIC \""+dbPublicID + |
|
1094 |
"\" \"" + dbSystemID + "\">"); |
|
1095 |
} |
|
1096 |
else |
|
1097 |
{ |
|
1098 |
|
|
1099 |
out.print("<!DOCTYPE " + dbDocName + ">"); |
|
1100 |
} |
|
1101 |
} |
|
1102 |
|
|
1103 |
//reset these variable |
|
1104 |
dbDocName = null; |
|
1105 |
dbPublicID = null; |
|
1106 |
dbSystemID = null; |
|
1107 |
} |
|
1108 |
|
|
1058 | 1109 |
// Handle any other node type (do nothing) |
1059 | 1110 |
} else { |
1060 | 1111 |
// Any other types of nodes are not handled. |
Also available in: Unified diff
in toxml method, add new code to handle dtd.