Bug 26849 - [PATCH] Pathconvert output in xml format and write to file
Summary: [PATCH] Pathconvert output in xml format and write to file
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.7.0
Hardware: Other other
: P3 enhancement (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2004-02-11 10:19 UTC by Nicola Ken Barozzi
Modified: 2009-07-31 04:04 UTC (History)
0 users



Attachments
pathconvert.patch (5.81 KB, patch)
2004-02-11 10:20 UTC, Nicola Ken Barozzi
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nicola Ken Barozzi 2004-02-11 10:19:46 UTC
I have thge need of writing in xml a set of file and dir names. Since
PathConvert makes it easy to do exactly what I want but outputs to a single
string with a separator, I have patched it to output also in xml format.

So instead of

 path1,path2

it writes

 <path><pathelement>path1</pathelement><pathelement>path2</pathelement></path>

The option is

 @type="plain|xml"

Then I need to write it to a file, so I added also a file attribute, that is not
exclusive with the property attribute

 @file="filetowriteto"

I'm using it in a scratchpad project in Forrest
Comment 1 Nicola Ken Barozzi 2004-02-11 10:20:18 UTC
Created attachment 10309 [details]
pathconvert.patch
Comment 2 Jan Mat 2004-02-11 10:32:24 UTC
That works:

    <fileset id="fs" dir="C:/WINNT" includes="*.ini"/>

    <pathconvert 
      property="fs.tmp"
      refid="fs"
      pathSep="&lt;/pathelement&gt;&lt;pathelement&gt;"
    />
    <property name="fs.xml" value="&lt;path&gt;&lt;pathelement&gt;${fs.tmp}
&lt;/pathelement&gt;&lt;/path&gt;"/>

    <echo>${fs.xml}</echo>
Comment 3 peter reilly 2004-02-11 11:28:05 UTC
The patch does not handle filenames that contain characters
that need to be escaped for xml (<>& others?).
{ok, I know that the current code does not handle filenames
with ',' in them}

Also would be nice to have update for manual and very
nice to have unit tests......
Comment 4 Nicola Ken Barozzi 2004-02-11 14:46:33 UTC
peter reilly wrote:
> The patch does not handle filenames that contain characters
> that need to be escaped for xml (<>& others?).

Gosh, I didn't know filenames could have those chars B-)

>{ok, I know that the current code does not handle filenames
>with ',' in them}

Can , also be in filenames?

> Also would be nice to have update for manual and very
> nice to have unit tests......

At first I wanted to see if it could be ok. In any case I should write some
tests, I really gotta learn to write them quicker :-)  brb
Comment 5 peter reilly 2004-02-11 15:14:35 UTC
>Gosh, I didn't know filenames could have those chars B-)
Easy:
<project>
  <concat destfile="&lt;x.out&gt;">
    Hello world
  </concat>
  <concat><path path="&lt;x.out&gt;"/></concat>
</project>

>Can , also be in filenames?
They are used for example in rcs/cvs files on the server.

Using xml with it's defined escapes makes a lot of sense for
pathconvert.

One could escape them (I think) by checking for dubious
characters and by placing the name in a <![CDATA[]] structure.
Comment 6 Nicola Ken Barozzi 2004-04-29 10:58:32 UTC
In bug 28681 (SQLExec xml output) there's the "escape" method that escapes xml.

Sorry, don't have time to include it here, just adding it to this bug as a reminder.