Skip to Main Content
SAX2
book

SAX2

by David Brownell
January 2002
Intermediate to advanced content levelIntermediate to advanced
240 pages
6h 58m
English
O'Reilly Media, Inc.
Content preview from SAX2

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Special Edition Using XML, Second Edition

Special Edition Using XML, Second Edition

- et al. David Gulbransen

Publisher Resources

ISBN: 0596002378Supplemental ContentCatalog PageErrata