You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2010/01/14 22:48:27 UTC
svn commit: r899429 - in /cxf/branches/2.2.x-fixes: ./
tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/model/XNode.java
Author: dkulp
Date: Thu Jan 14 21:48:27 2010
New Revision: 899429
URL: http://svn.apache.org/viewvc?rev=899429&view=rev
Log:
Merged revisions 899428 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r899428 | dkulp | 2010-01-14 16:47:00 -0500 (Thu, 14 Jan 2010) | 4 lines
Using full XPaths for wsdl validation when they are very simple is
apparently VERY expensive. Do a much quicker basic search. A very
complex wsdl I have (500+ operations, 3000+ classes generated) now
does a wsdl2java in 30 secs compared to over 2 minutes.
........
Modified:
cxf/branches/2.2.x-fixes/ (props changed)
cxf/branches/2.2.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
cxf/branches/2.2.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/model/XNode.java
Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.2.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java?rev=899429&r1=899428&r2=899429&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java (original)
+++ cxf/branches/2.2.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java Thu Jan 14 21:48:27 2010
@@ -201,10 +201,8 @@
}
private boolean isExist(List<Document> docs, XNode vNode) {
- XPathUtils xpather = new XPathUtils(vNode.getNSMap());
- String expression = vNode.toString();
for (Document doc : docs) {
- if (xpather.isExist(expression, doc, XPathConstants.NODE)) {
+ if (vNode.matches(doc)) {
return true;
}
}
@@ -239,8 +237,8 @@
List<Document> wsdlDocs = getWSDLDocuments();
for (XNode vNode : vNodes) {
-
if (!isExist(wsdlDocs, vNode)) {
+ //System.out.println("Fail: " + vNode.getXPath());
FailureLocation loc = getFailureLocation(wsdlDocs, vNode.getFailurePoint());
vResults.addError(new Message("FAILED_AT_POINT",
Modified: cxf/branches/2.2.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/model/XNode.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/model/XNode.java?rev=899429&r1=899428&r2=899429&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/model/XNode.java (original)
+++ cxf/branches/2.2.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/model/XNode.java Thu Jan 14 21:48:27 2010
@@ -24,6 +24,10 @@
import java.util.Stack;
import javax.xml.namespace.QName;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
import org.apache.cxf.common.util.StringUtils;
public class XNode {
@@ -165,4 +169,53 @@
nsMap.put(prefix, name.getNamespaceURI());
return sb.toString();
}
+
+
+ private boolean matches(Element el) {
+ if (el.getLocalName().equals(name.getLocalPart())
+ && el.getNamespaceURI().equals(name.getNamespaceURI())) {
+ if (!StringUtils.isEmpty(attributeName) && !StringUtils.isEmpty(attributeValue)) {
+ String v = el.getAttribute(attributeName);
+ if (attributeValue.equals(v) || (StringUtils.isEmpty(v) && isDefaultAttributeValue)) {
+ return true;
+ }
+ } else {
+ return true;
+ }
+ }
+ return false;
+ }
+ private boolean matches(Element el, Stack<XNode> stack) {
+ if (matches(el)) {
+ if (stack.isEmpty()) {
+ return true;
+ }
+ XNode next = stack.pop();
+ Node nd = el.getFirstChild();
+ while (nd != null) {
+ if (nd instanceof Element) {
+ el = (Element)nd;
+ if (next.matches(el, stack)) {
+ return true;
+ }
+ }
+ nd = nd.getNextSibling();
+ }
+ stack.push(next);
+ }
+ return false;
+ }
+
+ public boolean matches(Document doc) {
+ Stack<XNode> nodes = new Stack<XNode>();
+ nodes.push(this);
+ XNode pNode = getParentNode();
+ while (pNode != null) {
+ nodes.push(pNode);
+ pNode = pNode.getParentNode();
+ }
+ pNode = nodes.pop();
+ return pNode.matches(doc.getDocumentElement(), nodes);
+
+ }
}