com.caucho.xsl.java
Class XslNode

java.lang.Object
  extended by com.caucho.xsl.java.XslNode
Direct Known Subclasses:
TextNode, XslApplyImports, XslApplyTemplates, XslAttribute, XslAttributeNode, XslAttributeSet, XslCallTemplate, XslChoose, XslComment, XslCopy, XslCopyOf, XslDecimalFormat, XslElement, XslElementNode, XslForEach, XslIf, XslImport, XslInclude, XslKey, XslMessage, XslNamespaceAlias, XslNamespaceNode, XslNumber, XslOtherwise, XslOutput, XslParam, XslPreserveSpace, XslProcessingInstruction, XslResultDocument, XslSort, XslStripSpace, XslStylesheet, XslTemplate, XslText, XslUseAttributeSets, XslValueOf, XslVariable, XslWhen, XslWithParam, XslWrapperNode, XtpDeclaration, XtpDirectiveCache, XtpDirectivePage, XtpExpression, XtpScriptlet

public abstract class XslNode
extends java.lang.Object

Represents any XSL node from the stylesheet.


Field Summary
protected  java.util.ArrayList<XslNode> _children
           
protected  int _endLine
           
protected  java.lang.String _filename
           
protected  JavaGenerator _gen
           
protected  NamespaceContext _matchNamespace
           
protected  QName _name
           
protected  NamespaceContext _outputNamespace
           
protected  XslNode _parent
           
protected  int _startLine
           
protected  java.lang.String _systemId
           
 
Constructor Summary
protected XslNode()
           
 
Method Summary
 void addAttribute(QName name, java.lang.String value)
          Adds an attribute.
 void addChild(XslNode node)
          Adds a child node.
protected  int addExpr(java.lang.String pattern)
           
protected  void addNamespaceAttribute(QName name, java.lang.String url)
          Adds an attribute.
 void addText(java.lang.String text)
          Adds text.
 void addVariableCount()
          Add variable.
protected  boolean allowJavaSelect(AbstractPattern select)
          Returns true if we can compile in the java select.
 void endAttributes()
          Called after all the attributes from the tag.
 void endElement()
          Called when the tag closes.
protected  XslParseException error(java.lang.String msg)
          Creates a parse exception with the proper line information.
protected  XslParseException error(java.lang.Throwable e)
          Creates a parse exception with the proper line information.
 java.lang.String escapeJavaString(java.lang.String s)
           
abstract  void generate(JavaWriter out)
          Generates the code for the tag
 void generateChildren(JavaWriter out)
          Generates the code for the children.
 void generateDeclaration(JavaWriter out)
          Generates the prelude code for the tag
 void generateDeclarationChildren(JavaWriter out)
          Generates the declaration code for the children.
protected  int generateId()
           
 java.lang.String getBaseURI()
          Returns the base URI.
 java.util.ArrayList<XslNode> getChildren()
          Returns the children.
 int getEndLine()
          Gets the ending line number
protected  java.lang.String getEnv()
           
 java.lang.String getFilename()
          Gets the filename of the node
 NamespaceContext getMatchNamespace()
          Returns the namespaces.
 java.lang.String getNamespace(java.lang.String prefix)
          Returns the matching node in the namespace.
 NamespaceContext getOutputNamespace()
          Returns the namespaces.
 XslNode getParent()
          Returns the parent node.
 QName getQName()
          Returns the qname of the node.
 int getStartLine()
          Gets the starting line number
 java.lang.String getSystemId()
          Gets the system id of the node
 java.lang.String getTagName()
          Returns the qname of the node.
 boolean hasChildren()
          Returns true if there are any children.
protected  Expr parseExpr(java.lang.String pattern)
          Parses an XPath expression in the current context.
 AbstractPattern parseMatch(java.lang.String pattern)
           
protected  AbstractPattern parseSelect(java.lang.String pattern)
           
protected  void popCall(JavaWriter out)
           
protected  void popScope(JavaWriter out)
           
protected  void printAttributeValue(JavaWriter out, java.lang.String value)
          Prints an attribute value.
protected  void printAttributeValue(JavaWriter out, java.lang.String name, java.lang.String value)
          Prints an attribute value.
protected  void printExprTest(JavaWriter out, int id, java.lang.String node)
          Prints a test expr.
