|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.lotus.xsl.XSLProcessor
It's the responsibility of the XSLProcessor class,
collaborating with the XML parser liaison, the DOM,
and the query/match engine, to transform a source tree
of nodes into a result tree according to instructions
and templates specified by a stylesheet tree.
The methods process(...)
are the primary
public entry points.
Look at the ProcessXSL class (com.lotus.xsl.xml4j)
for an example of usage by the main() function.
You must create a new instance of the XSLProcessor class each time you run a transformation. Fixing this is high on my priority list.
Inner Class Summary | |
class |
XSLProcessor.Stylesheet
This class represents the base stylesheet or an "import" stylesheet. |
Field Summary | |
static int |
EXITONPARSEERROR
|
Formatter |
m_formatter
The formatter interface, which has the toMarkup method, and which will eventually hold other non-event methods. |
com.lotus.xsl.Document |
m_resultTreeFactory
The factory that will be used to create result tree fragments. |
boolean |
m_useATVsInSelects
|
static int |
NOREPORTPARSEERROR
|
static int |
REPORTPARSEERROR
|
Constructor Summary | |
XSLProcessor(java.lang.String xslURLString,
XMLParserLiaison parserLiason)
Construct an XSL processor that can call back to a XML processor, so it can handle included files, and the like, and do the initial parse of the XSL document. |
|
XSLProcessor(XMLParserLiaison parserLiason)
Construct an XSL processor that can call back to a XML processor, so it can handle included files, and the like. |
Method Summary | |
void |
cdata(char[] ch,
int start,
int length)
Bottleneck the cdata event. |
void |
characters(char[] ch,
int start,
int length)
Bottleneck the characters event. |
void |
comment(java.lang.String data)
Bottleneck the comment event. |
void |
copyNamespaceAttributes(com.lotus.xsl.Node src,
boolean srcIsStylesheetTree,
com.lotus.xsl.AttributeListImpl destination)
Copy xmlns: attributes in if not already in scope. |
void |
endDocument()
Bottleneck the endDocument event. |
void |
endElement(java.lang.String name)
Bottleneck the endElement event. |
void |
entityReference(java.lang.String name)
Bottleneck the comment event. |
void |
error(com.lotus.xsl.Node styleNode,
com.lotus.xsl.Node sourceNode,
java.lang.String msg)
Tell the user of an error, and probably throw an exception. |
void |
error(java.lang.String msg)
Tell the user of an error, and probably throw an exception. |
java.lang.String |
fixWhiteSpace(java.lang.String string,
boolean trimHead,
boolean trimTail,
boolean doublePunctuationSpaces)
(Code stolen and modified from XML4J) Conditionally trim all leading and trailing whitespace in the specified String. |
java.util.Vector |
getKeyDeclarations()
Get the table of KeyDeclaration objects. |
java.util.Hashtable |
getKeysTable()
Get the table of element IDs. |
boolean |
getNeedToBuildKeysTable()
Set the needToBuildKeysTable property, which, if true, will trigger the building of the keys table. |
ProblemListener |
getProblemListener()
Get the problem listener property. |
QueryEngine |
getQueryEngine()
Get the query/pattern-matcher object. |
java.util.Hashtable |
getSourceDocsTable()
Get table of source tree documents. |
com.lotus.xsl.Node |
getSourceNode()
Returns the current input node that is being processed. |
com.lotus.xsl.Node |
getSourceNode(java.lang.String selectPattern,
com.lotus.xsl.Element namespaceContext)
Returns the current input node that is being processed. |
java.util.Hashtable |
getStylesheetsTable()
Get table of stylesheet documents. |
java.lang.String |
getStyleSheetURIfromDoc(com.lotus.xsl.Document sourceTree)
Given a document, get the default stylesheet URI from the xsl:stylesheet PI. |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Bottleneck the ignorableWhitespace event. |
static boolean |
isSpace(char ch)
Returns whether the specified ch conforms to the XML 1.0 definition of whitespace. |
boolean |
modifyStylesheetAttribute(com.lotus.xsl.Document styleSheet,
java.lang.String nameOfIDAttr,
java.lang.String idOfElementToModify,
java.lang.String attrNameToSet,
java.lang.String attrValueToSet)
Given an id of a stylesheet element, search the tree for the element, and modify the named attribute on that element. |
com.lotus.xsl.Document |
parseXML(java.lang.String urlString,
int howToHandleParseError)
Read in the XML file. |
com.lotus.xsl.Document |
parseXML(java.lang.String urlString,
java.lang.String[] holder)
Take a user string and try and parse XML, and also return the url. |
com.lotus.xsl.Document |
parseXML(java.lang.String urlString,
java.lang.String[] holder,
java.lang.String base)
Take a user string and try and parse XML, and also return the url. |
com.lotus.xsl.Document |
parseXML(java.net.URL url,
int howToHandleParseError)
Read in the XML file. |
long |
popDuration(java.lang.Object key)
Returns the duration since pushTime was called, in milliseconds. |
com.lotus.xsl.Document |
process(com.lotus.xsl.Document sourceTree)
Process a source document that contains a xml:stylesheet PI, transform the XML according to the instructions found in the XSL stylesheet pointed to by the PI. |
com.lotus.xsl.Document |
process(com.lotus.xsl.Document sourceTree,
com.lotus.xsl.Document styleTree,
java.lang.String styleBaseURI)
Given the source and the style trees, transform the nodes according to the instructions found in the style tree. |
com.lotus.xsl.Document |
process(com.lotus.xsl.Document sourceTree,
com.lotus.xsl.Document styleTree,
java.lang.String styleBaseURI,
com.lotus.xsl.Document out)
Given the source and the style trees, transform the source according to the instructions found in the style document. |
void |
process(com.lotus.xsl.Document sourceTree,
com.lotus.xsl.Document styleTree,
java.lang.String styleBaseURI,
java.io.PrintWriter resultWriter)
Given the source and the style trees, transform the source according to the instructions found in the style document, and stream the result to a PrintWriter via the SAX-based FormatterListener. |
com.lotus.xsl.Document |
process(java.io.Reader xmlReader)
Given a stream of XML, apply the stylesheet found in the document's stylesheet PI, and return the result as a DOM tree. |
void |
process(java.io.Reader xmlReader,
java.io.PrintWriter writer)
Given a stream of XML, stream the result to a PrintWriter via the SAX-based FormatterListener. |
com.lotus.xsl.Document |
process(java.io.Reader xmlReader,
java.io.Reader xslReader,
java.lang.String styleBaseURI)
Given a stream of XML, and a stream of XSL, return the result as a DOM tree. |
void |
process(java.io.Reader xmlReader,
java.io.Reader xslReader,
java.lang.String styleBaseURI,
java.io.PrintWriter writer)
Given a stream of XML, and a stream of XSL, and stream the result to a PrintWriter via the SAX-based FormatterListener. |
com.lotus.xsl.Document |
process(java.lang.String xmldocURLString)
Given a URI to a XML document, transform the XML according to the instructions found in the XSL. |
com.lotus.xsl.Document |
process(java.lang.String xmldocURLString,
com.lotus.xsl.Document out)
Given a URL to a XML document, transform the XML according to the instructions found in the XSL. |
com.lotus.xsl.Document |
process(java.lang.String xmldocURLString,
java.lang.String xsldocURLString)
Given a URI to a XML document and a URI to an XSL stylesheet, transform the XML according to the instructions found in the XSL. |
com.lotus.xsl.Document |
process(java.lang.String xmldocURLString,
java.lang.String xsldocURLString,
com.lotus.xsl.Document out)
Given a URL to XML and XSL documents, transform the XML according to the instructions found in the XSL. |
void |
process(java.lang.String xmlurl,
java.lang.String xslurl,
java.lang.String outFileName)
Given a URL to an XML document, and a URL to a XSL stylesheet, write the transformed result to a file. |
void |
process(java.lang.String xmldocURLString,
java.lang.String xsldocURLString,
java.lang.String writerName,
java.io.PrintWriter pw)
Given a URL to an XML document, and a URL to a XSL stylesheet, write the transformed result to a file. |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Bottleneck the processingInstruction event. |
void |
pushTime(java.lang.Object key)
Mark the time, so that displayDuration can later display the elapse. |
void |
registerExtensionHandler(java.lang.String mimeType,
DispatcherFactory factory)
Register the given DispatcherFactor for a given mime type. |
void |
registerExtensionHandlerByName(java.lang.String classid,
java.lang.String codetype)
Given a classID and codetype, tr to register a code dispatcher. |
void |
setConstant(java.lang.String name,
java.lang.String value)
This special user function lets the caller set a defined constant, so they can dynamicaly give some control to a given stylesheet. |
void |
setDiagnosticsOutput(java.io.PrintWriter pw)
If this is set, diagnostics will be written to the m_diagnosticsPrintWriter stream. |
void |
setDocumentLocator(com.lotus.xsl.Locator locator)
To fullfill the FormatterListener interface... |
void |
setFormatter(Formatter formatter)
Set the formatter interface, which has the toMarkup method, and which will eventually hold other non-event methods. |
void |
setKeyDeclarationsTable(java.util.Vector table)
Set the table of KeyDeclaration objects, which are set by the xsl:key element. |
void |
setKeyTable(java.util.Hashtable table)
Set the table of keys. |
void |
setNeedToBuildKeysTable(boolean b)
Set needToBuildKeysTable to true if an xsl:key directive is found. |
void |
setOutputCarriageReturns(boolean b)
Control if carriage returns are put in the result tree. |
void |
setOutputLinefeeds(boolean b)
Control if linefeeds are put in the result tree. |
void |
setProblemListener(ProblemListener l)
Set the problem listener property. |
void |
setQueryEngine(QueryEngine queryEngine)
Set the query/pattern-matcher object. |
void |
setQuietConflictWarnings(boolean b)
If the quietConflictWarnings property is set to true, warnings about pattern conflicts won't be printed to the diagnostics stream. |
void |
setSourceDocument(java.lang.String uri,
com.lotus.xsl.Document doc)
Set a source document. |
void |
setStripWhiteSpace(boolean b)
This changes the default of the default-space attribute. |
void |
setStyleSheet(java.lang.String uri,
com.lotus.xsl.Document doc,
boolean shouldBuildTables)
Not yet implemented! Set a stylesheet keyed by a URI. |
void |
setStylesheetParam(java.lang.String key,
java.lang.String expression)
Push a top-level stylesheet parameter. |
void |
setTraceSelect(boolean b)
If this is set to true, simple traces of template calls are made. |
void |
setTraceTemplateChildren(boolean b)
If this is set to true, debug diagnostics about template children as they are being constructed will be written to the m_diagnosticsPrintWriter stream. |
void |
setTraceTemplates(boolean b)
If this is set to true, simple traces of template calls are made. |
void |
setTranslateCSS(boolean b)
Deprecated. |
boolean |
shouldStripSourceNode(com.lotus.xsl.Node textNode)
Tells, through the combination of the default-space attribute on xsl:stylesheet, xsl:strip-space, xsl:preserve-space, and the xml:space attribute, whether or not extra whitespace should be stripped from the node. |
void |
startDocument()
Bottleneck the startDocument event. |
void |
startElement(java.lang.String name)
Bottleneck the startElement event. |
void |
startElement(java.lang.String name,
com.lotus.xsl.AttributeList atts)
Bottleneck the startElement event. |
void |
warn(com.lotus.xsl.Node styleNode,
com.lotus.xsl.Node sourceNode,
java.lang.String msg)
Warn the user of an problem. |
void |
warn(java.lang.String msg)
Warn the user of an problem. |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public boolean m_useATVsInSelects
public Formatter m_formatter
public com.lotus.xsl.Document m_resultTreeFactory
public static final int NOREPORTPARSEERROR
public static final int REPORTPARSEERROR
public static final int EXITONPARSEERROR
Constructor Detail |
public XSLProcessor(XMLParserLiaison parserLiason)
You must create a new instance of the XSLProcessor class each time you run a transformation. Fixing this is high on my priority list.
XMLParserLiaison
- A liaison to an object
that can help with stuff
specific to a parser
implementation.XMLParserLiaison
,
ProcessXSL
public XSLProcessor(java.lang.String xslURLString, XMLParserLiaison parserLiason) throws java.lang.Exception
You must create a new instance of the XSLProcessor class each time you run a transformation. Fixing this is high on my priority list.
xslURLString
- A valid URI or filename.XMLParserLiaison
- A liaison to an object
that can help with stuff
specific to a parser
implementation.XMLParserLiaison
,
ProcessXSL
Method Detail |
public com.lotus.xsl.Document process(com.lotus.xsl.Document sourceTree, com.lotus.xsl.Document styleTree, java.lang.String styleBaseURI, com.lotus.xsl.Document out) throws XSLProcessorException, java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, com.lotus.xsl.SAXException
sourceTree
- The input DOM tree (immutable).stylesheetTree
- The XSL DOM tree (immutable).styleBaseURI
- A base URI from where to look for included and imported files.out
- The result tree, may be null.public void process(com.lotus.xsl.Document sourceTree, com.lotus.xsl.Document styleTree, java.lang.String styleBaseURI, java.io.PrintWriter resultWriter) throws XSLProcessorException, java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, com.lotus.xsl.SAXException
sourceTree
- The input DOM tree (immutable).stylesheetTree
- The XSL DOM tree (immutable).styleBaseURI
- A base URI from where to look for included and imported files.resultWriter
- The stream where you wish the result tree to be written.public com.lotus.xsl.Document process(com.lotus.xsl.Document sourceTree, com.lotus.xsl.Document styleTree, java.lang.String styleBaseURI) throws XSLProcessorException, java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, com.lotus.xsl.SAXException
sourceTree
- The input DOM tree (immutable).stylesheetTree
- The XSL DOM tree (immutable).styleBaseURI
- A base URI from where to look for included and imported files.public com.lotus.xsl.Document process(com.lotus.xsl.Document sourceTree) throws XSLProcessorException, java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, com.lotus.xsl.SAXException
sourceTree
- The input DOM tree (immutable).public com.lotus.xsl.Document process(java.lang.String xmldocURLString, java.lang.String xsldocURLString, com.lotus.xsl.Document out) throws XSLProcessorException, java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, com.lotus.xsl.SAXException
xmldocURLString
- The URI to the input XML document.xsldocURLString
- The URI to the XSL stylesheet.out
- The result tree, may be null.public com.lotus.xsl.Document process(java.lang.String xmldocURLString, com.lotus.xsl.Document out) throws XSLProcessorException, java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, com.lotus.xsl.SAXException
xmldocURLString
- The URI to the input XML document.out
- The result tree, may be null.public void process(java.lang.String xmlurl, java.lang.String xslurl, java.lang.String outFileName) throws XSLProcessorException, java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, com.lotus.xsl.SAXException
xmldocURLString
- The URI to the input XML document.xsldocURLString
- The URI to the XSL stylesheet.outFileName
- The name of the file to write to.public void process(java.lang.String xmldocURLString, java.lang.String xsldocURLString, java.lang.String writerName, java.io.PrintWriter pw) throws XSLProcessorException, java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, com.lotus.xsl.SAXException
xmldocURLString
- The URI to the input XML document.xsldocURLString
- The URI to the XSL stylesheet.displayName
- The name of the stream for diagnostics.pw
- A PrintWriter to write the results to.public com.lotus.xsl.Document process(java.lang.String xmldocURLString, java.lang.String xsldocURLString) throws XSLProcessorException, java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, com.lotus.xsl.SAXException
xmldocURLString
- The URI to the input XML document.xsldocURLString
- The URI to the XSL stylesheet.public com.lotus.xsl.Document process(java.lang.String xmldocURLString) throws XSLProcessorException, java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, com.lotus.xsl.SAXException
xmldocURLString
- The URL to the input XML document.public void process(java.io.Reader xmlReader, java.io.Reader xslReader, java.lang.String styleBaseURI, java.io.PrintWriter writer) throws XSLProcessorException, java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, com.lotus.xsl.SAXException
xmlReader
- A reader for XML.xslReader
- A reader for XSL.styleBaseURI
- The base directory from where to find
included stylesheets.writer
- The writer that will receive the result XML.public void process(java.io.Reader xmlReader, java.io.PrintWriter writer) throws XSLProcessorException, java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, com.lotus.xsl.SAXException
xmlReader
- A reader for XML.writer
- The writer that will receive the result XML.public com.lotus.xsl.Document process(java.io.Reader xmlReader, java.io.Reader xslReader, java.lang.String styleBaseURI) throws XSLProcessorException, java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, com.lotus.xsl.SAXException
xmlReader
- A reader for XML.xslReader
- A reader for XSL.styleBaseURI
- The base directory from where to find
included stylesheets.public com.lotus.xsl.Document process(java.io.Reader xmlReader) throws XSLProcessorException, java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException, com.lotus.xsl.SAXException
xmlReader
- A reader for XML.public com.lotus.xsl.Document parseXML(java.lang.String urlString, java.lang.String[] holder) throws XSLProcessorException, java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException
public com.lotus.xsl.Document parseXML(java.lang.String urlString, java.lang.String[] holder, java.lang.String base) throws XSLProcessorException, java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException
public com.lotus.xsl.Document parseXML(java.lang.String urlString, int howToHandleParseError) throws XSLProcessorException, java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException
urlString
- Pointer to a XML-complient file.howToHandleParseError
- One of
NOREPORTPARSEERROR, REPORTPARSEERROR,EXITONPARSEERROR.baseURL
- returns the base URL.public com.lotus.xsl.Document parseXML(java.net.URL url, int howToHandleParseError) throws XSLProcessorException, java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException
urlString
- Pointer to a XML-complient file.howToHandleParseError
- One of
NOREPORTPARSEERROR, REPORTPARSEERROR,EXITONPARSEERROR.baseURL
- returns the base URL.public java.util.Hashtable getStylesheetsTable()
public void setStyleSheet(java.lang.String uri, com.lotus.xsl.Document doc, boolean shouldBuildTables) throws XSLProcessorException
uri
- A unique URI.doc
- A DOM tree that is an XSL stylesheet.public java.util.Hashtable getSourceDocsTable()
public void setSourceDocument(java.lang.String uri, com.lotus.xsl.Document doc)
public void warn(java.lang.String msg) throws XSLProcessorException
public void warn(com.lotus.xsl.Node styleNode, com.lotus.xsl.Node sourceNode, java.lang.String msg) throws XSLProcessorException
public void error(java.lang.String msg) throws XSLProcessorException
public void error(com.lotus.xsl.Node styleNode, com.lotus.xsl.Node sourceNode, java.lang.String msg) throws XSLProcessorException
public void pushTime(java.lang.Object key)
public long popDuration(java.lang.Object key)
public void setDiagnosticsOutput(java.io.PrintWriter pw)
public void setTraceTemplates(boolean b)
public void setTraceSelect(boolean b)
public void setTraceTemplateChildren(boolean b)
public void setQuietConflictWarnings(boolean b)
b
- true if conflict warnings should be suppressed.public void setDocumentLocator(com.lotus.xsl.Locator locator)
public void startDocument() throws com.lotus.xsl.SAXException
public void endDocument() throws com.lotus.xsl.SAXException
public void startElement(java.lang.String name) throws com.lotus.xsl.SAXException
public void startElement(java.lang.String name, com.lotus.xsl.AttributeList atts) throws com.lotus.xsl.SAXException
public void endElement(java.lang.String name) throws com.lotus.xsl.SAXException
public void characters(char[] ch, int start, int length) throws com.lotus.xsl.SAXException
public void ignorableWhitespace(char[] ch, int start, int length) throws com.lotus.xsl.SAXException
public void processingInstruction(java.lang.String target, java.lang.String data) throws com.lotus.xsl.SAXException
public void comment(java.lang.String data) throws com.lotus.xsl.SAXException
public void entityReference(java.lang.String name) throws com.lotus.xsl.SAXException
public void cdata(char[] ch, int start, int length) throws com.lotus.xsl.SAXException
public void copyNamespaceAttributes(com.lotus.xsl.Node src, boolean srcIsStylesheetTree, com.lotus.xsl.AttributeListImpl destination)
public void setTranslateCSS(boolean b)
b
- If true, translate CSS attributes on the output to a
"style" attribute.public void setStripWhiteSpace(boolean b)
b
- Sets the default of the default-space attribute
to "strip" if true, or "preserve" if false.public boolean shouldStripSourceNode(com.lotus.xsl.Node textNode)
textNode
- A text node from the source tree.public static boolean isSpace(char ch)
S
for details.ch
- Character to check as XML whitespace.public java.lang.String fixWhiteSpace(java.lang.String string, boolean trimHead, boolean trimTail, boolean doublePunctuationSpaces)
string
- String to be trimmed.trimHead
- Trim leading whitespace?trimTail
- Trim trailing whitespace?doublePunctuationSpaces
- Use double spaces for punctuation?public void setOutputCarriageReturns(boolean b)
b
- If true, output carriage returns.public void setOutputLinefeeds(boolean b)
b
- If true, output linefeeds.public java.lang.String getStyleSheetURIfromDoc(com.lotus.xsl.Document sourceTree)
public void setConstant(java.lang.String name, java.lang.String value)
public void setStylesheetParam(java.lang.String key, java.lang.String expression)
public boolean modifyStylesheetAttribute(com.lotus.xsl.Document styleSheet, java.lang.String nameOfIDAttr, java.lang.String idOfElementToModify, java.lang.String attrNameToSet, java.lang.String attrValueToSet) throws XSLProcessorException
styleSheet
- The stylesheet to look in.nameOfIDAttr
- The name of an attribute to search for a unique id.idOfElementToModify
- The unique ID to look for.attrNameToSet
- Once the element is found, the name of the attribute to set.attrValueToSet
- The value to set the attribute to.public com.lotus.xsl.Node getSourceNode()
public com.lotus.xsl.Node getSourceNode(java.lang.String selectPattern, com.lotus.xsl.Element namespaceContext) throws XSLProcessorException, java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException
public void registerExtensionHandlerByName(java.lang.String classid, java.lang.String codetype) throws XSLProcessorException
public void registerExtensionHandler(java.lang.String mimeType, DispatcherFactory factory)
public void setFormatter(Formatter formatter) throws com.lotus.xsl.SAXException
public void setQueryEngine(QueryEngine queryEngine)
queryEngine
- A QueryEngine interface.public QueryEngine getQueryEngine()
public void setKeyDeclarationsTable(java.util.Vector table)
table
- Table of IDAttributeHolder objects.public java.util.Vector getKeyDeclarations()
public void setKeyTable(java.util.Hashtable table)
public java.util.Hashtable getKeysTable()
public void setNeedToBuildKeysTable(boolean b)
public boolean getNeedToBuildKeysTable()
public void setProblemListener(ProblemListener l)
l
- A ProblemListener interface.public ProblemListener getProblemListener()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |