【问题标题】:How to add Prefix for the attribute while marshling如何在编组时为属性添加前缀
【发布时间】:2014-08-25 06:39:44
【问题描述】:

我喜欢在使用脚轮编组时为属性添加前缀。

我想得到如下结果

<ThesaurusConcept dc:identifier="C268">
    <ScopeNote xml:lang="en">
        <LexicalValue>index heading is Atomic absorption spectroscopy</LexicalValue>
    </ScopeNote>            
</ThesaurusConcept>

但我得到了

<ThesaurusConcept identifier="C621">
<ScopeNote lang="en">
    <LexicalValue>index heading is Atomic absorption spectroscopy</LexicalValue>
    </ScopeNote>  
</ThesaurusConcept>

【问题讨论】:

    标签: java attributes marshalling castor


    【解决方案1】:

    我的问题得到了答案

    我们需要在ma​​pping.xml文件中添加以下内容

    <mapping  xmlns:dc="http://purl.org/dc/elements/1.1/"> 
    
    <bind-xml name="dc:identifier" node="attribute" ></bind-xml>
    

    我们还需要使用以下代码设置命名空间。

    Marshaller  casreactmp = new Marshaller(handler);
                casreactmp.setNamespaceMapping("dc", "http://purl.org/dc/elements/1.1/");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-12
      • 1970-01-01
      相关资源
      最近更新 更多