私はアクセスしたいサービスを公開するUPnPデバイスを使っています。私はデータをマーシャリングするためにSimpleXML
を使用しています。これまでのところ、とても良いですが、今はもう固まっています。 以下のXMLを考えるとSimpleXMLが属性を逆シリアル化しないのはなぜですか?
:
<DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<item id="123456" parentID="1" restricted="1">
<res protocolInfo="http-get:*:video/mpeg:*">http://stream_resource/media/index.m3u8</res>
<upnp:callSign>My Call Sign here</upnp:callSign>
<upnp:class>object.item.videoItem.videoBroadcast</upnp:class>
<dc:title>My Title Here</dc:title>
</item>
</DIDL-Lite>
私は、次ののPOJOあります
ルート:
@Root(name = "DIDL-Lite")
@NamespaceList({
@Namespace(reference = "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"),
@Namespace(reference = "urn:schemas-upnp-org:metadata-1-0/upnp/", prefix = "upnp"),
@Namespace(reference = "http://purl.org/dc/elements/1.1/", prefix = "dc")
})
public class ResultObject {
@ElementList(name = "item")
private List<ObjectItem> listItems;
}
ObjectItem:
@Root(name = "item")
public class ObjectItem {
@Attribute(name = "id")
private String id;
@Attribute(name = "parentID")
private String parentID;
@Attribute(name = "restricted")
private String restricted;
@Element(name = "res")//something appears to be wrong here ! this element is not actually parsed ?
private ResourceInfo resInfo;
@Element(name = "callSign")
private String callSign;
@Element(name = "class")
private String upnpClass;
@Element(name = "title")
private String dcTitle;
}
を
たResourceInfo:
@Root(name = "res")
public class ResourceInfo {
@Attribute(name = "protocolInfo")
private String protocolInfo;
}
これは私が取得パースエラー:System.errのは/ W:org.simpleframework.xml.core.AttributeException:属性 'protocolInfoは' クラスの試合を持っていません
ObjectItem:
xx.yyy.ObjectItemは掘り幾つか後ライン1において、IはElementMap
そう等にその値をデシリアライズしようとしました
まだ取得中です。解析エラーです。
ヒント
あなたは、UPnP用のまとわりつきを使用していないのはなぜ? http://4thline.org/projects/cling/ –
@PogonetsAnton私は抱きつけを統合しようとしましたが、2つの理由であきらめました:主に、私はUPNPでの作業経験が足りず、スタッキングとして私にとって重苦しいようでした。第二に、私が使用しているUPNPデバイスはカスタム検出と認証のメカニズムを使用していますが、私はそれを使用してデバイスとの接続を確立することはできませんでした。それを除いて、Clingはすばらしい図書館です。 – nightfixed