You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Matthew Smith <sm...@me.com> on 2010/11/03 02:51:11 UTC

XMLPropertyListConfiguration and saving arrays

Hi! I am attempting to save out plist files from some groovy code, and I am not having much success when it comes to arrays. Instead of values wrapped in array tags, I get a series of key-value pairs. Here is my code (hopefully it should be close enough to java to be clear):

groovy> import org.apache.commons.configuration.plist.* 
groovy> def bob = new XMLPropertyListConfiguration() 
groovy> bob.addProperty("key", "stringvalue") 
groovy> bob.addProperty("numbers", 12345) 
groovy> bob.addProperty("settings", ['height': 20, 'width': 40, 'scale':'very yes']) 
groovy> bob.addProperty("things", ['chair', 'hat', 'door']) 
groovy> bobsave(System.out) 

<?xml version="1.0"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="1.0">
    <dict>
        <key>key</key>
        <string>stringvalue</string>

        <key>numbers</key>
        <integer>12345</integer>

        <key>settings</key>
        <dict>
            <key>height</key>
            <integer>20</integer>

            <key>width</key>
            <integer>40</integer>

            <key>scale</key>
            <string>very yes</string>
        </dict>

        <key>things</key>
        <string>chair</string>

        <key>things</key>
        <string>hat</string>

        <key>things</key>
        <string>door</string>
    </dict>
</plist>


I would expect something like:

        <key>things</key>
        <array>
          <string>chair</string>
          <string>hat</string>
        <string>door</string>
      </array>


From what I can tell, the test case for this currently does not test arrays, the code is commented out with the caption "todo : investigate why the array structure of 'newarray' is lost in the saved file":
http://commons.apache.org/configuration/xref-test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.html#199

I cannot find an open issue in jira that relates to XMLPropertyListConfiguration, either. Is the output I am getting correct, or is it effected by the issue that is preventing array testing, or something else? should I post a bug?

I should note that I am using the commons-configuration-1.6.tar.gz as a source for org.apache.commons.configuration.

Any help would be great!

Thanks,
Matt Smith

Re: XMLPropertyListConfiguration and saving arrays

Posted by Matthew Smith <sm...@me.com>.
Thanks Emmanuel,

Will post it asap.

Thanks for chasing this up!
Matt

On 03/11/2010, at 8:56 PM, Emmanuel Bourg <eb...@apache.org> wrote:

> Hi Matthew,
> 
> I have to get another look at this issue, I don't remember why I gave up on the arrays when I implemented the plist configurations.
> 
> Could you register your report in JIRA please?
> 
> Emmanuel Bourg
> 
> 
> Le 03/11/2010 02:51, Matthew Smith a écrit :
>> Hi! I am attempting to save out plist files from some groovy code, and I
>> am not having much success when it comes to arrays. Instead of values
>> wrapped in array tags, I get a series of key-value pairs. Here is my
>> code (hopefully it should be close enough to java to be clear):
>> 
>> groovy> import org.apache.commons.configuration.plist.*
>> groovy> def bob = new XMLPropertyListConfiguration()
>> groovy> bob.addProperty("key", "stringvalue")
>> groovy> bob.addProperty("numbers", 12345)
>> groovy> bob.addProperty("settings", ['height': 20, 'width': 40,
>> 'scale':'very yes'])
>> groovy> bob.addProperty("things", ['chair', 'hat', 'door'])
>> groovy> bob.save(System.out)
>> 
>> <?xml version="1.0"?>
>> <!DOCTYPE plist SYSTEM
>> "file://localhost/System/Library/DTDs/PropertyList.dtd">
>> <plist version="1.0">
>> <dict>
>> <key>key</key>
>> <string>stringvalue</string>
>> 
>> <key>numbers</key>
>> <integer>12345</integer>
>> 
>> <key>settings</key>
>> <dict>
>> <key>height</key>
>> <integer>20</integer>
>> 
>> <key>width</key>
>> <integer>40</integer>
>> 
>> <key>scale</key>
>> <string>very yes</string>
>> </dict>
>> 
>> <key>things</key>
>> <string>chair</string>
>> 
>> <key>things</key>
>> <string>hat</string>
>> 
>> <key>things</key>
>> <string>door</string>
>> </dict>
>> </plist>
>> 
>> 
>> I would expect something like:
>> 
>> <key>things</key>
>> <array>
>> <string>chair</string>
>> <string>hat</string>
>> <string>door</string>
>> </array>
>> 
>> 
>> From what I can tell, the test case for this currently does not test
>> arrays, the code is commented out with the caption "todo : investigate
>> why the array structure of 'newarray' is lost in the saved file":
>> http://commons.apache.org/configuration/xref-test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.html#199
>> 
>> I cannot find an open issue in jira that relates to
>> XMLPropertyListConfiguration, either. Is the output I am getting
>> correct, or is it effected by the issue that is preventing array
>> testing, or something else? should I post a bug?
>> 
>> I should note that I am using the commons-configuration-1.6.tar.gz as a
>> source for org.apache.commons.configuration.
>> 
>> Any help would be great!
>> 
>> Thanks,
>> Matt Smith
> 
> 

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


