蚂蚁:build.xml文件; XML文档结构必须在同一实体中开始和结束

时间:2013-08-03 20:34:14

标签: java xml ant

我有以下目录结构

+project
    +--profile
         +---src
         +---WebContent
         +---build

我正在尝试使用Ant进行编译和复制,但是当我执行以下 build.xml 文件时,我收到此错误 XML文档结构必须在同一实体内开始和结束没有别的。我检查了几个几乎相似的问题,但没有一个问题有帮助,唯一的问题是通过在评论中添加任何不适合我的内容来收集。我在构建文件中缺少什么?

<?xml version="1.0"?>
<project name="profile" basedir="." default="Task-of-build">
<property name="src.dir" value="src"/>
<property name="webcontent.dir" value="WebContent"/>
<property name="javadoc" value="doc"/>
<property name="name" value="profile"/>
<property name="build.dir" value="${webcontent.dir}/WEB-INF/classes"/>
<property name="backup.dir" value="C:/project/backup"/>

<path id="classpathvalue">
    <fileset dir="${webcontent.dir}/WEB-INF/lib">
        <include name="*.jar"/>
    <!-- this is a comment -->
    </fileset>
    <pathelement path="${build.dir}"/>
</path>

<target name="javadoc">
    <javadoc packagenames="com.mucyo.prep.profile.*" sourcepath="${src.dir}"
        destdir = "doc" version="true" windowtitle="Profile Mngt">
       <doctitle><![CDATA[<h1>=Profile Mgnt =</h1>]]</doctitle>
       <bottom><![CDATA[Copyright 2011. All Rights reserved></bottom>
       <group title="Beans packages" packages="com.mucyo.prep.profile.bean.*"/>
       <group title="Service packages" pachages="com.mucyo.prep.profile.services.*"/>
       <group title="servlets packages" packages="com.mucyo.profile.servlets.*"/>
    </javadoc>
</target>
<target name="Task-of-build">
    <echo message="This a build example"/>
</target>
<target name="build" description="compiling java files">
    <mkdir dir="${build.dir}"/>
    <javac destdir="${build.dir}" source="1.6" target="1.6" debug="true"
       deprecation="false" optimize="false" failonerror="true">
          <src path="${src.dir}"/>
          <classpath refid="classpathvalue"/>
    </javac>
</target>
<target name="create-war" depends="build">
    <war destfile="${name}.war" webxml="${webcontent.dir}/WEB-INF/web.xml">
       <fileset dir=".">
          <include name="**/*.*"/>
       </fileset>
    </war>
</target>
<target name="backup" depends="build">
    <mkdir dir="${backup.dir}"/>
    <copy todir="${backup.dir}" preservelastmodified="true">
       <fileset dir=".">
          <include dir="${src.dir}:${build.dir}"/>
       </fileset>
    </copy>
</target>
<target name="clean" depends="build">
    <delete>
       <fileset dir="${build.dir}">
          <include name="**/*.class"/>
       </fileset>
    </delete>
</target>
</project>

1 个答案:

答案 0 :(得分:4)

我认为这是问题:

<doctitle><![CDATA[<h1>=Profile Mgnt =</h1>]]</doctitle>
<bottom><![CDATA[Copyright 2011. All Rights reserved></bottom>

您的CDATA部分都没有正确终止,因此您的文件根本就不是有效的XML。我想你应该:

<doctitle><![CDATA[<h1>=Profile Mgnt =</h1>]]></doctitle>
<bottom><![CDATA[Copyright 2011. All Rights reserved>]]></bottom>

...虽然这些字符串中的第二个字符串可以执行任何需要在XML中进行转义的内容,但我甚至都没有使用CDATA部分:

<doctitle><![CDATA[<h1>=Profile Mgnt =</h1>]]></doctitle>
<bottom>Copyright 2011. All Rights reserved></bottom>

......甚至第一个只需要开放的尖括号逃脱:

<doctitle>&lt;h1>=Profile Mgnt =&lt;/h1></doctitle>
<bottom>Copyright 2011. All Rights reserved></bottom>

(您也可以选择将>转换为&gt;,但我认为您不必这样做。)

相关问题