| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.style; |
| 9 |
|
| 10 |
import net.sf.saxon.Configuration; |
| 11 |
import net.sf.saxon.expr.Expression; |
| 12 |
import net.sf.saxon.expr.StringLiteral; |
| 13 |
import net.sf.saxon.expr.instruct.ValueOf; |
| 14 |
import net.sf.saxon.om.AttributeCollection; |
| 15 |
import net.sf.saxon.trans.XPathException; |
| 16 |
import net.sf.saxon.type.TypeHierarchy; |
| 17 |
import net.sf.saxon.value.StringValue; |
| 18 |
import net.sf.saxon.value.Whitespace; |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public final class XSLValueOf extends XSLLeafNodeConstructor { |
| 32 |
|
| 33 |
private boolean disable = false; |
| 34 |
private Expression separator; |
| 35 |
|
| 36 |
|
| 37 |
public void prepareAttributes() throws XPathException { |
| 38 |
|
| 39 |
String selectAtt = null; |
| 40 |
String disableAtt = null; |
| 41 |
String separatorAtt = null; |
| 42 |
|
| 43 |
AttributeCollection atts = getAttributeList(); |
| 44 |
|
| 45 |
for (int a = 0; a < atts.getLength(); a++) { |
| 46 |
String f = atts.getQName(a); |
| 47 |
if (f.equals("disable-output-escaping")) { |
| 48 |
disableAtt = Whitespace.trim(atts.getValue(a)); |
| 49 |
} else if (f.equals("select")) { |
| 50 |
selectAtt = atts.getValue(a); |
| 51 |
select = makeExpression(selectAtt, a); |
| 52 |
} else if (f.equals("separator")) { |
| 53 |
separatorAtt = atts.getValue(a); |
| 54 |
separator = makeAttributeValueTemplate(separatorAtt, a); |
| 55 |
} else { |
| 56 |
checkUnknownAttribute(atts.getNodeName(a)); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
if (disableAtt != null) { |
| 61 |
disable = processBooleanAttribute("disable-output-escaping", disableAtt); |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
public void validate(ComponentDeclaration decl) throws XPathException { |
| 66 |
super.validate(decl); |
| 67 |
select = typeCheck("select", select); |
| 68 |
separator = typeCheck("separator", separator); |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
protected String getErrorCodeForSelectPlusContent() { |
| 78 |
return "XTSE0870"; |
| 79 |
} |
| 80 |
|
| 81 |
public Expression compile(Compilation exec, ComponentDeclaration decl) throws XPathException { |
| 82 |
Configuration config = getConfiguration(); |
| 83 |
final TypeHierarchy th = config.getTypeHierarchy(); |
| 84 |
if (separator == null && select != null && xPath10ModeIsEnabled()) { |
| 85 |
|
| 86 |
select = config.getTypeChecker(true).processValueOf(select, config); |
| 87 |
} else { |
| 88 |
if (separator == null) { |
| 89 |
if (select == null) { |
| 90 |
separator = new StringLiteral(StringValue.EMPTY_STRING); |
| 91 |
} else { |
| 92 |
separator = new StringLiteral(StringValue.SINGLE_SPACE); |
| 93 |
} |
| 94 |
} |
| 95 |
} |
| 96 |
ValueOf inst = new ValueOf(select, disable, false); |
| 97 |
inst.setRetainedStaticContext(makeRetainedStaticContext()); |
| 98 |
compileContent(exec, decl, inst, separator); |
| 99 |
return inst; |
| 100 |
} |
| 101 |
|
| 102 |
} |
| 103 |
|