protected  void printFragmentString(JavaWriter out, java.lang.String id)
          Prints the children as a fragment stored in a variable.
protected  void printFragmentValue(JavaWriter out, java.lang.String id)
          Prints the children as a fragment stored in a variable.
protected  void printNamespace(JavaWriter out, NamespaceContext namespace)
           
protected  void printPopScope(JavaWriter out)
           
protected  java.lang.String printSelectBegin(JavaWriter out, AbstractPattern select, boolean isForEach, java.lang.String loopVar)
          Prints iterator code to start a select.
protected  void printStringExpr(JavaWriter out, java.lang.String exprString)
          Prints a value-of expression
protected  void pushCall(JavaWriter out)
           
 void setEndLocation(java.lang.String filename, int line)
          Sets the end location of the node.
 void setGenerator(JavaGenerator gen)
          Sets the Java generator.
 void setParent(XslNode parent)
          Sets the parent node
 void setQName(QName name)
          Sets the node's qname
 void setStartLocation(java.lang.String systemId, java.lang.String filename, int line)
          Sets the start location of the node.
protected  void stringExpr(JavaWriter out, java.lang.String exprString)
           
 java.lang.String toString()
          Returns a printable version of the node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_systemId

protected java.lang.String _systemId

_filename

protected java.lang.String _filename

_startLine

protected int _startLine

_endLine

protected int _endLine

_gen

protected JavaGenerator _gen

_name

protected QName _name

_parent

protected XslNode _parent

_children

protected java.util.ArrayList<XslNode> _children

_matchNamespace

protected NamespaceContext _matchNamespace

_outputNamespace

protected NamespaceContext _outputNamespace
Constructor Detail

XslNode

protected XslNode()
Method Detail

setGenerator

public void setGenerator(JavaGenerator gen)
Sets the Java generator.


getQName

public QName getQName()
Returns the qname of the node.


setQName

public void setQName(QName name)
Sets the node's qname


getTagName

public java.lang.String getTagName()
Returns the qname of the node.


getParent

public XslNode getParent()
Returns the parent node.


setParent

public void setParent(XslNode parent)
Sets the parent node


addVariableCount

public void addVariableCount()
Add variable.


setStartLocation

public void setStartLocation(java.lang.String systemId,
                             java.lang.String filename,
                             int line)
Sets the start location of the node.


setEndLocation

public void setEndLocation(java.lang.String filename,
                           int line)
Sets the end location of the node.


getSystemId

public java.lang.String getSystemId()
Gets the system id of the node


getFilename

public java.lang.String getFilename()
Gets the filename of the node


getStartLine

public int getStartLine()
Gets the starting line number


getEndLine

public int getEndLine()
Gets the ending line number


getBaseURI

public java.lang.String getBaseURI()
Returns the base URI.


getMatchNamespace

public NamespaceContext getMatchNamespace()
Returns the namespaces.


getOutputNamespace

public NamespaceContext getOutputNamespace()
Returns the namespaces.


getNamespace

public java.lang.String getNamespace(java.lang.String prefix)
Returns the matching node in the namespace.


addAttribute

public void addAttribute(QName name,
                         java.lang.String value)
                  throws XslParseException
Adds an attribute.

Throws:
XslParseException

addNamespaceAttribute

protected void addNamespaceAttribute(QName name,
                                     java.lang.String url)
                              throws XslParseException
Adds an attribute.

Throws:
XslParseException

endAttributes

public void endAttributes()
                   throws XslParseException
Called after all the attributes from the tag.

Throws:
XslParseException

addText

public void addText(java.lang.String text)
             throws XslParseException
Adds text.

Throws:
XslParseException

addChild

public void addChild(XslNode node)
              throws XslParseException
Adds a child node.

Throws:
XslParseException

endElement

public void endElement()
                throws java.lang.Exception
Called when the tag closes.

Throws:
java.lang.Exception

getChildren

public java.util.ArrayList<XslNode> getChildren()
Returns the children.


hasChildren

public boolean hasChildren()
Returns true if there are any children.


generate

public abstract void generate(JavaWriter out)
                       throws java.lang.Exception
Generates the code for the tag

Parameters:
out - the output writer for the generated java.
Throws:
java.lang.Exception

