| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.style; |
| 9 |
|
| 10 |
import net.sf.saxon.expr.instruct.BreakInstr; |
| 11 |
import net.sf.saxon.expr.Expression; |
| 12 |
import net.sf.saxon.expr.instruct.Block; |
| 13 |
import net.sf.saxon.om.AttributeCollection; |
| 14 |
import net.sf.saxon.om.AxisInfo; |
| 15 |
import net.sf.saxon.trans.XPathException; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
public class XSLBreak extends XSLBreakOrContinue { |
| 22 |
|
| 23 |
private Expression select; |
| 24 |
|
| 25 |
public void prepareAttributes() throws XPathException { |
| 26 |
|
| 27 |
String selectAtt = null; |
| 28 |
|
| 29 |
AttributeCollection atts = getAttributeList(); |
| 30 |
|
| 31 |
for (int a = 0; a < atts.getLength(); a++) { |
| 32 |
String f = atts.getQName(a); |
| 33 |
if (f.equals("select")) { |
| 34 |
selectAtt = atts.getValue(a); |
| 35 |
select = makeExpression(selectAtt, a); |
| 36 |
} else { |
| 37 |
checkUnknownAttribute(atts.getNodeName(a)); |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
protected boolean mayContainSequenceConstructor() { |
| 50 |
return true; |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
public void validate(ComponentDeclaration decl) throws XPathException { |
| 63 |
validatePosition(); |
| 64 |
if (xslIterate == null) { |
| 65 |
compileError(getDisplayName() + " must be a descendant of an xsl:iterate instruction", "XTSE3120"); |
| 66 |
} |
| 67 |
if (select != null && iterateAxis(AxisInfo.CHILD).next() != null) { |
| 68 |
compileError("An xsl:break element with a select attribute must be empty", "XTSE3125"); |
| 69 |
} |
| 70 |
select = typeCheck("select", select); |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
public Expression compile(Compilation exec, ComponentDeclaration decl) throws XPathException { |
| 75 |
|
| 76 |
|
| 77 |
Expression val = select; |
| 78 |
if (val == null) { |
| 79 |
val = compileSequenceConstructor(exec, decl, false); |
| 80 |
} |
| 81 |
|
| 82 |
Expression brake = new BreakInstr(); |
| 83 |
brake.setRetainedStaticContext(makeRetainedStaticContext()); |
| 84 |
return Block.makeBlock(val, brake); |
| 85 |
} |
| 86 |
|
| 87 |
} |