| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.expr.instruct; |
| 9 |
|
| 10 |
import net.sf.saxon.expr.StaticProperty; |
| 11 |
import net.sf.saxon.expr.XPathContext; |
| 12 |
import net.sf.saxon.om.StandardNames; |
| 13 |
import net.sf.saxon.om.StructuredQName; |
| 14 |
import net.sf.saxon.trace.ExpressionPresenter; |
| 15 |
import net.sf.saxon.trace.LocationKind; |
| 16 |
import net.sf.saxon.trans.SymbolicName; |
| 17 |
import net.sf.saxon.trans.XPathException; |
| 18 |
import net.sf.saxon.trans.XsltController; |
| 19 |
|
| 20 |
import java.util.Stack; |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
public class AttributeSet extends Actor { |
| 27 |
|
| 28 |
StructuredQName attributeSetName; |
| 29 |
private boolean declaredStreamable; |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
public AttributeSet() { |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
@Override |
| 44 |
public SymbolicName getSymbolicName() { |
| 45 |
return new SymbolicName(StandardNames.XSL_ATTRIBUTE_SET, attributeSetName); |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
public void setName(StructuredQName attributeSetName) { |
| 55 |
this.attributeSetName = attributeSetName; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
public void setDeclaredStreamable(boolean value) { |
| 64 |
this.declaredStreamable = value; |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
public boolean isDeclaredStreamable() { |
| 73 |
return this.declaredStreamable; |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
public void setStackFrameMap( SlotManager stackFrameMap) { |
| 83 |
if (stackFrameMap != null) { |
| 84 |
super.setStackFrameMap(stackFrameMap); |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
public int getFocusDependencies() { |
| 95 |
return body.getDependencies() & StaticProperty.DEPENDS_ON_FOCUS; |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
public void expand(XPathContext context) throws XPathException { |
| 106 |
Stack<AttributeSet> stack = ((XsltController)context.getController()).getAttributeSetEvaluationStack(); |
| 107 |
if (stack.contains(this)) { |
| 108 |
throw new XPathException("Attribute set " + getObjectName().getEQName() + " invokes itself recursively", "XTDE0640"); |
| 109 |
} |
| 110 |
stack.push(this); |
| 111 |
getBody().process(context); |
| 112 |
stack.pop(); |
| 113 |
if (stack.isEmpty()) { |
| 114 |
((XsltController)context.getController()).releaseAttributeSetEvaluationStack(); |
| 115 |
} |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
public int getConstructType() { |
| 125 |
return StandardNames.XSL_ATTRIBUTE_SET; |
| 126 |
} |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
public StructuredQName getObjectName() { |
| 134 |
return attributeSetName; |
| 135 |
} |
| 136 |
|
| 137 |
public int getComponentKind() { |
| 138 |
return StandardNames.XSL_ATTRIBUTE_SET; |
| 139 |
} |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
@Override |
| 148 |
public void export(ExpressionPresenter presenter) throws XPathException { |
| 149 |
presenter.startElement("attributeSet"); |
| 150 |
presenter.emitAttribute("name", getObjectName()); |
| 151 |
presenter.emitAttribute("line", getLineNumber() + ""); |
| 152 |
presenter.emitAttribute("module", getSystemId()); |
| 153 |
presenter.emitAttribute("slots", getStackFrameMap().getNumberOfVariables() + ""); |
| 154 |
presenter.emitAttribute("binds", getDeclaringComponent().getComponentBindings().size() + ""); |
| 155 |
if (isDeclaredStreamable()) { |
| 156 |
presenter.emitAttribute("flags", "s"); |
| 157 |
} |
| 158 |
getBody().export(presenter); |
| 159 |
presenter.endElement(); |
| 160 |
} |
| 161 |
|
| 162 |
|
| 163 |
} |
| 164 |
|