com.caucho.xsl
Class XslWriter

java.lang.Object
  extended by java.io.Writer
      extended by com.caucho.xsl.XslWriter
All Implemented Interfaces:
ExtendedLocator, java.io.Closeable, java.io.Flushable, java.lang.Appendable, org.xml.sax.Locator

public class XslWriter
extends java.io.Writer
implements ExtendedLocator

Writer stream for generating stylesheet output.

Because XSL produces an XML tree, XslWriter contains extra methods for constructing the tree.

The writer methods, e.g. println, add to the current text node.

In addition, stylesheets can access variables through getPwd and getPage.


Field Summary
 
Fields inherited from class java.io.Writer
lock
 
Method Summary
 void addCacheDepend(Path path)
          Add a dependency to the result document.
 void addNamespace(java.lang.String prefix, java.lang.String url)
           
 void attribute(java.lang.String qName, java.lang.String value)
          Sends the attribute to the output
 void attribute(java.lang.String url, java.lang.String prefix, java.lang.String local, java.lang.String qName, java.lang.String value)
          Sends the attribute to the output
 void bindNamespace(java.lang.String prefix, java.lang.String url)
           
 void close()
           
 void copyOf(java.lang.Object value)
          Adds a deep copy of the node to the current node.
 boolean disableEscaping(boolean disable)
           
 void flush()
          flush is meaningless for XslWriter.
 int getColumnNumber()
           
 boolean getDisableEscaping()
           
 java.lang.String getFilename()
           
 int getLineNumber()
           
 PageContext getPage()
          Deprecated.  
 java.lang.Object getParameter(java.lang.String name)
           
 java.lang.Object getProperty(java.lang.String name)
          Returns the attribute with the given name.
 java.util.Iterator getPropertyNames()
          Lists the names of all the attributes.
 java.lang.String getPublicId()
           
 Path getPwd()
           
 java.lang.String getSystemId()
           
 TransformerImpl getTransformer()
           
 boolean isFlagFirst(int id)
          Implementation function so jsp:decl tags aren't repeated.
 XslWriter openResultDocument(java.io.OutputStream os)
           
 java.io.OutputStream openWrite(ExprEnvironment env, java.lang.String href)
           
 void popAttribute(XMLWriter writer)
          Sets the attribute value to the current text, and sets the current node to the parent.
 void popComment()
          Sets the comment data to the current text, and sets the current to the the parent.
 void popCopy(org.w3c.dom.Node copyNode)
          Pops the copy.
 void popElement()
           
 org.w3c.dom.Node popFragment(XMLWriter oldWriter)
          Returns the generated fragment.
 void popPi(java.lang.String name)
          Sets the PI data to the current text, and sets the current node to the parent.
 void popText()
          Pop the accumulated text to the DOM.
 void print(boolean b)
          Adds a boolean to the current text node.
 void print(char ch)
          Adds a character to the current text node.
 void print(double d)
          Adds a double to the current text node.
 void print(float f)
          Adds a float to the current text node.
 void print(int i)
          Adds an integer to the current text node.
 void print(long l)
          Adds an integer to the current text node.
 void print(java.lang.Object o)
          Adds an object to the current text node, converted by String.valueOf.
 void print(java.lang.String string)
          Adds a string to the current text node.
 void println()
          Adds a newline to the current text node.
 void println(boolean b)
          Adds a boolean to the current text node.
 void println(char ch)
          Adds a character to the current text node.
 void println(double d)
          Adds a double to the current text node.
 void println(float f)
          Adds a float to the current text node.
 void println(int i)
          Adds an integer to the current text node.
 void println(long l)
          Adds a long to the current text node.
 void println(java.lang.Object o)
          Adds an object to the current text node, converted by String.valueOf.
 void println(java.lang.String s)
          Adds a string to the current text node.
 XMLWriter pushAttribute(java.lang.String name)
          Adds a new attribute with the given name to the current node, making the attribute the current node.
 XMLWriter pushAttribute(java.lang.String name, NamespaceContext namespace)
          Adds a new attribute with the given name to the current node, making the attribute the current node.
 XMLWriter pushAttribute(java.lang.String prefix, java.lang.String local, java.lang.String url)
          Adds a namespace-aware attribute to the current node, making the new attribute the current node.
 XMLWriter pushAttributeNs(java.lang.String name, java.lang.String url)
          Adds a new attribute to the current node, making the new attribute the current node.
 void pushComment()
          Adds an empty comment to the current node, making the attribute the current node.
 void pushCopy(org.w3c.dom.Node copyNode)
          Copies the node without attributes or children.
 void pushElement(java.lang.String name)
          Adds a new element to the current node, making the new element the current node.
 void pushElement(java.lang.String name, NamespaceContext namespace)
          Adds a new element to the current node, making the new element the current node.
 void pushElement(java.lang.String url, java.lang.String prefix, java.lang.String local, java.lang.String name)
          Adds a namespace-aware element to the current node, making the new element the current node.
 void pushElementNs(java.lang.String name, java.lang.String url)
          Adds a new element to the current node, making the new element the current node.
 XMLWriter pushFragment()
          Starts a fragment.
 void pushPi()
           
 void removeProperty(java.lang.String name)
          removes the attribute with the given name.
 void setAttribute(java.lang.String name, NamespaceContext namespace, java.lang.String value)
          Adds a new attribute with the given name to the current node, making the attribute the current node.
 void setAttribute(java.lang.String name, java.lang.String value)
          Directly sets an attribute with a value.
 void setAttribute(java.lang.String prefix, java.lang.String local, java.lang.String url, java.lang.String value)
          Adds a namespace-aware attribute to the current node, making the new attribute the current node.
 void setLocation(java.lang.String systemId, java.lang.String filename, int line)
           
 void setNotCacheable()
          Indicate that the result document is not cacheable.
 void setProperty(java.lang.String name, java.lang.Object value)
          Sets the attribute with the given name.
 void valueOf(java.lang.Object node)
          Adds a the contents of the node to the current node.
 void write(byte[] buf, int offset, int length)
          Adds a byte buffer to the current text node.
 void write(char[] buf, int offset, int length)
          Adds a char buffer to the current text node.
 void write(int ch)
          Adds a byte to the current text node.
 
