diff servlet/src/digilib/io/XMLMetaLoader.java @ 139:11cfe4c89fdc

Servlet version 1.11b1 with improved original-size. - fixed lots of bugs in metadata handling.
author robcast
date Thu, 31 Jul 2003 20:56:51 +0200
parents c36944be0b58
children bc8df0133c04
line wrap: on
line diff
--- a/servlet/src/digilib/io/XMLMetaLoader.java	Sat Jul 12 01:26:56 2003 +0200
+++ b/servlet/src/digilib/io/XMLMetaLoader.java	Thu Jul 31 20:56:51 2003 +0200
@@ -56,9 +56,22 @@
 		private String fileName;
 		private String filePath;
 
-		//		public HashMap getData() {
-		//			return meta;
-		//		}
+		/**
+		 * extracts the elements name from either localName ln or qName qn.
+		 * 
+		 * @param ln localName
+		 * @param qn qName
+		 * @return element name
+		 */
+		private String getName(String ln, String qn) {
+			if (ln != null) {
+				if (ln.length() > 0) {
+					return ln;
+				}
+			}
+			// else it's qName (or nothing)
+			return qn;
+		}
 
 		// Parser calls this once at the beginning of a document
 		public void startDocument() throws SAXException {
@@ -74,7 +87,7 @@
 			Attributes atts)
 			throws SAXException {
 
-			String name = (localName != null) ? localName : qName;
+			String name = getName(localName, qName);
 			// open a new tag
 			tags.addLast(name);
 			// start new content (no nesting of tags and content)
@@ -87,6 +100,7 @@
 				// new file tag
 				fileName = null;
 				filePath = null;
+				meta = new HashMap();
 			}
 		}
 
@@ -104,7 +118,7 @@
 			String qName)
 			throws SAXException {
 				
-			String name = (localName != null) ? localName : qName;
+			String name = getName(localName, qName);
 			// exit the tag
 			tags.removeLast();