diff src/de/mpiwg/itgroup/eSciDoc/utils/eSciDocXmlObject.java @ 8:a844f6948dd8

?nderungen im Walker tools f?r pubman
author dwinter
date Mon, 14 May 2012 09:58:45 +0200
parents 58b52df9763c
children 7c7bce334b6f
line wrap: on
line diff
--- a/src/de/mpiwg/itgroup/eSciDoc/utils/eSciDocXmlObject.java	Sat Jan 15 17:05:29 2011 +0100
+++ b/src/de/mpiwg/itgroup/eSciDoc/utils/eSciDocXmlObject.java	Mon May 14 09:58:45 2012 +0200
@@ -53,12 +53,14 @@
 		try {
 			dom = builder.build(template);
 			
-			xpath = EScidocTools.getESciDocXpath("//prop:pid");
+			if (pid!=null){
+				xpath = EScidocTools.getESciDocXpath("//prop:pid");
 			
-			Element test = (Element) xpath.selectSingleNode(dom);
+				Element test = (Element) xpath.selectSingleNode(dom);
 				
-			test.setText(pid);
-			this.pid=pid;
+				test.setText(pid);
+				this.pid=pid;
+			}
 		} catch (JDOMException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
@@ -483,7 +485,22 @@
 		
 		XPath xp = EScidocTools.getESciDocXpath("./@xlink:href");
 		Attribute href = (Attribute) xp.selectSingleNode(el);
-	    return href.getValue();
+		
+	
+		return href.getValue();
+		
+	}
+	
+	public String getESciDocObjId() throws JDOMException {
+		
+		Element el = dom.getRootElement();
+		
+		XPath xp = EScidocTools.getESciDocXpath("./@objid");
+		Attribute href = (Attribute) xp.selectSingleNode(el);
+		
+	
+		return href.getValue();
+		
 	}
 
 	public void setContentModel(String href) throws JDOMException {
@@ -512,22 +529,21 @@
 		try {
 			XPath xp = EScidocTools.getESciDocXpath(".//escidocItem:item/@last-modification-date");
 			item = (Attribute)xp.selectSingleNode(dom);
+			if (item==null){
+				xp = EScidocTools.getESciDocXpath(".//escidocItem:item");
+				Element element = (Element)xp.selectSingleNode(dom);
+				element.setAttribute("last-modification-date", lastModificationDateOld);
+			}
+			else {
+				item.setValue(lastModificationDateOld);	
+			}
 			
-		
-		if (item==null) {//existiert noch nicht}
-			//Namespace namespace = Namespace.getNamespace("item",EScidocTools.item);
-			xp = EScidocTools.getESciDocXpath(".//escidocItem:item");
-			Element itemElement = (Element)xp.selectSingleNode(dom);
-			itemElement.setAttribute("last-modification-date", lastModificationDateOld);
-			
-			
-		} else {
-		item.setValue(lastModificationDateOld);
-		}
 		} catch (JDOMException e) {
 			e.printStackTrace();
 			throw new ESciDocXmlObjectException();
 		}
+		
+	
 
 		
 	}