You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by em...@free.fr on 2003/10/16 15:31:39 UTC

j:file and xml files


Hi,

How can I generate XML files with <j:file ... >, notice that I need to add DTD
declaration in generated files. 

    <j:file name="${basedir}/resources/application.xml" escapeText="true"
trim="true" prettyPrint="true" outputMode="xml" xmlns="dummy">

<!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application
1.3//EN' 'http://java.sun.com/dtd/application_1_3.dtd'>
<application>
    <display-name>${j2ee.displayName}</display-name>
    <description>${j2ee.displayName}</description>
    <module>
        <ejb>${ejb}</ejb>
    </module>
    <module>
        <web>
          <web-uri>${uri}</web-uri>
          <context-root>${j2ee.contextRoot}</context-root>
        </web>
      </module>
</application>

    </j:file>

Maven crash with : 

org.xml.sax.SAXParseException: doctype not allowed in content.
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at javax.xml.parsers.SAXParser.parse(Unknown Source)
        at
org.apache.maven.plugin.PluginCacheManager.parse(PluginCacheManager.java:365)
        at
org.apache.maven.plugin.PluginManager.loadJellyScript(PluginManager.java:481)
      

Thx,
-emmanuel

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: j:file and xml files

Posted by Richard Kirby <rb...@capdm.com>.
emmanuel.boudrant@free.fr wrote:

>Hi,
>
>How can I generate XML files with <j:file ... >, notice that I need to add DTD
>declaration in generated files. 
>
>
>  
>
Try:

    <j:file name="${basedir}/resources/application.xml" escapeText="true"
trim="true" prettyPrint="true" outputMode="xml" xmlns="dummy">
<![CDATA[
<!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application
1.3//EN' 'http://java.sun.com/dtd/application_1_3.dtd'>
]]>
<application>
    <display-name>${j2ee.displayName}</display-name>
    <description>${j2ee.displayName}</description>
    <module>
        <ejb>${ejb}</ejb>
    </module>
    <module>
        <web>
          <web-uri>${uri}</web-uri>
          <context-root>${j2ee.contextRoot}</context-root>
        </web>
      </module>
</application>

    </j:file>

The issue is that maven.xml is itself an XML file and the parser does 
not expect to find a <!DOCTYPE declaration in the middle of an XML file, 
so you need to escape it by using the CDATA declaration. You might need 
to move the closing ]]> to the end of your file contents so that none of 
the XML fragment is interpreted by the parser of the maven.xml file!

Richard.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: j:file and xml files

Posted by di...@multitask.com.au.
Have a look at:

http://jakarta.apache.org/commons/jelly/libs/xml/tags.html#xml:doctype
--
dIon Gillard, Multitask Consulting
Blog:      http://blogs.codehaus.org/people/dion/


emmanuel.boudrant@free.fr wrote on 16/10/2003 11:31:39 PM:

> 
> 
> Hi,
> 
> How can I generate XML files with <j:file ... >, notice that I need to 
add DTD
> declaration in generated files. 
> 
>     <j:file name="${basedir}/resources/application.xml" 
escapeText="true"
> trim="true" prettyPrint="true" outputMode="xml" xmlns="dummy">
> 
> <!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE 
Application
> 1.3//EN' 'http://java.sun.com/dtd/application_1_3.dtd'>
> <application>
>     <display-name>${j2ee.displayName}</display-name>
>     <description>${j2ee.displayName}</description>
>     <module>
>         <ejb>${ejb}</ejb>
>     </module>
>     <module>
>         <web>
>           <web-uri>${uri}</web-uri>
>           <context-root>${j2ee.contextRoot}</context-root>
>         </web>
>       </module>
> </application>
> 
>     </j:file>
> 
> Maven crash with : 
> 
> org.xml.sax.SAXParseException: doctype not allowed in content.
>         at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown 
Source)
>         at javax.xml.parsers.SAXParser.parse(Unknown Source)
>         at
> 
org.apache.maven.plugin.PluginCacheManager.parse(PluginCacheManager.java:365)
>         at
> 
org.apache.maven.plugin.PluginManager.loadJellyScript(PluginManager.java:481)
> 
> 
> Thx,
> -emmanuel
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org