Skip to content

Commit 11cabd5

Browse files
committed
[bugfix] fn:local-name should return the target of a Processing Instruction. Now passes XQTS fn-local-name-14 and fn-local-name-15
1 parent 5086400 commit 11cabd5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

exist-core/src/main/java/org/exist/xquery/functions/fn/FunLocalName.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.exist.xquery.value.StringValue;
4040
import org.exist.xquery.value.Type;
4141
import org.w3c.dom.Node;
42+
import org.w3c.dom.ProcessingInstruction;
4243

4344
/**
4445
* Built-in function fn:local-name().
@@ -126,8 +127,14 @@ public Sequence eval(Sequence contextSequence, final Item contextItem) throws XP
126127
}
127128

128129
//TODO : how to improve performance ?
130+
final String localName;
129131
final Node n = ((NodeValue) item).getNode();
130-
final String localName = n.getLocalName();
132+
if (n.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
133+
localName = ((ProcessingInstruction) n).getTarget();
134+
} else {
135+
localName = n.getLocalName();
136+
}
137+
131138
if (localName != null) {
132139
result = new StringValue(localName);
133140
} else {

0 commit comments

Comments
 (0)