| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.functions; |
| 9 |
|
| 10 |
import net.sf.saxon.expr.Expression; |
| 11 |
import net.sf.saxon.expr.StaticProperty; |
| 12 |
import net.sf.saxon.expr.XPathContext; |
| 13 |
import net.sf.saxon.om.Item; |
| 14 |
import net.sf.saxon.om.NodeInfo; |
| 15 |
import net.sf.saxon.om.One; |
| 16 |
import net.sf.saxon.om.ZeroOrOne; |
| 17 |
import net.sf.saxon.trans.XPathException; |
| 18 |
import net.sf.saxon.tree.util.FastStringBuffer; |
| 19 |
import net.sf.saxon.value.AtomicValue; |
| 20 |
import net.sf.saxon.value.StringValue; |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
public class GenerateId_1 extends ScalarSystemFunction { |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
public int getSpecialProperties(Expression[] arguments) { |
| 37 |
int p = super.getSpecialProperties(arguments); |
| 38 |
return p & ~StaticProperty.NO_NODES_NEWLY_CREATED; |
| 39 |
} |
| 40 |
|
| 41 |
@Override |
| 42 |
public ZeroOrOne<? extends AtomicValue> resultWhenEmpty() { |
| 43 |
return One.string(""); |
| 44 |
} |
| 45 |
|
| 46 |
@Override |
| 47 |
public AtomicValue evaluate(Item arg, XPathContext context) throws XPathException { |
| 48 |
return generateId((NodeInfo)arg); |
| 49 |
} |
| 50 |
|
| 51 |
public static StringValue generateId(NodeInfo node) { |
| 52 |
FastStringBuffer buffer = new FastStringBuffer(FastStringBuffer.C16); |
| 53 |
node.generateId(buffer); |
| 54 |
buffer.condense(); |
| 55 |
return new StringValue(buffer); |
| 56 |
|
| 57 |
} |
| 58 |
|
| 59 |
public String getCompilerName() { |
| 60 |
return "GenerateIdCompiler"; |
| 61 |
} |
| 62 |
|
| 63 |
} |
| 64 |
|