ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xav...@apache.org
Subject svn commit: r632405 - in /ant/ivy/core/trunk: ./ src/java/org/apache/ivy/plugins/parser/xml/ test/java/org/apache/ivy/plugins/parser/xml/
Date Fri, 29 Feb 2008 18:44:26 GMT
Author: xavier
Date: Fri Feb 29 10:44:20 2008
New Revision: 632405

URL: http://svn.apache.org/viewvc?rev=632405&view=rev
Log:
FIX: XML schema ambiguity (IVY-750)

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/ivy.xsd
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test.xml

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=632405&r1=632404&r2=632405&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Fri Feb 29 10:44:20 2008
@@ -66,6 +66,7 @@
 =====================================
 - IMPROVEMENT: Make Ivy standalone runnable with no required dependencies (IVY-757)
 
+- FIX: XML schema ambiguity (IVY-750)
 - FIX: ivy-resolve fails when a project has different dependencies in different branches
(IVY-717)
 - FIX: PublishEventsTest fails when Ivy sources are located in a directory with a + (IVY-755)
 - FIX: XML entity parsing does not work properly (IVY-737) (thanks to Patrick Woodworth)

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java?rev=632405&r1=632404&r2=632405&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
Fri Feb 29 10:44:20 2008
@@ -179,6 +179,8 @@
         private static final int DEPS = 10;
         
         private static final int DESCRIPTION = 11;
+
+        private static final int EXTRA_INFO = 12;
         
         private int state = NONE;
 
@@ -259,7 +261,10 @@
         public void startElement(String uri, String localName, String qName, Attributes attributes)
                 throws SAXException {
             try {
-                if ("ivy-module".equals(qName)) {
+                if (state == DESCRIPTION) {
+                    //make sure we don't interpret any tag while in description tag 
+                    return;
+                } else if ("ivy-module".equals(qName)) {
                     ivyModuleStarted(attributes);
                 } else if ("info".equals(qName)) {
                     infoStarted(attributes);
@@ -269,8 +274,13 @@
                 } else if (state == INFO && "description".equals(qName)) {
                     md.setHomePage(ivy.substitute(attributes.getValue("homepage")));
                     state = DESCRIPTION;
-                } else if (state == INFO) {
+                } else if (state == INFO && "ivyauthor".equals(qName)) {
+                    // nothing to do, we don't store this
+                } else if (state == INFO && "repository".equals(qName)) {
+                    // nothing to do, we don't store this
+                } else if (state == INFO && isOtherNamespace(qName)) {
                     buffer = new StringBuffer();
+                    state = EXTRA_INFO;
                 } else if ("configurations".equals(qName)) {
                     configurationStarted(attributes);
                 } else if ("publications".equals(qName)) {
@@ -303,8 +313,8 @@
                     managerStarted(attributes);
                 } else if ("include".equals(qName) && state == CONF) {
                     includeConfStarted(attributes);
-                } else if (validate && state != INFO) {
-                    addError("unknwon tag " + qName);
+                } else if (validate && state != EXTRA_INFO && state != DESCRIPTION)
{
+                    addError("unknown tag " + qName);
                 }
             } catch (Exception ex) {
                 if (ex instanceof SAXException) {
@@ -315,6 +325,10 @@
             }
         }
 
+        private boolean isOtherNamespace(String qName) {
+            return qName.indexOf(':') != -1;
+        }
+
         private void managerStarted(Attributes attributes) {
             String org = ivy.substitute(attributes.getValue("org"));
             org = org == null ? PatternMatcher.ANY_EXPRESSION : org;
@@ -745,20 +759,21 @@
                 }
                 confAware = null;
                 state = DEPS;
-            } else if ("dependency".equals(qName)) {
+            } else if ("dependency".equals(qName) && state == DEP) {
                 if (dd.getModuleConfigurations().length == 0) {
                     parseDepsConfs(getDefaultConf(), dd);
                 }
                 state = DEPS;
-            } else if ("dependencies".equals(qName)) {
+            } else if ("dependencies".equals(qName) && state == DEPS) {
                 state = NONE;
             } else if (state == INFO && "info".equals(qName)) {
                 state = NONE;
-            } else if (state == INFO && "description".equals(qName)) {
+            } else if (state == DESCRIPTION && "description".equals(qName)) {
                 state = INFO;
-            } else if (state == INFO) {
-                md.addExtraInfo(qName, buffer==null?"":buffer.toString());
+            } else if (state == EXTRA_INFO) {
+                md.addExtraInfo(qName, buffer == null ? "" : buffer.toString());
                 buffer = null;
+                state = INFO;
             }
         }
 

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java?rev=632405&r1=632404&r2=632405&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
Fri Feb 29 10:44:20 2008
@@ -382,11 +382,12 @@
             printExtraAttributes(md, out, "\t\t");
             out.println();
         }