Re: XMLPropertyListConfiguration and saving arrays

Posted by Emmanuel Bourg <eb...@apache.org>.
Hi Matthew,

I have to get another look at this issue, I don't remember why I gave up 
on the arrays when I implemented the plist configurations.

Could you register your report in JIRA please?

Emmanuel Bourg


Le 03/11/2010 02:51, Matthew Smith a écrit :
> Hi! I am attempting to save out plist files from some groovy code, and I
> am not having much success when it comes to arrays. Instead of values
> wrapped in array tags, I get a series of key-value pairs. Here is my
> code (hopefully it should be close enough to java to be clear):
>
> groovy> import org.apache.commons.configuration.plist.*
> groovy> def bob = new XMLPropertyListConfiguration()
> groovy> bob.addProperty("key", "stringvalue")
> groovy> bob.addProperty("numbers", 12345)
> groovy> bob.addProperty("settings", ['height': 20, 'width': 40,
> 'scale':'very yes'])
> groovy> bob.addProperty("things", ['chair', 'hat', 'door'])
> groovy> bob.save(System.out)
>
> <?xml version="1.0"?>
> <!DOCTYPE plist SYSTEM
> "file://localhost/System/Library/DTDs/PropertyList.dtd">
> <plist version="1.0">
> <dict>
> <key>key</key>
> <string>stringvalue</string>
>
> <key>numbers</key>
> <integer>12345</integer>
>
> <key>settings</key>
> <dict>
> <key>height</key>
> <integer>20</integer>
>
> <key>width</key>
> <integer>40</integer>
>
> <key>scale</key>
> <string>very yes</string>
> </dict>
>
> <key>things</key>
> <string>chair</string>
>
> <key>things</key>
> <string>hat</string>
>
> <key>things</key>
> <string>door</string>
> </dict>
> </plist>
>
>
> I would expect something like:
>
> <key>things</key>
> <array>
> <string>chair</string>
> <string>hat</string>
> <string>door</string>
> </array>
>
>
>  From what I can tell, the test case for this currently does not test
> arrays, the code is commented out with the caption "todo : investigate
> why the array structure of 'newarray' is lost in the saved file":
> http://commons.apache.org/configuration/xref-test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.html#199
>
> I cannot find an open issue in jira that relates to
> XMLPropertyListConfiguration, either. Is the output I am getting
> correct, or is it effected by the issue that is preventing array
> testing, or something else? should I post a bug?
>
> I should note that I am using the commons-configuration-1.6.tar.gz as a
> source for org.apache.commons.configuration.
>
> Any help would be great!
>
> Thanks,
> Matt Smith