ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chen Becky" <Becky.C...@core.fanniemae.com>
Subject RE: Doubt in using ENTITY
Date Wed, 29 Oct 2003 22:33:41 GMT

Bob (Robert E. Newby),

Your code sample is helpful for me as well.
I have an extra requirement that I need to setup a property with
different value based on some conditions.

I wonder if I can have build-properties.xml looks like this:
	<a>
		<property name="output-char" value="A"/>
	<a/>
	<b>
		<property name="output-char" value="B"/>
	<b/>
	<c>
		<property name="output-char" value="C"/>
	<c/>


But when I invoke "build-properties-file;" from build.xml, how can I
tell build-properties.xml to run only <a>, <b> or <c>?
I know this is more like XML question than ANT, any thoughts?

Thanks.
Becky
-----Original Message-----
From: Robert E. Newby [mailto:Bob_Newby@vestmark.com] 
Sent: Wednesday, October 29, 2003 11:15 AM
To: user@ant.apache.org
Subject: Re: Doubt in using ENTITY


vikramjit singh wrote:
> 
> Hi,
> 
> I am making a properties.xml file, which holds all the properties and 
> the corresponding path. I am including the properties.xml file in 
> build.xml like this below
> 
> <!-- Define the target includes for all package types --> <!DOCTYPE 
> project [
>     <!ENTITY properties SYSTEM "file:./properties.xml">
> ]>
> 
> <project name="CustomerProfile" default="dist" basedir=".">
> 
>   &properties;
> 
> ...
> </project>
> 
> In my properties file, if i make the xml well formed i.e. enclose the 
> properties and path tags in a parent tag, then i get the following 
> error. The properties.xml file structure snippet is as below..
> 
> <?xml version="1.0"?>
> 
> <properties>
>     <property environment="env"/>
>     <property name="src" value="src"/>
> ...
> </properties>
> 
> BUILD FAILED
> file:./properties.xml:1: more pseudo attributes is expected.
> 
> But if i remove, <?xml version="1.0"?> and the <properties> tag and 
> dont enclose a parent tag, then all runs fine.
> 
> Is this as it is to be done, or am i missing something.
> 
> Regards,
> Vikram.


Vikram,

We do this all the time, with great results.  Here are some code
snippets.

>From a representative build.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project [
  <!ENTITY build-properties-file SYSTEM "file:build-properties.xml">
  <!ENTITY livespace-build-properties-file SYSTEM
"file:livespace-build-properties.xml">
]>

and:

<project name="Master com.viviport Building and Deployment"
default="usage" basedir="../..">

  <!-- PROPERTIES -->

  <!-- load standard build properties -->
  <property name="top" value="${basedir}/utilities"/>
  &build-properties-file;

etc.

In the referenced build-properties.xml file, both:

<?xml version="1.0" encoding="UTF-8"?>

and:

  <!-- Set path to parent of all project trees -->
  <property name="dir.dev" value="${top}/.."/>
  
  <property name="dir.utilities" value="${dir.dev}/utilities"/>
  <property name="dir.utilities.build" value="${dir.utilities}/build"/>
  <property name="dir.utilities.tools" value="${dir.utilities}/tools"/>
  <property name="dir.utilities.tools.ant"
value="${dir.utilities.tools}/ant"/>
  <property name="dir.utilities.tools.ant.lib"
value="${dir.utilities.tools.ant}/lib"/>

etc.

As you've discovered, since the &build-properties-file; performs textual
inclusion of the external entity's content, the external entity cannot
have a root xml element.

I hope this helps clear things up for you.

Regards,

Bob
--
Robert E. Newby

Principal Software Engineer
Vestmark, Inc.
500 Edgewater Drive, Suite 564
Wakefield, Massachusetts 01880 USA
781-224-3646 | Bob _ Newby @ vestmark . com | www . vestmark . com


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message