Apple PropertyList-1.0.dtd的java库

时间:2013-12-29 13:31:42

标签: java xml collections plist in-memory

我需要使用这样的标题读入内存XML文件

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

这是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 -->

这种数据格式的正确名称是什么?

用于阅读此类文件的Java库是什么? 我想进入内存标准Java集合(实现List和/或Set)

相关:

这两个问题都是2年,所以也许有更好的东西?

2 个答案:

答案 0 :(得分:2)

使用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

  

您可以使用PropertyListParserFile或字节数组提供InputStreams。 PropertyListParser的parse方法将解析输入并为您提供NSObject作为结果。通常这是NSDictionary,但它也可以是NSArray。

有转换器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.

答案 1 :(得分:1)

&#34; http://www.apple.com/DTDs/PropertyList-1.0.dtd&#34; PUBLIC&#34; - // Apple Computer // DTD PLIST 1.0 // EN&#34;&gt;

java library for Apple PropertyList-1.0.dtd