gpt4 book ai didi

Apple PropertyList-1.0.dtd 的 java 库

转载 作者:行者123 更新时间:2023-12-01 23:18:59 29 4
gpt4 key购买 nike

我需要将带有此类 header 的 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 属性列表”。 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 年前提出的,所以也许有更好的东西?

最佳答案

选择http://code.google.com/p/plist/

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

关于 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.

有一个 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.

关于Apple PropertyList-1.0.dtd 的 java 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20825643/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com