我在Java中使用XMLBeans生成了一个XML文件。结果是这样的:
<ipdr:IPDRDoc IPDRRecorderInfo="192.168.95.82" xmlns:ipdr="uri://www.ipdr.org/namespaces/ipdr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:DOCSIS-QOS="uri://www.cablelabs.com/namespaces/DOCSIS/3.0/xsd/ipdr/DOCSIS-QOS">
<ipdr:IPDR xsi:type="doc:SAMIS-TYPE-1" xmlns:doc="uri://www.cablelabs.com/namespaces/DOCSIS/3.0/xsd/ipdr/DOCSIS-SAMIS-TYPE-1">
<DOCSIS-QOS:ServiceTimeCreated>1474597117000</DOCSIS-QOS:ServiceTimeCreated>
<DOCSIS-QOS:ServiceTimeActive>100</DOCSIS-QOS:ServiceTimeActive>
</ipdr:IPDR>
</ipdr:IPDRDoc>
现在我想将元素xmlns:doc="uri://www.cablelabs.com/namespaces/DOCSIS/3.0/xsd/ipdr/DOCSIS-SAMIS-TYPE-1"
中的名称空间<ipdr:IPDR>
的定义移动到根节点<ipdr:IPDRDoc>
中。之后,XML文件应如下所示:
<ipdr:IPDRDoc IPDRRecorderInfo="192.168.95.82" xmlns:ipdr="uri://www.ipdr.org/namespaces/ipdr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:DOCSIS-QOS="uri://www.cablelabs.com/namespaces/DOCSIS/3.0/xsd/ipdr/DOCSIS-QOS" xsi:schemaLocation="uri://www.cablelabs.com/namespaces/DOCSIS/3.0/xsd/ipdr/DOCSIS-SAMIS-TYPE-1
DOCSIS-SAMIS-TYPE-1_3.5.1-A.1.xsd">
<ipdr:IPDR xsi:type="doc:SAMIS-TYPE-1">
<DOCSIS-QOS:ServiceTimeCreated>1474597117000</DOCSIS-QOS:ServiceTimeCreated>
<DOCSIS-QOS:ServiceTimeActive>100</DOCSIS-QOS:ServiceTimeActive>
</ipdr:IPDR>
</ipdr:IPDRDoc>
我该怎么办?我尝试使用xmlOption.setSaveSuggestedPrefixes(suggestedPrefixes);
但没有成功。
有没有办法做到这一点?