簡體   English   中英

螞蟻:build.xml文件; XML文檔結構必須在同一實體中開始和結束

[英]Ant:build.xml; XML document structure must start and end within the same entity

我有以下目錄結構

+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>

我相信這是問題所在:

<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;但我不相信你必須這樣做。)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM