以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 XML工具及XML开发环境 』  (http://bbs.xml.org.cn/list.asp?boardid=7)
----  [求助]使用jdom如何为XML添加“如此”名称空间  (http://bbs.xml.org.cn/dispbbs.asp?boardid=7&rootid=&id=65238)


--  作者:IceWee
--  发布时间:8/1/2008 12:55:00 PM

--  [求助]使用jdom如何为XML添加“如此”名称空间
MessageQueueCommand.xml
------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<MessageQueueCommand xmlns="M.Box.MessageQueueCommands" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="M.Box.MessageQueueCommands E:\xsdtest\MessageCommands.xsd">
  <InjectionRequestCommand>
    <AdditionalInfo Key="myKey1">myValue1 </AdditionalInfo>
    <AdditionalInfo Key="myKey2">myValue2 </AdditionalInfo>
    <MessageId>9E479DFE-3360-4A08-9157-71F78D715365 </MessageId>
    <Msisdn>63125874557458 </Msisdn>
    <SourceTransactionId>A12324BD1-C </SourceTransactionId>
    <TelcoId>1 </TelcoId>
    <TransmitterName>01RouterProc01 </TransmitterName>
    <ResponseQueue>MIAB.01RouterProc01.Telco1.Injection.Response </ResponseQueue>
    <Amount>1000 </Amount>
    <CodeType>10 Telco1 Topup </CodeType>
    <InjectionType>Topup </InjectionType>
    <RetailerGroupId>A100 </RetailerGroupId>
    <RetailerId>A1001 </RetailerId>
    <StoreId>A1001_1 </StoreId>
    <TransactionId>924348347261 </TransactionId>
  </InjectionRequestCommand>
</MessageQueueCommand>
------------------------------------------------------------------------------------------------------

上面的MessageQueueCommand.xml是需用jdom生成的xml文件。现在这个XML文件除了一个地方(红色字体)我不会添加,其他的都解决了。问题也正是此,像红色字体的名称空间使用jdom该如何添加呢?

备注:
它是一个本地的xsd文件,用来验证生成的xml文件的有效性。


--  作者:andyhoward
--  发布时间:8/25/2008 7:02:00 PM

--  
获得根节点后,直接setAttribute行不?
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
625.000ms