org.simpleframework.xml
Annotation Type Namespace


@Retention(value=RUNTIME)
public @interface Namespace

The Namespace annotation is used to set a namespace on an element or attribute. By annotating a method, field or class with this annotation that entity assumes the XML namespace provided. When used on a class the annotation describes the namespace that should be used, this however can be overridden by an annotated field or method declaration of that type.

  
    <book:book xmlns:book="http://www.example.com/book">
       <author>saurabh</author>
       <title>example title</title>
       <isbn>ISB-16728-10</isbn>
    </book:book>

 
In the above XML snippet a namespace has been declared with the prefix "book" and the reference "http://www.example.com/book". If such a namespace is applied to a class, method, or field then that element will contain the namespace and the element name will be prefixed with a namespace qualifier, which is "book" here.

    <example xmlns="http://www.example.com/root">
       <child>
          <text xmlns="">text element</text>
       </child>
    </example>

 
In order for a namespace to be inherited it must be specified as a default namespace. A default namespace is one that does not have a prefix. All elements that do not have an explicit namespace will inherit the last default namespace in scope. For details see Section 6.2 of the namespaces in XML 1.0 specification. To remove the default namespace simply specify a namespace with no prefix or reference, such as the "text" element in the above example.

Author:
Niall Gallagher

Optional Element Summary
 String prefix
          This is used to specify the prefix used for the namespace.
 String reference
          This is used to specify the unique reference URI that is used to define the namespace within the document.
 

reference

public abstract String reference
This is used to specify the unique reference URI that is used to define the namespace within the document. This is typically a URI as this is a well know universally unique identifier. It can be anything unique, but typically should be a unique URI reference. If left as the empty string then this will signify that the anonymous namespace will be used.

Returns:
this returns the reference used by this namespace
Default:
""

prefix

public abstract String prefix
This is used to specify the prefix used for the namespace. If no prefix is specified then the reference becomes the default namespace for the enclosing element. This means that all attributes and elements that do not contain a prefix belong to the namespace declared by this annotation.

Returns:
this returns the prefix used for this namespace
Default:
""