-----Original Message-----
From: Jowie [mailto:joe.n...@mac.com] 
Sent: Monday, December 07, 2009 1:40 PM
To: user@ant.apache.org
Subject: RE: RegExp help needed!

/*
  <Question ID="531" Subject="L" Category="Punc" Presentation="PT01"
Engine="MC01" Body="test" Media="/bgmain/Image.ashx?ID=12">
    <TipID/>
    <Answers>
      <Answer ID="1457" Valid="false" Position="1"
Media="/bgmain/Image.ashx?ID=112">txt</Answer>
      <Answer ID="1458" Valid="true" Position="2"
Media="/bgmain/Image.ashx?ID=113">txt</Answer>
      <Answer ID="1459" Valid="false" Position="3"
Media="/bgmain/Image.ashx?ID=114">txt</Answer>
      <Answer ID="1460" Valid="false" Position="4"
Media="/bgmain/Image.ashx?ID=115">txt</Answer>
    </Answers>
  </Question>
-----

So from this, I need to:
1. Find any Media attribute, nested or otherwise (e.g. in E4X,
questionxm...@media)
2. Store each of these to download them
3. Replace the values in the XML with local path equivalents, e.g.
"images/ima...@{imageid}.jpg"
4. Go through stored list, download the images and put them in the right
place (I know how to do that bit with copy url)

*/


a quick response to get you going =

<project name="bla" default="main" basedir=".">
  <!-- Import XMLTask -->
  <taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"/>

  <target name="depends">
    <xmltask source="xpathtest.xml">
      <call path="/Question/Answers/*" target="foo">
        <param name="img" path="@Media" />
      </call>
    </xmltask>
  </target>

  <target name="foo">

<!-- do something with img or write to a file like that, there may be
another way with xmltask buffer too, never used it, see xmltask docs
-->
    <echo file="foo.txt" append="true">${img}${line.separator}</echo>
    <echo>Image = ${img}</echo>
  </target>

  <target name="xmlreplace">
    <xmltask source="xpathtest.xml" dest="xxxpathtest.xml" report="true">
      <regexp path="/Question/Answers/*/@Media"
              pattern="(.+\.)(.+=)(\d+)"
              replace="$1$3jpg"
      />
    </xmltask>
  </target>

  <target name="main" depends="depends,xmlreplace"/>
</project>


Regards, Gilbert
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org

Reply via email to