See the following (examples are some chunks of xsl I was playing with - resemblance to 
valid ant files at this point is
coincidental)

An XML file:
<?xml version="1.0"?>
<project name="_temp" default="export" basedir=".">
  <property name="src" value="src1"/>
  <property name="dest" value="dest1"/>
</project>

an XSLT file:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/project">
<project name="_temp" default="export" basedir=".">

  <target name="transform" depends="init">
  <xsl:variable name="destx">
  <xsl:text>${</xsl:text><xsl:value-of 
select="property[@name='dest']/@value"/><xsl:text>}</xsl:text>
  </xsl:variable>
  <xsl:variable name="desty">${<xsl:value-of 
select="property[@name='dest']/@value"/>}</xsl:variable>
  <xsl:variable name="dest" select="concat('${',property[@name='dest']/@value,'}')"/>


    <mkdir dir="{$dest}"/> <!-- NOTE: dynamically generated property reference. all of 
destx, desty and dest produce same output -->
  </target>

  <target name="clean">
    <delete dir="{'${dest}'}"/> <!-- NOTE: double escaping produces a standard Ant 
property reference -->
  </target>
</project>
</xsl:template>
</xsl:stylesheet>


> -----Original Message-----
> From: Frank Carver [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 10, 2001 2:21 AM
> To: [EMAIL PROTECTED]
> Subject: Generating build files with XSLT
>
>
> There has been some discussion here about generating build
> files with XSLT, so I tried it yesterday.
> I came up against a problem which seems to be the result of
> an ANT design decision and I wonder
> if anyone has worked round it.
>
> My need is to maintain a central, large, "template" build
> file with various subsitutions in it, and generate
> a specific build file for each new project or to update the
> build file of all the existing projects when the
> template changes.  This seemed an ideal use for XSLT - I
> could specify the project as a simple XML
> defintion, and the XSLT style process would merge the
> template and any extension specified in the
> project file.
>
> Unfortunately, Ant uses ${name} to refer to properties, and
> {name} is reserved XSLT syntax.  When I ran
> my XSLT process the resulting build file was full of just
> "$", which made no sense to Ant.
>
> Any suggestions?
>
>
>

Reply via email to