net.sf.swan.xml.input.components
Class XMLContextAttributes

java.lang.Object
  |
  +--net.sf.swan.xml.input.event.ContextAdapter
        |
        +--net.sf.swan.xml.input.components.XMLContextAttributes
All Implemented Interfaces:
ContextListener

public class XMLContextAttributes
extends ContextAdapter

Utility that tracks certain standard global XML context attributes, adding them as context properties of elements. This is most useful when used in conjunction with the StartElementFilters class. Note that this does not consume the events it is passed.


Field Summary
static java.lang.String XML_BASE
           
static java.lang.String XML_LANG
           
static java.lang.String XML_SPACE
           
 
Constructor Summary
XMLContextAttributes()
           
 
Method Summary
static java.lang.String getBaseUri(ElementContext context)
          Obtains a base URI from any xml:base value in scope, or from any available SAX Locator as a fallback.
static java.util.Locale getLocale(ElementContext context)
          Creates a Java Locale object representing any xml:lang value in scope.
 void startElement(StartElementEvent event)
           
 
Methods inherited from class net.sf.swan.xml.input.event.ContextAdapter
endElement, getErrorHandler, processingInstruction, text
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_SPACE

public static final java.lang.String XML_SPACE

XML_BASE

public static final java.lang.String XML_BASE

XML_LANG

public static final java.lang.String XML_LANG
Constructor Detail

XMLContextAttributes

public XMLContextAttributes()
Method Detail

getBaseUri

public static java.lang.String getBaseUri(ElementContext context)
Obtains a base URI from any xml:base value in scope, or from any available SAX Locator as a fallback. This relies upon an XMLContextAttributes object having been setup to filter context events.
Returns:
a base URI, or null if no xml:base is in scope and no system ID from a Locator is available.

getLocale

public static java.util.Locale getLocale(ElementContext context)
Creates a Java Locale object representing any xml:lang value in scope. This relies upon an XMLContextAttributes object having been setup to filter context events.
Returns:
a corresponding Locale object, or null if no xml:lang is in scope.

startElement

public void startElement(StartElementEvent event)
                  throws EventContextException
Overrides:
startElement in class ContextAdapter