| 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.NextMatch; |
| 12 |
import net.sf.saxon.om.AttributeCollection; |
| 13 |
import net.sf.saxon.om.AxisInfo; |
| 14 |
import net.sf.saxon.om.NodeInfo; |
| 15 |
import net.sf.saxon.trans.XPathException; |
| 16 |
import net.sf.saxon.tree.iter.AxisIterator; |
| 17 |
import net.sf.saxon.type.Type; |
| 18 |
import net.sf.saxon.value.Whitespace; |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
public class XSLNextMatch extends StyleElement { |
| 25 |
|
| 26 |
private boolean useTailRecursion = false; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
public boolean isInstruction() { |
| 35 |
return true; |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public boolean mayContainFallback() { |
| 44 |
return true; |
| 45 |
} |
| 46 |
|
| 47 |
public void prepareAttributes() throws XPathException { |
| 48 |
|
| 49 |
AttributeCollection atts = getAttributeList(); |
| 50 |
|
| 51 |
for (int a = 0; a < atts.getLength(); a++) { |
| 52 |
checkUnknownAttribute(atts.getNodeName(a)); |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
public void validate(ComponentDeclaration decl) throws XPathException { |
| 57 |
AxisIterator kids = iterateAxis(AxisInfo.CHILD); |
| 58 |
while (true) { |
| 59 |
NodeInfo child = kids.next(); |
| 60 |
if (child == null) { |
| 61 |
break; |
| 62 |
} |
| 63 |
if (child instanceof XSLWithParam || child instanceof XSLFallback) { |
| 64 |
|
| 65 |
} else if (child.getNodeKind() == Type.TEXT) { |
| 66 |
|
| 67 |
if (!Whitespace.isWhite(child.getStringValueCS())) { |
| 68 |
compileError("No character data is allowed within xsl:next-match", "XTSE0010"); |
| 69 |
} |
| 70 |
} else { |
| 71 |
compileError("Child element " + child.getDisplayName() + |
| 72 |
" is not allowed as a child of xsl:next-match", "XTSE0010"); |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
protected boolean markTailCalls() { |
| 85 |
useTailRecursion = true; |
| 86 |
return true; |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
public Expression compile(Compilation exec, ComponentDeclaration decl) throws XPathException { |
| 91 |
NextMatch inst = new NextMatch(useTailRecursion); |
| 92 |
inst.setLocation(allocateLocation()); |
| 93 |
inst.setActualParams(getWithParamInstructions(inst, exec, decl, false)); |
| 94 |
inst.setTunnelParams(getWithParamInstructions(inst, exec, decl, true)); |
| 95 |
return inst; |
| 96 |
} |
| 97 |
|
| 98 |
} |
| 99 |
|