-        if (md.getExtraInfo().size()>0) {
+        if (md.getExtraInfo().size() > 0) {
             out.println("\t>");
             for (Iterator it = md.getExtraInfo().entrySet().iterator(); it.hasNext();) {
                 Map.Entry extraDescr = (Map.Entry) it.next();
-                if (extraDescr.getValue()==null || ((String)extraDescr.getValue()).length()==0)
{
+                if (extraDescr.getValue() == null 
+                        || ((String) extraDescr.getValue()).length() == 0) {
                     continue;
                 }
                 out.print("\t\t<");

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/ivy.xsd
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/ivy.xsd?rev=632405&r1=632404&r2=632405&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/ivy.xsd (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/ivy.xsd Fri Feb 29 10:44:20
2008
@@ -71,7 +71,7 @@
 					            <xs:attribute name="homepage" type="xs:string"/>
 			            	</xs:complexType>
 			      		</xs:element>
-			      		<xs:any minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
+			      		<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other" processContents="lax"/>
 			        </xs:sequence>
 		            <xs:attribute name="organisation" type="xs:string" use="required"/>
 		            <xs:attribute name="module" type="xs:string" use="required"/>

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java?rev=632405&r1=632404&r2=632405&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java
(original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java
Fri Feb 29 10:44:20 2008
@@ -184,6 +184,9 @@
         assertEquals("http://www.my.org/mymodule/mylicense.html", licenses[0].getUrl());
 
         assertEquals("http://www.my.org/mymodule/", md.getHomePage());
+        
+        assertEquals(1, md.getExtraInfo().size());
+        assertEquals("56576", md.getExtraInfo().get("e:someExtra"));
 
         Configuration[] confs = md.getConfigurations();
         assertNotNull(confs);
@@ -434,7 +437,15 @@
         assertEquals(Arrays.asList(new String[] {"myconf1", "myconf2", "myconf3", "myconf4",
                 "myoldconf"}), Arrays.asList(rules[1].getConfigurations()));
     }
-
+    
+    public void testFullNoValidation() throws Exception {
+        ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
+            getClass().getResource("test.xml"), false);
+        assertNotNull(md);
+        assertEquals(1, md.getExtraInfo().size());
+        assertEquals("56576", md.getExtraInfo().get("e:someExtra"));
+    }
+    
     public void testBug60() throws Exception {
         ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
             getClass().getResource("test-bug60.xml"), true);

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test.xml?rev=632405&r1=632404&r2=632405&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test.xml (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test.xml Fri Feb 29 10:44:20
2008
@@ -32,12 +32,12 @@
 
 		<repository name="ivyrep" url="http://www.jayasoft.fr/org/ivyrep/" pattern="[organisation]/[module]/ivy-[revision].xml"
ivys="true" artifacts="false"/>
 
-		<e:someExtra>56576</e:someExtra>
-
 		<description homepage="http://www.my.org/mymodule/">			
 	This module is <b>great</b> !<br/>
 	You can use it especially with myconf1 and myconf2, and myconf4 is not too bad too.
 		</description>
+
+		<e:someExtra>56576</e:someExtra>
 	</info>
 	<configurations>
 		<conf name="myconf1" description="desc 1" e:attr2="value2"/>



Mime
View raw message