Question

I need to read into memory XML file with such header

<?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">

It is XML "Apple Property List" . XML Schema is below:

<!ENTITY % plistObject "(array | data | date | dict | real | integer | string | true | false )" >
<!ELEMENT plist %plistObject;>
<!ATTLIST plist version CDATA "1.0" >

<!-- Collections -->
<!ELEMENT array (%plistObject;)*>
<!ELEMENT dict (key, %plistObject;)*>
<!ELEMENT key (#PCDATA)>

<!--- Primitive types -->
<!ELEMENT string (#PCDATA)>
<!ELEMENT data (#PCDATA)> <!-- Contents interpreted as Base-64 encoded -->
<!ELEMENT date (#PCDATA)> <!-- Contents should conform to a subset of ISO 8601 (in particular, YYYY '-' MM '-' DD 'T' HH ':' MM ':' SS 'Z'.  Smaller units may be omitted with a loss of precision) -->

<!-- Numerical primitives -->
<!ELEMENT true EMPTY>  <!-- Boolean constant true -->
<!ELEMENT false EMPTY> <!-- Boolean constant false -->
<!ELEMENT real (#PCDATA)> <!-- Contents should represent a floating point number matching ("+" | "-")? d+ ("."d*)? ("E" ("+" | "-") d+)? where d is a digit 0-9.  -->
<!ELEMENT integer (#PCDATA)> <!-- Contents should represent a (possibly signed) integer number in base 10 -->

What is right name for such data format?

What Java library to use for reading such file? I would like to get in memory standard Java Collections (that implements List and/or Set)

Related:

Both questions are 2 years old, so maybe there is something better?

Was it helpful?

Solution

Go with http://code.google.com/p/plist/

<dependency>
    <groupId>com.googlecode.plist</groupId>
    <artifactId>dd-plist</artifactId>
    <version>1.3</version> <!-- corresponds to r103 -->
</dependency>

on http://code.google.com/p/plist/wiki/Examples

You can feed the PropertyListParser with a File, an InputStreams or a byte array. The parse method of the PropertyListParser will parse the input and give you a NSObject as result. Generally this is a NSDictionary but it can also be a NSArray.

is has converter toJavaObject()

 Object com.dd.plist.NSObject.toJavaObject()


Converts this NSObject into an equivalent object of the Java Runtime Environment. 

NSArray objects are converted to arrays. 
NSDictionary objects are converted to objects extending the java.util.Map class. 
NSSet objects are converted to objects extending the java.util.Set class. 
NSNumber objects are converted to primitive number values (int, long, double or boolean). 
NSString objects are converted to String objects. 
NSData objects are converted to byte arrays. 
NSDate objects are converted to java.util.Date objects. 
UID objects are converted to byte arrays. 
Returns:
A native java object representing this NSObject's value.

OTHER TIPS

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top