Methods inherited from class java.io.Writer
append, append, append, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTransformer

public TransformerImpl getTransformer()

setNotCacheable

public void setNotCacheable()
Indicate that the result document is not cacheable.


addCacheDepend

public void addCacheDepend(Path path)
Add a dependency to the result document. When the result is checked for modification, this path will also be checked.


isFlagFirst

public boolean isFlagFirst(int id)
Implementation function so jsp:decl tags aren't repeated.


write

public void write(int ch)
Adds a byte to the current text node.

Overrides:
write in class java.io.Writer

write

public void write(byte[] buf,
                  int offset,
                  int length)
Adds a byte buffer to the current text node.


write

public void write(char[] buf,
                  int offset,
                  int length)
Adds a char buffer to the current text node.

Specified by:
write in class java.io.Writer

print

public void print(java.lang.String string)
Adds a string to the current text node.


print

public void print(boolean b)
Adds a boolean to the current text node.


print

public void print(char ch)
Adds a character to the current text node.


print

public void print(int i)
Adds an integer to the current text node.


print

public void print(long l)
Adds an integer to the current text node.


print

public void print(float f)
Adds a float to the current text node.


print

public void print(double d)
Adds a double to the current text node.


print

public void print(java.lang.Object o)
Adds an object to the current text node, converted by String.valueOf.


println

public void println()
Adds a newline to the current text node.


println

public void println(boolean b)
Adds a boolean to the current text node.


println

public void println(java.lang.String s)
Adds a string to the current text node.


println

public void println(char ch)
Adds a character to the current text node.


println

public void println(int i)
Adds an integer to the current text node.


println

public void println(long l)
Adds a long to the current text node.


println

public void println(double d)
Adds a double to the current text node.


println

public void println(float f)
Adds a float to the current text node.


println

public void println(java.lang.Object o)
Adds an object to the current text node, converted by String.valueOf.


flush

public void flush()
flush is meaningless for XslWriter. It's only added to conform to Writer.

Specified by:
flush in interface java.io.Flushable
Specified by:
flush in class java.io.Writer

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Writer
Throws:
java.io.IOException

getDisableEscaping

public boolean getDisableEscaping()

disableEscaping

public boolean disableEscaping(boolean disable)
                        throws java.io.IOException,
                               org.xml.sax.SAXException
Throws:
java.io.IOException
org.xml.sax.SAXException

setLocation

public void setLocation(java.lang.String systemId,
                        java.lang.String filename,
                        int line)
                 throws java.io.IOException,
                        org.xml.sax.SAXException
Throws:
java.io.IOException
org.xml.sax.SAXException

pushElement

public void pushElement(java.lang.String name)
                 throws java.io.IOException,
                        org.xml.sax.SAXException
Adds a new element to the current node, making the new element the current node.

Each pushElement should be matched by a popElement.

Parameters:
name - name of the element
Throws:
java.io.IOException
org.xml.sax.SAXException

pushElement

public void pushElement(java.lang.String name,
                        NamespaceContext namespace)
                 throws java.io.IOException,
                        org.xml.sax.SAXException
Adds a new element to the current node, making the new element the current node.

Each pushElement should be matched by a popElement.

