Author: bimargulies
Date: Mon Nov 17 11:42:30 2008
New Revision: 718345

URL: http://svn.apache.org/viewvc?rev=718345&view=rev
Log:
Merged revisions 718331,718337 via svnmerge from 
https://svn.apache.org/repos/asf/webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH

........
  r718331 | bimargulies | 2008-11-17 14:25:44 -0500 (Mon, 17 Nov 2008) | 3 lines
  
  WSCOMMONS-362. When capturing a node list, make a document fragment. Note 
that the 'set' APIs for AppInfo and Documentation don't do the cloning, the
  builder does. So anyone building their own XmlSchema should worry about this 
issue for themselves.
........
  r718337 | bimargulies | 2008-11-17 14:29:06 -0500 (Mon, 17 Nov 2008) | 2 lines
  
  WSCOMMONS-358
........

Added:
    
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/DocumentFragmentNodeList.java
      - copied unchanged from r718337, 
webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH/src/main/java/org/apache/ws/commons/schema/DocumentFragmentNodeList.java
Modified:
    webservices/commons/trunk/modules/XmlSchema/   (props changed)
    webservices/commons/trunk/modules/XmlSchema/build.xml
    webservices/commons/trunk/modules/XmlSchema/pom.xml
    
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
    
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
    
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/DOMUtil.java
    
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/XDOMUtil.java

Propchange: webservices/commons/trunk/modules/XmlSchema/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Nov 17 11:42:30 2008
@@ -1 +1 @@
-/webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH:1-718319
+/webservices/commons/branches/modules/XmlSchema/1_4_X_BRANCH:1-718344

Modified: webservices/commons/trunk/modules/XmlSchema/build.xml
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/build.xml?rev=718345&r1=718344&r2=718345&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/build.xml (original)
+++ webservices/commons/trunk/modules/XmlSchema/build.xml Mon Nov 17 11:42:30 
2008
@@ -30,16 +30,16 @@
        <property name="dist.dir" value="${build.dir}/dist"/>
        <property name="dist.zip" value="${project.name}.zip"/>
        <property name="srcdist.zip" value="${project.name}-src.zip"/>
-    <property name="test.dir" value="${basedir}/src/test/java"/>
+       <property name="test.dir" value="${basedir}/src/test/java"/>
        <property name="test_classes.dir" value="${build.dir}/test-classes"/>
-    <property name="test_reports.dir" value="${build.dir}/test-reports"/>
-    <property name="test_reports_w3c.dir" 
value="${build.dir}/test-reports-w3c"/>
+       <property name="test_reports.dir" value="${build.dir}/test-reports"/>
+       <property name="test_reports_w3c.dir" 
value="${build.dir}/test-reports-w3c"/>
 
-    <target name="setproxy" if="http.proxyhost">
-        <setproxy proxyhost="${http.proxyHost}" proxyport="${http.proxyPort}"/>
-    </target>
+       <target name="setproxy" if="http.proxyhost">
+         <setproxy proxyhost="${http.proxyHost}" 
proxyport="${http.proxyPort}"/>
+       </target>
 
-    <target name="prepare" depends="setproxy">
+       <target name="prepare" depends="setproxy">
                <mkdir dir="${build_classes.dir}"/>
                <mkdir dir="${build_lib.dir}"/>
        
@@ -74,13 +74,13 @@
              </not>
            </condition>
        <antcall target="get-xml-schema-tests"/>
-   </target>
+    </target>
        
-       <target name="get-xml-schema-tests" if="needsTestsDownload">
-               <echo>Downloading 6MB XML Schema test suite. This make take a 
few minutes...</echo>
-               <get dest="${build.dir}/xsts-2002-01-16.tar.gz" 
-                       
src="http://www.w3.org/XML/2004/xml-schema-test-suite/xmlschema2002-01-16/xsts-2002-01-16.tar.gz"/>
-               <untar src="${build.dir}/xsts-2002-01-16.tar.gz" 
compression="gzip" dest="${build.dir}"/>
+    <target name="get-xml-schema-tests" if="needsTestsDownload">
+      <echo>Downloading 6MB XML Schema test suite. This make take a few 
minutes...</echo>
+      <get dest="${build.dir}/xsts-2002-01-16.tar.gz" 
+          
src="http://www.w3.org/XML/2004/xml-schema-test-suite/xmlschema2002-01-16/xsts-2002-01-16.tar.gz"/>
+      <untar src="${build.dir}/xsts-2002-01-16.tar.gz" compression="gzip" 
dest="${build.dir}"/>
     </target>
 
     <target name="compile" depends="prepare" description="compiles the src and 
