public class JavaGenerator
extends java.lang.Object
package work.xsl; public class foo extends JavaStylesheet { }
Modifier and Type | Field and Description |
---|---|
protected java.util.ArrayList<java.lang.String> |
_cacheDepends |
protected java.util.ArrayList<Path> |
_depends |
protected int |
_destLine |
protected org.w3c.dom.Document |
_doc |
protected java.lang.String |
_encoding |
protected java.lang.String |
_errorPage |
protected java.util.HashMap<java.lang.String,java.lang.String> |
_excludedNamespaces |
protected FormatNumberFun |
_formatNumberFun |
protected java.util.ArrayList |
_globalActions |
protected java.util.ArrayList<java.lang.String> |
_globalParameters |
protected java.util.ArrayList<java.lang.String> |
_imports |
protected boolean |
_isRawText |
protected boolean |
_isSpecial |
protected boolean |
_isStyleScript |
protected KeyFun |
_keyFun |
protected LineMap |
_lineMap |
protected NamespaceContext |
_namespace |
protected java.util.HashMap<java.lang.String,java.lang.String[]> |
_namespaceAliases |
protected AbstractPattern |
_nodeListContext |
protected java.util.HashMap<java.lang.String,java.lang.String> |
_preserve |
protected CauchoDocument |
_qDoc |
protected java.util.HashMap<java.lang.String,java.lang.String> |
_strip |
protected AbstractStylesheetFactory |
_xslGenerator |
protected static L10N |
L |
static java.lang.String |
XSLNS |
static java.lang.String |
XTPNS |
Modifier and Type | Method and Description |
---|---|
void |
addAttributeSet(java.lang.String name,
XslAttributeSet attributeSet)
Scans through the stylesheet, grabbing the attribute set
definitions.
|
void |
addExcludedNamespace(java.lang.String ns) |
int |
addExpr(Expr expr)
Adds an expression constant returning its index.
|
int |
addExpr(java.lang.String exprString)
Adds an expression constant returning its index.
|
int |
addFormat(XslNumberFormat format) |
void |
addGlobalParameter(java.lang.String param) |
void |
addImport(java.lang.String pkg)
Adds a Java import to the generated stylesheet.
|
void |
addImportList(java.lang.String value) |
void |
addInit(XslNode node) |
void |
addKey(java.lang.String name,
AbstractPattern match,
Expr use) |
void |
addLocale(java.lang.String name,
java.text.DecimalFormatSymbols format) |
void |
addMacro(java.lang.String name,
java.lang.String functionName) |
int |
addMatch(AbstractPattern pattern)
Adds a match pattern, returning its index.
|
void |
addMode(java.lang.String mode) |
protected NamespaceContext |
addNamespace(org.w3c.dom.Element elt)
Adds the namespaces in the element to the current NamespaceContext.
|
int |
addNamespace(NamespaceContext namespace) |
void |
addNamespaceAlias(java.lang.String stylesheetPrefix,
java.lang.String resultPrefix) |
void |
addNamespaceAlias(java.lang.String namespace,
java.lang.String[] result) |
void |
addPreserveSpace(java.lang.String elements) |
int |
addSelect(AbstractPattern select)
Adds a select pattern returning its index.
|
int |
addSelect(java.lang.String selectString)
Adds a select pattern, returning its index.
|
int |
addSort(Sort[] sort) |
void |
addStripSpace(java.lang.String elements) |
int |
addStylesheet(java.lang.String filename) |
void |
clearUnique() |
void |
close()
Close call when an error occurs.
|
protected StylesheetImpl |
completeGenerate(java.util.ArrayList<XslNode> inits,
java.util.ArrayList globals) |
protected XslNode |
createChild(org.w3c.dom.Node child) |
protected XslNode |
createChild(XslNode parent,
org.w3c.dom.Node childNode) |
java.lang.String |
createTemplatePattern(java.lang.String name,
AbstractPattern match,
java.lang.String mode,
double priority)
Generates the pattern for a matching pattern
|
protected void |
endDisableEscaping() |
StylesheetImpl |
generate(org.w3c.dom.Node node)
Starts the generation from the top of the document.
|
protected void |
generateChild(org.w3c.dom.Node child) |
void |
generateChild(org.w3c.dom.Node child,
int code) |
void |
generateChildImpl(org.w3c.dom.Node child) |
protected void |
generateChildren(org.w3c.dom.Node node) |
int |
generateId() |
XslNode |
generateImport(java.lang.String href) |
void |
generateInclude(XslNode parent,
java.lang.String href) |
java.util.HashMap<java.lang.String,java.lang.String> |
getAttributeSet(java.lang.String name)
Returns the named attribute set.
|
java.util.ArrayList<XslAttribute> |
getAttributeSetList(java.lang.String name)
Returns the named attribute set.
|
int |
getCallDepth() |
java.lang.String |
getCurrentPosition() |
boolean |
getDisableOutputEscaping() |
java.lang.String |
getElement() |
java.lang.String |
getEnv() |
int |
getImportance() |
java.lang.String |
getMacroName(java.lang.String name) |
int |
getMaxImportance() |
int |
getMinImportance() |
java.lang.String |
getModeName(java.lang.String mode)
Returns the name of the applyNode method.
|
NamespaceContext |
getNamespace() |
java.lang.String[] |
getNamespaceAlias(java.lang.String namespace) |
AbstractPattern |
getNodeListContext() |
protected JavaWriter |
getOut() |
int |
getSelectDepth() |
int |
getSelectLoopDepth() |
protected java.lang.String |
getXslLocal(org.w3c.dom.Node node)
Returns the local name of an XSL element.
|
protected java.lang.String |
getXtpLocal(org.w3c.dom.Node node) |
boolean |
hasMacro(java.lang.String name) |
void |
incrementImportance() |
Expr |
parseExpr(java.lang.String pattern) |
AbstractPattern |
parseMatch(java.lang.String pattern) |
AbstractPattern |
parseSelect(java.lang.String pattern) |
protected AbstractPattern |
parseSelect(java.lang.String pattern,
org.w3c.dom.Node node) |
protected void |
popCall() |
int |
popCallDepth() |
void |
popLoop() |
int |
popSelectDepth() |
int |
popSelectLoopDepth() |
protected void |
printApplyImports(java.lang.String mode,
int min,
int max)
Prints code to implement xsl:apply-imports
|
protected void |
printApplyTemplates(AbstractPattern select,
java.lang.String mode,
Sort[] sort)
Prints code for xsl:apply-templates
|
protected void |
printAssign(java.lang.String name,
java.lang.Object value) |
protected void |
printAttribute(org.w3c.dom.Element element,
java.lang.String name)
Prints an xsl:attribute
|
protected void |
printAttribute(org.w3c.dom.Element element,
java.lang.String name,
java.lang.String namespace) |
protected void |
printCacheDepends(java.lang.String name) |
protected void |
printCallTemplate(java.lang.String name,
java.lang.String mode) |
protected void |
printChoose(org.w3c.dom.Element element,
Expr expr,
boolean first) |
protected void |
printComment(org.w3c.dom.Element element) |
protected void |
printCopy(org.w3c.dom.Element element) |
protected void |
printCopyElement(org.w3c.dom.Element element) |
protected void |
printCopyOf(java.lang.String select,
org.w3c.dom.Element elt) |
protected void |
printDeclaration(org.w3c.dom.Element element) |
protected void |
printElement(org.w3c.dom.Element element,
java.lang.String name) |
protected void |
printElement(org.w3c.dom.Element element,
java.lang.String name,
java.lang.String namespace) |
protected void |
printElement(org.w3c.dom.Node node) |
protected void |
printError(java.lang.String msg) |
protected void |
printExpression(org.w3c.dom.Element element)
Prints code to implement the xtp:expression tag, i.e.
|
void |
printExprTest(int exprId,
java.lang.String element) |
protected void |
printForEach(org.w3c.dom.Element element,
java.lang.String select) |
protected void |
printForEach(org.w3c.dom.Element element,
java.lang.String select,
Sort[] sort)
Prints code for xsl:for-each when the for-each has any xsl:sort.
|
protected void |
printHeader()
Prints the generated header.
|
protected void |
printIf(org.w3c.dom.Element element,
Expr test) |
protected void |
printInit() |
protected void |
printInitVars(java.util.ArrayList<XslNode> inits)
Generate code executed for all transformations.
|
void |
printLocation(java.lang.String systemId,
java.lang.String filename,
int line)
Prints a command to set the current file and line into the
generated document.
|
protected void |
printMessage(org.w3c.dom.Element msg) |
void |
printNamespace(NamespaceContext namespace) |
protected void |
printOtherwise(org.w3c.dom.Element element,
boolean first) |
protected void |
printParam(java.lang.String name,
java.lang.Object value) |
protected void |
printParam(java.lang.String name,
java.lang.String value,
org.w3c.dom.Element elt)
Prints the value for a parameter.
|
protected void |
printParamVariable(java.lang.String name,
org.w3c.dom.Element value) |
protected void |
printParamVariable(java.lang.String name,
Expr value)
Prints code to add the value of an expression as a parameter.
|
protected void |
printPi(org.w3c.dom.Element element) |
protected void |
printPopScope(int count) |
protected void |
printResultDocument(org.w3c.dom.Element element,
java.lang.String href,
java.lang.String format) |
protected void |
printScriptlet(org.w3c.dom.Element element) |
protected void |
printSelectValue(java.lang.String select,
org.w3c.dom.Element elt) |
protected void |
printString(java.lang.String str)
Prints the contents of a string, taking care of escapes.
|
protected void |
printTemplate(org.w3c.dom.Element absNode,
java.lang.String name,
java.lang.String pattern,
java.lang.String mode,
double priority)
Generates code for a template
|
protected void |
printVariable(java.lang.String name,
java.lang.Object value) |
protected void |
printWhile(org.w3c.dom.Element element,
Expr test) |
protected void |
pushCall() |
int |
pushCallDepth() |
void |
pushLoop() |
int |
pushSelectDepth() |
int |
pushSelectLoopDepth() |
void |
setContentType(java.lang.String type) |
void |
setCurrentPosition(java.lang.String pos) |
void |
setDisableOutputEscaping(boolean disable) |
void |
setErrorPage(java.lang.String errorPage) |
void |
setLocation(java.lang.String systemId,
java.lang.String filename,
int line) |
void |
setMinImportance(int importance) |
void |
setNodeListContext(AbstractPattern context) |
void |
setOutputAttribute(java.lang.String name,
java.lang.String value) |
void |
setSelectDepth(int depth) |
void |
setSelectLoopDepth(int depth) |
void |
setStyleScript(boolean stylescript) |
protected void |
startDisableEscaping() |
java.lang.String |
toJavaIdentifier(java.lang.String name)
Converts a string to a Java identifier, encoding unknown characters
as "_"
|
int |
uniqueId()
Generates a uniqueId
|
protected void |
writeText(java.lang.String text)
Creates Java code to print plain text.
|
protected static final L10N L
public static final java.lang.String XSLNS
public static final java.lang.String XTPNS
protected java.util.HashMap<java.lang.String,java.lang.String> _preserve
protected java.util.HashMap<java.lang.String,java.lang.String> _strip
protected java.util.HashMap<java.lang.String,java.lang.String[]> _namespaceAliases
protected java.util.HashMap<java.lang.String,java.lang.String> _excludedNamespaces
protected KeyFun _keyFun
protected FormatNumberFun _formatNumberFun
protected NamespaceContext _namespace
protected java.util.ArrayList _globalActions
protected java.util.ArrayList<java.lang.String> _globalParameters
protected org.w3c.dom.Document _doc
protected CauchoDocument _qDoc
protected LineMap _lineMap
protected int _destLine
protected java.lang.String _encoding
protected java.util.ArrayList<Path> _depends
protected java.util.ArrayList<java.lang.String> _cacheDepends
protected boolean _isRawText
protected java.lang.String _errorPage
protected AbstractPattern _nodeListContext
protected boolean _isSpecial
protected boolean _isStyleScript
protected AbstractStylesheetFactory _xslGenerator
protected java.util.ArrayList<java.lang.String> _imports
protected JavaWriter getOut()
public int getSelectDepth()
public void setSelectDepth(int depth)
public int pushSelectDepth()
public int popSelectDepth()
public int getSelectLoopDepth()
public int pushSelectLoopDepth()
public int popSelectLoopDepth()
public void setSelectLoopDepth(int depth)
public int generateId()
public void clearUnique()
protected void printHeader() throws java.io.IOException
java.io.IOException
protected void generateChild(org.w3c.dom.Node child) throws java.lang.Exception
java.lang.Exception
protected XslNode createChild(XslNode parent, org.w3c.dom.Node childNode) throws java.lang.Exception
java.lang.Exception
protected XslNode createChild(org.w3c.dom.Node child) throws java.lang.Exception
java.lang.Exception
protected void printTemplate(org.w3c.dom.Element absNode, java.lang.String name, java.lang.String pattern, java.lang.String mode, double priority) throws java.lang.Exception
absNode
- the XSL node for the emplacename
- the template namepattern
- the pattern stringmode
- the template's modepriority
- the template's priorityjava.lang.Exception
public void addMacro(java.lang.String name, java.lang.String functionName)
public boolean hasMacro(java.lang.String name)
public java.lang.String createTemplatePattern(java.lang.String name, AbstractPattern match, java.lang.String mode, double priority) throws java.lang.Exception
name
- the mangled name of the functionmatch
- the XPath match patternmode
- the template modepriority
- the template prioritynode
- the source XML node from the XSL filejava.lang.Exception
protected void startDisableEscaping() throws java.io.IOException
java.io.IOException
protected void endDisableEscaping() throws java.io.IOException
java.io.IOException
protected void writeText(java.lang.String text) throws java.lang.Exception
java.lang.Exception
protected void printElement(org.w3c.dom.Node node) throws java.lang.Exception
java.lang.Exception
public void printLocation(java.lang.String systemId, java.lang.String filename, int line) throws java.lang.Exception
filename
- the source filenameline
- the source line number.java.lang.Exception
protected void pushCall() throws java.io.IOException
java.io.IOException
public int pushCallDepth()
public int popCallDepth()
public int getCallDepth()
protected void popCall() throws java.io.IOException
java.io.IOException
protected void printApplyTemplates(AbstractPattern select, java.lang.String mode, Sort[] sort) throws java.lang.Exception
select
- the select patternmode
- the template modesort
- the sort expressionsjava.lang.Exception
public int addSort(Sort[] sort)
protected void printApplyImports(java.lang.String mode, int min, int max) throws java.lang.Exception
mode
- the mode of the imported filesmin
- the min importancemax
- the max importancejava.lang.Exception
protected void printCallTemplate(java.lang.String name, java.lang.String mode) throws java.lang.Exception
java.lang.Exception
public java.lang.String getMacroName(java.lang.String name)
protected void printParam(java.lang.String name, java.lang.String value, org.w3c.dom.Element elt) throws java.lang.Exception
java.lang.Exception
protected void printParam(java.lang.String name, java.lang.Object value) throws java.lang.Exception
java.lang.Exception
protected void printParamVariable(java.lang.String name, Expr value) throws java.lang.Exception
java.lang.Exception
protected void printParamVariable(java.lang.String name, org.w3c.dom.Element value) throws java.lang.Exception
java.lang.Exception
protected void printVariable(java.lang.String name, java.lang.Object value) throws java.lang.Exception
java.lang.Exception
protected void printAssign(java.lang.String name, java.lang.Object value) throws java.lang.Exception
java.lang.Exception
protected void printPopScope(int count) throws java.lang.Exception
java.lang.Exception
protected void printCopyOf(java.lang.String select, org.w3c.dom.Element elt) throws java.lang.Exception
java.lang.Exception
protected void printSelectValue(java.lang.String select, org.w3c.dom.Element elt) throws java.lang.Exception
java.lang.Exception
protected void printForEach(org.w3c.dom.Element element, java.lang.String select) throws java.lang.Exception
java.lang.Exception
protected void printForEach(org.w3c.dom.Element element, java.lang.String select, Sort[] sort) throws java.lang.Exception
java.lang.Exception
public java.lang.String getCurrentPosition()
public void setCurrentPosition(java.lang.String pos)
public AbstractPattern getNodeListContext()
public void setNodeListContext(AbstractPattern context)
protected void printIf(org.w3c.dom.Element element, Expr test) throws java.lang.Exception
java.lang.Exception
protected void printChoose(org.w3c.dom.Element element, Expr expr, boolean first) throws java.lang.Exception
java.lang.Exception
protected void printOtherwise(org.w3c.dom.Element element, boolean first) throws java.lang.Exception
java.lang.Exception
public int addFormat(XslNumberFormat format)
protected void printCopy(org.w3c.dom.Element element) throws java.lang.Exception
java.lang.Exception
protected void printResultDocument(org.w3c.dom.Element element, java.lang.String href, java.lang.String format) throws java.lang.Exception
java.lang.Exception
protected void printElement(org.w3c.dom.Element element, java.lang.String name) throws java.lang.Exception
java.lang.Exception
protected void printElement(org.w3c.dom.Element element, java.lang.String name, java.lang.String namespace) throws java.lang.Exception
java.lang.Exception
public java.util.HashMap<java.lang.String,java.lang.String> getAttributeSet(java.lang.String name)
public java.util.ArrayList<XslAttribute> getAttributeSetList(java.lang.String name)
protected void printAttribute(org.w3c.dom.Element element, java.lang.String name) throws java.lang.Exception
java.lang.Exception
public void printNamespace(NamespaceContext namespace) throws java.lang.Exception
java.lang.Exception
public int addNamespace(NamespaceContext namespace) throws java.lang.Exception
java.lang.Exception
protected void printAttribute(org.w3c.dom.Element element, java.lang.String name, java.lang.String namespace) throws java.lang.Exception
java.lang.Exception
protected void printPi(org.w3c.dom.Element element) throws java.lang.Exception
java.lang.Exception
protected void printComment(org.w3c.dom.Element element) throws java.lang.Exception
java.lang.Exception
protected void printError(java.lang.String msg) throws java.lang.Exception
java.lang.Exception
protected void printMessage(org.w3c.dom.Element msg) throws java.lang.Exception
java.lang.Exception
protected void printExpression(org.w3c.dom.Element element) throws java.lang.Exception
java.lang.Exception
protected void printScriptlet(org.w3c.dom.Element element) throws java.lang.Exception
java.lang.Exception
protected void printWhile(org.w3c.dom.Element element, Expr test) throws java.lang.Exception
java.lang.Exception
protected void printDeclaration(org.w3c.dom.Element element) throws java.lang.Exception
java.lang.Exception
protected void printCacheDepends(java.lang.String name) throws java.lang.Exception
java.lang.Exception
public java.lang.String getElement()
public void pushLoop()
public void popLoop()
public java.lang.String getEnv()
public void printExprTest(int exprId, java.lang.String element) throws java.lang.Exception
java.lang.Exception
public int addExpr(Expr expr) throws XslParseException
expr
- the expression to add.XslParseException
public int addExpr(java.lang.String exprString) throws XslParseException
exprString
- the expression to add.XslParseException
public int addSelect(AbstractPattern select) throws java.io.IOException, XslParseException
select
- the select pattern to add.java.io.IOException
XslParseException
public int addSelect(java.lang.String selectString) throws java.io.IOException, XslParseException
selectString
- the expression to add.java.io.IOException
XslParseException
public int addMatch(AbstractPattern pattern) throws XslParseException
pattern
- the expression to add.XslParseException
protected StylesheetImpl completeGenerate(java.util.ArrayList<XslNode> inits, java.util.ArrayList globals) throws java.lang.Exception
java.lang.Exception
protected void printInitVars(java.util.ArrayList<XslNode> inits) throws java.lang.Exception
java.lang.Exception
protected void printInit() throws java.lang.Exception
java.lang.Exception
protected void printString(java.lang.String str) throws java.io.IOException
java.io.IOException
public java.lang.String getModeName(java.lang.String mode)
mode
- the template's mode.public void addMode(java.lang.String mode)
public int addStylesheet(java.lang.String filename)
public java.lang.String toJavaIdentifier(java.lang.String name)
public void close() throws java.io.IOException
java.io.IOException
public void setErrorPage(java.lang.String errorPage)
public void setStyleScript(boolean stylescript)
public void addImport(java.lang.String pkg)
public void setContentType(java.lang.String type)
public int getMinImportance()
public int getMaxImportance()
public NamespaceContext getNamespace()
public void addLocale(java.lang.String name, java.text.DecimalFormatSymbols format)
public int uniqueId()
public StylesheetImpl generate(org.w3c.dom.Node node) throws java.lang.Exception
xsl
- the stylesheet document.java.lang.Exception
public void addImportList(java.lang.String value) throws XslParseException
XslParseException
public void addExcludedNamespace(java.lang.String ns)
public void addInit(XslNode node)
public void addGlobalParameter(java.lang.String param)
public XslNode generateImport(java.lang.String href) throws java.lang.Exception
java.lang.Exception
public void generateInclude(XslNode parent, java.lang.String href) throws java.lang.Exception
java.lang.Exception
public void addKey(java.lang.String name, AbstractPattern match, Expr use)
public void addNamespaceAlias(java.lang.String stylesheetPrefix, java.lang.String resultPrefix)
public void addNamespaceAlias(java.lang.String namespace, java.lang.String[] result)
public java.lang.String[] getNamespaceAlias(java.lang.String namespace)
public void addAttributeSet(java.lang.String name, XslAttributeSet attributeSet)
element
- the current nodepublic void setDisableOutputEscaping(boolean disable)
public boolean getDisableOutputEscaping()
public void setOutputAttribute(java.lang.String name, java.lang.String value)
public void addStripSpace(java.lang.String elements)
public void addPreserveSpace(java.lang.String elements)
protected void generateChildren(org.w3c.dom.Node node) throws java.lang.Exception
java.lang.Exception
public void generateChildImpl(org.w3c.dom.Node child) throws java.lang.Exception
java.lang.Exception
public void generateChild(org.w3c.dom.Node child, int code) throws java.lang.Exception
java.lang.Exception
public void setLocation(java.lang.String systemId, java.lang.String filename, int line) throws XslParseException, java.io.IOException
XslParseException
java.io.IOException
protected void printCopyElement(org.w3c.dom.Element element) throws java.lang.Exception
java.lang.Exception
public int getImportance()
public void setMinImportance(int importance)
public void incrementImportance()
public AbstractPattern parseMatch(java.lang.String pattern) throws XslParseException, java.io.IOException
XslParseException
java.io.IOException
public AbstractPattern parseSelect(java.lang.String pattern) throws java.io.IOException, XslParseException
java.io.IOException
XslParseException
protected AbstractPattern parseSelect(java.lang.String pattern, org.w3c.dom.Node node) throws java.io.IOException, XslParseException
java.io.IOException
XslParseException
public Expr parseExpr(java.lang.String pattern) throws XslParseException
XslParseException
protected java.lang.String getXslLocal(org.w3c.dom.Node node)
node
- the XSL source nodeprotected java.lang.String getXtpLocal(org.w3c.dom.Node node)
protected NamespaceContext addNamespace(org.w3c.dom.Element elt)
elt
- the XSL element being processed.