Parameters:
name - name of the element
namespace - namespace context
Throws:
java.io.IOException
org.xml.sax.SAXException

pushElementNs

public void pushElementNs(java.lang.String name,
                          java.lang.String url)
                   throws java.io.IOException,
                          org.xml.sax.SAXException
Adds a new element to the current node, making the new element the current node.

Each pushElement should be matched by a popElement.

Parameters:
name - name of the element
url - namespace url
Throws:
java.io.IOException
org.xml.sax.SAXException

pushElement

public void pushElement(java.lang.String url,
                        java.lang.String prefix,
                        java.lang.String local,
                        java.lang.String name)
                 throws java.io.IOException,
                        org.xml.sax.SAXException
Adds a namespace-aware element to the current node, making the new element the current node.

Each pushElement should be matched by a popElement.

Parameters:
prefix - the prefix of the element name, e.g. xsl
local - the local part of the element name, e.g. template
url - the namespace url, e.g. http://www.xml.org/...
Throws:
java.io.IOException
org.xml.sax.SAXException

pushAttribute

public XMLWriter pushAttribute(java.lang.String name)
                        throws java.io.IOException,
                               org.xml.sax.SAXException
Adds a new attribute with the given name to the current node, making the attribute the current node.

Throws:
java.io.IOException
org.xml.sax.SAXException

pushAttribute

public XMLWriter pushAttribute(java.lang.String name,
                               NamespaceContext namespace)
                        throws java.io.IOException,
                               org.xml.sax.SAXException
Adds a new attribute with the given name to the current node, making the attribute the current node.

Throws:
java.io.IOException
org.xml.sax.SAXException

pushAttributeNs

public XMLWriter pushAttributeNs(java.lang.String name,
                                 java.lang.String url)
                          throws java.io.IOException,
                                 org.xml.sax.SAXException
Adds a new attribute to the current node, making the new attribute the current node.

Each pushAttributeNs should be matched by a popAttribute.

Parameters:
name - name of the element
url - namespace url
Throws:
java.io.IOException
org.xml.sax.SAXException

pushAttribute

public XMLWriter pushAttribute(java.lang.String prefix,
                               java.lang.String local,
                               java.lang.String url)
                        throws java.io.IOException,
                               org.xml.sax.SAXException
Adds a namespace-aware attribute to the current node, making the new attribute the current node.

Each pushAttribute should be matched by a popAttribute.

Parameters:
prefix - the prefix of the element name, e.g. xsl
local - the local part of the element name, e.g. template
url - the namespace url, e.g. http://www.xml.org/...
Throws:
java.io.IOException
org.xml.sax.SAXException

setAttribute

public void setAttribute(java.lang.String prefix,
                         java.lang.String local,
                         java.lang.String url,
                         java.lang.String value)
                  throws java.io.IOException,
                         org.xml.sax.SAXException
Adds a namespace-aware attribute to the current node, making the new attribute the current node.

Each pushAttribute should be matched by a popAttribute.

Parameters:
prefix - the prefix of the element name, e.g. xsl
local - the local part of the element name, e.g. template
url - the namespace url, e.g. http://www.xml.org/...
Throws:
java.io.IOException
org.xml.sax.SAXException

setAttribute

public void setAttribute(java.lang.String name,
                         NamespaceContext namespace,
                         java.lang.String value)
                  throws java.io.IOException,
                         org.xml.sax.SAXException
Adds a new attribute with the given name to the current node, making the attribute the current node.

Throws:
java.io.IOException
org.xml.sax.SAXException

popAttribute

public void popAttribute(XMLWriter writer)
                  throws java.io.IOException,
                         org.xml.sax.SAXException
Sets the attribute value to the current text, and sets the current node to the parent.

Throws:
java.io.IOException
org.xml.sax.SAXException

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)
                  throws java.io.IOException,
                         org.xml.sax.SAXException
Directly sets an attribute with a value.

Throws:
java.io.IOException
org.xml.sax.SAXException

pushCopy

public void pushCopy(org.w3c.dom.Node copyNode)
              throws java.io.IOException,
                     org.xml.sax.SAXException
Copies the node without attributes or children.

Throws:
java.io.IOException
org.xml.sax.SAXException

popCopy

public void popCopy(org.w3c.dom.Node copyNode)
             throws java.io.IOException,
                    org.xml.sax.SAXException
Pops the copy.

Throws:
java.io.IOException
org.xml.sax.SAXException

pushPi

public void pushPi()
            throws java.io.IOException,
                   org.xml.sax.SAXException
Throws:
java.io.IOException
org.xml.sax.SAXException

popPi

public void popPi(java.lang.String name)
           throws java.io.IOException,
                  org.xml.sax.SAXException
