Project

General

Profile

« Previous | Next » 

Revision 3002

Added by sgarg about 18 years ago

Fix for a bug in MetacatServlet. Metacat assumed that it is supposed to get the schema information from the second line of the document. This is based
on the assumption that xml decleration will always be present. This is good practice but not required. Hence the fix -> Metacat should ignore the
xml declerations and then get the first line.

View differences:

src/edu/ucsb/nceas/metacat/MetaCatServlet.java
2170 2170
        int count = 0;
2171 2171
        int endIndex = 0;
2172 2172
        int startIndex = 0;
2173
        final int TARGETNUM = 2;
2173
        final int TARGETNUM = 1;
2174 2174
        StringBuffer buffer = new StringBuffer();
2175 2175
        boolean comment = false;
2176
        boolean processingInstruction = false;
2176 2177
        char thirdPreviousCharacter = '?';
2177 2178
        char secondPreviousCharacter = '?';
2178 2179
        char previousCharacter = '?';
......
2192 2193
                comment = false;
2193 2194
            }
2194 2195

  
2195
            //this is not comment
2196
            if (currentCharacter != '!' && previousCharacter == '<' && !comment) {
2196
            //in a processingInstruction
2197
            if (currentCharacter == '?' && previousCharacter == '<') {
2198
            	processingInstruction = true;
2199
            }
2200
            
2201
            //out of processingInstruction
2202
            if (processingInstruction && currentCharacter == '>' 
2203
            	&& previousCharacter == '?') {
2204
            	processingInstruction = false;
2205
            }
2206
            
2207
            //this is not comment or a processingInstruction
2208
            if (currentCharacter != '!' && previousCharacter == '<' 
2209
            	&& !comment && !processingInstruction) {
2197 2210
                count++;
2198 2211
            }
2212
            
2199 2213
            // get target line
2200 2214
            if (count == TARGETNUM && currentCharacter != '>') {
2201 2215
                buffer.append(currentCharacter);
......
2219 2233
    {
2220 2234
        Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
2221 2235
        String prefix = null;
2236
        
2222 2237
        if(schemaLine.indexOf(" ") > 0){
2223 2238
            String rootElement = "";
2224 2239
            try {
......
2233 2248
                prefix = rootElement.substring(rootElement.indexOf(":") + 1,
2234 2249
                    rootElement.length());
2235 2250
            }
2236

  
2251
            
2237 2252
            if(prefix != null){
2238 2253
                return prefix.trim();
2239 2254
            }

Also available in: Unified diff