| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.style; |
| 9 |
|
| 10 |
import net.sf.saxon.om.AttributeCollection; |
| 11 |
import net.sf.saxon.om.AxisInfo; |
| 12 |
import net.sf.saxon.om.NodeInfo; |
| 13 |
import net.sf.saxon.trans.XPathException; |
| 14 |
import net.sf.saxon.tree.iter.AxisIterator; |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
public abstract class XSLBreakOrContinue extends StyleElement { |
| 20 |
|
| 21 |
protected XSLIterate xslIterate = null; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
public boolean isInstruction() { |
| 30 |
return true; |
| 31 |
} |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
public void prepareAttributes() throws XPathException { |
| 40 |
AttributeCollection atts = getAttributeList(); |
| 41 |
for (int a = 0; a < atts.getLength(); a++) { |
| 42 |
checkUnknownAttribute(atts.getNodeName(a)); |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
protected void validatePosition() throws XPathException { |
| 54 |
NodeInfo inst = this; |
| 55 |
boolean isLast = true; |
| 56 |
while (true) { |
| 57 |
if (!(inst instanceof XSLWhen)) { |
| 58 |
AxisIterator sibs = inst.iterateAxis(AxisInfo.FOLLOWING_SIBLING); |
| 59 |
while (true) { |
| 60 |
NodeInfo sib = sibs.next(); |
| 61 |
if (sib == null) { |
| 62 |
break; |
| 63 |
} |
| 64 |
if (sib instanceof XSLFallback || sib instanceof XSLCatch) { |
| 65 |
continue; |
| 66 |
} |
| 67 |
isLast = false; |
| 68 |
} |
| 69 |
} |
| 70 |
inst = inst.getParent(); |
| 71 |
if (inst instanceof XSLIterate) { |
| 72 |
xslIterate = (XSLIterate) inst; |
| 73 |
break; |
| 74 |
} else if (inst instanceof XSLTry || inst instanceof XSLCatch) { |
| 75 |
|
| 76 |
} else if (inst instanceof XSLWhen || inst instanceof XSLOtherwise |
| 77 |
|| inst instanceof XSLIf || inst instanceof XSLChoose) { |
| 78 |
|
| 79 |
} else if (inst == null) { |
| 80 |
compileError(getDisplayName() + " is not allowed at outermost level", "XTSE3120"); |
| 81 |
return; |
| 82 |
} else { |
| 83 |
compileError(getDisplayName() + " is not allowed within " + inst.getDisplayName(), "XTSE3120"); |
| 84 |
return; |
| 85 |
} |
| 86 |
} |
| 87 |
if (!isLast) { |
| 88 |
compileError(getDisplayName() + " must be the last instruction in the xsl:iterate loop", "XTSE3120"); |
| 89 |
} |
| 90 |
} |
| 91 |
} |