|
|||||||||
| Home >> All >> org >> apache >> xalan >> xslt >> [ extensions overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.xalan.xslt.extensions
Class Redirect

java.lang.Objectorg.apache.xalan.xslt.extensions.Redirect
- public class Redirect
- extends java.lang.Object
Implements three extension elements to allow an XSLT transformation to redirect its output to multiple output files. You must declare the Xalan namespace (xmlns:lxslt="http://xml.apache.org/xslt"), a namespace for the extension prefix (such as xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"), and declare the extension namespace as an extension (extension-element-prefixes="redirect"). You can either just use redirect:write, in which case the file will be opened and immediately closed after the write, or you can bracket the write calls by redirect:open and redirect:close, in which case the file will be kept open for multiple writes until the close call is encountered. Calls can be nested. Calls can take a 'file' attribute and/or a 'select' attribute in order to get the filename. If a select attribute is encountered, it will evaluate that expression for a string that indicates the filename. If the string evaluates to empty, it will attempt to use the 'file' attribute as a default. Filenames can be relative or absolute. If they are relative, the base directory will be the same as the base directory for the output document (setOutputFileName(outFileName) must be called first on the processor when using the API).
Example:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
xmlns:lxslt="http://xml.apache.org/xslt"
xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
extension-element-prefixes="redirect">
<xsl:template match="/">
<out>
default output.
</out>
<redirect:open file="doc3.out"/>
<redirect:write file="doc3.out">
<out>
<redirect:write file="doc1.out">
<out>
doc1 output.
<redirect:write file="doc3.out">
Some text to doc3
</redirect:write>
</out>
</redirect:write>
<redirect:write file="doc2.out">
<out>
doc2 output.
<redirect:write file="doc3.out">
Some more text to doc3
<redirect:write select="doc/foo">
text for doc4
</redirect:write>
</redirect:write>
</out>
</redirect:write>
</out>
</redirect:write>
<redirect:close file="doc3.out"/>
</xsl:template>
</xsl:stylesheet>
- Version:
- 1.0
| Field Summary | |
protected java.util.Hashtable |
m_formatterListeners
List of formatter listeners indexed by filename. |
protected java.util.Hashtable |
m_outputStreams
List of output streams indexed by filename. |
| Constructor Summary | |
Redirect()
|
|
| Method Summary | |
void |
close(org.apache.xalan.xslt.XSLProcessorContext context,
org.w3c.dom.Element elem)
Close the given file and remove it from the formatter listener's table. |
private java.lang.String |
getFilename(org.apache.xalan.xslt.XSLProcessorContext context,
org.w3c.dom.Element elem)
Get the filename from the 'select' or the 'file' attribute. |
private org.xml.sax.DocumentHandler |
makeFormatterListener(org.apache.xalan.xslt.XSLProcessorContext context,
java.lang.String fileName,
boolean shouldPutInTable,
boolean mkdirs)
Create a new DocumentHandler, based on attributes of the current DocumentHandler. |
void |
open(org.apache.xalan.xslt.XSLProcessorContext context,
org.w3c.dom.Element elem)
Open the given file and put it in the XML, HTML, or Text formatter listener's table. |
void |
write(org.apache.xalan.xslt.XSLProcessorContext context,
org.w3c.dom.Element elem)
Write the evalutation of the element children to the given file. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
m_formatterListeners
protected java.util.Hashtable m_formatterListeners
- List of formatter listeners indexed by filename.
m_outputStreams
protected java.util.Hashtable m_outputStreams
- List of output streams indexed by filename.
| Constructor Detail |
Redirect
public Redirect()
| Method Detail |
open
public void open(org.apache.xalan.xslt.XSLProcessorContext context, org.w3c.dom.Element elem) throws java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, org.xml.sax.SAXException
- Open the given file and put it in the XML, HTML, or Text formatter listener's table.
write
public void write(org.apache.xalan.xslt.XSLProcessorContext context, org.w3c.dom.Element elem) throws java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, org.xml.sax.SAXException
- Write the evalutation of the element children to the given file. Then close the file
unless it was opened with the open extension element and is in the formatter listener's table.
close
public void close(org.apache.xalan.xslt.XSLProcessorContext context, org.w3c.dom.Element elem) throws java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, org.xml.sax.SAXException
- Close the given file and remove it from the formatter listener's table.
getFilename
private java.lang.String getFilename(org.apache.xalan.xslt.XSLProcessorContext context, org.w3c.dom.Element elem) throws java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, org.xml.sax.SAXException
- Get the filename from the 'select' or the 'file' attribute.
makeFormatterListener
private org.xml.sax.DocumentHandler makeFormatterListener(org.apache.xalan.xslt.XSLProcessorContext context, java.lang.String fileName, boolean shouldPutInTable, boolean mkdirs) throws java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, org.xml.sax.SAXException
- Create a new DocumentHandler, based on attributes of the current DocumentHandler.
|
|||||||||
| Home >> All >> org >> apache >> xalan >> xslt >> [ extensions overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.apache.xalan.xslt.extensions.Redirect