robweir 00/02/11 07:42:39
Modified: src/org/apache/xalan/xslt ElemApplyImport.java
ElemApplyTemplates.java ElemForEach.java
XSLTEngineImpl.java
Log:
A more accurate version of the previous fix. We now keeep track
of whether the current rule is null in a bool stack and reset it in
xsl:for-each (where it is null) and again in apply-templates (where it
becomes non-null). We then test to see if it is null in apply-imports
and issue an error if it is.
Revision Changes Path
1.4 +1 -1 xml-xalan/src/org/apache/xalan/xslt/ElemApplyImport.java
Index: ElemApplyImport.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/ElemApplyImport.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ElemApplyImport.java 2000/02/10 20:45:42 1.3
+++ ElemApplyImport.java 2000/02/11 15:42:39 1.4
@@ -106,7 +106,7 @@
java.io.IOException,
SAXException
{
- if (processor.m_inForEach >0)
+ if (!processor.m_currentTemplateRuleIsNull.isEmpty() &&
processor.m_currentTemplateRuleIsNull.peek() == true)
{
processor.error(XSLTErrorResources.ER_NO_APPLY_IMPORT_IN_FOR_EACH);
//"xsl:apply-imports not allowed in a xsl:for-each");
}
1.4 +46 -34
xml-xalan/src/org/apache/xalan/xslt/ElemApplyTemplates.java
Index: ElemApplyTemplates.java
===================================================================
RCS file:
/home/cvs/xml-xalan/src/org/apache/xalan/xslt/ElemApplyTemplates.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ElemApplyTemplates.java 2000/01/05 23:05:30 1.3
+++ ElemApplyTemplates.java 2000/02/11 15:42:39 1.4
@@ -128,40 +128,52 @@
java.io.IOException,
SAXException
{
- if(null != m_stylesheet.m_stylesheetRoot.m_traceListeners)
- {
- m_stylesheet.m_stylesheetRoot.fireTraceEvent(new
TracerEvent(processor,
-
sourceTree,
-
sourceNode,
- mode,
- this));
- }
- if(null != sourceNode)
- {
- boolean needToTurnOffInfiniteLoopCheck = false;
-
- if(!m_isDefaultTemplate)
- {
- mode = m_mode;
- }
- transformSelectedChildren(m_stylesheet,
- this,
- null,
- sourceTree,
- sourceNode, mode,
- m_selectPattern,
- Constants.ELEMNAME_APPLY_TEMPLATES,
- processor);
-
- if(true == needToTurnOffInfiniteLoopCheck)
- {
- processor.m_needToCheckForInfiniteLoops = false;
- }
- }
- else // if(null == sourceNode)
- {
-
processor.error(XSLTErrorResources.ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES);//"sourceNode
is null in handleApplyTemplatesInstruction!");
- }
+ processor.m_currentTemplateRuleIsNull.push(false);
+
+ try
+ {
+
+ if(null != m_stylesheet.m_stylesheetRoot.m_traceListeners)
+ {
+ m_stylesheet.m_stylesheetRoot.fireTraceEvent(new
TracerEvent(processor,
+
sourceTree,
+
sourceNode,
+ mode,
+
this));
+ }
+ if(null != sourceNode)
+ {
+ boolean needToTurnOffInfiniteLoopCheck = false;
+
+ if(!m_isDefaultTemplate)
+ {
+ mode = m_mode;
+ }
+ transformSelectedChildren(m_stylesheet,
+ this,
+ null,
+ sourceTree,
+ sourceNode, mode,
+ m_selectPattern,
+ Constants.ELEMNAME_APPLY_TEMPLATES,
+ processor);
+
+ if(true == needToTurnOffInfiniteLoopCheck)
+ {
+ processor.m_needToCheckForInfiniteLoops = false;
+ }
+ }
+ else // if(null == sourceNode)
+ {
+
processor.error(XSLTErrorResources.ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES);//"sourceNode
is null in handleApplyTemplatesInstruction!");
+ }
+ }
+
+ finally
+ {
+ processor.m_currentTemplateRuleIsNull.pop();
+ }
+
}
/**
1.4 +2 -2 xml-xalan/src/org/apache/xalan/xslt/ElemForEach.java
Index: ElemForEach.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/ElemForEach.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ElemForEach.java 2000/02/10 20:45:42 1.3
+++ ElemForEach.java 2000/02/11 15:42:39 1.4
@@ -113,7 +113,7 @@
java.io.IOException,
SAXException
{
- processor.m_inForEach++;
+ processor.m_currentTemplateRuleIsNull.push(true);
try
{
@@ -138,7 +138,7 @@
finally
{
- processor.m_inForEach--;
+ processor.m_currentTemplateRuleIsNull.pop();
}
}
}
1.35 +1 -1 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.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- XSLTEngineImpl.java 2000/02/10 20:45:42 1.34
+++ XSLTEngineImpl.java 2000/02/11 15:42:39 1.35
@@ -370,7 +370,7 @@
/**
* Is >0 when we're processing a for-each
*/
- int m_inForEach = 0;
+ BoolStack m_currentTemplateRuleIsNull = new BoolStack();
/**
* Get the table of counters, for optimized xsl:number support.