@Retention(value=RUNTIME) public @interface Namespace
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.
public abstract String reference
public abstract String prefix
Copyright © 2021 Alibaba Cloud Computing. All rights reserved.