maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r711970 - in /maven/doxia/doxia/trunk/doxia-modules: doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlValidatorTest.java doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocValidatorTest.java
Date Thu, 06 Nov 2008 20:38:36 GMT
Author: vsiveton
Date: Thu Nov  6 12:38:31 2008
New Revision: 711970

URL: http://svn.apache.org/viewvc?rev=711970&view=rev
Log:
o fix r711955

Modified:
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlValidatorTest.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocValidatorTest.java

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlValidatorTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlValidatorTest.java?rev=711970&r1=711969&r2=711970&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlValidatorTest.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlValidatorTest.java
Thu Nov  6 12:38:31 2008
@@ -23,6 +23,8 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.maven.doxia.xsd.AbstractXmlValidatorTest;
 import org.codehaus.plexus.util.FileUtils;
@@ -221,16 +223,24 @@
     /** {@inheritDoc} */
     protected String addNamespaces( String content )
     {
-        if ( content.indexOf( FML_XSD.getName() ) != -1 )
+        Pattern pattern = Pattern.compile( ".*<([A-Za-z][A-Za-z0-9:_.-]*)([^>]*)>.*"
);
+        Matcher matcher = pattern.matcher( content );
+        if ( matcher.find() )
         {
-            return content;
-        }
+            String root = matcher.group( 1 );
+            String value = matcher.group( 2 );
+
+            if ( value.indexOf( FML_XSD.getName() ) == -1 )
+            {
+                String faqs =
+                    "<" + root + " xmlns=\"http://maven.apache.org/FML/1.0\""
+                        + "  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+                        + "  xsi:schemaLocation=\"http://maven.apache.org/FML/1.0 " + FML_XSD.toURI()
+ "\" ";
 
-        String faqs =
-            "<faqs xmlns=\"http://maven.apache.org/FML/1.0\""
-                + "  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
-                + "  xsi:schemaLocation=\"http://maven.apache.org/FML/1.0 " + FML_XSD.toURI()
+ "\" ";
+                return StringUtils.replace( content, "<" + root, faqs );
+            }
+        }
 
-        return StringUtils.replace( content, "<faqs", faqs );
+        return content;
     }
 }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocValidatorTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocValidatorTest.java?rev=711970&r1=711969&r2=711970&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocValidatorTest.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocValidatorTest.java
Thu Nov  6 12:38:31 2008
@@ -23,6 +23,8 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.maven.doxia.xsd.AbstractXmlValidatorTest;
 import org.codehaus.plexus.util.FileUtils;
@@ -82,16 +84,24 @@
     /** {@inheritDoc} */
     protected String addNamespaces( String content )
     {
-        if ( content.indexOf( XDOC_XSD.getName() ) != -1 )
+        Pattern pattern = Pattern.compile( ".*<([A-Za-z][A-Za-z0-9:_.-]*)([^>]*)>.*"
);
+        Matcher matcher = pattern.matcher( content );
+        if ( matcher.find() )
         {
-            return content;
-        }
+            String root = matcher.group( 1 );
+            String value = matcher.group( 2 );
+
+            if ( value.indexOf( XDOC_XSD.getName() ) == -1 )
+            {
+                String faqs =
+                    "<" + root + " xmlns=\"http://maven.apache.org/XDOC/2.0\""
+                        + "  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+                        + "  xsi:schemaLocation=\"http://maven.apache.org/XDOC/2.0 " + XDOC_XSD.toURI()
+ "\" ";
 
-        String document =
-            "<document xmlns=\"http://maven.apache.org/XDOC/2.0\" "
-                + "  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
-                + "  xsi:schemaLocation=\"http://maven.apache.org/XDOC/2.0 " + XDOC_XSD.toURI()
+ "\">";
+                return StringUtils.replace( content, "<" + root, faqs );
+            }
+        }
 
-        return StringUtils.replace( content, "<document>", document );
+        return content;
     }
 }



Mime
View raw message