| 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.SequenceInstr; |
| 12 |
import net.sf.saxon.lib.Feature; |
| 13 |
import net.sf.saxon.om.AttributeCollection; |
| 14 |
import net.sf.saxon.om.AxisInfo; |
| 15 |
import net.sf.saxon.om.NodeInfo; |
| 16 |
import net.sf.saxon.trans.XPathException; |
| 17 |
import net.sf.saxon.tree.iter.AxisIterator; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
public class XSLSequence extends StyleElement { |
| 25 |
|
| 26 |
private Expression select; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
public boolean isInstruction() { |
| 35 |
return true; |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
public boolean mayContainSequenceConstructor() { |
| 45 |
return true; |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
public boolean mayContainFallback() { |
| 54 |
return true; |
| 55 |
} |
| 56 |
|
| 57 |
public Expression getSelectExpression() { |
| 58 |
return select; |
| 59 |
} |
| 60 |
|
| 61 |
public void setSelectExpression(Expression select) { |
| 62 |
this.select = select; |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
public void prepareAttributes() throws XPathException { |
| 67 |
|
| 68 |
String selectAtt = null; |
| 69 |
|
| 70 |
AttributeCollection atts = getAttributeList(); |
| 71 |
|
| 72 |
for (int a = 0; a < atts.getLength(); a++) { |
| 73 |
String f = atts.getQName(a); |
| 74 |
if (f.equals("select")) { |
| 75 |
selectAtt = atts.getValue(a); |
| 76 |
select = makeExpression(selectAtt, a); |
| 77 |
} else { |
| 78 |
checkUnknownAttribute(atts.getNodeName(a)); |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
} |
| 83 |
|
| 84 |
public void validate(ComponentDeclaration decl) throws XPathException { |
| 85 |
AxisIterator kids = iterateAxis(AxisInfo.CHILD); |
| 86 |
NodeInfo child; |
| 87 |
while ((child = kids.next()) != null) { |
| 88 |
if (!(child instanceof XSLFallback)) { |
| 89 |
if (select != null) { |
| 90 |
compileError("An " + getDisplayName() + " element with a select attribute must be empty", "XTSE3185"); |
| 91 |
} |
| 92 |
break; |
| 93 |
} |
| 94 |
} |
| 95 |
select = typeCheck("select", select); |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
public Expression compile(Compilation exec, ComponentDeclaration decl) throws XPathException { |
| 100 |
if (select == null) { |
| 101 |
select = compileSequenceConstructor(exec, decl, false); |
| 102 |
} |
| 103 |
if (getConfiguration().getBooleanProperty(Feature.STRICT_STREAMABILITY)) { |
| 104 |
select = new SequenceInstr(select); |
| 105 |
} |
| 106 |
return select; |
| 107 |
} |
| 108 |
|
| 109 |
} |
| 110 |
|