On Tue, Apr 28, 2009 at 10:24 PM, John Casey <[email protected]> wrote:
> 1. MNG-4140: even working around the NoClassDefFoundError for XPath* in JDK
> 1.4, this means that version expressions won't be interpolated on
> install/deploy unless JDK 1.5+ is used. This was something we talked about
> in [1].
If I understand the issue correctly, then it is about finding
<version>.*</version> in a DOM tree. That's easily possible without
XPath (see below).
Don't get me wrong: I am not refusing 1.5 as a dependency at all. I'm
just refusing it for the reasons you mention.
Jochen
--
Don't trust a government that doesn't trust you.
public Node[] findVersionNodes(Node pNode) {
final List nodes = new ArrayList();
findVersionNodes(nodes, pNode);
return (Node[]) nodes.toArray(new Node[nodes.size()]);
}
private void findVersionNodes(List pNodes, Node pNode) {
switch (pNode.getNodeType()) {
case Node.ELEMENT_NODE:
if (pNode.getNodeType() == Node.ELEMENT_NODE &&
"version".equals(pNode.getLocalName()) &&
(pNode.getNamespaceURI() == null ||
"<maven-pom-namespace>".equals(pNode.getNamespaceURI()))) {
boolean nonTextNodes = false;
for (Node child = pNode.getFirstChild(); child !=
null; child = child.getNextSibling()) {
switch (child.getNodeType()) {
case Node.TEXT_NODE:
case Node.CDATA_SECTION_NODE:
case Node.COMMENT_NODE:
break;
default:
nonTextNodes = true;
break;
}
}
if (!nonTextNodes) {
pNodes.add(pNode);
return;
}
}
break;
case Node.DOCUMENT_FRAGMENT_NODE:
case Node.DOCUMENT_NODE:
break;
default:
return;
}
for (Node child = pNode.getFirstChild(); child != null;
child = child.getNextSibling()) {
findVersionNodes(pNodes, child);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]