puts it in build/classes">

Modified: webservices/commons/trunk/modules/XmlSchema/pom.xml
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/pom.xml?rev=718345&r1=718344&r2=718345&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/pom.xml (original)
+++ webservices/commons/trunk/modules/XmlSchema/pom.xml Mon Nov 17 11:42:30 2008
@@ -29,7 +29,7 @@
     <version>1.4-SNAPSHOT</version>
     <description>Commons XMLSchema is a light weight schema object model that 
can be used to manipualte or
         generate a schema. It has a clean, easy to use API and can easily be 
integrated into an existing project
-        since it has almost no dependancies on third party 
libraries.</description>
+        since it has almost no dependencies on third party 
libraries.</description>
     <url>http://ws.apache.org/commons/XmlSchema</url>
     <issueManagement>
         <system>JIRA</system>
@@ -84,7 +84,7 @@
                     the assembly plugin cannot override the filter properties 
(as explained
                         in the docs) and also does not inherit the maven 
standard properties. This
                     is the one that points to a seperare filter props file --> 
-               <filters>
+       <filters>
                <filter>src/main/assembly/filter.properties</filter>
         </filters>
 
@@ -92,8 +92,14 @@
        <resources>
           <resource>
              <directory>src/main/resources</directory>
-       </resource>
-     </resources>
+         </resource>
+       </resources>
+       <testResources>
+         <testResource>
+           <directory>src/test/test-resources</directory>
+         </testResource>
+       </testResources>
+
 
         <plugins>
             <plugin>
@@ -142,10 +148,6 @@
             </plugin>
             <plugin>
                 <artifactId>maven-surefire-plugin</artifactId>
-                <!--
-                        Required to run the TestW3CSchemaBucket test
-                        <version>2.3-SNAPSHOT</version>
-                -->
                 <configuration>
                     <includes>
                         <include>**/*Test.java</include>
@@ -223,10 +225,6 @@
                        <plugins>
                                <plugin>
                                        
<artifactId>maven-surefire-plugin</artifactId>
-                                       <!--
-                                               Required to run the 
TestW3CSchemaBucket test
-                                               <version>2.3-SNAPSHOT</version>
-                                       -->
                                        <configuration>
                                                <includes>
                                                        
<include>**/*Test.java</include>
@@ -281,10 +279,6 @@
                        <plugins>
                                <plugin>
                                        
<artifactId>maven-surefire-plugin</artifactId>
-                                       <!--
-                                               Required to run the 
TestW3CSchemaBucket test
-                                               <version>2.3-SNAPSHOT</version>
-                                       -->
                                        <configuration>
                                                <includes>
                                                        
<include>**/*Test.java</include>
@@ -371,7 +365,7 @@
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>jdepend-maven-plugin</artifactId>
-                <version>2.0-beta-1</version>
+                <version>2.0-beta-2</version>
             </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>

Modified: 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java?rev=718345&r1=718344&r2=718345&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
 (original)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
 Mon Nov 17 11:42:30 2008
@@ -34,7 +34,9 @@
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import java.lang.ref.SoftReference;
+import java.util.ArrayList;
 import java.util.Hashtable;
+import java.util.List;
 import java.util.StringTokenizer;
 import java.util.Vector;
 
@@ -771,7 +773,7 @@
                
                return complexContent;
        }
-
+       
        private XmlSchemaSimpleContentRestriction 
handleSimpleContentRestriction(
                        XmlSchema schema, Element restrictionEl, Element 
schemaEl) {
 
@@ -805,10 +807,7 @@
                                restriction.setAnnotation(handleAnnotation(el));
                        } else {
                                XmlSchemaFacet facet = 
XmlSchemaFacet.construct(el);
-                               NodeList annotations = 
el.getElementsByTagNameNS(
-                                               XmlSchema.SCHEMA_NS, 
"annotation");
-
-                               if (annotations.getLength() > 0) {
+                               if(XDOMUtil.anyElementsWithNameNS(el, 
XmlSchema.SCHEMA_NS, "annotation")) {
                                        XmlSchemaAnnotation facetAnnotation = 
handleAnnotation(el);
                                        facet.setAnnotation(facetAnnotation);
                                }
@@ -1564,7 +1563,7 @@
        }
 
        /**
-        * Hanlde the import
+        * Handle the import
         * @param schema
         * @param importEl
         * @param schemaEl
@@ -1734,10 +1733,9 @@
         */
        XmlSchemaAppInfo handleAppInfo(Element content) {
                XmlSchemaAppInfo appInfo = new XmlSchemaAppInfo();
-               NodeList markup = getChildren(content);
+               NodeList markup = new DocumentFragmentNodeList(content);
 
-               if (!content.hasAttribute("source")
-                               && (markup == null || markup.getLength() <= 0)) 
{
+               if (!content.hasAttribute("source")) {
                        return null;
                }
                appInfo.setSource(getAttribute(content, "source"));
@@ -1748,16 +1746,16 @@
        //iterate each documentation element, create new XmlSchemaAppinfo and 
add to collection
        XmlSchemaDocumentation handleDocumentation(Element content) {
                XmlSchemaDocumentation documentation = new 
XmlSchemaDocumentation();
-               NodeList markup = getChildren(content);
+               List markup = getChildren(content);
 
                if (!content.hasAttribute("source")
                                && !content.hasAttribute("xml:lang")
-                               && (markup == null || markup.getLength() <= 0))
+                               && markup == null)
                        return null;
 
                documentation.setSource(getAttribute(content, "source"));
                documentation.setLanguage(getAttribute(content, "xml:lang"));
-               documentation.setMarkup(getChildren(content));
+               documentation.setMarkup(new DocumentFragmentNodeList(content));
 
                return documentation;
        }
@@ -1768,11 +1766,16 @@
                return null;
        }
 
