You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by apachexmlbeans <ap...@126.com> on 2009/05/25 11:13:55 UTC

change the defult namespace

With the xmlbeans I made a xml file,however the namespace is "n1 n2" and so on,
<ns:Execute language="en_US" version="1.0.0" xmlns:ns=http://www.swe.com/ow>
<ns1:Identifier xmlns:ns1="http://www.swe.net">org</ns1:Identifier>
<ns:DataInputs>
     <ns:Input>
          <ns1:Identifier xmlns:ns1="http://www.swe.net">inder inner</ns1:Identifier>
          <ns1:Title xmlns:ns1="http://www.swe.net">title</ns1:Title>
     </ns:Input>
</ns:DataInputs>
</ns:Execute>
how to specify them? they should look like this:
<com:Executelanguage="en_US" version="1.0.0" xmlns:com=http://www.swe.com/ow>
<net:Identifier xmlns:net="http://www.swe.net">org</net:Identifier>
<com:DataInputs>
     <com:Input>
          <net:Identifier xmlns:net="http://www.swe.net">inder inner</net:Identifier>
          <net:Title xmlns:net="http://www.swe.net">title</net:Title>
     </com:Input>
</com:DataInputs>
</com:Execute>
 
PS:
what is the difference between the add and set method?
take the above for example:
Execute.addNewInstance(IdentifierType id)
Execute.setIdentifier(CodeType id)

 

Re:Re: change the defult namespace

Posted by apachexmlbeans <ap...@126.com>.
You can use XmlOptions.setSaveSuggestedPrefixes() to specify the 
namespace prefixes.

See the FAQ for details:
http://wiki.apache.org/xmlbeans/XmlBeansFaq#suggestedPrefixes
====================
Actually ,I have seen the faq and I found it did not work ,my codes:
Map<String,String> nMap=new HashMap<String,String>();
nMap.put("http://www.swe.com/ow","com");
nMap.put("http://www.swe.net","net");
doc.xmlText(new XmlOption().setSaveSuggestionPrefixes(nMap));
the namespace is still the ns1 ns2....
========================================================



在2009-05-25?20:59:25,"Christian?Kaltepoth"?<ch...@kaltepoth.de>?写道:
>On?Monday?25?May?2009?11:13:55?apachexmlbeans?wrote:
>>?With?the?xmlbeans?I?made?a?xml?file,however?the?namespace?is?"n1?n2"?and?so
>>?how?to?specify?them??they?should?look?like?this:
>
>You?can?use?XmlOptions.setSaveSuggestedPrefixes()?to?specify?the?
>namespace?prefixes.
>
>See?the?FAQ?for?details:
>http://wiki.apache.org/xmlbeans/XmlBeansFaq#suggestedPrefixes
>
>
>>?what?is?the?difference?between?the?add?and?set?method?
>>?take?the?above?for?example:
>>?Execute.addNewInstance(IdentifierType?id)
>>?Execute.setIdentifier(CodeType?id)
>
>IMHO?the?addNewXXX()?methods?a?short?form?for?creating?a?new?XmlObject?and?
>setting?it?via?the?setXXX()?method.
>
>See:
>http://xmlbeans.apache.org/docs/2.4.0/guide/conMethodsForGeneratedJavaTypes.html
>
>Kind?regards
>
>Christian
>
>--?
>Christian?Kaltepoth
>Blog:?http://chkal.blogspot.com/
>Twitter:?http://twitter.com/chkal
>
>---------------------------------------------------------------------
>To?unsubscribe,?e-mail:?user-unsubscribe@xmlbeans.apache.org
>For?additional?commands,?e-mail:?user-help@xmlbeans.apache.org
>

Re: change the defult namespace

Posted by Christian Kaltepoth <ch...@kaltepoth.de>.
On Monday 25 May 2009 11:13:55 apachexmlbeans wrote:
> With the xmlbeans I made a xml file,however the namespace is "n1 n2" and so
> how to specify them? they should look like this:

You can use XmlOptions.setSaveSuggestedPrefixes() to specify the 
namespace prefixes.

See the FAQ for details:
http://wiki.apache.org/xmlbeans/XmlBeansFaq#suggestedPrefixes


> what is the difference between the add and set method?
> take the above for example:
> Execute.addNewInstance(IdentifierType id)
> Execute.setIdentifier(CodeType id)

IMHO the addNewXXX() methods a short form for creating a new XmlObject and 
setting it via the setXXX() method.

See:
http://xmlbeans.apache.org/docs/2.4.0/guide/conMethodsForGeneratedJavaTypes.html

Kind regards

Christian

-- 
Christian Kaltepoth
Blog: http://chkal.blogspot.com/
Twitter: http://twitter.com/chkal

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org