[jira] Created: (CONFIGURATION-427) XMLPropertyListConfiguration cannot save arrays in the correct plist form

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (CONFIGURATION-427) XMLPropertyListConfiguration cannot save arrays in the correct plist form

Gilles (Jira)
XMLPropertyListConfiguration cannot save arrays in the correct plist form
-------------------------------------------------------------------------

                 Key: CONFIGURATION-427
                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-427
             Project: Commons Configuration
          Issue Type: Bug
    Affects Versions: 1.6
         Environment: should show up in any environment, as the test cases are disabled for arrays and maps:
http://commons.apache.org/configuration/xref-test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.html#199
I was testing 1.6 using groovy console under Mac OS X 10.6
            Reporter: matthew smith
            Priority: Minor


groovy> import org.apache.commons.configuration.plist.*
groovy> def config = new XMLPropertyListConfiguration()
groovy> config.addProperty("things", ['chair', 'hat', 'door'])  
groovy> config.save(System.out)

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

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

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

expecting

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

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (CONFIGURATION-427) XMLPropertyListConfiguration cannot save arrays in the correct plist form

Gilles (Jira)

     [ https://issues.apache.org/jira/browse/CONFIGURATION-427?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Bourg updated CONFIGURATION-427:
-----------------------------------------

    Component/s: Format
    Description:
{code:java}
groovy> import org.apache.commons.configuration.plist.*
groovy> def config = new XMLPropertyListConfiguration()
groovy> config.addProperty("things", ['chair', 'hat', 'door'])  
groovy> config.save(System.out)
{code}

results in
 
{code:xml}
<?xml version="1.0"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="1.0">
    <dict>
        <key>things</key>
        <string>chair</string>

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

        <key>things</key>
        <string>door</string>
    </dict>
</plist>
{code}

expecting

{code:xml}
<?xml version="1.0"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="1.0">
    <dict>
        <key>things</key>
        <array>
          <string>chair</string>
          <string>hat</string>
          <string>door</string>
      </array>
    </dict>
</plist>
{code}

  was:
groovy> import org.apache.commons.configuration.plist.*
groovy> def config = new XMLPropertyListConfiguration()
groovy> config.addProperty("things", ['chair', 'hat', 'door'])  
groovy> config.save(System.out)

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

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

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

expecting

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


> XMLPropertyListConfiguration cannot save arrays in the correct plist form
> -------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-427
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-427
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: Format
>    Affects Versions: 1.6
>         Environment: should show up in any environment, as the test cases are disabled for arrays and maps:
> http://commons.apache.org/configuration/xref-test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.html#199
> I was testing 1.6 using groovy console under Mac OS X 10.6
>            Reporter: matthew smith
>            Priority: Minor
>
> {code:java}
> groovy> import org.apache.commons.configuration.plist.*
> groovy> def config = new XMLPropertyListConfiguration()
> groovy> config.addProperty("things", ['chair', 'hat', 'door'])  
> groovy> config.save(System.out)
> {code}
> results in
>  
> {code:xml}
> <?xml version="1.0"?>
> <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
> <plist version="1.0">
>     <dict>
>         <key>things</key>
>         <string>chair</string>
>         <key>things</key>
>         <string>hat</string>
>         <key>things</key>
>         <string>door</string>
>     </dict>
> </plist>
> {code}
> expecting
> {code:xml}
> <?xml version="1.0"?>
> <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
> <plist version="1.0">
>     <dict>
>         <key>things</key>
>         <array>
>           <string>chair</string>
>           <string>hat</string>
>           <string>door</string>
>       </array>
>     </dict>
> </plist>
> {code}

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (CONFIGURATION-427) XMLPropertyListConfiguration cannot save arrays in the correct plist form

Gilles (Jira)
In reply to this post by Gilles (Jira)

    [ https://issues.apache.org/jira/browse/CONFIGURATION-427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12928163#action_12928163 ]

Emmanuel Bourg commented on CONFIGURATION-427:
----------------------------------------------

Nested array structures are also flattened.

For example:

{code:java}
XMLPropertyListConfiguration config = new XMLPropertyListConfiguration();
config.addProperty("array", new String[][]{{"element1", "element2"},{"element3", "element4"}});
{code}

turns into:

{code:xml}
<plist version="1.0">
    <dict>
        <key>array</key>
        <string>element1</string>

        <key>array</key>
        <string>element2</string>

        <key>array</key>
        <string>element3</string>

        <key>array</key>
        <string>element4</string>
    </dict>
</plist>
{code}

> XMLPropertyListConfiguration cannot save arrays in the correct plist form
> -------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-427
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-427
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: Format
>    Affects Versions: 1.6
>         Environment: should show up in any environment, as the test cases are disabled for arrays and maps:
> http://commons.apache.org/configuration/xref-test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.html#199
> I was testing 1.6 using groovy console under Mac OS X 10.6
>            Reporter: matthew smith
>            Priority: Minor
>
> {code:java}
> groovy> import org.apache.commons.configuration.plist.*
> groovy> def config = new XMLPropertyListConfiguration()
> groovy> config.addProperty("things", ['chair', 'hat', 'door'])  
> groovy> config.save(System.out)
> {code}
> results in
>  
> {code:xml}
> <?xml version="1.0"?>
> <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
> <plist version="1.0">
>     <dict>
>         <key>things</key>
>         <string>chair</string>
>         <key>things</key>
>         <string>hat</string>
>         <key>things</key>
>         <string>door</string>
>     </dict>
> </plist>
> {code}
> expecting
> {code:xml}
> <?xml version="1.0"?>
> <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
> <plist version="1.0">
>     <dict>
>         <key>things</key>
>         <array>
>           <string>chair</string>
>           <string>hat</string>
>           <string>door</string>
>       </array>
>     </dict>
> </plist>
> {code}

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (CONFIGURATION-427) XMLPropertyListConfiguration cannot save arrays in the correct plist form

Gilles (Jira)
In reply to this post by Gilles (Jira)

    [ https://issues.apache.org/jira/browse/CONFIGURATION-427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12928591#action_12928591 ]

Emmanuel Bourg commented on CONFIGURATION-427:
----------------------------------------------

The array structure is lost for two reasons:
# adding an array of values is done by adding the values separately
# in a hierarchical configuration, a new node is created for each value

That means that adding an array like ['element1', 'element2'] results in the creation of two nodes for the same key. This is correct for an XMLConfiguration, it isn't for a plist.

A solution is to change how the nodes are added and ensure that paths are unique. I've implemented that for XMLPropertyListConfiguration and it works fine for the case reported. However it doesn't solve the issue with multidimensional arrays, this one is not specific to plist configuration.


> XMLPropertyListConfiguration cannot save arrays in the correct plist form
> -------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-427
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-427
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: Format
>    Affects Versions: 1.6
>         Environment: should show up in any environment, as the test cases are disabled for arrays and maps:
> http://commons.apache.org/configuration/xref-test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.html#199
> I was testing 1.6 using groovy console under Mac OS X 10.6
>            Reporter: matthew smith
>            Priority: Minor
>         Attachments: configuration-427.patch
>
>
> {code:java}
> groovy> import org.apache.commons.configuration.plist.*
> groovy> def config = new XMLPropertyListConfiguration()
> groovy> config.addProperty("things", ['chair', 'hat', 'door'])  
> groovy> config.save(System.out)
> {code}
> results in
>  
> {code:xml}
> <?xml version="1.0"?>
> <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
> <plist version="1.0">
>     <dict>
>         <key>things</key>
>         <string>chair</string>
>         <key>things</key>
>         <string>hat</string>
>         <key>things</key>
>         <string>door</string>
>     </dict>
> </plist>
> {code}
> expecting
> {code:xml}
> <?xml version="1.0"?>
> <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
> <plist version="1.0">
>     <dict>
>         <key>things</key>
>         <array>
>           <string>chair</string>
>           <string>hat</string>
>           <string>door</string>
>       </array>
>     </dict>
> </plist>
> {code}

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (CONFIGURATION-427) XMLPropertyListConfiguration cannot save arrays in the correct plist form

Gilles (Jira)
In reply to this post by Gilles (Jira)

     [ https://issues.apache.org/jira/browse/CONFIGURATION-427?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Bourg updated CONFIGURATION-427:
-----------------------------------------

    Attachment: configuration-427.patch

Attaching the proposed change for review

> XMLPropertyListConfiguration cannot save arrays in the correct plist form
> -------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-427
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-427
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: Format
>    Affects Versions: 1.6
>         Environment: should show up in any environment, as the test cases are disabled for arrays and maps:
> http://commons.apache.org/configuration/xref-test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.html#199
> I was testing 1.6 using groovy console under Mac OS X 10.6
>            Reporter: matthew smith
>            Priority: Minor
>         Attachments: configuration-427.patch
>
>
> {code:java}
> groovy> import org.apache.commons.configuration.plist.*
> groovy> def config = new XMLPropertyListConfiguration()
> groovy> config.addProperty("things", ['chair', 'hat', 'door'])  
> groovy> config.save(System.out)
> {code}
> results in
>  
> {code:xml}
> <?xml version="1.0"?>
> <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
> <plist version="1.0">
>     <dict>
>         <key>things</key>
>         <string>chair</string>
>         <key>things</key>
>         <string>hat</string>
>         <key>things</key>
>         <string>door</string>
>     </dict>
> </plist>
> {code}
> expecting
> {code:xml}
> <?xml version="1.0"?>
> <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
> <plist version="1.0">
>     <dict>
>         <key>things</key>
>         <array>
>           <string>chair</string>
>           <string>hat</string>
>           <string>door</string>
>       </array>
>     </dict>
> </plist>
> {code}

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (CONFIGURATION-427) XMLPropertyListConfiguration cannot save arrays in the correct plist form

Gilles (Jira)
In reply to this post by Gilles (Jira)

     [ https://issues.apache.org/jira/browse/CONFIGURATION-427?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Bourg updated CONFIGURATION-427:
-----------------------------------------

    Fix Version/s: 1.7
         Assignee: Emmanuel Bourg

> XMLPropertyListConfiguration cannot save arrays in the correct plist form
> -------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-427
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-427
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: Format
>    Affects Versions: 1.6
>         Environment: should show up in any environment, as the test cases are disabled for arrays and maps:
> http://commons.apache.org/configuration/xref-test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.html#199
> I was testing 1.6 using groovy console under Mac OS X 10.6
>            Reporter: matthew smith
>            Assignee: Emmanuel Bourg
>            Priority: Minor
>             Fix For: 1.7
>
>         Attachments: configuration-427.patch
>
>
> {code:java}
> groovy> import org.apache.commons.configuration.plist.*
> groovy> def config = new XMLPropertyListConfiguration()
> groovy> config.addProperty("things", ['chair', 'hat', 'door'])  
> groovy> config.save(System.out)
> {code}
> results in
>  
> {code:xml}
> <?xml version="1.0"?>
> <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
> <plist version="1.0">
>     <dict>
>         <key>things</key>
>         <string>chair</string>
>         <key>things</key>
>         <string>hat</string>
>         <key>things</key>
>         <string>door</string>
>     </dict>
> </plist>
> {code}
> expecting
> {code:xml}
> <?xml version="1.0"?>
> <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
> <plist version="1.0">
>     <dict>
>         <key>things</key>
>         <array>
>           <string>chair</string>
>           <string>hat</string>
>           <string>door</string>
>       </array>
>     </dict>
> </plist>
> {code}

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (CONFIGURATION-427) XMLPropertyListConfiguration cannot save arrays in the correct plist form

Gilles (Jira)
In reply to this post by Gilles (Jira)

     [ https://issues.apache.org/jira/browse/CONFIGURATION-427?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oliver Heger updated CONFIGURATION-427:
---------------------------------------

    Fix Version/s:     (was: 1.7)
                   1.8

> XMLPropertyListConfiguration cannot save arrays in the correct plist form
> -------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-427
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-427
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: Format
>    Affects Versions: 1.6
>         Environment: should show up in any environment, as the test cases are disabled for arrays and maps:
> http://commons.apache.org/configuration/xref-test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.html#199
> I was testing 1.6 using groovy console under Mac OS X 10.6
>            Reporter: matthew smith
>            Assignee: Emmanuel Bourg
>            Priority: Minor
>             Fix For: 1.8
>
>         Attachments: configuration-427.patch
>
>
> {code:java}
> groovy> import org.apache.commons.configuration.plist.*
> groovy> def config = new XMLPropertyListConfiguration()
> groovy> config.addProperty("things", ['chair', 'hat', 'door'])  
> groovy> config.save(System.out)
> {code}
> results in
>  
> {code:xml}
> <?xml version="1.0"?>
> <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
> <plist version="1.0">
>     <dict>
>         <key>things</key>
>         <string>chair</string>
>         <key>things</key>
>         <string>hat</string>
>         <key>things</key>
>         <string>door</string>
>     </dict>
> </plist>
> {code}
> expecting
> {code:xml}
> <?xml version="1.0"?>
> <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
> <plist version="1.0">
>     <dict>
>         <key>things</key>
>         <array>
>           <string>chair</string>
>           <string>hat</string>
>           <string>door</string>
>       </array>
>     </dict>
> </plist>
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira