org.apache.cocoon.transformation
Class XIncludeTransformer

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.cocoon.xml.AbstractXMLProducer
              |
              +--org.apache.cocoon.xml.AbstractXMLPipe
                    |
                    +--org.apache.cocoon.transformation.AbstractTransformer
                          |
                          +--org.apache.cocoon.transformation.XIncludeTransformer
All Implemented Interfaces:
org.apache.avalon.framework.component.Component, org.apache.avalon.framework.component.Composable, org.xml.sax.ContentHandler, org.apache.avalon.framework.activity.Disposable, org.xml.sax.ext.LexicalHandler, org.apache.avalon.framework.logger.Loggable, org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, SitemapModelComponent, Transformer, XMLConsumer, XMLPipe, XMLProducer

public class XIncludeTransformer
extends AbstractTransformer
implements org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.activity.Disposable

My first pass at an XInclude transformation. Currently it should set the base URI from the SAX Locator's system id but allow it to be overridden by xml:base elements as the XInclude spec mandates. It's also got some untested code that should handle inclusion of text includes, but that method isn't called by the SAX event FSM yet.

Version:
CVS $Id: XIncludeTransformer.java,v 1.11.2.1 2002/11/29 08:52:16 bdelacretaz Exp $
Author:
Donald Ball

Field Summary
protected  Source base_xmlbase_uri
           
protected  Source current_xmlbase_uri
          The current XMLBase URI.
protected  java.lang.String last_xmlbase_element_name
          name of the last element which had an xml:base attribute
protected  java.lang.String last_xmlbase_element_uri
          namespace uri of the last element which had an xml:base attribute
protected  org.apache.avalon.framework.component.ComponentManager manager
           
static java.lang.String XINCLUDE_INCLUDE_ELEMENT
           
static java.lang.String XINCLUDE_INCLUDE_ELEMENT_HREF_ATTRIBUTE
           
static java.lang.String XINCLUDE_INCLUDE_ELEMENT_PARSE_ATTRIBUTE
           
static java.lang.String XINCLUDE_NAMESPACE_URI
           
static java.lang.String XMLBASE_ATTRIBUTE
           
protected  java.util.Stack xmlbase_element_name_stack
           
protected  java.util.Stack xmlbase_element_uri_stack
           
static java.lang.String XMLBASE_NAMESPACE_URI
           
protected  java.util.Stack xmlbase_stack
          This is a stack of xml:base attributes which belong to our ancestors
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.transformation.Transformer
ROLE
 
Constructor Summary
XIncludeTransformer()
           
 
Method Summary
 void compose(org.apache.avalon.framework.component.ComponentManager manager)
           
 void dispose()
           
 void endElement(java.lang.String uri, java.lang.String name, java.lang.String raw)
          Receive notification of the end of an element.
protected  void endXMLBaseAttribute()
           
protected  void processXIncludeElement(java.lang.String href, java.lang.String parse)
           
 void recycle()
          Recycle the producer by removing references
 void setDocumentLocator(org.xml.sax.Locator locator)
          Receive an object for locating the origin of SAX document events.
 void setup(SourceResolver resolver, java.util.Map objectModel, java.lang.String source, org.apache.avalon.framework.parameters.Parameters parameters)
          Set the SourceResolver, objectModel Map, the source and sitemap Parameters used to process the request.
 void startElement(java.lang.String uri, java.lang.String name, java.lang.String raw, org.xml.sax.Attributes attr)
          Receive notification of the beginning of an element.
protected  void startXMLBaseAttribute(java.lang.String uri, java.lang.String name, java.lang.String value)
           
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
characters, comment, endCDATA, endDocument, endDTD, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, skippedEntity, startCDATA, startDocument, startDTD, startEntity, startPrefixMapping
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable
getLogger, setLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
characters, endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, skippedEntity, startDocument, startPrefixMapping
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
 
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
 

Field Detail

manager

protected org.apache.avalon.framework.component.ComponentManager manager

XMLBASE_NAMESPACE_URI

public static final java.lang.String XMLBASE_NAMESPACE_URI

XMLBASE_ATTRIBUTE

public static final java.lang.String XMLBASE_ATTRIBUTE

