cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r888161 - in /cxf/branches/2.2.x-fixes: ./ common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
Date Mon, 07 Dec 2009 22:23:36 GMT
Author: dkulp
Date: Mon Dec  7 22:23:32 2009
New Revision: 888161

URL: http://svn.apache.org/viewvc?rev=888161&view=rev
Log:
Merged revisions 888159 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r888159 | dkulp | 2009-12-07 17:20:55 -0500 (Mon, 07 Dec 2009) | 2 lines
  
  [CXF-2571] Set systemId on the dom things for xjc
  Workaround bug in xjc not resolving jar: urls
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    cxf/branches/2.2.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Dec  7 22:23:32 2009
@@ -1 +1 @@
-/cxf/trunk:887328,887353,887669,888083,888105
+/cxf/trunk:887328,887353,887669,888083,888105,888159

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=888161&r1=888160&r2=888161&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
(original)
+++ cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
Mon Dec  7 22:23:32 2009
@@ -1034,6 +1034,13 @@
     public static XMLStreamReader createXMLStreamReader(Document doc) {
         return new W3CDOMStreamReader(doc.getDocumentElement());
     }
+    public static XMLStreamReader createXMLStreamReader(Element el, String sysId) {
+        return new W3CDOMStreamReader(el, sysId);
+    }
+    public static XMLStreamReader createXMLStreamReader(Document doc, String sysId) {
+        return new W3CDOMStreamReader(doc.getDocumentElement(), sysId);
+    }
+    
     public static XMLStreamReader createXMLStreamReader(Source source) {
         try {
             if (source instanceof DOMSource) {

Modified: cxf/branches/2.2.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java?rev=888161&r1=888160&r2=888161&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
(original)
+++ cxf/branches/2.2.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
Mon Dec  7 22:23:32 2009
@@ -99,6 +99,7 @@
 
     public class LocationFilterReader extends StreamReaderDelegate implements XMLStreamReader
{
         boolean isImport;
+        boolean isInclude;
         int locIdx = -1;
         LocationFilterReader(XMLStreamReader read) {
             super(read);
@@ -108,6 +109,10 @@
             int i = super.next();
             if (i == XMLStreamReader.START_ELEMENT) {
                 QName qn = super.getName();
+                isInclude = qn.equals(WSDLConstants.QNAME_SCHEMA_INCLUDE);
+                if (isInclude) {
+                    return nextTag();
+                }
                 isImport = qn.equals(WSDLConstants.QNAME_SCHEMA_IMPORT);
                 if (isImport) {
                     findLocation();
@@ -124,7 +129,13 @@
         public int nextTag() throws XMLStreamException {
             int i = super.nextTag();
             if (i == XMLStreamReader.START_ELEMENT) {
-                isImport = super.getName().equals(WSDLConstants.QNAME_SCHEMA_IMPORT);
+                QName qn = super.getName();
+                isInclude = qn.equals(WSDLConstants.QNAME_SCHEMA_INCLUDE);
+                if (isInclude) {
+                    return super.nextTag();
+                }
+
+                isImport = qn.equals(WSDLConstants.QNAME_SCHEMA_IMPORT);
                 if (isImport) {
                     findLocation();
                 } else {
@@ -145,10 +156,6 @@
                 }
             }
         }
-        public String getAttributeValue(String namespaceURI, String localName) {
-            return super.getAttributeValue(namespaceURI, localName);
-        }
-    
         public int getAttributeCount() {
             int i = super.getAttributeCount();
             if (locIdx != -1) {
@@ -163,7 +170,22 @@
             }
             return index;
         }
-    
+        public String getAttributeValue(String namespaceURI, String localName) {
+            if (isInclude && "schemaLocation".equals(localName)) {
+                return null;
+            }
+            return super.getAttributeValue(namespaceURI, localName);
+        }
+        public String getAttributeValue(int index) {
+            if (isInclude) {
+                String n = getAttributeLocalName(index);
+                if ("schemaLocation".equals(n)) {
+                    return null;
+                }
+            }
+            return super.getAttributeValue(mapIdx(index));
+        }
+
         public QName getAttributeName(int index) {
             return super.getAttributeName(mapIdx(index));
         }
@@ -184,16 +206,10 @@
             return super.getAttributeType(mapIdx(index));
         }
     
-        public String getAttributeValue(int index) {
-            return super.getAttributeValue(mapIdx(index));
-        }
     
         public boolean isAttributeSpecified(int index) {
             return super.isAttributeSpecified(mapIdx(index));
         }
-
-        
-
     }
 
 
@@ -378,7 +394,7 @@
                 continue;
             }
             
-            if (!key.startsWith("file:")) {
+            if (!key.startsWith("file:") && !key.startsWith("jar:")) {
                 XmlSchemaSerializer xser = new XmlSchemaSerializer();
                 xser.setExtReg(schemaCollection.getExtReg());
                 Document[] docs;
@@ -393,21 +409,25 @@
                     String uri = null;
                     try {
                         uri = docs[0].getDocumentURI();
-                    } catch (Exception ex) {
+                    } catch (Throwable ex) {
                         //ignore - DOM level 3
                     }
                     validateSchema(ele, uri);
                 }           
+                try {
+                    docs[0].setDocumentURI(key);
+                } catch (Throwable t) {
+                    //ignore - DOM level 3
+                }
                 InputSource is = new InputSource((InputStream)null);
                 //key = key.replaceFirst("#types[0-9]+$", "");
                 is.setSystemId(key);
                 is.setPublicId(key);
                 opts.addGrammar(is);
                 try {
-                    schemaCompiler.parseSchema(key, StaxUtils.createXMLStreamReader(ele));
+                    schemaCompiler.parseSchema(key, StaxUtils.createXMLStreamReader(ele,
key));
                 } catch (XMLStreamException e) {
-                    // TODO Auto-generated catch block
-                    e.printStackTrace();
+                    throw new ToolException(e);
                 }
             }
         }
@@ -419,10 +439,15 @@
             if (ids.contains(key)) {
                 continue;
             }
-            if (key.startsWith("file:")) {
+            if (key.startsWith("file:") || key.startsWith("jar:")) {
+                InputStream in = null;
                 try {
-                    FileInputStream fin = new FileInputStream(new File(new URI(key)));
-                    XMLStreamReader reader = StaxUtils.createXMLStreamReader(key, fin);
+                    if (key.startsWith("file:")) {
+                        in = new FileInputStream(new File(new URI(key)));
+                    } else {
+                        in = new URL(key).openStream();
+                    }
+                    XMLStreamReader reader = StaxUtils.createXMLStreamReader(key, in);
                     reader = new LocationFilterReader(reader);
                     InputSource is = new InputSource(key);
                     opts.addGrammar(is);
@@ -432,6 +457,14 @@
                     throw ex;
                 } catch (Exception ex) {
                     throw new RuntimeException(ex);
+                } finally {
+                    if (in != null) {
+                        try {
+                            in.close();
+                        } catch (IOException e) {
+                            //ignore
+                        }
+                    }
                 }
             }
         }
@@ -454,7 +487,7 @@
                 is.setPublicId(key);
                 opts.addGrammar(is);
                 try {
-                    schemaCompiler.parseSchema(key, StaxUtils.createXMLStreamReader(ele));
+                    schemaCompiler.parseSchema(key, StaxUtils.createXMLStreamReader(ele,
key));
                 } catch (XMLStreamException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
@@ -587,21 +620,34 @@
     }
 
     private Element removeImportElement(Element element) {
-        List<Element> elemList = DOMUtils.findAllElementsByTagNameNS(element, 
+        List<Element> impElemList = DOMUtils.findAllElementsByTagNameNS(element, 
                                                                      ToolConstants.SCHEMA_URI,

                                                                      "import");
-        if (elemList.size() == 0) {
+        List<Element> incElemList = DOMUtils.findAllElementsByTagNameNS(element, 
+                                                                     ToolConstants.SCHEMA_URI,

+                                                                     "include");
+        if (impElemList.size() == 0 && incElemList.size() == 0) {
             return element;
         }
         element = (Element)cloneNode(element.getOwnerDocument(), element, true);
-        elemList = DOMUtils.findAllElementsByTagNameNS(element, 
+        List<Node> ns = new ArrayList<Node>();
+        
+        impElemList = DOMUtils.findAllElementsByTagNameNS(element, 
                                                        ToolConstants.SCHEMA_URI, 
                                                        "import");
-        List<Node> ns = new ArrayList<Node>();
-        for (Element elem : elemList) {
+        for (Element elem : impElemList) {
             Node importNode = elem;
             ns.add(importNode);
         }
+        incElemList = DOMUtils.findAllElementsByTagNameNS(element, 
+                                                       ToolConstants.SCHEMA_URI, 
+                                                       "include");
+        for (Element elem : incElemList) {
+            Node importNode = elem;
+            ns.add(importNode);
+        }
+        
+        
         for (Node item : ns) {
             Node schemaNode = item.getParentNode();
             schemaNode.removeChild(item);



Mime
View raw message