ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patrick Surry <Patrick.Su...@quadstone.com>
Subject Re: AW: Custom ant task with nested 'literal' XML data fragment?
Date Fri, 24 Oct 2003 14:03:08 GMT
OK, I'd thought of that, it just looks a bit ugly to have to embed XML in
CDATA.  I wondered if my setStyle() method could somehow get access to the DOM
fragment for its content and process it itself (without triggering any of Ant's
inner setXXX methods) rather than have to parse a string from a CDATA section
separately.

Cheers,
Patrick

=================================

Hi Patrick,
it is perfectly possible to write a custom task which will accept the nested
literal XML data fragment.
You might want to take a look at the <echo/> task and at the <replace/>
task.

in your build file, you need to enclose your XML fragment in <![CDATA[
section like this :
<xslt in="foo.xml" out="bar.xml>
  <style><![CDATA[
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
      <xsl:template match="something">
        <!-- more random xslt stuff -->
      </xsl:template>
    </xsl:transform>
    ]]>
  </style>
</xslt>

Your build file fragment suggests that you have an <xslt> task with a
<style> nested element.
In the class representing in Java the style nested element you need then to
insert this method :
(copied from org.apache.tools.ant.taskdefs.Echo) :
    /**
     * Set the XSL fragment inline.
     */
    public void addText(String msg) {
        // replaceProperties allows as its name suggest to replace
${something} tokens with their value.
        xsltext = getProject().replaceProperties(msg);
    }

Hopes this helps,

Antoine

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


Mime
View raw message