1
2
3
4
5
6
7
8 package net.sf.jour.config.impl.runtime;
9
10 import javax.xml.namespace.NamespaceContext;
11
12 /***
13 * Maintains namespace<->prefix bindings.
14 *
15 * <p>
16 * This interface extends {@link NamespaceContext} and provides
17 * an additional functionality, which is necessary to declare
18 * namespaced attributes on elements. The added method is for
19 * self-consumption by the marshaller.
20 *
21 * This object is composed into a Serializer.
22 */
23 public interface NamespaceContext2 extends NamespaceContext
24 {
25 /***
26 * Declares a new namespace binding within the current context.
27 *
28 * <p>
29 * The prefix is automatically assigned by MarshallingContext. If
30 * a given namespace URI is already declared, nothing happens.
31 *
32 * <p>
33 * It is <b>NOT</b> an error to declare the same namespace URI
34 * more than once.
35 *
36 * <p>
37 * For marshalling to work correctly, all namespace bindings
38 * for an element must be declared between its startElement method and
39 * its endAttributes event. Calling the same method with the same
40 * parameter between the endAttributes and the endElement returns
41 * the same prefix.
42 *
43 * @param requirePrefix
44 * If this parameter is true, this method must assign a prefix
45 * to this namespace, even if it's already bound to the default
46 * namespace. IOW, this method will never return null if this
47 * flag is true. This functionality is necessary to declare
48 * namespace URI used for attribute names.
49 * @param preferedPrefix
50 * If the caller has any particular preference to the
51 * prefix, pass that as a parameter. The callee will try
52 * to honor it. Set null if there's no particular preference.
53 *
54 * @return
55 * returns the assigned prefix. If the namespace is bound to
56 * the default namespace, null is returned.
57 */
58 String declareNamespace( String namespaceUri, String preferedPrefix, boolean requirePrefix );
59 }