You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by dl...@locus.apache.org on 2000/02/24 00:03:31 UTC
cvs commit: xml-xalan/src/org/apache/xalan/xslt XSLTProcessor.java XSLTEngineImpl.java XSLProcessorContext.java XMLSourceInfo.java UnImplNode.java TemplateList.java StylesheetRoot.java
dleslie 00/02/23 15:03:31
Modified: src/org/apache/xalan/xslt XSLTProcessor.java
XSLTEngineImpl.java XSLProcessorContext.java
XMLSourceInfo.java UnImplNode.java
TemplateList.java StylesheetRoot.java
Log:
javadoc updates
Revision Changes Path
1.9 +1 -1 xml-xalan/src/org/apache/xalan/xslt/XSLTProcessor.java
Index: XSLTProcessor.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/XSLTProcessor.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XSLTProcessor.java 2000/02/18 20:53:35 1.8
+++ XSLTProcessor.java 2000/02/23 23:03:29 1.9
@@ -77,7 +77,7 @@
import org.apache.xml.serialize.OutputFormat;
/**
- * For doing transformations; use {@link org.apache.xalan.xslt.XSLTProcessorFactory} to instantiate an implementation of this interface.
+ * The transformation processor -- use {@link org.apache.xalan.xslt.XSLTProcessorFactory} to instantiate an implementation of this interface.
* It's the responsibility of the implementation (XSLTEngineImpl),
* collaborating with a XMLParserLiaison, the DOM,
* and the XPath engine, to transform a source tree
1.47 +82 -83 xml-xalan/src/org/apache/xalan/xslt/XSLTEngineImpl.java
Index: XSLTEngineImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/XSLTEngineImpl.java,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- XSLTEngineImpl.java 2000/02/23 17:09:44 1.46
+++ XSLTEngineImpl.java 2000/02/23 23:03:29 1.47
@@ -24,7 +24,7 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "XSLT4J" and "Apache Software Foundation" must
+ * 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
@@ -73,8 +73,7 @@
import org.apache.xalan.xpath.xml.XSLMessages;
/**
- * It's the responsibility of the XSLTEngineImpl class,
- * collaborating with the XML parser liaison, the DOM,
+ * Collaborates with the XML parser liaison, the DOM,
* and the XPath engine, to transform a source tree
* of nodes into a result tree according to instructions
* and templates specified by a stylesheet tree.
@@ -206,7 +205,7 @@
* can call startElement.
*/
protected String m_pendingElementName = null;
-
+
/**
* Flag to tell if a StartDocument event is pending.
*/
@@ -291,10 +290,10 @@
* The stack of Variable stacks. A VariableStack will be
* pushed onto this stack for each template invocation.
*/
- private VariableStack m_variableStacks = new VariableStack();
-
+ private VariableStack m_variableStacks = new VariableStack();
+
/**
- * Get the variable stack, which is in charge of variables and
+ * Get the variable stack, which is in charge of variables and
* parameters.
*/
final VariableStack getVarStack() { return m_variableStacks; }
@@ -339,15 +338,15 @@
* Static false for pushing on the stack and the like.
*/
private static final Boolean FALSE = new Boolean(false);
-
+
/**
* Table of tables of element keys.
* @see KeyTable.
*/
transient Vector m_key_tables = null;
-
+
/**
- * Stack for the purposes of flagging infinite recursion with
+ * Stack for the purposes of flagging infinite recursion with
* attribute sets.
*/
transient Stack m_attrSetStack = null;
@@ -362,7 +361,7 @@
* Is >0 when we're processing a for-each
*/
BoolStack m_currentTemplateRuleIsNull = new BoolStack();
-
+
/**
* Get the table of counters, for optimized xsl:number support.
*/
@@ -372,7 +371,7 @@
m_countersTable = new CountersTable();
return m_countersTable;
}
-
+
//==========================================================
// SECTION: Constructors
//==========================================================
@@ -391,7 +390,7 @@
Class parserLiaisonClass = Class.forName(parserLiaisonClassName);
Constructor parserLiaisonCtor = parserLiaisonClass.getConstructor(null);
m_parserLiaison
- = (XMLParserLiaison)parserLiaisonCtor.newInstance(null);
+ = (XMLParserLiaison)parserLiaisonCtor.newInstance(null);
m_parserLiaison.setEnvSupport(this);
}
catch(Exception e)
@@ -402,9 +401,9 @@
/**
* Construct an XSL processor that uses the the given parser liaison.
- * (This must be made public for use by derived classes and so it
- * can also be accessed by the XSLTProcessorFactory. But, normally,
- * one should use the XSLTProcessorFactory to create an instance of
+ * (This must be made public for use by derived classes and so it
+ * can also be accessed by the XSLTProcessorFactory. But, normally,
+ * one should use the XSLTProcessorFactory to create an instance of
* this class.)
*/
public XSLTEngineImpl(String parserLiaisonClassName)
@@ -415,7 +414,7 @@
Class parserLiaisonClass = Class.forName(parserLiaisonClassName);
Constructor parserLiaisonCtor = parserLiaisonClass.getConstructor(null);
m_parserLiaison
- = (XMLParserLiaison)parserLiaisonCtor.newInstance(null);
+ = (XMLParserLiaison)parserLiaisonCtor.newInstance(null);
m_parserLiaison.setEnvSupport(this);
}
catch(Exception e)
@@ -426,9 +425,9 @@
/**
* Construct an XSL processor that uses the the given parser liaison.
- * (This must be made public for use by derived classes and so it
- * can also be accessed by the XSLTProcessorFactory. But, normally,
- * one should use the XSLTProcessorFactory to create an instance of
+ * (This must be made public for use by derived classes and so it
+ * can also be accessed by the XSLTProcessorFactory. But, normally,
+ * one should use the XSLTProcessorFactory to create an instance of
* this class.)
* @param XMLParserLiaison A liaison to an object
* that can help with stuff
@@ -438,7 +437,7 @@
* @see org.apache.xalan.xslt.xml4j.ProcessXSL
*/
public XSLTEngineImpl(XMLParserLiaison parserLiason)
- {
+ {
m_parserLiaison = parserLiason;
m_parserLiaison.setEnvSupport(this);
}
@@ -455,7 +454,7 @@
* @see org.apache.xalan.xslt.xml4j.ProcessXSL
*/
XSLTEngineImpl(XMLParserLiaison parserLiason, XPathFactory xpathFactory)
- {
+ {
m_parserLiaison = parserLiason;
m_parserLiaison.setEnvSupport(this);
}
@@ -631,12 +630,12 @@
// throw se;
}
}
-
+
/**
* Bottleneck the creation of the stylesheet for derivation purposes.
*/
protected StylesheetRoot createStylesheetRoot(String baseIdentifier)
- throws MalformedURLException, FileNotFoundException,
+ throws MalformedURLException, FileNotFoundException,
IOException, SAXException
{
return new StylesheetRoot(this, baseIdentifier);
@@ -727,8 +726,8 @@
/**
* Set the stylesheet for this processor. If this is set, then the
* process calls that take only the input .xml will use
- * this instead of looking for a stylesheet PI. Also,
- * setting the stylesheet is needed if you are going
+ * this instead of looking for a stylesheet PI. Also,
+ * setting the stylesheet is needed if you are going
* to use the processor as a SAX DocumentHandler.
*/
public void setStylesheet(StylesheetRoot stylesheetRoot)
@@ -869,21 +868,21 @@
}
return doc;
}
-
+
/**
- * Get the preferred InputSource specification that is associated with a
+ * Get the preferred InputSource specification that is associated with a
* given document specified in the source param,
- * via the xml-stylesheet processing instruction
- * (see http://www.w3.org/TR/xml-stylesheet/), and that matches
+ * via the xml-stylesheet processing instruction
+ * (see http://www.w3.org/TR/xml-stylesheet/), and that matches
* the given criteria. Does not yet handle the LINK REL="stylesheet" syntax.
- * @param media The media attribute to be matched. May be null, in which
+ * @param media The media attribute to be matched. May be null, in which
* case the prefered stylesheet will be used (i.e. alternate = no).
* @param title The value of the title attribute to match. May be null.
* @param charset The value of the charset attribute to match. May be null.
* @returns An InputSource that can be passed to createStylesheet method.
*/
public StylesheetSpec getAssociatedStylesheet(XSLTInputSource source,
- String media,
+ String media,
String charset)
throws SAXException
{
@@ -894,27 +893,27 @@
return null;
}
-
+
/**
- * Get the InputSource specifications that are associated with a
+ * Get the InputSource specifications that are associated with a
* given document specified in the source param,
- * via the xml-stylesheet processing instruction
- * (see http://www.w3.org/TR/xml-stylesheet/), and that matches
+ * via the xml-stylesheet processing instruction
+ * (see http://www.w3.org/TR/xml-stylesheet/), and that matches
* the given criteria. Does not yet handle the LINK REL="stylesheet" syntax.
- * @param media The media attribute to be matched. May be null, in which
+ * @param media The media attribute to be matched. May be null, in which
* case the prefered stylesheet will be used (i.e. alternate = no).
* @param title The value of the title attribute to match. May be null.
* @param charset The value of the charset attribute to match. May be null.
* @returns A list of input sources that can be passed to createStylesheet method.
*/
public Vector getAssociatedStylesheets(XSLTInputSource source,
- String mediaRequest,
+ String mediaRequest,
String charsetRequest)
throws SAXException
{
Vector inputSources = null;
Node sourceTree = getSourceTreeFromInput(source);
-
+
for(Node child=sourceTree.getFirstChild(); null != child; child=child.getNextSibling())
{
if(Node.PROCESSING_INSTRUCTION_NODE == child.getNodeType())
@@ -937,7 +936,7 @@
if(name.equals("type"))
{
String typeVal = tokenizer.nextToken();
- type = typeVal.substring(1, typeVal.length()-1);
+ type = typeVal.substring(1, typeVal.length()-1);
}
else if(name.equals("href"))
{
@@ -965,10 +964,10 @@
alternate = alternateStr.substring(1, alternateStr.length()-1).equals("yes");
}
}
-
+
if((null != type) && type.equals("text/xsl") && (null != href))
{
-
+
if(null != mediaRequest)
{
if(null != media)
@@ -991,20 +990,20 @@
}
if(null == inputSources)
inputSources = new Vector();
-
- StylesheetSpec spec
+
+ StylesheetSpec spec
= new StylesheetSpec(href, type, title, media, alternate, charset);
-
+
if(!alternate)
inputSources.insertElementAt(spec, 0);
else
inputSources.addElement(spec);
}
}
-
+
}
} // end for(int i = 0; i < nNodes; i++)
-
+
return inputSources;
}
@@ -1033,16 +1032,16 @@
diag("Locating stylesheet from fragment identifier...");
String fragID = xslURLString.substring(1);
PrefixResolver nsNode = getExecContext().getNamespaceContext();
-
+
// Try a bunch of really ugly stuff to find the fragment.
// What's the right way to do this?
-
+
// Create a XPath parser.
XPathProcessorImpl parser = new XPathProcessorImpl();
-
+
// Create the XPath object.
XPath xpath = new XPath();
-
+
// Parse the xpath
parser.initXPath(xpath, "id("+fragID+")", nsNode);
XObject xobj = xpath.execute(getExecContext(), fragBase, nsNode);
@@ -1053,7 +1052,7 @@
// xobj = Stylesheet.evalXPathStr(getExecContext(), "//*[@id='"+fragID+"']", fragBase, nsNode);
// Create the XPath object.
xpath = new XPath();
-
+
// Parse the xpath
parser.initXPath(xpath, "//*[@id='"+fragID+"']", nsNode);
xobj = xpath.execute(getExecContext(), fragBase, nsNode);
@@ -1064,7 +1063,7 @@
// xobj = Stylesheet.evalXPathStr(getExecContext(), "//*[@name='"+fragID+"']", fragBase, nsNode);
// Create the XPath object.
xpath = new XPath();
-
+
// Parse the xpath
parser.initXPath(xpath, "//*[@name='"+fragID+"']", nsNode);
xobj = xpath.execute(getExecContext(), fragBase, nsNode);
@@ -1075,7 +1074,7 @@
// xobj = Stylesheet.evalXPathStr(getExecContext(), fragID, fragBase, nsNode);
// Create the XPath object.
xpath = new XPath();
-
+
// Parse the xpath
parser.initXPath(xpath, fragID, nsNode);
xobj = xpath.execute(getExecContext(), fragBase, nsNode);
@@ -1472,7 +1471,7 @@
throws SAXException
{
warn(styleNode, sourceNode, msg, null);
- }
+ }
/**
* Warn the user of an problem.
@@ -1503,7 +1502,7 @@
throw new XSLProcessorException(formattedMsg);
}
}
-
+
/**
* Tell the user of an error, and probably throw an
* exception.
@@ -1569,7 +1568,7 @@
throws SAXException
{
error(msg, null, e);
- }
+ }
/**
* Tell the user of an error, and probably throw an
@@ -1579,7 +1578,7 @@
*/
public void error(int msg, Object args[], Exception e)
throws SAXException
- {
+ {
//msg = (null == msg) ? XSLTErrorResources.ER_PROCESSOR_ERROR : msg;
String formattedMsg = m_XSLMessages.createMessage(msg, args);
Locator locator = m_stylesheetLocatorStack.isEmpty()
@@ -1616,8 +1615,8 @@
public void error(Node styleNode, Node sourceNode, int msg)
throws SAXException
{
- error(styleNode, sourceNode, msg, null);
- }
+ error(styleNode, sourceNode, msg, null);
+ }
/**
* Tell the user of an error, and probably throw an
@@ -1627,7 +1626,7 @@
*/
public void error(Node styleNode, Node sourceNode, int msg, Object args[])
throws SAXException
- {
+ {
String formattedMsg = m_XSLMessages.createMessage(msg, args);
Locator locator = m_stylesheetLocatorStack.isEmpty()
? null :
@@ -2433,7 +2432,7 @@
int nAttributes = (null != attributes) ? attributes.getLength() : 0;
String attrSetUseVal = null;
for(int i = 0; i < nAttributes; i++)
- {
+ {
Attr attr = (Attr)attributes.item(i);
if(m_parserLiaison.getExpandedAttributeName(attr).equals(m_stylesheetRoot.m_XSLNameSpaceURL+":use"))
{
@@ -2668,7 +2667,7 @@
public boolean shouldStripSourceNode(Node textNode)
throws org.xml.sax.SAXException
{
- if((null != m_stylesheetRoot) &&
+ if((null != m_stylesheetRoot) &&
((null != m_stylesheetRoot.m_whitespacePreservingElements) ||
(null != m_stylesheetRoot.m_whitespaceStrippingElements))
)
@@ -3316,7 +3315,7 @@
{
int nAttributes = (null != attributes) ? attributes.getLength() : 0;
for(int i = 0; i < nAttributes; i++)
- {
+ {
Attr attr =
(Attr)attributes.item(i);
String attrName = attr.getName();
@@ -3436,7 +3435,7 @@
{
m_flistener = flistener;
}
-
+
/**
* Set a DOM document factory, primarily for creating result
* tree fragments.
@@ -3478,7 +3477,7 @@
* @return A ProblemListener interface.
*/
public ProblemListener getProblemListener()
- {
+ {
return m_parserLiaison.getProblemListener();
}
@@ -3533,7 +3532,7 @@
XSLTResultTarget result = (null == m_outputStream) ?
new XSLTResultTarget(m_flistener) :
new XSLTResultTarget(m_outputStream);
-
+
m_stylesheetRoot.process(this, m_sourceTreeHandler.getRootNode(),
result);
}
@@ -3772,10 +3771,10 @@
//attList.removeAttribute(aname);
attList.addAttribute(aname, "CDATA", value);
}
-
+
/**
- * Tell if the default namespace is listed in the pending
- * attributes. *Only* for use to see if the HTML element should
+ * Tell if the default namespace is listed in the pending
+ * attributes. *Only* for use to see if the HTML element should
* be used to indicate a switch to the HTML formatter.
*/
private boolean pendingHasDefaultNS()
@@ -3793,9 +3792,9 @@
}
return false;
}
-
+
boolean m_mustFlushStartDoc = false;
-
+
/**
* Check to see if the output prefix should be excluded.
*/
@@ -3834,7 +3833,7 @@
try
{
xmlListener = (FormatterToXML)m_flistener;
-
+
}
catch(ClassCastException cce)
{
@@ -3858,7 +3857,7 @@
fireGenerateEvent(new GenerateEvent(XSLTEngineImpl.this,
GenerateEvent.EVENTTYPE_STARTDOCUMENT));
}
-
+
if((null != m_pendingElementName) && m_mustFlushStartDoc)
{
if(null != m_stylesheetRoot.m_cdataSectionElems)
@@ -3925,7 +3924,7 @@
GenerateEvent.EVENTTYPE_ENDDOCUMENT));
m_variableStacks.popCurrentContext();
}
-
+
/**
* Bottleneck the startElement event.
*/
@@ -4006,7 +4005,7 @@
((LexicalHandler)m_flistener).startCDATA();
m_flistener.characters(ch, start, length);
-
+
if(isLexHandler)
((LexicalHandler)m_flistener).endCDATA();
@@ -4107,7 +4106,7 @@
GenerateEvent.EVENTTYPE_COMMENT,
data));
}
-
+
/**
* Bottleneck the comment event.
*/
@@ -4143,7 +4142,7 @@
GenerateEvent.EVENTTYPE_ENTITYREF,
name));
}
-
+
/**
* Start an entity.
*/
@@ -4173,7 +4172,7 @@
GenerateEvent.EVENTTYPE_ENTITYREF,
name));
}
-
+
/**
* Start the DTD.
*/
@@ -4185,7 +4184,7 @@
((LexicalHandler)m_flistener).startDTD(s1, s2, s3);
}
}
-
+
/**
* End the DTD.
*/
@@ -4209,7 +4208,7 @@
((LexicalHandler)m_flistener).startCDATA();
}
}
-
+
/**
* End the CDATA characters.
*/
@@ -4234,12 +4233,12 @@
!m_cdataStack.isEmpty() && (m_cdataStack.peek() == TRUE))
{
boolean isLexH = (m_flistener instanceof LexicalHandler);
-
+
if(m_flistener instanceof LexicalHandler)
((LexicalHandler)m_flistener).startCDATA();
m_flistener.characters(ch, start, length);
-
+
if(m_flistener instanceof LexicalHandler)
((LexicalHandler)m_flistener).endCDATA();
1.2 +9 -9 xml-xalan/src/org/apache/xalan/xslt/XSLProcessorContext.java
Index: XSLProcessorContext.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/XSLProcessorContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSLProcessorContext.java 1999/11/08 20:56:38 1.1
+++ XSLProcessorContext.java 2000/02/23 23:03:30 1.2
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,15 +18,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "XSLT4J" and "Apache Software Foundation" must
+ * 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -62,8 +62,8 @@
// import org.apache.xalan.xslt.*;
/**
- * This class is used to capture all the processor context to be
- * passed to an extension function.
+ * Captures processor context to be
+ * passed to an extension element.
*
* @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
*/
@@ -75,7 +75,7 @@
public QName mode;
public XSLProcessorContext (XSLTEngineImpl processor,
- Stylesheet stylesheetTree,
+ Stylesheet stylesheetTree,
Node sourceTree, Node sourceNode, QName mode) {
this.processor = processor;
this.stylesheetTree = stylesheetTree;
@@ -86,7 +86,7 @@
/**
* I need a "Node transformNode (Node)" method somewhere that the
- * user can call to process the transformation of a node but not
+ * user can call to process the transformation of a node but not
* serialize out automatically. ????????????????
*
* Does ElemTemplateElement.executeChildren() cut it? It sends
1.2 +10 -10 xml-xalan/src/org/apache/xalan/xslt/XMLSourceInfo.java
Index: XMLSourceInfo.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/XMLSourceInfo.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XMLSourceInfo.java 1999/11/08 20:56:37 1.1
+++ XMLSourceInfo.java 2000/02/23 23:03:30 1.2
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "XSLT4J" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -59,9 +59,9 @@
//XMLSourceInfo.java
/**
- * This interface may be implemented by XSL output classes
- * that are DOM node derivatives, to point back to the originating
- * source XML elements.
+ * Use {@link org.apache.xalan.xslt.XSLTInputSource} for XML inpu and XSL stylesheets. This interface may be implemented by XSL output classes
+ * that are DOM node derivatives, to point back to the originating
+ * source XML elements.
* Mainly for use with authoring applications.
* @deprecated
*/
@@ -71,10 +71,10 @@
* Set the originating source element reference.
*/
public void setXMLSourceNode(org.w3c.dom.Node el);
-
+
/**
- * Get the originating source element reference. This may
- * easily return NULL! Not all output elements will be
+ * Get the originating source element reference. This may
+ * easily return NULL! Not all output elements will be
* sourced from the XML, but may instead be a sole fabrication
* of the XSL sheet.
*/
1.6 +48 -49 xml-xalan/src/org/apache/xalan/xslt/UnImplNode.java
Index: UnImplNode.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/UnImplNode.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- UnImplNode.java 2000/01/13 19:45:27 1.5
+++ UnImplNode.java 2000/02/23 23:03:30 1.6
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,15 +18,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "XSLT4J" and "Apache Software Foundation" must
+ * 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -61,15 +61,14 @@
import org.apache.xalan.xpath.xml.XSLMessages;
/**
- * This class is meant to be subclassed by classes who
- * wish to fake being nodes.
+ * To be subclassed by classes that wish to fake being nodes.
*/
public class UnImplNode implements Element, NodeList
{
UnImplNode()
{
}
-
+
/**
* Throw an error.
*/
@@ -77,7 +76,7 @@
{
throw new RuntimeException(XSLMessages.createMessage(msg, null));
}
-
+
/**
* Throw an error.
*/
@@ -85,7 +84,7 @@
{
throw new RuntimeException(XSLMessages.createMessage(msg, args)); //"UnImplNode error: "+msg);
}
-
+
/** Unimplemented. */
public Node appendChild(Node newChild)
throws DOMException
@@ -93,104 +92,104 @@
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"appendChild not supported!");
return null;
}
-
+
/** Unimplemented. */
public boolean hasChildNodes()
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"hasChildNodes not supported!");
return false;
}
-
+
/** Unimplemented. */
public short getNodeType()
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getNodeType not supported!");
return 0;
}
-
+
/** Unimplemented. */
public Node getParentNode()
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getParentNode not supported!");
return null;
}
-
+
/** Unimplemented. */
public NodeList getChildNodes()
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getChildNodes not supported!");
return null;
}
-
+
/** Unimplemented. */
public Node getFirstChild()
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getFirstChild not supported!");
return null;
}
-
+
/** Unimplemented. */
public Node getLastChild()
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getLastChild not supported!");
return null;
}
-
+
/** Unimplemented. */
public Node getNextSibling()
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getNextSibling not supported!");
return null;
}
-
+
/** Unimplemented. */
- public int getLength()
+ public int getLength()
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getLength not supported!");
return 0;
} // getLength():int
-
+
/** Unimplemented. */
- public Node item(int index)
+ public Node item(int index)
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"item not supported!");
return null;
} // item(int):Node
-
+
/** Unimplemented. */
public Document getOwnerDocument()
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getOwnerDocument not supported!");
return null;
}
-
+
/** Unimplemented. */
public String getTagName()
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getTagName not supported!");
return null;
}
-
+
/** Unimplemented. */
public String getNodeName()
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getNodeName not supported!");
return null;
}
-
+
/** Unimplemented. */
public void normalize()
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"normalize not supported!");
}
-
+
/** Unimplemented. */
public NodeList getElementsByTagName(String name)
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getElementsByTagName not supported!");
return null;
}
-
+
/** Unimplemented. */
public Attr removeAttributeNode(Attr oldAttr)
throws DOMException
@@ -198,7 +197,7 @@
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"removeAttributeNode not supported!");
return null;
}
-
+
/** Unimplemented. */
public Attr setAttributeNode(Attr newAttr)
throws DOMException
@@ -206,28 +205,28 @@
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"setAttributeNode not supported!");
return null;
}
-
+
public Attr getAttributeNode(String name)
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getAttributeNode not supported!");
return null;
}
-
+
/** Unimplemented. */
public void removeAttribute(String name)
throws DOMException
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"removeAttribute not supported!");
}
-
+
/** Unimplemented. */
- public void setAttribute(String name,
+ public void setAttribute(String name,
String value)
throws DOMException
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"setAttribute not supported!");
}
-
+
/** Unimplemented. */
public String getAttribute(String name)
{
@@ -236,13 +235,13 @@
}
/** Unimplemented. */
- public NodeList getElementsByTagNameNS(String namespaceURI,
+ public NodeList getElementsByTagNameNS(String namespaceURI,
String localName)
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getElementsByTagNameNS not supported!");
return null;
}
-
+
/** Unimplemented. */
public Attr setAttributeNodeNS(Attr newAttr)
throws DOMException
@@ -252,7 +251,7 @@
}
/** Unimplemented. */
- public Attr getAttributeNodeNS(String namespaceURI,
+ public Attr getAttributeNodeNS(String namespaceURI,
String localName)
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getAttributeNodeNS not supported!");
@@ -260,7 +259,7 @@
}
/** Unimplemented. */
- public void removeAttributeNS(String namespaceURI,
+ public void removeAttributeNS(String namespaceURI,
String localName)
throws DOMException
{
@@ -268,8 +267,8 @@
}
/** Unimplemented. */
- public void setAttributeNS(String namespaceURI,
- String qualifiedName,
+ public void setAttributeNS(String namespaceURI,
+ String qualifiedName,
String value)
throws DOMException
{
@@ -277,7 +276,7 @@
}
/** Unimplemented. */
- public String getAttributeNS(String namespaceURI,
+ public String getAttributeNS(String namespaceURI,
String localName)
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getAttributeNS not supported!");
@@ -290,7 +289,7 @@
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getPreviousSibling not supported!");
return null;
}
-
+
/** Unimplemented. */
public Node cloneNode(boolean deep)
{
@@ -312,32 +311,32 @@
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"setNodeValue not supported!");
}
-
+
/** Unimplemented. */
public NamedNodeMap getAttributes()
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getAttributes not supported!");
return null;
}
-
+
/** Unimplemented. */
- public Node insertBefore(Node newChild,
+ public Node insertBefore(Node newChild,
Node refChild)
throws DOMException
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"insertBefore not supported!");
return null;
}
-
+
/** Unimplemented. */
- public Node replaceChild(Node newChild,
+ public Node replaceChild(Node newChild,
Node oldChild)
throws DOMException
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"replaceChild not supported!");
return null;
}
-
+
/** Unimplemented. */
public Node removeChild(Node oldChild)
throws DOMException
@@ -347,7 +346,7 @@
}
/** Unimplemented. */
- public boolean supports(String feature,
+ public boolean supports(String feature,
String version)
{
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"supports not supported!");
@@ -360,7 +359,7 @@
error(XSLTErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getNamespaceURI not supported!");
return null;
}
-
+
/** Unimplemented. */
public String getPrefix()
{
1.5 +77 -78 xml-xalan/src/org/apache/xalan/xslt/TemplateList.java
Index: TemplateList.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/TemplateList.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TemplateList.java 2000/02/21 08:14:28 1.4
+++ TemplateList.java 2000/02/23 23:03:30 1.5
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,15 +18,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "XSLT4J" and "Apache Software Foundation" must
+ * 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -66,8 +66,7 @@
import org.apache.xalan.xslt.res.XSLTErrorResources;
/**
- * This class segregates the template list, and performs template
- * finding services.
+ * Encapsulates a template list, and helps locate templates.
*/
public class TemplateList implements java.io.Serializable
{
@@ -78,12 +77,12 @@
{
m_stylesheet = stylesheet;
}
-
+
/**
* The stylesheet owner of the list.
*/
Stylesheet m_stylesheet;
-
+
/**
* The first template of the template children.
* @serial
@@ -107,38 +106,38 @@
}
/**
- * Keyed on string macro names, and holding values
+ * Keyed on string macro names, and holding values
* that are macro elements in the XSL DOM tree.
* Initialized in initMacroLookupTable, and used in
* findNamedTemplate.
* @serial
*/
Hashtable m_namedTemplates = new Hashtable();
-
+
/**
- * Tells if the stylesheet is without an xsl:stylesheet
+ * Tells if the stylesheet is without an xsl:stylesheet
* and xsl:template wrapper.
* @serial
*/
private boolean m_isWrapperless = false;
-
+
/**
* The manufactured template if there is no wrapper.
* @serial
*/
private ElemTemplate m_wrapperlessTemplate = null;
-
+
/**
- * This table is keyed on the target elements
+ * This table is keyed on the target elements
* of patterns, and contains linked lists of
* the actual patterns that match the target element
* to some degree of specifity.
* @serial
*/
private Hashtable m_patternTable = new Hashtable();
-
+
/**
- * Set if the stylesheet is without an xsl:stylesheet
+ * Set if the stylesheet is without an xsl:stylesheet
* and xsl:template wrapper.
*/
void setIsWrapperless(boolean b)
@@ -147,7 +146,7 @@
}
/**
- * Get if the stylesheet is without an xsl:stylesheet
+ * Get if the stylesheet is without an xsl:stylesheet
* and xsl:template wrapper.
*/
boolean getIsWrapperless()
@@ -175,7 +174,7 @@
/**
* Get table of named Templates.
- * These are keyed on string macro names, and holding values
+ * These are keyed on string macro names, and holding values
* that are template elements in the XSL DOM tree.
*/
public Hashtable getNamedTemplates()
@@ -185,30 +184,30 @@
/**
* Set table of named Templates.
- * These are keyed on string macro names, and holding values
+ * These are keyed on string macro names, and holding values
* that are template elements in the XSL DOM tree.
*/
public void setNamedTemplates(Hashtable v)
{
m_namedTemplates = v;
}
-
+
/**
- * Given a target element, find the template that best
- * matches in the given XSL document, according
- * to the rules specified in the xsl draft.
+ * Given a target element, find the template that best
+ * matches in the given XSL document, according
+ * to the rules specified in the xsl draft.
* @param stylesheetTree Where the XSL rules are to be found.
* @param sourceTree Where the targetElem is to be found.
* @param targetElem The element that needs a rule.
* @param mode A string indicating the display mode.
* @param useImports means that this is an xsl:apply-imports commend.
* @return Rule that best matches targetElem.
- * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
+ * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
public ElemTemplate findTemplate(XSLTEngineImpl transformContext,
- Node sourceTree,
- Node targetNode,
+ Node sourceTree,
+ Node targetNode,
QName mode,
boolean useImports)
throws SAXException
@@ -223,10 +222,10 @@
if(!useImports)
{
double highScore = XPath.MATCH_SCORE_NONE;
-
+
MatchPattern2 matchPat = null;
int targetNodeType = targetNode.getNodeType();
-
+
switch(targetNodeType)
{
case Node.ELEMENT_NODE:
@@ -234,7 +233,7 @@
String targetName = transformContext.m_parserLiaison.getLocalNameOfNode(targetNode);
matchPat = locateMatchPatternList2(targetName, true);
break;
-
+
case Node.PROCESSING_INSTRUCTION_NODE:
case Node.ATTRIBUTE_NODE:
matchPat = locateMatchPatternList2(targetNode.getNodeName(), true);
@@ -256,39 +255,39 @@
case Node.DOCUMENT_FRAGMENT_NODE:
matchPat = locateMatchPatternList2(XPath.PSEUDONAME_ANY, false);
break;
-
+
default:
{
matchPat = locateMatchPatternList2(targetNode.getNodeName(), false);
}
}
-
+
String prevPat = null;
MatchPattern2 prevMatchPat = null;
-
+
while(null != matchPat)
{
ElemTemplate rule = matchPat.getTemplate();
- // We'll be needing to match rules according to what
+ // We'll be needing to match rules according to what
// mode we're in.
QName ruleMode = rule.m_mode;
-
+
// The logic here should be that if we are not in a mode AND
// the rule does not have a node, then go ahead.
- // OR if we are in a mode, AND the rule has a node,
+ // OR if we are in a mode, AND the rule has a node,
// AND the rules match, then go ahead.
- if(((null == mode) && (null == ruleMode)) ||
+ if(((null == mode) && (null == ruleMode)) ||
((null != ruleMode) && (null != mode) && ruleMode.equals(mode)))
{
String patterns = matchPat.getPattern();
-
- if((null != patterns) && !((prevPat != null) && prevPat.equals(patterns) &&
- (prevMatchPat.getTemplate().m_priority
+
+ if((null != patterns) && !((prevPat != null) && prevPat.equals(patterns) &&
+ (prevMatchPat.getTemplate().m_priority
== matchPat.getTemplate().m_priority)) )
{
prevMatchPat = matchPat;
prevPat = patterns;
-
+
// Date date1 = new Date();
XPath xpath = matchPat.getExpression();
// System.out.println("Testing score for: "+targetNode.getNodeName()+
@@ -300,12 +299,12 @@
if(XPath.MATCH_SCORE_NONE != score)
{
- double priorityOfRule
- = (XPath.MATCH_SCORE_NONE != rule.m_priority)
+ double priorityOfRule
+ = (XPath.MATCH_SCORE_NONE != rule.m_priority)
? rule.m_priority : score;
matchPat.m_priority = priorityOfRule;
double priorityOfBestMatched = (null != bestMatchedPattern) ?
- bestMatchedPattern.m_priority :
+ bestMatchedPattern.m_priority :
XPath.MATCH_SCORE_NONE;
// System.out.println("priorityOfRule: "+priorityOfRule+", priorityOfBestMatched: "+priorityOfBestMatched);
if(priorityOfRule > priorityOfBestMatched)
@@ -329,14 +328,14 @@
}
// Date date2 = new Date();
// m_totalTimePatternMatching+=(date2.getTime() - date1.getTime());
- } // end if(null != patterns)
+ } // end if(null != patterns)
} // end if if(targetModeString.equals(mode))
-
+
MatchPattern2 nextMatchPat = matchPat.getNext();
// We also have to consider wildcard matches.
- if((null == nextMatchPat) && !matchPat.m_targetString.equals("*") &&
- ((Node.ELEMENT_NODE == targetNodeType) ||
+ if((null == nextMatchPat) && !matchPat.m_targetString.equals("*") &&
+ ((Node.ELEMENT_NODE == targetNodeType) ||
(Node.ATTRIBUTE_NODE == targetNodeType) ||
(Node.PROCESSING_INSTRUCTION_NODE == targetNodeType)))
{
@@ -345,14 +344,14 @@
matchPat = nextMatchPat;
}
} // end if(!useImports)
-
+
if(null == bestMatchedRule)
{
int nImports = m_stylesheet.m_imports.size();
for(int i = 0; i < nImports; i++)
{
Stylesheet stylesheet = (Stylesheet)m_stylesheet.m_imports.elementAt(i);
- bestMatchedRule = stylesheet.findTemplate(transformContext, sourceTree, targetNode, mode,
+ bestMatchedRule = stylesheet.findTemplate(transformContext, sourceTree, targetNode, mode,
false);
if(null != bestMatchedRule)
{
@@ -365,7 +364,7 @@
{
int nConflicts = conflicts.size();
// System.out.println("nConflicts: "+nConflicts);
- String conflictsString = (!transformContext.m_quietConflictWarnings)
+ String conflictsString = (!transformContext.m_quietConflictWarnings)
? "" : null;
for(int i = 0; i < nConflicts; i++)
{
@@ -374,7 +373,7 @@
{
if(!transformContext.m_quietConflictWarnings)
conflictsString += ", ";
-
+
// Find the furthest one towards the bottom of the document.
if(conflictPat.m_posInStylesheet > bestMatchedPattern.m_posInStylesheet)
{
@@ -399,7 +398,7 @@
return bestMatchedRule;
} // end findTemplate
-
+
/**
* Add object to vector if not already there.
*/
@@ -420,9 +419,9 @@
v.addElement(obj);
}
}
-
+
/**
- * Given an element type, locate the start of a linked list of
+ * Given an element type, locate the start of a linked list of
* possible template matches.
*/
private MatchPattern2 locateMatchPatternList2(String sourceElementType, boolean tryWildCard)
@@ -443,7 +442,7 @@
}
return startMatchList;
}
-
+
/**
* Add a template to the template list.
*/
@@ -473,22 +472,22 @@
{
m_namedTemplates.put(template.m_name, template);
}
-
+
if(null != template.m_matchPattern)
{
Vector strings = template.m_matchPattern.getTargetElementStrings();
if(null != strings)
{
int nTargets = strings.size();
- for(int stringIndex = 0; stringIndex < nTargets; stringIndex++)
+ for(int stringIndex = 0; stringIndex < nTargets; stringIndex++)
{
String target = (String)strings.elementAt(stringIndex);
-
- Object newMatchPat = new MatchPattern2(template.m_matchPattern.m_currentPattern,
- template.m_matchPattern,
- template, pos,
+
+ Object newMatchPat = new MatchPattern2(template.m_matchPattern.m_currentPattern,
+ template.m_matchPattern,
+ template, pos,
target, m_stylesheet);
-
+
// See if there's already one there
Object val = m_patternTable.get(target);
if(null == val)
@@ -516,23 +515,23 @@
}
}
}
-
+
/**
* Locate a macro via the "name" attribute.
- * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
+ * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
ElemTemplateElement findNamedTemplate(String name)
throws XSLProcessorException
{
QName qname = new QName(name, m_stylesheet.m_namespaces);
-
+
return findNamedTemplate(qname);
}
-
+
/**
* Locate a macro via the "name" attribute.
- * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
+ * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
ElemTemplateElement findNamedTemplate(QName qname)
@@ -565,10 +564,10 @@
{
namedTemplate = (ElemTemplateElement)obj;
}
-
+
return namedTemplate;
}
-
+
/**
* A class to contain a match pattern and it's corresponding template.
* This class also defines a node in a match pattern linked list.
@@ -579,10 +578,10 @@
* Construct a match pattern from a pattern and template.
* @param pat For now a Nodelist that contains old-style element patterns.
* @param template The node that contains the template for this pattern.
- * @param isMatchPatternsOnly tells if pat param contains only match
+ * @param isMatchPatternsOnly tells if pat param contains only match
* patterns (for compatibility with old syntax).
*/
- MatchPattern2(String pat, XPath exp, ElemTemplate template, int posInStylesheet,
+ MatchPattern2(String pat, XPath exp, ElemTemplate template, int posInStylesheet,
String targetString, Stylesheet stylesheet)
{
m_pattern = pat;
@@ -592,25 +591,25 @@
m_stylesheet = stylesheet;
m_expression = exp;
}
-
+
Stylesheet m_stylesheet;
String m_targetString;
-
+
XPath m_expression;
public XPath getExpression() { return m_expression; }
int m_posInStylesheet;
-
+
/**
- * Transient... only used to track priority while
+ * Transient... only used to track priority while
* processing.
*/
double m_priority = XPath.MATCH_SCORE_NONE;
-
+
private String m_pattern;
public String getPattern() { return m_pattern; }
-
+
private ElemTemplate m_template; // ref to the corrisponding template
public ElemTemplate getTemplate() { return m_template; }
1.28 +142 -142 xml-xalan/src/org/apache/xalan/xslt/StylesheetRoot.java
Index: StylesheetRoot.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/StylesheetRoot.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- StylesheetRoot.java 2000/02/21 20:44:50 1.27
+++ StylesheetRoot.java 2000/02/23 23:03:30 1.28
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "XSLT4J" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -68,30 +68,30 @@
import org.apache.xalan.xslt.res.XSLTErrorResources;
import org.apache.xalan.xpath.xml.XSLMessages;
import org.apache.xml.serialize.*;
-
+
/**
- * This acts as the stylesheet root of the stylesheet
- * tree, and holds values that are shared by all
- * stylesheets in the tree.
+ * Binary representation of a stylesheet -- use the {@link org.apache.xalan.xslt.XSLTProcessor} ProcessStylesheet
+ * method to create a StylesheetRoot and improve performance for a stylesheet performing multiple transformations.
+ * Also required for XSLTProcessor to function as SAX DocumentHandler.
*/
public class StylesheetRoot extends Stylesheet implements java.io.Serializable
{
-
+
/**
* The URL that belongs to the result namespace.
* @serial
*/
String m_resultNameSpaceURL = null;
-
+
/**
* List of listeners who are interested in tracing what's going on.
*/
transient Vector m_traceListeners = null;
-
+
static final String DEFAULT_ENCODING = "UTF-8";
-
+
String m_liaisonClassUsedToCreate = null;
-
+
/**
* Read the stylesheet root from a serialization stream.
*/
@@ -110,11 +110,11 @@
m_traceListeners = null;
// System.out.println("Done reading Stylesheet");
}
-
+
/**
* Add a trace listener for the purposes of debugging and diagnosis.
*/
- public void
+ public void
addTraceListener(TraceListener tl)
throws TooManyListenersException
{
@@ -126,7 +126,7 @@
/**
* Remove a trace listener.
*/
- public void
+ public void
removeTraceListener(TraceListener tl)
{
if(null != m_traceListeners)
@@ -134,7 +134,7 @@
m_traceListeners.removeElement(tl);
}
}
-
+
/**
* Fire a trace event.
*/
@@ -150,7 +150,7 @@
}
}
}
-
+
/**
* Fire a trace event.
*/
@@ -170,34 +170,34 @@
/**
* Constructor for a Stylesheet needs a Document.
- * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
+ * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
- public StylesheetRoot(XSLTEngineImpl processor,
+ public StylesheetRoot(XSLTEngineImpl processor,
String baseIdentifier)
- throws XSLProcessorException,
- MalformedURLException,
+ throws XSLProcessorException,
+ MalformedURLException,
FileNotFoundException,
IOException,
SAXException
{
super(null, processor, baseIdentifier);
}
-
+
/**
* Do common initialization.
*/
protected void init(XSLTEngineImpl processor)
- throws XSLProcessorException,
- MalformedURLException,
+ throws XSLProcessorException,
+ MalformedURLException,
FileNotFoundException,
IOException,
SAXException
{
m_liaisonClassUsedToCreate = ((Object)processor.getXMLProcessorLiaison()).getClass().getName();
m_importStack = new Stack();
- // For some reason, the imports aren't working right if I
- // don't set the baseIdent to full url. I think this is OK,
+ // For some reason, the imports aren't working right if I
+ // don't set the baseIdent to full url. I think this is OK,
// and probably safer and faster in general.
// System.out.println("this.m_baseIdent: "+this.m_baseIdent);
if(null == this.m_baseIdent)
@@ -207,9 +207,9 @@
m_importStack.push(processor.getURLFromString(this.m_baseIdent, null));
m_stylesheetRoot = this;
super.init(processor);
- // initDefaultRule();
+ // initDefaultRule();
}
-
+
/**
* Get a new OutputFormat object according to the attributes of xsl:output.
*/
@@ -226,11 +226,11 @@
// This is to get around differences between Xalan and Xerces.
// Xalan uses -1 as default for no indenting, Xerces uses 0.
// So we just bump up the indent value here because we will
- // subtract from it at output time (FormatterToXML.init());
+ // subtract from it at output time (FormatterToXML.init());
if (getOutputIndent())
formatter.setIndent(formatter.getIndent()+1);
-
- // Don't pass the cdata elements to the formatter, 'cause we
+
+ // Don't pass the cdata elements to the formatter, 'cause we
// handle it ourselves.
/*
QName[] qnames = this.getCDataSectionElems();
@@ -242,62 +242,62 @@
*/
return formatter;
}
-
+
/**
- * Transform the source tree to the output in the given
+ * Transform the source tree to the output in the given
* result tree target.
* @param inputSource The input source tree.
* @param outputTarget The output source tree.
- * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
+ * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
- public void process( XSLTInputSource xmlSource,
+ public void process( XSLTInputSource xmlSource,
XSLTResultTarget outputTarget)
- throws SAXException,
- MalformedURLException,
+ throws SAXException,
+ MalformedURLException,
FileNotFoundException,
IOException
{
XSLTProcessor iprocessor =
- (null != m_liaisonClassUsedToCreate) ?
+ (null != m_liaisonClassUsedToCreate) ?
new XSLTProcessorFactory().getProcessorUsingLiaisonName(m_liaisonClassUsedToCreate)
: new XSLTProcessorFactory().getProcessor();
process(iprocessor, iprocessor.getSourceTreeFromInput(xmlSource), outputTarget);
// System.out.println("Number counters made: "+
// ((XSLTEngineImpl)iprocessor).getCountersTable().m_countersMade);
}
-
+
/**
- * Transform the source tree to the output in the given
+ * Transform the source tree to the output in the given
* result tree target.
* @param iprocessor The processor that will track the running state.
* @param inputSource The input source tree.
* @param outputTarget The output source tree.
- * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
+ * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
- public void process( XSLTProcessor iprocessor, XSLTInputSource xmlSource,
+ public void process( XSLTProcessor iprocessor, XSLTInputSource xmlSource,
XSLTResultTarget outputTarget)
- throws SAXException,
- MalformedURLException,
+ throws SAXException,
+ MalformedURLException,
FileNotFoundException,
IOException
{
process(iprocessor, iprocessor.getSourceTreeFromInput(xmlSource), outputTarget);
}
-
+
/**
- * Transform the source tree to the output in the given
+ * Transform the source tree to the output in the given
* result tree target.
* @param inputSource The input source tree.
* @param outputTarget The output source tree.
- * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
+ * @exception XSLProcessorException thrown if the active ProblemListener and XMLParserLiaison decide
* the error condition is severe enough to halt processing.
*/
- public void process( XSLTProcessor iprocessor, Node sourceTree,
+ public void process( XSLTProcessor iprocessor, Node sourceTree,
XSLTResultTarget outputTarget)
- throws SAXException,
- MalformedURLException,
+ throws SAXException,
+ MalformedURLException,
FileNotFoundException,
IOException
{
@@ -305,24 +305,24 @@
synchronized(processor)
{
processor.m_stylesheetRoot = this;
-
+
OutputStream ostream = null;
-
+
try
{
// Double-check the node to make sure it matches the processor liaison.
processor.getXMLProcessorLiaison().checkNode(sourceTree);
-
- // Needs work: We have to put the extension namespaces
- // into the liaison's table. We wouldn't have to do this
- // if the stylesheet handled it's own extensions, which
+
+ // Needs work: We have to put the extension namespaces
+ // into the liaison's table. We wouldn't have to do this
+ // if the stylesheet handled it's own extensions, which
// I'll fix on a later date.
Enumeration keys = m_extensionNamespaces.keys();
while(keys.hasMoreElements())
{
Object key = keys.nextElement();
// System.out.println("Putting ext namespace: "+key);
- processor.getExecContext().addExtensionNamespace ((String)key,
+ processor.getExecContext().addExtensionNamespace ((String)key,
(ExtensionFunctionHandler)m_extensionNamespaces.get(key));
}
@@ -333,14 +333,14 @@
{
rootRule = m_defaultRootRule;
}
-
+
DocumentHandler docHandler = outputTarget.getDocumentHandler();
-
+
OutputFormat formatter = getOutputFormat();
-
+
if(null != outputTarget.getEncoding())
formatter.setEncoding(outputTarget.getEncoding());
-
+
if(null != docHandler)
{
processor.m_flistener = docHandler;
@@ -354,14 +354,14 @@
// So we just bump up the indent value here because we will
// subtract from it at output time (FormatterToXML.init());
formatter.setIndent(processor.m_parserLiaison.getIndent() + 1);
- }
+ }
processor.m_flistener = makeSAXSerializer(outputTarget.getByteStream(),
formatter);
}
else if(null != outputTarget.getCharacterStream())
{
if (!(processor.m_parserLiaison.getIndent() < 0))
- {
+ {
formatter.setIndent(processor.m_parserLiaison.getIndent() + 1);
}
processor.m_flistener = makeSAXSerializer(outputTarget.getCharacterStream(),
@@ -370,7 +370,7 @@
else if(null != outputTarget.getFileName())
{
if (!(processor.m_parserLiaison.getIndent() < 0))
- {
+ {
formatter.setIndent(processor.m_parserLiaison.getIndent() + 1);
}
ostream = new FileOutputStream(outputTarget.getFileName());
@@ -386,11 +386,11 @@
processor.m_flistener = new FormatterToDOM((Document)outputTarget.getNode());
break;
case Node.DOCUMENT_FRAGMENT_NODE:
- processor.m_flistener = new FormatterToDOM(processor.m_parserLiaison.createDocument(),
+ processor.m_flistener = new FormatterToDOM(processor.m_parserLiaison.createDocument(),
(DocumentFragment)outputTarget.getNode());
break;
case Node.ELEMENT_NODE:
- processor.m_flistener = new FormatterToDOM(processor.m_parserLiaison.createDocument(),
+ processor.m_flistener = new FormatterToDOM(processor.m_parserLiaison.createDocument(),
(Element)outputTarget.getNode());
break;
default:
@@ -402,17 +402,17 @@
outputTarget.setNode(processor.m_parserLiaison.createDocument());
processor.m_flistener = new FormatterToDOM((Document)outputTarget.getNode());
}
-
+
processor.resetCurrentState(sourceTree);
processor.m_rootDoc = sourceTree;
-
+
if(null != processor.m_diagnosticsPrintWriter)
{
processor.diag("=============================");
processor.diag("Transforming...");
processor.pushTime(sourceTree);
}
-
+
processor.getVarStack().pushContextMarker();
try
{
@@ -422,26 +422,26 @@
{
throw new SAXException(XSLMessages.createMessage(XSLTErrorResources.ER_PROCESS_ERROR, null), e); //"StylesheetRoot.process error", e);
}
-
+
processor.m_resultTreeHandler.startDocument();
// Output the action of the found root rule. All processing
// occurs from here. buildResultFromTemplate is highly recursive.
rootRule.execute(processor, sourceTree, sourceTree, null);
-
+
processor.m_resultTreeHandler.endDocument();
-
+
// Reset the top-level params for the next round.
processor.m_topLevelParams = new Vector();
-
+
if(null != processor.m_diagnosticsPrintWriter)
{
processor.displayDuration("transform", sourceTree);
- }
+ }
}
finally
{
- if (null != ostream)
+ if (null != ostream)
{
ostream.close();
}
@@ -449,15 +449,15 @@
}
}
-
+
/**
- * If this is set to true, the Xerces serializers will
- * be used, otherwise the Xalan serializers will be
- * used. This is meant as a stop-gap until the Xerces
+ * If this is set to true, the Xerces serializers will
+ * be used, otherwise the Xalan serializers will be
+ * used. This is meant as a stop-gap until the Xerces
* serializers come up to speed.
*/
public boolean m_useXercesSerializers = false;
-
+
/**
* Creates a compatible SAX serializer for the specified writer
* and output format. If the output format is missing, the default
@@ -475,7 +475,7 @@
handler = new XMLSerializer(writer, format);
//handler = Serializer.makeSAXSerializer(writer, format);
}
- else if ( format == null )
+ else if ( format == null )
{
format = new OutputFormat( "xml", "UTF-8", false );
FormatterToXML serializer = new FormatterToXML();
@@ -508,10 +508,10 @@
handler = new XMLSerializer(writer, format);
//handler = Serializer.makeSAXSerializer(writer, format);
}
-
+
return handler;
}
-
+
/**
* Creates a compatible SAX serializer for the specified output stream
* and output format. If the output format is missing, the default
@@ -525,7 +525,7 @@
{
return makeSAXSerializer(ostream, getOutputFormat());
}
-
+
/**
* Creates a compatible SAX serializer for the specified output stream
* and output format. If the output format is missing, the default
@@ -544,7 +544,7 @@
handler = new XMLSerializer(ostream, format);
//handler = Serializer.makeSAXSerializer(ostream, format);
}
- else if ( format == null )
+ else if ( format == null )
{
format = new OutputFormat( "xml", "UTF-8", false );
FormatterToXML serializer = new FormatterToXML();
@@ -572,7 +572,7 @@
{
encoding = System.getProperty("file.encoding");
encoding = (null != encoding) ?
- FormatterToXML.convertJava2MimeEncoding( encoding ) : "ASCII";
+ FormatterToXML.convertJava2MimeEncoding( encoding ) : "ASCII";
if(null == encoding)
{
encoding = "ASCII";
@@ -583,11 +583,11 @@
encoding = "ASCII";
}
}
-
+
this.m_encoding = encoding;
-
+
String javaEncoding = FormatterToXML.convertMime2JavaEncoding(encoding);
-
+
Writer w = new OutputStreamWriter( ostream, javaEncoding );
handler = new FormatterToText(w);
}
@@ -601,31 +601,31 @@
handler = new XMLSerializer(ostream, format);
//handler = Serializer.makeSAXSerializer(ostream, format);
}
-
+
return handler;
}
+
-
/**
* The output method as specified in xsl:output.
*/
String m_outputmethod = null;
- /**
- * Return the output method that was specified in the stylesheet.
+ /**
+ * Return the output method that was specified in the stylesheet.
* The returned value is one of Formatter.OUTPUT_METH_XML,
* Formatter.OUTPUT_METH_HTML, or Formatter.OUTPUT_METH_TEXT.
*/
public String getOutputMethod() { return (null == m_outputmethod) ? "xml" : m_outputmethod; }
- /**
- * Return the output method that was specified in the stylesheet.
+ /**
+ * Return the output method that was specified in the stylesheet.
* The returned value is one of Formatter.OUTPUT_METH_XML,
* Formatter.OUTPUT_METH_HTML, or Formatter.OUTPUT_METH_TEXT.
*/
public boolean isOutputMethodSet() { return (null != m_outputmethod); }
-
+
/**
* Set the output method.
*/
@@ -654,19 +654,19 @@
public boolean getOutputIndent() { return m_indentResult; }
/**
- * The encoding attribute specifies the preferred encoding to use
- * for outputting the result tree.
+ * The encoding attribute specifies the preferred encoding to use
+ * for outputting the result tree.
*/
String m_encoding = null;
/** Get the encoding string that was specified in the stylesheet. */
- public String getOutputEncoding()
- {
- return m_encoding;
+ public String getOutputEncoding()
+ {
+ return m_encoding;
}
-
+
/**
- * The media-type attribute is applicable for the xml output method.
+ * The media-type attribute is applicable for the xml output method.
* The default value for the media-type attribute is text/xml.
*/
String m_mediatype = null;
@@ -675,9 +675,9 @@
public String getOutputMediaType() { return m_mediatype; }
/**
- * If the doctype-system-id attribute is specified, the xml output method should
- * output a document type declaration immediately before the first element.
- * The name following <!DOCTYPE should be the name of the first element.
+ * If the doctype-system-id attribute is specified, the xml output method should
+ * output a document type declaration immediately before the first element.
+ * The name following <!DOCTYPE should be the name of the first element.
*/
String m_doctypeSystem = null;
@@ -685,15 +685,15 @@
public String getOutputDoctypeSystem() { return m_doctypeSystem; }
/**
- * If doctype-public-id attribute is also specified, then the xml output
- * method should output PUBLIC followed by the public identifier and then
- * the system identifier; otherwise, it should output SYSTEM followed by
- * the system identifier. The internal subset should be empty. The
- * doctype-public-id attribute should be ignored unless the doctype-system-id
+ * If doctype-public-id attribute is also specified, then the xml output
+ * method should output PUBLIC followed by the public identifier and then
+ * the system identifier; otherwise, it should output SYSTEM followed by
+ * the system identifier. The internal subset should be empty. The
+ * doctype-public-id attribute should be ignored unless the doctype-system-id
* attribute is specified.
*/
String m_doctypePublic = null;
-
+
/** Get the doctype-public-id string that was specified in the stylesheet. */
public String getOutputDoctypePublic() { return m_doctypePublic; }
@@ -701,10 +701,10 @@
* Tells whether or not to output an XML declaration.
*/
boolean m_omitxmlDecl = false;
-
+
/** Get the XML Declaration that was specified in the stylesheet. */
public boolean getOmitOutputXMLDecl() { return m_omitxmlDecl; }
-
+
/**
* Tells what the xmldecl should specify for the standalone value.
*/
@@ -714,20 +714,20 @@
public boolean getOutputStandalone() { return m_standalone; }
/**
- * List of qnames that specifies elements that should be formatted
+ * List of qnames that specifies elements that should be formatted
* as CDATA.
*/
QName[] m_cdataSectionElems = null;
-
+
/**
- * Get list of qnames that specifies elements that should be formatted
+ * Get list of qnames that specifies elements that should be formatted
* as CDATA.
*/
- public QName[] getCDataSectionElems()
+ public QName[] getCDataSectionElems()
{
return m_cdataSectionElems;
}
-
+
/**
* Process the xsl:output element.
*/
@@ -807,11 +807,11 @@
}
else
{
- // If the attribute is test, or foo:test and foo is not a
+ // If the attribute is test, or foo:test and foo is not a
// known namespace prefix, the attribute is invalid.
// if foo is a known prefix, then the attribute is valid.
boolean attrOK = true;
- try{
+ try{
if(isAttrOK(aname, atts, i))
{
// If a namespace other than xsl was specified, make sure it is defined.
@@ -824,7 +824,7 @@
}
else
attrOK = false;
- }
+ }
}
catch(Exception e)
{
@@ -833,7 +833,7 @@
}
if (!attrOK)
throw new SAXException(XSLMessages.createMessage(XSLTErrorResources.ER_ILLEGAL_ATTRIBUTE, new Object[] {name, aname}));
- }
+ }
}
if((null != m_outputmethod) && (m_outputmethod.equals("html")) &&
(false == didSpecifyIndent))
@@ -841,7 +841,7 @@
m_indentResult = true;
}
}
-
+
/**
* Tell if this is the root of the stylesheet tree.
*/
@@ -849,19 +849,19 @@
{
return true;
}
-
+
/**
- * A stack of who's importing who is needed in order to support
- * "It is an error if a stylesheet directly or indirectly imports
- * itself. Apart from this, the case where a stylesheet with a
- * particular URI is imported in multiple places is not treated
+ * A stack of who's importing who is needed in order to support
+ * "It is an error if a stylesheet directly or indirectly imports
+ * itself. Apart from this, the case where a stylesheet with a
+ * particular URI is imported in multiple places is not treated
* specially."
*/
transient Stack m_importStack;
-
+
/**
- * The default template to use for text nodes if we don't find
+ * The default template to use for text nodes if we don't find
* anything else. This is initialized in initDefaultRule().
* @serial
*/
@@ -875,9 +875,9 @@
public ElemTemplate m_defaultRule;
/**
- * The default template to use for the root if we don't find
+ * The default template to use for the root if we don't find
* anything else. This is initialized in initDefaultRule().
- * We kind of need this because the defaultRule isn't good
+ * We kind of need this because the defaultRule isn't good
* enough because it doesn't supply a document context.
* For now, I default the root document element to "HTML".
* Don't know if this is really a good idea or not.
@@ -898,18 +898,18 @@
MutableAttrListImpl attrs = new MutableAttrListImpl();
attrs.addAttribute(Constants.ATTRNAME_MATCH, "CDATA", "*");
m_defaultRule = new ElemTemplate(null, this,
- "xsl:"+Constants.ELEMNAME_TEMPLATE_STRING,
+ "xsl:"+Constants.ELEMNAME_TEMPLATE_STRING,
attrs, lineNumber, columnNumber);
attrs.clear();
- ElemApplyTemplates childrenElement
+ ElemApplyTemplates childrenElement
= new ElemApplyTemplates(null, this,
"xsl:"+Constants.ELEMNAME_APPLY_TEMPLATES_STRING,
attrs, lineNumber, columnNumber);
childrenElement.m_isDefaultTemplate = true;
m_defaultRule.appendChild(childrenElement);
-
+
// -----------------------------
-
+
attrs.clear();
attrs.addAttribute(Constants.ATTRNAME_MATCH, "CDATA", "text() | @*");
m_defaultTextRule = new ElemTemplate(null, this,
@@ -917,14 +917,14 @@
attrs, lineNumber, columnNumber);
attrs.clear();
attrs.addAttribute(Constants.ATTRNAME_SELECT, "CDATA", ".");
- ElemValueOf elemValueOf
+ ElemValueOf elemValueOf
= new ElemValueOf(null, this,
"xsl:"+Constants.ELEMNAME_VALUEOF_STRING,
attrs, lineNumber, columnNumber);
m_defaultTextRule.appendChild(elemValueOf);
-
+
//--------------------------------
-
+
attrs.clear();
attrs.addAttribute(Constants.ATTRNAME_MATCH, "CDATA", "/");
m_defaultRootRule = new ElemTemplate(null, this,
@@ -932,7 +932,7 @@
attrs, lineNumber, columnNumber);
attrs.clear();
- childrenElement
+ childrenElement
= new ElemApplyTemplates(null, this,
"xsl:"+Constants.ELEMNAME_APPLY_TEMPLATES_STRING,
attrs, lineNumber, columnNumber);