mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V2.0 to HEAD
5146: AR-1122 5148: AR-1116 5149: RM-5 5152: AR-1167 5153: WCM-324 5154: WCM-325, WCM-301, WCM-258, WCM-25, WCM-320 5156: WCM-338 5158: AR-1164 5169: AR-1216 5177: WCM-328 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5327 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -39,6 +39,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
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;
|
||||
@@ -166,6 +167,37 @@ public class XMLUtil
|
||||
return XMLUtil.documentBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* FOR DIAGNOSTIC PURPOSES ONLY - incomplete<br/>
|
||||
* Builds a path to the node relative to the to node provided.
|
||||
* @param from the node from which to build the xpath
|
||||
* @param to an ancestor of <tt>from</tt> which will be the root of the path
|
||||
* @return an xpath to <tt>to</tt> rooted at <tt>from</tt>.
|
||||
*/
|
||||
public static String buildXPath(final Element from, final Element to)
|
||||
{
|
||||
String result = "";
|
||||
Node tmp = from;
|
||||
do
|
||||
{
|
||||
Node tmp2 = tmp;
|
||||
int position = 1;
|
||||
while (tmp2.getPreviousSibling() != null)
|
||||
{
|
||||
if (tmp2.getNodeName().equals(tmp.getNodeName()))
|
||||
{
|
||||
position++;
|
||||
}
|
||||
tmp2 = tmp2.getPreviousSibling();
|
||||
}
|
||||
String part = tmp.getNodeName() + "[" + position + "]";
|
||||
result = result == null ? "/" + part : "/" + part + result;
|
||||
tmp = tmp.getParentNode();
|
||||
}
|
||||
while (tmp != to.getParentNode() && tmp != null);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static DocumentBuilder getDocumentBuilder(final boolean namespaceAware,
|
||||
final boolean validating)
|
||||
{
|
||||
|
Reference in New Issue
Block a user