Book HomeSAX2Search this book

B.13. Namespace Information Items

These information items expose namespace identifiers and the prefixes currently used to associate element or attribute names with those identifiers. With SAX2, applications that track these prefixes need to use a stack to handle the lexical scoping rules: in the context of one element and its children, a prefix may indicate a different namespace than in parent elements because of a locally scoped redefinition. You can use the NamespaceSupport helper class to manage this stack or write something of your own.

These information items start with a ContentHandler.startPrefixMapping() call and end with a ContentHandler.endPrefixMapping() call. These are the only two start/end calls that SAX2 doesn't require to be cleanly nested. Alternatively, if the namespaces feature flag is false, this information can be reconstructed from the xmlns and xmlns:* element attributes.

Property

Callbacks

Explanation

[prefix]

ContentHandler.startPrefixMapping(), prefix parameter

[namespace name]

ContentHandler.startPrefixMapping(), uri parameter

Since these values aren't dereferenced, they are exactly as provided in the XML source text. Don't assume dereferencing such URIs lets you do anything useful.

If the namespaces feature is set to false (its default is true) this information is not made available except implicitly through the element [attributes] property, which will implicitly include all [namespace attributes]. (It is illegal to set namespaces to false without setting namespace-prefixes to true.)



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.