-       private NodeList getChildren(Element content) {
-               NodeList childs = content.getChildNodes();
-               if (childs.getLength() > 0)
-                       return childs;
-               return null;
+       private List getChildren(Element content) {
+               List result = new ArrayList();
+               for(Node n = content.getFirstChild(); n != null; n = 
n.getNextSibling()) {
+                       result.add(n);
+               }
+               if(result.size() == 0) {
+                       return null;
+               } else {
+                       return result;
+               }
        }
 
        long getMinOccurs(Element el) {

Modified: 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java?rev=718345&r1=718344&r2=718345&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
 (original)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
 Mon Nov 17 11:42:30 2008
@@ -1952,7 +1952,7 @@
         if (appInfoObj.markup != null) {
             int markupLength = appInfoObj.markup.getLength();
             for (int j = 0; j < markupLength; j++) {
-                Node n = appInfoObj.markup.item(j);
+                Node n = (Node) appInfoObj.markup.item(j);
                appInfoEl.appendChild(doc.importNode(n,true));
             }
         }
@@ -1998,7 +1998,7 @@
         if (documentationObj.markup != null) {
             int markupLength = documentationObj.markup.getLength();
             for (int j = 0; j < markupLength; j++) {
-                Node n = documentationObj.markup.item(j);
+                Node n = (Node) documentationObj.markup.item(j);
 
                 switch (n.getNodeType()) {
                     case Node.ELEMENT_NODE:

Modified: 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/DOMUtil.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/DOMUtil.java?rev=718345&r1=718344&r2=718345&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/DOMUtil.java
 (original)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/DOMUtil.java
 Mon Nov 17 11:42:30 2008
@@ -598,9 +598,9 @@
      */
     public static String getInputEncoding(Document doc) {
         try {
-            Method m = Document.class.getMethod("getInputEncoding", new 
Class[]{});
+            Method m = doc.getClass().getMethod("getInputEncoding", new 
Class[]{});
             return (String) m.invoke(doc, new Object[]{});
-        } catch (Exception e) {
+        } catch (Throwable e) {
             return DEFAULT_ENCODING;
         }
     }
@@ -615,10 +615,10 @@
      */
     public static String getXmlEncoding(Document doc) {
         try {
-                Method m = Document.class.getMethod("getXmlEncoding", new 
Class[]{});
+                Method m = doc.getClass().getMethod("getXmlEncoding", new 
Class[]{});
              return (String) m.invoke(doc, new Object[]{});
-        } catch (Exception e) {
+        } catch (Throwable e) {
             return DEFAULT_ENCODING;
         }
     }
-} // class XUtil
+} 

Modified: 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/XDOMUtil.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/XDOMUtil.java?rev=718345&r1=718344&r2=718345&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/XDOMUtil.java
 (original)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/XDOMUtil.java
 Mon Nov 17 11:42:30 2008
@@ -66,5 +66,15 @@
         return null;
 
     }
+    
+    public static boolean anyElementsWithNameNS(Element element, String uri, 
String name) {
+       for (Element el = getFirstChildElementNS(element, uri); el != null; el 
= XDOMUtil.getNextSiblingElementNS(el, uri)) {
+               if(el.getLocalName().equals(name) && 
el.getNamespaceURI().equals(uri)) {
+                       return true;
+               }
+       }
+       return false;
+    }
+    
 
 }


Reply via email to