Author: ltheussl
Date: Tue Oct  9 12:52:25 2007
New Revision: 583277

URL: http://svn.apache.org/viewvc?rev=583277&view=rev
Log:
DOXIA-157: generalize determination of parser Ids, files with .xml extension, 
eg xdocs, were always parsed by the docbook parser.

Modified:
    
maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/io/DefaultBookIo.java

Modified: 
maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/io/DefaultBookIo.java
URL: 
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/io/DefaultBookIo.java?rev=583277&r1=583276&r2=583277&view=diff
==============================================================================
--- 
maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/io/DefaultBookIo.java
 (original)
+++ 
maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/io/DefaultBookIo.java
 Tue Oct  9 12:52:25 2007
@@ -89,19 +89,36 @@
 
             String extension = siteModule.getExtension();
 
+            String sourceDirectory = File.separator + 
siteModule.getSourceDirectory() + File.separator;
+
+            String parserId = siteModule.getParserId();
+
             for ( Iterator j = files.iterator(); j.hasNext(); )
             {
                 File file = (File) j.next();
 
                 String name = file.getName();
 
-                if ( name.endsWith( extension ) )
+                String path = file.getAbsolutePath();
+
+                // first check if the file path contains one of the recognized 
source dir identifiers
+                // (there's trouble if a pathname contains 2 identifiers), 
then match file extensions (not unique).
+
+                if ( path.indexOf( sourceDirectory ) != -1 )
                 {
-                    name = name.substring( 0, name.length() - 
siteModule.getExtension().length() - 1 );
+                    name = name.substring( 0, name.length() - 
extension.length() - 1 );
 
-                    BookContext.BookFile bookFile = new BookContext.BookFile( 
file, siteModule.getParserId() );
+                    context.getFiles().put( name, new BookContext.BookFile( 
file, parserId ) );
+                }
+                else if ( name.endsWith( extension ) )
+                {
+                    name = name.substring( 0, name.length() - 
extension.length() - 1 );
 
-                    context.getFiles().put( name, bookFile );
+                    // don't overwrite if it's there already
+                    if ( !context.getFiles().containsKey( name ) )
+                    {
+                        context.getFiles().put( name, new 
BookContext.BookFile( file, parserId ) );
+                    }
                 }
             }
         }


Reply via email to