generateChildren

public void generateChildren(JavaWriter out)
                      throws java.lang.Exception
Generates the code for the children.

Parameters:
out - the output writer for the generated java.
Throws:
java.lang.Exception

generateDeclaration

public void generateDeclaration(JavaWriter out)
                         throws java.lang.Exception
Generates the prelude code for the tag

Parameters:
out - the output writer for the generated java.
Throws:
java.lang.Exception

generateDeclarationChildren

public void generateDeclarationChildren(JavaWriter out)
                                 throws java.lang.Exception
Generates the declaration code for the children.

Parameters:
out - the output writer for the generated java.
Throws:
java.lang.Exception

printAttributeValue

protected void printAttributeValue(JavaWriter out,
                                   java.lang.String name,
                                   java.lang.String value)
                            throws java.lang.Exception
Prints an attribute value.

Throws:
java.lang.Exception

printAttributeValue

protected void printAttributeValue(JavaWriter out,
                                   java.lang.String value)
                            throws java.lang.Exception
Prints an attribute value.

Throws:
java.lang.Exception

printStringExpr

protected void printStringExpr(JavaWriter out,
                               java.lang.String exprString)
                        throws java.lang.Exception
Prints a value-of expression

Throws:
java.lang.Exception

stringExpr

protected void stringExpr(JavaWriter out,
                          java.lang.String exprString)
                   throws java.lang.Exception,
                          XslParseException
Throws:
java.lang.Exception
XslParseException

pushCall

protected void pushCall(JavaWriter out)
                 throws java.io.IOException
Throws:
java.io.IOException

popCall

protected void popCall(JavaWriter out)
                throws java.io.IOException
Throws:
java.io.IOException

printSelectBegin

protected java.lang.String printSelectBegin(JavaWriter out,
                                            AbstractPattern select,
                                            boolean isForEach,
                                            java.lang.String loopVar)
                                     throws java.io.IOException,
                                            XslParseException
Prints iterator code to start a select.

Throws:
java.io.IOException
XslParseException

allowJavaSelect

protected boolean allowJavaSelect(AbstractPattern select)
Returns true if we can compile in the java select.


printNamespace

protected void printNamespace(JavaWriter out,
                              NamespaceContext namespace)
                       throws java.lang.Exception
Throws:
java.lang.Exception

printFragmentString

protected void printFragmentString(JavaWriter out,
                                   java.lang.String id)
                            throws java.lang.Exception
Prints the children as a fragment stored in a variable.

Throws:
java.lang.Exception

printFragmentValue

protected void printFragmentValue(JavaWriter out,
                                  java.lang.String id)
                           throws java.lang.Exception
Prints the children as a fragment stored in a variable.

Throws:
java.lang.Exception

popScope

protected void popScope(JavaWriter out)
                 throws java.lang.Exception
Throws:
java.lang.Exception

printPopScope

protected void printPopScope(JavaWriter out)
                      throws java.lang.Exception
Throws:
java.lang.Exception

printExprTest

protected void printExprTest(JavaWriter out,
                             int id,
                             java.lang.String node)
                      throws java.io.IOException
Prints a test expr.

Throws:
java.io.IOException

parseMatch

public AbstractPattern parseMatch(java.lang.String pattern)
                           throws XslParseException,
                                  java.io.IOException
Throws:
XslParseException
java.io.IOException

parseSelect

protected AbstractPattern parseSelect(java.lang.String pattern)
                               throws XslParseException
Throws:
XslParseException

addExpr

protected int addExpr(java.lang.String pattern)
               throws XslParseException
Throws:
XslParseException

parseExpr

protected Expr parseExpr(java.lang.String pattern)
                  throws XslParseException
Parses an XPath expression in the current context.

Throws:
XslParseException

generateId

protected int generateId()

getEnv

protected java.lang.String getEnv()

escapeJavaString

public java.lang.String escapeJavaString(java.lang.String s)

error

protected XslParseException error(java.lang.String msg)
Creates a parse exception with the proper line information.


error

protected XslParseException error(java.lang.Throwable e)
Creates a parse exception with the proper line information.


toString

public java.lang.String toString()
Returns a printable version of the node.

Overrides:
toString in class java.lang.Object