users@jaxb.java.net

RE: RE: Default Namespace in JAXB

From: <Vishal.Manchanda_at_iflexsolutions.com>
Date: Wed, 28 Jul 2004 09:39:46 +0530

 

 

I've already created NamespacePrefixMapperImpl and the property was set
for the marshaller

 

But my concern is

 

public String getPreferredPrefix(String namespaceUri, String suggestion,
boolean requirePrefix) {

        // I want this namespace to be mapped to "xsi"

        if(
"http://www.w3.org/2001/XMLSchema-instance".equals(namespaceUri) )

            return "xsi";

      // I want this namespace to be mapped to "" i.e I want ebagent as
default namespace.

            if( "ebagent".equals(namespaceUri) )

            return "";

 

        // otherwise I don't care. Just use the default suggestion,
whatever it may be.

        return suggestion;

    }

 

In the abocve method ,in case of ebagent , the prefix returned after
marshalling is "ns1" whereas I want it to return "".

 

Please suggest.

 

In the output I want like this

 

<msg xmlns="ebagent" >

..................

...............

.

</msg>

 

 

  _____

From: Ted Poovey [mailto:tpoovey_at_uscentral.coop]
Sent: Tuesday, July 27, 2004 6:37 PM
To: users_at_jaxb.dev.java.net
Subject: RE: Default Namespace in JAXB

 

Create you own and use it. Class is NamespacePrefixMapperImpl and

      marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper",

                             new NamespacePrefixMapperImpl());

 

Thank you

 

Ted D. Poovey

Software Engineer III

U.S. Central

Phone : (913) 227-6106

Fax : (913) 227-6254

 

-----Original Message-----
From: Vishal.Manchanda_at_iflexsolutions.com
[mailto:Vishal.Manchanda_at_iflexsolutions.com]
Sent: Tuesday, July 27, 2004 1:43 AM
To: users_at_jaxb.dev.java.net
Subject: Default Namespace in JAXB

 

 

Hi,

I'm using JAXB.

In my xml I need default namespace to be shown after marshalling.

Like this

 

<msg xmlns="dnamespace" >

..................

...............

.

</msg>

 

 

I'm using my own NamespacePrefixMapperImpl

But it is automatically generating "ns1" as prefix whereas I do not want
any prefix

It is showing output as

 

<msg xmlns:ns1="dnamespace" >

..................

...............

.

</msg>

 

Please suggest how I can declare default namespaces using JAXB

 

 

 

Vishal Manchanda

 Associate Consultant , e-Solutions

    PrimeSourcing(tm)," Add Value Reduce Risk" The Global IT Services
business from i-flex

 i-flex Solutions Ltd-Mumbai

    Tel: 91-22-5668 5362 OR 91-22-28391909 xtn-5360

    Cell: 91-98925 20922

 www.iflexsolutions.com/services/services.asp

 Email: vishal.manchanda_at_iflexsolutions.com