XINCLUDE_NAMESPACE_URI

public static final java.lang.String XINCLUDE_NAMESPACE_URI

XINCLUDE_INCLUDE_ELEMENT

public static final java.lang.String XINCLUDE_INCLUDE_ELEMENT

XINCLUDE_INCLUDE_ELEMENT_HREF_ATTRIBUTE

public static final java.lang.String XINCLUDE_INCLUDE_ELEMENT_HREF_ATTRIBUTE

XINCLUDE_INCLUDE_ELEMENT_PARSE_ATTRIBUTE

public static final java.lang.String XINCLUDE_INCLUDE_ELEMENT_PARSE_ATTRIBUTE

base_xmlbase_uri

protected Source base_xmlbase_uri

current_xmlbase_uri

protected Source current_xmlbase_uri
The current XMLBase URI. We start with an empty "dummy" URL.

xmlbase_stack

protected java.util.Stack xmlbase_stack
This is a stack of xml:base attributes which belong to our ancestors

last_xmlbase_element_uri

protected java.lang.String last_xmlbase_element_uri
namespace uri of the last element which had an xml:base attribute

xmlbase_element_uri_stack

protected java.util.Stack xmlbase_element_uri_stack

last_xmlbase_element_name

protected java.lang.String last_xmlbase_element_name
name of the last element which had an xml:base attribute

xmlbase_element_name_stack

protected java.util.Stack xmlbase_element_name_stack
Constructor Detail

XIncludeTransformer

public XIncludeTransformer()
Method Detail

setup

public void setup(SourceResolver resolver,
                  java.util.Map objectModel,
                  java.lang.String source,
                  org.apache.avalon.framework.parameters.Parameters parameters)
           throws ProcessingException,
                  org.xml.sax.SAXException,
                  java.io.IOException
Description copied from interface: SitemapModelComponent
Set the SourceResolver, objectModel Map, the source and sitemap Parameters used to process the request.

compose

public void compose(org.apache.avalon.framework.component.ComponentManager manager)
Specified by:
compose in interface org.apache.avalon.framework.component.Composable

startElement

public void startElement(java.lang.String uri,
                         java.lang.String name,
                         java.lang.String raw,
                         org.xml.sax.Attributes attr)
                  throws org.xml.sax.SAXException
Description copied from class: AbstractXMLPipe
Receive notification of the beginning of an element.
Overrides:
startElement in class AbstractXMLPipe
Following copied from class: org.apache.cocoon.xml.AbstractXMLPipe
Parameters:
uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
loc - The local name (without prefix), or the empty string if Namespace processing is not being performed.
raw - The raw XML 1.0 name (with prefix), or the empty string if raw names are not available.
a - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.

endElement

public void endElement(java.lang.String uri,
                       java.lang.String name,
                       java.lang.String raw)
                throws org.xml.sax.SAXException
Description copied from class: AbstractXMLPipe
Receive notification of the end of an element.
Overrides:
endElement in class AbstractXMLPipe
Following copied from class: org.apache.cocoon.xml.AbstractXMLPipe
Parameters:
uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
loc - The local name (without prefix), or the empty string if Namespace processing is not being performed.
raw - The raw XML 1.0 name (with prefix), or the empty string if raw names are not available.

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Description copied from class: AbstractXMLPipe
Receive an object for locating the origin of SAX document events.
Overrides:
setDocumentLocator in class AbstractXMLPipe
Following copied from class: org.apache.cocoon.xml.AbstractXMLPipe
Parameters:
locator - An object that can return the location of any SAX document event.

startXMLBaseAttribute

protected void startXMLBaseAttribute(java.lang.String uri,
                                     java.lang.String name,
                                     java.lang.String value)
                              throws ProcessingException

endXMLBaseAttribute

protected void endXMLBaseAttribute()

processXIncludeElement

protected void processXIncludeElement(java.lang.String href,
                                      java.lang.String parse)
                               throws org.xml.sax.SAXException,
                                      ProcessingException,
                                      java.io.IOException

recycle

public void recycle()
Description copied from class: AbstractXMLProducer
Recycle the producer by removing references
Overrides:
recycle in class AbstractXMLProducer

dispose

public void dispose()
Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.