You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by st...@apache.org on 2013/09/24 14:53:40 UTC

svn commit: r1525874 - in /sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui: ./ META-INF/ lib/ src/org/apache/sling/ide/eclipse/ui/nav/model/

Author: stefanegli
Date: Tue Sep 24 12:53:40 2013
New Revision: 1525874

URL: http://svn.apache.org/r1525874
Log:
SLING-3101 : decentXml-integration done: changes in .content.xml are now minimal - to improve usability of team-notification-mails, etc

Added:
    sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/lib/
    sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/lib/decentxml-1.4.jar   (with props)
    sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/TolerantXMLTokenizer.java   (with props)
Modified:
    sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/META-INF/MANIFEST.MF
    sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/build.properties
    sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/DirNode.java
    sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/GenericJcrRootFile.java
    sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java
    sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/LinkHelper.java
    sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/ModifiableProperties.java

Modified: sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/META-INF/MANIFEST.MF?rev=1525874&r1=1525873&r2=1525874&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/META-INF/MANIFEST.MF (original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/META-INF/MANIFEST.MF Tue Sep 24 12:53:40 2013
@@ -5,12 +5,14 @@ Bundle-SymbolicName: org.apache.sling.id
 Bundle-Activator: org.apache.sling.ide.eclipse.ui.internal.Activator
 Bundle-Version: 0.0.1.qualifier
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Bundle-ClassPath: .
+Bundle-ClassPath: .,
+ lib/decentxml-1.4.jar
 Import-Package: org.apache.commons.httpclient;version="3.1.0",
  org.apache.commons.httpclient.auth;version="3.1.0",
  org.apache.commons.httpclient.methods;version="3.1.0",
  org.apache.commons.httpclient.methods.multipart;version="3.1.0",
  org.apache.commons.httpclient.params;version="3.1.0",
+ org.apache.commons.io;version="2.0.1",
  org.apache.jackrabbit.util,
  org.apache.sling.ide.eclipse.core,
  org.apache.sling.ide.filter,

Modified: sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/build.properties
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/build.properties?rev=1525874&r1=1525873&r2=1525874&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/build.properties (original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/build.properties Tue Sep 24 12:53:40 2013
@@ -2,5 +2,6 @@ bin.includes = plugin.xml,\
                META-INF/,\
                .,\
                icons/,\
-               OSGI-INF/
+               OSGI-INF/,\
+               lib/decentxml-1.4.jar
 source.. = src/

Added: sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/lib/decentxml-1.4.jar
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/lib/decentxml-1.4.jar?rev=1525874&view=auto
==============================================================================
Binary file - no diff available.

Propchange: sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/lib/decentxml-1.4.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/DirNode.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/DirNode.java?rev=1525874&r1=1525873&r2=1525874&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/DirNode.java (original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/DirNode.java Tue Sep 24 12:53:40 2013
@@ -24,7 +24,8 @@ import org.eclipse.core.resources.IConta
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IResource;
-import org.w3c.dom.Node;
+
+import de.pdark.decentxml.Element;
 
 public class DirNode extends JcrNode {
 	
@@ -66,7 +67,7 @@ public class DirNode extends JcrNode {
 		return true;
 	}
 	
-	DirNode(JcrNode parent, Node domNode, IResource resource) {
+	DirNode(JcrNode parent, Element domNode, IResource resource) {
 		super(parent, domNode, resource);
 		if (!isDirNode(resource)) {
 			throw new IllegalArgumentException("resource is not a DirNode: "+resource);

Modified: sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/GenericJcrRootFile.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/GenericJcrRootFile.java?rev=1525874&r1=1525873&r2=1525874&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/GenericJcrRootFile.java (original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/GenericJcrRootFile.java Tue Sep 24 12:53:40 2013
@@ -17,38 +17,35 @@
 package org.apache.sling.ide.eclipse.ui.nav.model;
 
 import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.Iterator;
 import java.util.List;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
 
+import org.apache.commons.io.IOUtils;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.NullProgressMonitor;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
 
+import de.pdark.decentxml.Document;
+import de.pdark.decentxml.Element;
+import de.pdark.decentxml.XMLParser;
+import de.pdark.decentxml.XMLSource;
+import de.pdark.decentxml.XMLStringSource;
+import de.pdark.decentxml.XMLTokenizer;
+import de.pdark.decentxml.XMLTokenizer.Type;
+
 /** WIP: model object for a [.content.xml] shown in the content package view in project explorer **/
 public class GenericJcrRootFile extends JcrNode {
 
 	final IFile file;
 	private final Document document;
 
-	public GenericJcrRootFile(JcrNode parent, IFile file) throws ParserConfigurationException, SAXException, IOException, CoreException {
+	public GenericJcrRootFile(JcrNode parent, final IFile file) throws ParserConfigurationException, SAXException, IOException, CoreException {
 		if (file==null) {
 			throw new IllegalArgumentException("file must not be null");
 		}
@@ -58,11 +55,20 @@ public class GenericJcrRootFile extends 
 			throw new IllegalArgumentException("parent must not be null");
 		}
 		this.parent = parent;
-		this.domNode = null;
+		this.domElement = null;
 		
-		DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
-		this.document = docBuilder.parse(file.getContents());
-		handleJcrRoot(this.document.getFirstChild());
+		XMLParser parser = new XMLParser () {
+			@Override
+			protected XMLTokenizer createTokenizer(XMLSource source) {
+				XMLTokenizer tolerantTokenizerIgnoringEntities = new TolerantXMLTokenizer(source, file);
+				tolerantTokenizerIgnoringEntities.setTreatEntitiesAsText (this.isTreatEntitiesAsText());
+		        return tolerantTokenizerIgnoringEntities;
+			}
+		};
+		InputStream in = file.getContents();
+		String xml = IOUtils.toString(in);
+		this.document = parser.parse (new XMLStringSource (xml));	
+		handleJcrRoot(this.document.getRootElement());
 	}
 	
 	@Override
@@ -78,29 +84,30 @@ public class GenericJcrRootFile extends 
 		}
 		return false;
 	}
-
-	private void handleJcrRoot(Node domNode) {
-		NodeList children = domNode.getChildNodes();
+	
+	private void handleJcrRoot(Element element) {
+		List<Element> children = element.getChildren();
 		final JcrNode effectiveParent;
 		if (isRootContentXml()) {
 			if (parent instanceof DirNode) {
 				DirNode dirNodeParent = (DirNode)parent;
 				JcrNode dirNodeParentParent = dirNodeParent.getParent();
 				JcrNode effectiveSibling = dirNodeParent.getEffectiveSibling();
-				handleProperties(domNode, effectiveSibling.properties);
+				handleProperties(element, effectiveSibling.properties);
 				effectiveParent = parent;
 				dirNodeParentParent.hide(parent);
 			} else {
-				handleProperties(domNode, parent.properties);
+				handleProperties(element, parent.properties);
 				effectiveParent = parent;
 			}
 		} else {
-			handleProperties(domNode, properties);
+			handleProperties(element, properties);
 			effectiveParent = this;
 			parent.addChild(this);
 		}
-		for(int i=0; i<children.getLength(); i++) {
-			handleChild(effectiveParent, children.item(i));
+		for (Iterator<Element> it = children.iterator(); it.hasNext();) {
+			Element aChild = it.next();
+			handleChild(effectiveParent, aChild);
 		}
 	}
 
@@ -108,7 +115,7 @@ public class GenericJcrRootFile extends 
 		return file.getName().equals(".content.xml");
 	}
 	
-	private void handleProperties(Node domNode, ModifiableProperties properties) {
+	private void handleProperties(Element domNode, ModifiableProperties properties) {
 		properties.setNode(this, domNode);
 //		NamedNodeMap attributes = domNode.getAttributes();
 //		for(int i=0; i<attributes.getLength(); i++) {
@@ -143,16 +150,17 @@ public class GenericJcrRootFile extends 
 		}
 	}
 
-	private void handleChild(JcrNode parent, Node domNode) {
-		if (domNode.getNodeType() == Node.TEXT_NODE) {
+	private void handleChild(JcrNode parent, Element domNode) {
+		if (domNode.getType() == Type.TEXT) {
 			// ignore
 			return;
 		}
 		JcrNode childJcrNode = new JcrNode(parent, domNode, this, null);
 		handleProperties(domNode, childJcrNode.properties);
-		NodeList children = domNode.getChildNodes();
-		for(int i=0; i<children.getLength(); i++) {
-			handleChild(childJcrNode, children.item(i));
+		List<Element> children = domNode.getChildren();
+		for (Iterator<Element> it = children.iterator(); it.hasNext();) {
+			Element element = it.next();
+			handleChild(childJcrNode, element);
 		}
 	}
 
@@ -186,28 +194,13 @@ public class GenericJcrRootFile extends 
 	
 	@Override
 	public void createChild(String nodeName) {
-		Element element = document.createElement(nodeName);
-		element.setAttribute("jcr:primaryType", "nt:unstructured");
-		Node childDomNode = document.getFirstChild().appendChild(element);
-		JcrNode childNode = new JcrNode(this, childDomNode, null);
-		underlying.save();
+		createChild(nodeName, document.getRootElement());
 	}
 	
 	public void save() {
 		try {
-			TransformerFactory transformerFactory = TransformerFactory.newInstance();
-			Transformer transformer = transformerFactory.newTransformer();
-			DOMSource source = new DOMSource(document);
-			ByteArrayOutputStream out = new ByteArrayOutputStream();
-			StreamResult result = new StreamResult(out);
-			transformer.transform(source, result);
-			file.setContents(new ByteArrayInputStream(out.toByteArray()), true, true, new NullProgressMonitor());
-		} catch (TransformerConfigurationException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		} catch (TransformerException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
+			String xml = document.toXML();
+			file.setContents(new ByteArrayInputStream(xml.getBytes()), true, true, new NullProgressMonitor());
 		} catch (CoreException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();

Modified: sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java?rev=1525874&r1=1525873&r2=1525874&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java (original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java Tue Sep 24 12:53:40 2013
@@ -34,7 +34,6 @@ import org.apache.jackrabbit.util.ISO907
 import org.apache.sling.ide.eclipse.core.ISlingLaunchpadServer;
 import org.apache.sling.ide.eclipse.core.ProjectUtil;
 import org.apache.sling.ide.eclipse.ui.WhitelabelSupport;
-import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
@@ -57,13 +56,18 @@ import org.eclipse.ui.model.WorkbenchLab
 import org.eclipse.ui.views.properties.IPropertySource;
 import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
 import org.eclipse.wst.server.core.IServer;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
 import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
 
+import de.pdark.decentxml.Element;
+import de.pdark.decentxml.Namespace;
+import de.pdark.decentxml.Node;
+import de.pdark.decentxml.Text;
+import de.pdark.decentxml.XMLParseException;
+import de.pdark.decentxml.XMLTokenizer.Type;
+
 /** WIP: model object for a jcr node shown in the content package view in project explorer **/
 public class JcrNode implements IAdaptable {
 
@@ -101,7 +105,7 @@ public class JcrNode implements IAdaptab
 
 	final List<JcrNode> children = new LinkedList<JcrNode>();
 
-	Node domNode;
+	Element domElement;
 
 	private IResource resource;
 	
@@ -120,18 +124,18 @@ public class JcrNode implements IAdaptab
 		}
 	}
 	
-	JcrNode(JcrNode parent, Node domNode, IResource resource) {
-		this(parent, domNode, parent.underlying, resource);
+	JcrNode(JcrNode parent, Element domElement, IResource resource) {
+		this(parent, domElement, parent.underlying, resource);
 	}
 	
 	
-	JcrNode(JcrNode parent, Node domNode, GenericJcrRootFile underlying, IResource resource) {
+	JcrNode(JcrNode parent, Element domElement, GenericJcrRootFile underlying, IResource resource) {
 		if (parent == null) {
 			throw new IllegalArgumentException("parent must not be null");
 		}
 		this.parent = parent;
-		// domNode can be null
-		this.domNode = domNode;
+		// domElement can be null
+		this.domElement = domElement;
 		this.underlying = underlying;
 		this.resource = resource;
 		parent.addChild(this);
@@ -139,26 +143,26 @@ public class JcrNode implements IAdaptab
 	
 	@Override
 	public String toString() {
-		return "JcrNode[dom:"+domNode+", file:"+resource+", jcrPath:"+getJcrPath()+"]";
+		return "JcrNode[dom:"+domElement+", file:"+resource+", jcrPath:"+getJcrPath()+"]";
 	}
 	
 	@Override
 	public int hashCode() {
 		if (underlying==null) {
 			if (resource==null) {
-				if (domNode==null) {
+				if (domElement==null) {
 					return toString().hashCode();
 				} else {
-					return domNode.toString().hashCode() + parent.hashCode();
+					return domElement.toString().hashCode() + parent.hashCode();
 				}
 			} else {
 				return resource.getFullPath().hashCode();
 			}
 		} else {
-			if (domNode==null) {
+			if (domElement==null) {
 				return underlying.hashCode();
 			}
-			return underlying.hashCode() + domNode.toString().hashCode();
+			return underlying.hashCode() + domElement.toString().hashCode();
 		}
 	}
 	
@@ -194,7 +198,7 @@ public class JcrNode implements IAdaptab
 			if (!parent.equals(other.parent)) {
 				return false;
 			}
-			return domNode.toString().equals(other.domNode.toString());
+			return domElement.toString().equals(other.domElement.toString());
 		}
 		return toString().equals(obj.toString());
 	}
@@ -217,10 +221,10 @@ public class JcrNode implements IAdaptab
 
 	/** shown in the navigator (project explorer) as the label of this element **/
 	public String getLabel() {
-		if (domNode!=null && resource!=null) {
-			return ISO9075.decode(domNode.getNodeName());// + "[domnode+file]";
-		} else if (domNode!=null && resource==null) {
-			return ISO9075.decode(domNode.getNodeName());// + "[domnode]";
+		if (domElement!=null && resource!=null) {
+			return ISO9075.decode(getDomName());// + "[domnode+file]";
+		} else if (domElement!=null && resource==null) {
+			return ISO9075.decode(getDomName());// + "[domnode]";
 		} else if (resource!=null) {
 			return resource.getName();//+" [file]";
 		} else {
@@ -273,13 +277,13 @@ public class JcrNode implements IAdaptab
 		if (children.size()!=0) {
 			return false;
 		}
-		if (domNode==null) {
+		if (domElement==null) {
 			return true;
 		}
-		if (domNode.hasChildNodes()) {
+		if (domElement.hasChildren()) {
 			return false;
 		}
-		if (domNode.getAttributes().getLength()!=0) {
+		if (domElement.getAttributes().size()!=0) {
 			return false;
 		}
 		return true;
@@ -334,9 +338,9 @@ public class JcrNode implements IAdaptab
 						IResource iResource = (IResource) it.next();
 						JcrNode node;
 						if (DirNode.isDirNode(iResource)) {
-							node = new DirNode(this, (Node)null, iResource);
+							node = new DirNode(this, (Element)null, iResource);
 						} else {
-							node = new JcrNode(this, (Node)null, iResource);
+							node = new JcrNode(this, (Element)null, iResource);
 						}
 						childrenNames.add(node.getName());
 						newNodes.add(node);
@@ -468,14 +472,26 @@ public class JcrNode implements IAdaptab
 	}
 
 	public String getName() {
-		if (domNode!=null) {
-			return ISO9075.decode(domNode.getNodeName());
+		if (domElement!=null) {
+			return ISO9075.decode(getDomName());
 		} else if (resource!=null) {
 			return resource.getName();
 		} else {
 			return "";
 		}
 	}
+
+	private String getDomName() {
+		String domName = domElement.getName();
+		Namespace ns = domElement.getNamespace();
+		if (ns!=null) {
+			String prefix = ns.getPrefix();
+			if (!prefix.isEmpty()) {
+				domName = prefix + ":" + domName;
+			}
+		}
+		return domName;
+	}
 		
 	String getJcrPath() {
 		String prefix;
@@ -514,10 +530,10 @@ public class JcrNode implements IAdaptab
 					}
 					final JcrNode node = (JcrNode)target;
 					if ("domNode".equals(name)) {
-						return node.domNode!=null;	
+						return node.domElement!=null;	
 					}
 					if ("nonDomNode".equals(name)) {
-						return node.domNode==null;	
+						return node.domElement==null;	
 					}
 					if ("browseableNode".equals(name)) {
 						return node.isBrowsable();
@@ -624,7 +640,13 @@ public class JcrNode implements IAdaptab
 		if (resource instanceof IFile) {
 //			if (!isVaultFile(resource)) {
 			return (IFile)resource;
-		} else if (underlying!=null && underlying.file!=null && domNode!=null) {
+		} else if (underlying!=null && underlying.file!=null && domElement!=null) {
+			if (properties!=null) {
+				GenericJcrRootFile propUnderlying = properties.getUnderlying();
+				if (propUnderlying!=null) {
+					return propUnderlying.file;
+				}
+			}
 			return underlying.file;
 		} else {
 			return null;
@@ -632,8 +654,8 @@ public class JcrNode implements IAdaptab
 	}
 
 	public void rename(String string) {
-		if (domNode!=null && underlying!=null) {
-			domNode.getOwnerDocument().renameNode(domNode, domNode.getNamespaceURI(), string);
+		if (domElement!=null && underlying!=null) {
+			domElement.setName(string);
 			underlying.save();
 		}
 	}
@@ -642,8 +664,8 @@ public class JcrNode implements IAdaptab
 		if (resource!=null) {
 			return false;
 		}
-		if (domNode!=null && underlying!=null) {
-			if (domNode.getNodeName().equals("jcr:content")) {
+		if (domElement!=null && underlying!=null) {
+			if (getDomName().equals("jcr:content")) {
 				return false;
 			}
 			return true;
@@ -670,10 +692,10 @@ public class JcrNode implements IAdaptab
 	}
 
 	public void createChild(String nodeName) {
-		if (domNode==null) {
+		if (domElement==null) {
 			// then we're not in the context of a .content.xml file yet
 			// so we need to create one
-			final String minimalContentXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><jcr:root xmlns:sling=\"http://sling.apache.org/jcr/sling/1.0\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\"/>";
+			final String minimalContentXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<jcr:root\n    xmlns:sling=\"http://sling.apache.org/jcr/sling/1.0\"\n    xmlns:jcr=\"http://www.jcp.org/jcr/1.0\"/>";
 			if (resource instanceof IFolder) {
 				IFolder folder = (IFolder)resource;
 				IFile file = folder.getFile(nodeName+".xml");
@@ -689,25 +711,66 @@ public class JcrNode implements IAdaptab
 			}
 		} else {
 			try{
-				Element element = domNode.getOwnerDocument().createElement(nodeName);
-				element.setAttribute("jcr:primaryType", "nt:unstructured");
-				Node childDomNode = domNode.appendChild(element);
-				JcrNode childNode = new JcrNode(this, childDomNode, null);
-				underlying.save();
+				createChild(nodeName, domElement);
 			} catch(Exception e) {
 				MessageDialog.openError(Display.getDefault().getActiveShell(), "Error creating new JCR node", "The following error occurred: "+e.getMessage());
 			}
 		}
 	}
 
+	protected void createChild(String nodeName,
+			Element domElement) {
+		if (domElement==null) {
+			throw new IllegalArgumentException("domNode must not be null");
+		}
+		if (underlying==null) {
+			throw new IllegalArgumentException("underlying must not be null");
+		}
+		Element element = new Element(nodeName);
+		element.addAttribute("jcr:primaryType", "nt:unstructured");
+		StringBuffer indent = new StringBuffer();
+		Element parElement = domElement.getParentElement();
+		while(parElement!=null) {
+			indent.append("    ");
+			parElement = parElement.getParentElement();
+		}
+		domElement.addNode(new Text("\n    "+indent.toString()));
+		element = domElement.addNode(element);
+		domElement.addNode(new Text("\n"+indent.toString()));
+		JcrNode childNode = new JcrNode(this, element, null);
+		underlying.save();
+	}
+
 	public void delete() {
 		if (parent==null) {
 			// then I dont know how to delete
 			return;
 		}
 		parent.children.remove(this);
-		if (domNode!=null) {
-			domNode.getParentNode().removeChild(domNode);
+		if (domElement!=null) {
+			Element parentNode = domElement.getParentElement();
+			domElement.remove();
+			if (parentNode!=null) {
+				List<Node> allChildNodes = parentNode.getNodes();
+				boolean nonTextChild = false;
+				for (Iterator<Node> it = allChildNodes.iterator(); it
+						.hasNext();) {
+					Node node = it.next();
+					if (node.getType()!=Type.TEXT) {
+						nonTextChild = true;
+					}					
+				}
+				if (!nonTextChild) {
+					for (Iterator<Node> it = allChildNodes.iterator(); it
+							.hasNext();) {
+						Node node = it.next();
+						it.remove();
+					}
+					if (!parentNode.hasNodes()) {
+						parentNode.setCompactEmpty(true);
+					}
+				}
+			}
 		}
 		underlying.save();
 	}

Modified: sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/LinkHelper.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/LinkHelper.java?rev=1525874&r1=1525873&r2=1525874&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/LinkHelper.java (original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/LinkHelper.java Tue Sep 24 12:53:40 2013
@@ -35,7 +35,8 @@ import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.ide.ResourceUtil;
 import org.eclipse.ui.navigator.ILinkHelper;
-import org.w3c.dom.Node;
+
+import de.pdark.decentxml.Element;
 
 public class LinkHelper implements ILinkHelper {
 
@@ -83,7 +84,7 @@ public class LinkHelper implements ILink
 		if (parent==null) {
 			return null;
 		}
-		Node domNode = null;
+		Element domNode = null;
 		JcrNode selectedNode = new JcrNode(parent, domNode, resource);
 		return selectedNode;
 	}

Modified: sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/ModifiableProperties.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/ModifiableProperties.java?rev=1525874&r1=1525873&r2=1525874&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/ModifiableProperties.java (original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/ModifiableProperties.java Tue Sep 24 12:53:40 2013
@@ -25,14 +25,15 @@ import java.util.Map;
 import org.eclipse.ui.views.properties.IPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertySource;
 import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
+
+import de.pdark.decentxml.Attribute;
+import de.pdark.decentxml.Element;
 
 public class ModifiableProperties implements IPropertySource {
 	
 	private Map<String, String> properties = new HashMap<String, String>();
 	private JcrNode node;
-	private Node domNode;
+	private Element domElement;
 	private GenericJcrRootFile genericJcrRootFile;
 	
 	public ModifiableProperties(JcrNode node) {
@@ -46,6 +47,10 @@ public class ModifiableProperties implem
 		this.node = node;
 	}
 	
+	public GenericJcrRootFile getUnderlying() {
+		return genericJcrRootFile;
+	}
+	
 	@Override
 	public Object getEditableValue() {
 		return this;
@@ -86,19 +91,18 @@ public class ModifiableProperties implem
 	public void setPropertyValue(Object id, Object value) {
 		Map.Entry<String, String> entry = (Map.Entry<String, String>)id;
 		entry.setValue(String.valueOf(value));
-		NamedNodeMap attributes = domNode.getAttributes();
-		Node n = attributes.getNamedItem(entry.getKey());
-		n.setNodeValue(String.valueOf(value));
+		Attribute a = domElement.getAttribute(entry.getKey());
+		a.setValue(String.valueOf(value));
 		genericJcrRootFile.save();
 	}
 
-	public void setNode(GenericJcrRootFile genericJcrRootFile, Node domNode) {
-		this.domNode = domNode;
-		NamedNodeMap attributes = domNode.getAttributes();
+	public void setNode(GenericJcrRootFile genericJcrRootFile, Element domNode) {
+		this.domElement = domNode;
+		List<Attribute> attributes = domNode.getAttributes();
 		if (attributes!=null) {
-			for(int i=0; i<attributes.getLength(); i++) {
-				Node attr = attributes.item(i);
-				properties.put(attr.getNodeName(), attr.getNodeValue());
+			for (Iterator<Attribute> it = attributes.iterator(); it.hasNext();) {
+				Attribute a = it.next();
+				properties.put(a.getName(), a.getValue());
 			}
 		}
 		this.genericJcrRootFile = genericJcrRootFile;

Added: sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/TolerantXMLTokenizer.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/TolerantXMLTokenizer.java?rev=1525874&view=auto
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/TolerantXMLTokenizer.java (added)
+++ sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/TolerantXMLTokenizer.java Tue Sep 24 12:53:40 2013
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.ide.eclipse.ui.nav.model;
+
+import org.eclipse.core.resources.IFile;
+
+import de.pdark.decentxml.Location;
+import de.pdark.decentxml.Token;
+import de.pdark.decentxml.XMLParseException;
+import de.pdark.decentxml.XMLSource;
+import de.pdark.decentxml.XMLTokenizer;
+
+/**
+ * In parts inspired by/copied from de.pdark.decentxml.XMLTokenizer.
+ * <p>
+ * Note: this variant of the XMLTokenizer became necessary since in some
+ * rare cases, the vault does not correctly escape '>' and '<' inside
+ * an xml attribute. 
+ * TODO: reproduce and file an appropriate bug with vault.
+ */
+final class TolerantXMLTokenizer extends XMLTokenizer {
+	private final IFile file;
+
+	TolerantXMLTokenizer(XMLSource source, IFile file) {
+		super(source);
+		this.file = file;
+	}
+
+	@Override
+	protected void parseAttribute(Token token) {
+	    token.setType (Type.ATTRIBUTE);
+
+	    parseName ("attribute");
+	    
+	    if (pos == token.getStartOffset())
+	        throw new XMLParseException ("Expected attribute name", source, pos);
+	    
+	    skipWhiteSpace ();
+	    expect ('=');
+	    skipWhiteSpace ();
+	    
+	    char c = 0;
+	    if (pos < source.length ())
+	        c = source.charAt (pos);
+	    if (c != '\'' && c != '"')
+	        throw new XMLParseException ("Expected single or double quotes", source, pos);
+	    
+	    char endChar = c;
+	    
+	    while (true)
+	    {
+	        pos ++;
+	        if (pos >= source.length ())
+	        {
+	            int i = Math.min (20, source.length () - token.getStartOffset ());
+	            throw new XMLParseException ("Missing end quote ("+endChar+") of attribute: "
+	                    +lookAheadForErrorMessage (null, token.getStartOffset (), i), token);
+	        }
+	        
+	        c = source.charAt (pos);
+	        if (c == endChar)
+	            break;
+	        if (c == '<' || c == '>') {
+	        	Location l = new Location(source, pos);
+	            System.err.println("Illegal character in attribute value: '"+c+"' in "+file.getFullPath()+" at "+l);
+	        }
+	    }
+	    
+	    // Skip end-char
+	    pos ++;
+	}
+}
\ No newline at end of file

Propchange: sling/branches/tooling-ide-vlt/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/TolerantXMLTokenizer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain