Dash XSD名称空间映射 [英] Dash XSD namespace mapping
问题描述
我已经建立了以下XML模式
I have made the following XML schema
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
targetNamespace="urn:mpeg:dash:schema:mpd:2011"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:cenc="urn:mpeg:cenc:2013"
xmlns:mspr="urn:microsoft:playready"
elementFormDefault="qualified"
>
<xs:element name="ContentProtection">
<xs:complexType>
<xs:sequence>
<xs:element name="pssh" type="xs:string"/>
<xs:element name="pro" type="xs:string"/>
</xs:sequence>
<xs:attribute name="value" type="xs:string" />
<xs:attribute name="schemeIdUri" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:schema>
我试图了解如何进行正确的映射,以便在生成XJC情节文件时获得映射,以使JAXB知道 pssh
XML元素属于骨灰盒":mpeg:cenc:2013"命名空间,而 pro
XML元素属于"urn:microsoft:playready"命名空间.
I'm trying to understand how to do the correct mapping so that when I generate a XJC episode file, I get a mapping such that JAXB knows that the pssh
XML element belongs to the "urn:mpeg:cenc:2013" namespace and the pro
XML element belongs to the "urn:microsoft:playready" namespace.
基本上,我需要反序列化的类才能像这样结束:
Basically, I need my deserialized class to end up like:
@XmlElement(namespace = "urn:mpeg:cenc:2013", required = true)
protected String pssh;
@XmlElement(namespace = "urn:microsoft:playready", required = true)
protected String pro;
关于如何执行此操作的任何想法?
Any ideas on how to do this?
推荐答案
想通了...
必须创建自己的 cenc
和 mspr
XML模式并将其作为类型导入到原始模式中.
Had to make my own cenc
and mspr
XML schemas and import them into the original one as types.
<xs:schema targetNamespace="urn:mpeg:cenc:2013"
attributeFormDefault="qualified"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="urn:mpeg:cenc:2013">
<xs:element name="pssh" type="xs:base64Binary"/>
</xs:schema>
mspr.xsd
<xs:schema targetNamespace="urn:microsoft:playready"
attributeFormDefault="qualified"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="urn:microsoft:playready">
<xs:element name="pro" type="xs:base64Binary"/>
</xs:schema>
ContentProtection.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
targetNamespace="urn:mpeg:dash:schema:mpd:2011"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:cenc="urn:mpeg:cenc:2013"
xmlns:mspr="urn:microsoft:playready"
elementFormDefault="qualified"
>
<xs:import namespace="urn:mpeg:cenc:2013" schemaLocation="cenc.xsd"/>
<xs:import namespace="urn:microsoft:playready" schemaLocation="mspr.xsd"/>
<xs:element name="ContentProtection">
<xs:complexType>
<xs:sequence>
<xs:element ref="cenc:pssh"/>
<xs:element ref="mspr:pro"/>
</xs:sequence>
<xs:attribute name="value" type="xs:string" />
<xs:attribute name="schemeIdUri" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:schema>
现在,JAXB可以正确地反序列化所有内容.
Now JAXB deserializes everything correctly.
这篇关于Dash XSD名称空间映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!