| 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.LocalVariableReference; |
| 12 |
import net.sf.saxon.expr.VariableReference; |
| 13 |
import net.sf.saxon.om.AxisInfo; |
| 14 |
import net.sf.saxon.om.NodeInfo; |
| 15 |
import net.sf.saxon.om.StructuredQName; |
| 16 |
import net.sf.saxon.trans.XPathException; |
| 17 |
import net.sf.saxon.tree.iter.AxisIterator; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
public class TextValueTemplateContext extends ExpressionContext { |
| 25 |
|
| 26 |
TextValueTemplateNode textNode; |
| 27 |
|
| 28 |
public TextValueTemplateContext(StyleElement parent, TextValueTemplateNode textNode) { |
| 29 |
super(parent, null); |
| 30 |
this.textNode = textNode; |
| 31 |
} |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
@Override |
| 42 |
public Expression bindVariable(StructuredQName qName) throws XPathException { |
| 43 |
SourceBinding siblingVar = bindLocalVariable(qName); |
| 44 |
if (siblingVar == null) { |
| 45 |
return super.bindVariable(qName); |
| 46 |
} else { |
| 47 |
VariableReference var = new LocalVariableReference(qName); |
| 48 |
siblingVar.registerReference(var); |
| 49 |
return var; |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
private SourceBinding bindLocalVariable(StructuredQName qName) { |
| 54 |
NodeInfo curr = textNode; |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
AxisIterator preceding = curr.iterateAxis(AxisInfo.PRECEDING_SIBLING); |
| 59 |
while ((curr = preceding.next()) != null) { |
| 60 |
if (curr instanceof XSLGeneralVariable) { |
| 61 |
SourceBinding sourceBinding = ((XSLGeneralVariable) curr).getBindingInformation(qName); |
| 62 |
if (sourceBinding != null) { |
| 63 |
return sourceBinding; |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
} |
| 68 |
return null; |
| 69 |
} |
| 70 |
|
| 71 |
} |
| 72 |
|