users@jaxb.java.net

RE: Re: xmlns="" in direct child element.

From: Malachi de Aelfweald <malachid_at_temporal-wave.com>
Date: Mon, 20 Oct 2003 12:48:21 -0700

It works quite well from my testing of it. Here's what I am doing to
help speed you along doing it yourself:

package com.temporalwave.spec;

import com.sun.xml.bind.marshaller.NamespacePrefixMapper;
import java.util.*;

public class NSPrefixMapper
extends NamespacePrefixMapper
{
        HashMap mappings;
        
        public NSPrefixMapper()
        {
                mappings = new HashMap();
                setDefaultMappings();
        }

        protected void setDefaultMappings()
        {
                clear();
                addMapping("http://www.temporal-wave.com/spec/dynarray",
"dyn");
                addMapping("http://www.temporal-wave.com/spec/taskman",
"tm");
                addMapping("http://www.w3.org/2001/XMLSchema-instance",
"xsi");
                addMapping("http://java.sun.com/xml/ns/jaxb", "jaxb");
        }
        
        public void addMapping(String uri, String
prefix){mappings.put(uri, prefix);}
        public String getMapping(String uri){return
(String)mappings.get(uri);}
        public HashMap getMappings(){return mappings;}
        public void clear(){mappings.clear();}
        
        public String getPreferredPrefix(String namespaceURI, String
suggestion, boolean requirePrefix)
        {
                String toReturn = getMapping(namespaceURI);
                if(toReturn != null)
                        return toReturn;
                
                return suggestion;
        }
}


-----Original Message-----
From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM]
Sent: Monday, October 20, 2003 12:33 PM
To: users_at_jaxb.dev.java.net


You could also use NamespacePrefixMapper to change how the RI assigns
prefixes. See namespace-prefix sample for details.


regards,
--
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net