| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.style; |
| 9 |
|
| 10 |
import net.sf.saxon.expr.Component; |
| 11 |
import net.sf.saxon.expr.Expression; |
| 12 |
import net.sf.saxon.expr.instruct.GlobalParam; |
| 13 |
import net.sf.saxon.expr.parser.Optimizer; |
| 14 |
import net.sf.saxon.trans.Visibility; |
| 15 |
import net.sf.saxon.trans.XPathException; |
| 16 |
import net.sf.saxon.value.SequenceType; |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
public class XSLGlobalParam extends XSLGlobalVariable { |
| 25 |
|
| 26 |
protected int getPermittedAttributes() { |
| 27 |
return |
| 28 |
SourceBinding.REQUIRED | |
| 29 |
SourceBinding.SELECT | |
| 30 |
SourceBinding.AS | |
| 31 |
SourceBinding.STATIC; |
| 32 |
} |
| 33 |
|
| 34 |
Expression conversion = null; |
| 35 |
|
| 36 |
public XSLGlobalParam() { |
| 37 |
sourceBinding.setProperty(SourceBinding.PARAM, true); |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
public Visibility getVisibility() { |
| 46 |
return Visibility.PUBLIC; |
| 47 |
} |
| 48 |
|
| 49 |
public void validate(ComponentDeclaration decl) throws XPathException { |
| 50 |
|
| 51 |
if (sourceBinding.hasProperty(SourceBinding.REQUIRED)) { |
| 52 |
if (sourceBinding.getSelectExpression() != null) { |
| 53 |
|
| 54 |
compileError("The select attribute must be absent when required='yes'", "XTSE0010"); |
| 55 |
} |
| 56 |
if (hasChildNodes()) { |
| 57 |
compileError("A parameter specifying required='yes' must have empty content", "XTSE0010"); |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
super.validate(decl); |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
public void compileDeclaration(Compilation compilation, ComponentDeclaration decl) throws XPathException { |
| 71 |
if (sourceBinding.isStatic()) { |
| 72 |
super.compileDeclaration(compilation, decl); |
| 73 |
|
| 74 |
} else if (!redundant) { |
| 75 |
sourceBinding.handleSequenceConstructor(compilation, decl); |
| 76 |
|
| 77 |
GlobalParam binding = (GlobalParam)compiledVariable; |
| 78 |
binding.setPackageData(getCompilation().getPackageData()); |
| 79 |
binding.obtainDeclaringComponent(this); |
| 80 |
Expression select = sourceBinding.getSelectExpression(); |
| 81 |
binding.setSelectExpression(select); |
| 82 |
binding.setVariableQName(sourceBinding.getVariableQName()); |
| 83 |
initializeBinding(binding); |
| 84 |
|
| 85 |
binding.setRequiredType(getRequiredType()); |
| 86 |
binding.setRequiredParam(sourceBinding.hasProperty(SourceBinding.REQUIRED)); |
| 87 |
binding.setImplicitlyRequiredParam(sourceBinding.hasProperty(SourceBinding.IMPLICITLY_REQUIRED)); |
| 88 |
sourceBinding.fixupBinding(binding); |
| 89 |
|
| 90 |
|
| 91 |
Component overridden = getOverriddenComponent(); |
| 92 |
if (overridden != null) { |
| 93 |
checkCompatibility(overridden); |
| 94 |
} |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
public SequenceType getRequiredType() { |
| 105 |
SequenceType declaredType = sourceBinding.getDeclaredType(); |
| 106 |
if (declaredType != null) { |
| 107 |
return declaredType; |
| 108 |
} else { |
| 109 |
return SequenceType.ANY_SEQUENCE; |
| 110 |
} |
| 111 |
} |
| 112 |
|
| 113 |
public void insertBytecodeCandidate(Optimizer opt) { |
| 114 |
|
| 115 |
} |
| 116 |
} |
| 117 |
|