Sets the PI data to the current text, and sets the current node to the parent.

Throws:
java.io.IOException
org.xml.sax.SAXException

pushComment

public void pushComment()
                 throws java.io.IOException,
                        org.xml.sax.SAXException
Adds an empty comment to the current node, making the attribute the current node.

Throws:
java.io.IOException
org.xml.sax.SAXException

popComment

public void popComment()
                throws java.io.IOException,
                       org.xml.sax.SAXException
Sets the comment data to the current text, and sets the current to the the parent.

Throws:
java.io.IOException
org.xml.sax.SAXException

pushFragment

public XMLWriter pushFragment()
                       throws java.io.IOException,
                              org.xml.sax.SAXException
Starts a fragment. The fragment becomes the current node.

Throws:
java.io.IOException
org.xml.sax.SAXException

popFragment

public org.w3c.dom.Node popFragment(XMLWriter oldWriter)
                             throws java.io.IOException,
                                    org.xml.sax.SAXException
Returns the generated fragment. The current node does not contain the new fragment.

Returns:
the generated fragment.
Throws:
java.io.IOException
org.xml.sax.SAXException

valueOf

public void valueOf(java.lang.Object node)
             throws java.io.IOException,
                    org.xml.sax.SAXException
Adds a the contents of the node to the current node.

Parameters:
node - node to print
Throws:
java.io.IOException
org.xml.sax.SAXException

copyOf

public void copyOf(java.lang.Object value)
            throws java.io.IOException,
                   org.xml.sax.SAXException,
                   XPathException
Adds a deep copy of the node to the current node.

Parameters:
XPath - node to be copied to the destination.
Throws:
java.io.IOException
org.xml.sax.SAXException
XPathException

addNamespace

public void addNamespace(java.lang.String prefix,
                         java.lang.String url)

popElement

public void popElement()
                throws java.io.IOException,
                       org.xml.sax.SAXException
Throws:
java.io.IOException
org.xml.sax.SAXException

attribute

public void attribute(java.lang.String url,
                      java.lang.String prefix,
                      java.lang.String local,
                      java.lang.String qName,
                      java.lang.String value)
               throws java.io.IOException,
                      org.xml.sax.SAXException
Sends the attribute to the output

Parameters:
url - the namespace for the attribute name
prefix - the prefix for the attribute name
local - the local attribute name
qName - the full qualified name
value - the attribute's value
Throws:
java.io.IOException
org.xml.sax.SAXException

attribute

public void attribute(java.lang.String qName,
                      java.lang.String value)
               throws java.io.IOException,
                      org.xml.sax.SAXException
Sends the attribute to the output

Parameters:
url - the namespace for the attribute name
prefix - the prefix for the attribute name
local - the local attribute name
qName - the full qualified name
value - the attribute's value
Throws:
java.io.IOException
org.xml.sax.SAXException

bindNamespace

public void bindNamespace(java.lang.String prefix,
                          java.lang.String url)
                   throws java.io.IOException,
                          org.xml.sax.SAXException
Throws:
java.io.IOException
org.xml.sax.SAXException

popText

public void popText()
             throws java.io.IOException,
                    org.xml.sax.SAXException
Pop the accumulated text to the DOM.

Throws:
java.io.IOException
org.xml.sax.SAXException

getProperty

public java.lang.Object getProperty(java.lang.String name)
Returns the attribute with the given name.


setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
Sets the attribute with the given name.


removeProperty

public void removeProperty(java.lang.String name)
removes the attribute with the given name.


getPropertyNames

public java.util.Iterator getPropertyNames()
Lists the names of all the attributes.


getParameter

public java.lang.Object getParameter(java.lang.String name)

getPwd

public Path getPwd()

openWrite

public java.io.OutputStream openWrite(ExprEnvironment env,
                                      java.lang.String href)
                               throws java.io.IOException
Throws:
java.io.IOException

openResultDocument

public XslWriter openResultDocument(java.io.OutputStream os)
                             throws java.io.IOException,
                                    org.xml.sax.SAXException
Throws:
java.io.IOException
org.xml.sax.SAXException

getPage

public PageContext getPage()
Deprecated. 


getSystemId

public java.lang.String getSystemId()
Specified by:
getSystemId in interface org.xml.sax.Locator

getFilename

public java.lang.String getFilename()
Specified by:
getFilename in interface ExtendedLocator

getPublicId

public java.lang.String getPublicId()
Specified by:
getPublicId in interface org.xml.sax.Locator

getLineNumber

public int getLineNumber()
Specified by:
getLineNumber in interface org.xml.sax.Locator

getColumnNumber

public int getColumnNumber()
Specified by:
getColumnNumber in interface org.xml.sax.Locator