匹配的命名空间中JAXB匹配的命名空间/在JAXB解组编组上/解组
我使用JAXB马歇尔/和解组XML。如果我马歇尔的XML文件是这样的:
<om:RequestCreateEvent xmlns:om="http://ossj.org/xml/OrderManagement/v1-0" xmlns:v1="http://ossj.org/xml/Common/v1-5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:v11="http://ossj.org/xml/Common-CBECore/v1-5" xmlns:v12="http://ossj.org/xml/Common-CBEBi/v1-5">
<om:event>
<v1:applicationDN>System/JSR264/ApplicationType/OrderManagement/Application/1-0;1-0-2;ReferenceImplementation/</v1:applicationDN>
<v1:eventTime>2008-11-12T07:39:34.896+01:00</v1:eventTime>
<om:requestValue xmlns:v1="http://ossj.org/xml/om/ri/omimpl/v1-0" xsi:type="v1:ProductOrderImplValue">
<v13:key xmlns:v1="http://ossj.org/xml/OrderManagement/v1-0" xmlns:v13="http://ossj.org/xml/Common/v1-5" xsi:type="v1:ProductOrderKey">
<v13:type>http://ossj.org/xml/om/ri/omimpl/v1-0#ProductOrderImplValue</v13:type>
<v13:primaryKey>12</v13:primaryKey>
</v13:key>
<v1:requestState>open.not_running.not_started</v1:requestState>
<v12:description xsi:nil="true"/>
</om:requestValue>
</om:event>
</om:RequestCreateEvent>
,随后试图来解读它,我得到这个:
<ns4:RequestCreateEvent xmlns="http://ossj.org/xml/Common/v1-5" xmlns:ns2="http://ossj.org/xml/Common-CBECore/v1-5" xmlns:ns3="http://ossj.org/xml/Common-CBEBi/v1-5" xmlns:ns4="http://ossj.org/xml/OrderManagement/v1-0" xmlns:ns5="http://ossj.org/xml/om/ri/omimpl/v1-0" xmlns:ns6="http://ossj.org/xml/Common-CBEDatatypes/v1-5" xmlns:ns7="http://ossj.org/xml/Common-CBELocation/v1-5" xmlns:ns8="http://ossj.org/xml/Common-CBEResource/v1-5" xmlns:ns9="http://ossj.org/xml/Common-CBEService/v1-5" xmlns:ns10="http://ossj.org/xml/Common-CBEProduct/v1-5" xmlns:ns11="http://ossj.org/xml/Common-CBEProductOffering/v1-5" xmlns:ns12="http://ossj.org/xml/Common-CBEParty/v1-5">
<ns4:event>
<applicationDN>System/JSR264/ApplicationType/OrderManagement/Application/1-0;1-0-2;ReferenceImplementation/</applicationDN>
<eventTime>
2008-11-12T07:39:34.896+01:00</eventTime>
<ns4:requestValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns5:ProductOrderImplValue">
<key xsi:type="ns4:ProductOrderKey">
<type>
http://ossj.org/xml/om/ri/omimpl/v1-0#ProductOrderImplValue</type>
<primaryKey/>
</key>
<ns5:requestState>open.not_running.not_started</ns5:requestState>
<ns3:description xsi:nil="true"/>
</ns4:requestValue>
</ns4:event>
</ns4:RequestCreateEvent>
我需要的时候,以确保在命名空间中使用前缀我马歇尔jaxb生成的pojo创建的XML文件匹配那些使用 我解组同一个文件。
当我进行编组时,可能有一个使用NamespaceContext的解决方案。但是我不能在NamespaceContext的实现 中对前缀和他们的uris进行硬编码,因为我没有这些信息可用(我使用了大量的模式等)。因此,如果我尝试使用NamespaceContext,我需要能够从JAXB unmarshaller获取前缀和他们的uris,我似乎无法得到它。
因此,如果任何人有任何关于NamespaceContext解决方案或其他方法的建议,我将不胜感激。
你也注意到,' 12 V13:PrimaryKey的>'改成'' 解组时?好奇,如果你能克服这个问题,我遇到这个问题 –
JGlass