commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <Ralph.Go...@dslextreme.com>
Subject Re: [Configuration] Call me a moron, but I just can't make it work!
Date Mon, 14 Jul 2008 14:37:25 GMT
Your problem is that you are searching for the value of an element, not 
the element name, i.e. there are no elements named SndwichFillings, 
Dictionary or SidebarTitle. Your element names are all named "key".  I 
can never remember how to filter based on the value of an element of a 
key using the default expression language. With XML I use the XPath 
expression lanaguage.

Michael Robinson wrote:
> Hi,
>
> I'm writing a program that must load, search, edit and save Mac OS X 
> plist files.
>
> I was attempting to use apple's NS* foundation classes, but I couldn't 
> work out how to write to the plist files (maybe I'm just stupid).
>
> I searched around the internet and was overjoyed to find 
> apache.commons.configuration.
>
> I've played with it for the past few days, trying to figure out how 
> I'm meant to get data out of the plist files I'm working with.
>
> So far, nothing I've tried has worked:
>
> ***CODE***
>
> XMLPropertyListConfiguration sigh = new 
> XMLPropertyListConfiguration(plistPath);
>
>            sigh.load();
>
>            
> System.out.println(sigh.containsKey("SandwichFillings"));    //this 
> prints "true" - great!
>
>     //What I actually want, is the "SidebarTitle" string.  When I try:
>
> sigh.containsKey("SidebarTitle");
>
> //or
>
> sigh.containsKey("SandwichFillings.Dictionary.SidebarTitle");
>
> //or any other combination that I could think of - I get false.
>
> ***/CODE***
>
> If I save the file with a different name, I can open it and see that 
> the information has all been copied correctly.
>
> I just haven't been able to figure out how to access/edit information 
> in the file.
>
> For the past two days I've been trawling the internet and trying 
> everything I could think of, but I am yet to succeed.
>
> Is what I want to do even possible?  If so, please tell me how!  
> Please!  It's been driving me insane.
>
> This is an example of the files I'll be reading (currently I want to 
> get key = SidebarTitle, and change its value).
>
> ***PLIST FILE***
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
> "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
> <plist version="1.0">
> <dict>
>     <key>SandwichFillings</key>
>     <array>
>         <dict>
>             <key>Dictionary</key>
>             <dict>
>            
>                 <key>Changed</key>
>                 <true/>
>                
>                 <key>ColourStyles</key>
>                 <dict/>
>                
>                 <key>CreditRapidWeaver</key>
>                 <true/>
>                
>                 <key>CustomCopyrightUsed</key>
>                 <false/>
>                
>                 <key>CustomSiteTitleUsed</key>
>                 <false/>
>                
>                 <key>CustomSloganUsed</key>
>                 <false/>
>                
>                 <key>DefaultLinkTarget</key>
>                 <string>self</string>
>                
>                 <key>FilenameExtension</key>
>                 <string>html</string>
>                
>                 <key>HasCustomThemeStyle</key>
>                 <true/>
>                
>                 <key>ImageFormat</key>
>                 <string>Original</string>
>                
>                 <key>ImageQuality</key>
>                 <string>High</string>
>                
>                 <key>IndexFilename</key>
>                 <string></string>
>                
>                 <key>OutputFormat</key>
>                 <string>Default</string>
>                
>                 <key>OutputXMLDeclaration</key>
>                 <false/>
>                
>                 <key>SidebarEnabled</key>
>                 <integer>1</integer>
>                
>                 <key>SidebarTitle</key>
>                 <string>SIDE TITLE</string>
>                
>                 <key>TextEncoding</key>
>                 <string>utf-8</string>
>             </dict>
>             <key>Files</key>
>             <array>
>                 <string>Sidebar.as</string>
>             </array>
>             <key>Subsandwiches</key>
>             <array/>
>         </dict>
>     </array>
>     <key>Type</key>
>     <string>Page Attributes</string>
> </dict>
> </plist>
>
> ***/PLIST FILE***
>
> I'm using Netbeans 6.01 with Mavenide, Maven2.  I get no errors at 
> compile time, no error during my attempts to get the key/value (unless 
> one counts "null" when you know it's damn-well there as an error!).
>
> Thank you for taking the time to read my message,
>
> Mike
>
> -    -    -
> Everything is gone;
> Your life's work has been destroyed.
> Squeeze trigger (yes/no)?
> -    -    -
> David Carlson

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


Mime
View raw message