问题描述
我对JAXB感到烦恼。
我正在解组一个XML,这是一个编辑软件(Adobe Premiere Pro)的项目文件。 解组后,我操纵了一些元素值(文件路径),然后将其编组回xml并写出新的xml文件。
一旦我将xml压缩回Premiere期望的形式,它就会拒绝读取它并说它已损坏或过时。
我比较了原始的xml文件和由我的代码生成的xml文件,并记下了所有差异。 其中一些并不重要,在将这些文件复制到原始文件中之后,该文件仍然被Premiere欣然接受。
真正的罪魁祸首:所生成的xml中缺少整个元素。 为了确保不是我的代码“消失”了,我将其修改为取消编组,然后立即再次编组而不对数据进行任何操作:生成的文件中缺少相同的行...
在下面的xml摘录中,是缺少行的示例。
原文:
<AudioComponentChain ObjectID="52" ClassID="3cb131d1-d3c0-47ae-a19a-bdf75ea11674" Version="3">
<ComponentChain Version="3">
</ComponentChain>
<DefaultVol>true</DefaultVol>
<DefaultVolumeComponentID>1</DefaultVolumeComponentID>
<DefaultChannelVolumeComponentID>2</DefaultChannelVolumeComponentID>
<ChannelType>1</ChannelType>
<FrameRate>5760000</FrameRate>
<AutomationMode>1</AutomationMode>
<AudioChannelLayout>[{"channellabel":100},{"channellabel":101}]</AudioChannelLayout>
</AudioComponentChain>
<AudioComponentChain ObjectID="52" ClassID="3cb131d1-d3c0-47ae-a19a-bdf75ea11674" Version="3">
<ComponentChain Version="3">
</ComponentChain>
<DefaultVol>true</DefaultVol>
<DefaultVolumeComponentID>1</DefaultVolumeComponentID>
<ChannelType>1</ChannelType>
<FrameRate>5760000</FrameRate>
<AutomationMode>1</AutomationMode>
<AudioChannelLayout>[{"channellabel":100},{"channellabel":101}]</AudioChannelLayout>
</AudioComponentChain>
线
<DefaultChannelVolumeComponentID>2</DefaultChannelVolumeComponentID>
丢失了。
<SecondaryContents Version="1">
<SecondaryContentItem Index="0" ObjectRef="98"/>
<SecondaryContentItem Index="1" ObjectRef="99"/>
</SecondaryContents>
<SecondaryContents Version="1">
<SecondaryContentItem Index="1" ObjectRef="99"></SecondaryContentItem>
</SecondaryContents>
有趣的是,这种相同的模式稍后会在xml中重复:生成的xml中缺少两个SecondaryContentItem元素中的第一个:
原始文件:
<SecondaryContents Version="1">
<SecondaryContentItem Index="0" ObjectRef="104"/>
<SecondaryContentItem Index="1" ObjectRef="105"/>
</SecondaryContents>
<SecondaryContents Version="1">
<SecondaryContentItem Index="1" ObjectRef="105"></SecondaryContentItem>
</SecondaryContents>
还有一项,以防万一有人辨认出我看不见的图案:
原始文件:
<ComponentChain Version="3">
<Node Version="1">
<Properties Version="1">
<MZ.ComponentChain.ActiveComponentID>1</MZ.ComponentChain.ActiveComponentID>
<MZ.ComponentChain.ActiveComponentParamIndex>4294967295</MZ.ComponentChain.ActiveComponentParamIndex>
</Properties>
</Node>
</ComponentChain>
<ComponentChain Version="3">
</ComponentChain>
在我使用IntelliJ的“从XML文件生成XSD架构”生成的XSD架构中,我找不到“ DefaultChannelVolumeComponentID”的踪迹(我使用了global elements / local types选项)。所以我至少知道问题的一部分是XSD并未从XML结构中捕获所有内容。
在那里定义了其他元素,例如SecondaryContentItem和Node,因此这些元素的消失一定是由于其他原因所致吗?也许它们如何在XSD中描述?我可以看到Node是在XSD的父元素ComponentChain下正确定义的,所以不确定为什么它不能进入输出...
任何有关进一步解决此问题的技巧将不胜感激!
我想在这里共享xsd和原始xml文件,但是它们太长了,超出了帖子的字符允许范围。可以链接到外部站点以供人们访问吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)