| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.style; |
| 9 |
|
| 10 |
import net.sf.saxon.expr.Expression; |
| 11 |
import net.sf.saxon.expr.instruct.WithParam; |
| 12 |
import net.sf.saxon.om.AxisInfo; |
| 13 |
import net.sf.saxon.om.Item; |
| 14 |
import net.sf.saxon.trans.XPathException; |
| 15 |
import net.sf.saxon.tree.iter.AxisIterator; |
| 16 |
import net.sf.saxon.value.SequenceType; |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
public class XSLWithParam extends XSLGeneralVariable { |
| 24 |
|
| 25 |
private int allowedAttributes = |
| 26 |
SourceBinding.SELECT | SourceBinding.AS | SourceBinding.TUNNEL; |
| 27 |
|
| 28 |
@Override |
| 29 |
protected void prepareAttributes() throws XPathException { |
| 30 |
sourceBinding.prepareAttributes(allowedAttributes); |
| 31 |
} |
| 32 |
|
| 33 |
public boolean isTunnelParam() { |
| 34 |
return sourceBinding.hasProperty(SourceBinding.TUNNEL); |
| 35 |
} |
| 36 |
|
| 37 |
public void validate(ComponentDeclaration decl) throws XPathException { |
| 38 |
super.validate(decl); |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
AxisIterator iter = iterateAxis(AxisInfo.PRECEDING_SIBLING); |
| 43 |
Item prev; |
| 44 |
while ((prev = iter.next()) != null) { |
| 45 |
if (prev instanceof XSLWithParam) { |
| 46 |
if (sourceBinding.getVariableQName().equals(((XSLWithParam) prev).sourceBinding.getVariableQName())) { |
| 47 |
compileError("Duplicate parameter name", "XTSE0670"); |
| 48 |
} |
| 49 |
} |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
public void checkAgainstRequiredType(SequenceType required) throws XPathException { |
| 54 |
sourceBinding.checkAgainstRequiredType(required); |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
public WithParam compileWithParam(Expression parent, Compilation exec, ComponentDeclaration decl) throws XPathException { |
| 59 |
|
| 60 |
sourceBinding.handleSequenceConstructor(exec, decl); |
| 61 |
|
| 62 |
WithParam inst = new WithParam(); |
| 63 |
inst.setSelectExpression(parent, sourceBinding.getSelectExpression()); |
| 64 |
inst.setVariableQName(sourceBinding.getVariableQName()); |
| 65 |
inst.setRequiredType(sourceBinding.getInferredType(true)); |
| 66 |
return inst; |
| 67 |
} |
| 68 |
|
| 69 |
} |
| 70 |
|