Skip to content

Commit ced4937

Browse files
committed
fn:transform - remove redundant code
All XQTS tests work within the raw Saxon to eXist conversion code we have, so remove the fallback conversion-via-serialization, which incidentally helps coverage checking.
1 parent 067c8b2 commit ced4937

File tree

1 file changed

+2
-43
lines changed
  • exist-core/src/main/java/org/exist/xquery/functions/fn/transform

1 file changed

+2
-43
lines changed

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

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,13 @@
2727
import org.exist.dom.memtree.DocumentBuilderReceiver;
2828
import org.exist.dom.memtree.DocumentImpl;
2929
import org.exist.dom.memtree.MemTreeBuilder;
30-
import org.exist.xquery.ErrorCodes;
3130
import org.exist.xquery.XPathException;
3231
import org.exist.xquery.XQueryContext;
33-
import org.exist.xquery.value.NodeValue;
3432
import org.exist.xquery.value.Sequence;
3533
import org.exist.xquery.value.StringValue;
36-
import org.exist.xquery.value.ValueSequence;
37-
import org.w3c.dom.Node;
38-
import org.w3c.dom.NodeList;
3934

4035
import java.io.StringWriter;
36+
import java.util.Objects;
4137

4238
class Delivery {
4339

@@ -120,47 +116,10 @@ Sequence convert() throws XPathException {
120116
case SERIALIZED:
121117
return new StringValue(getSerializedString());
122118
case RAW:
123-
//TODO (AP) rawOutput and mediation via document when the Xdm value is complex, is a hack
124-
final XdmValue xdmValue = getXdmValue();
125-
if (xdmValue != null) {
126-
return Convert.ToExist.of(xdmValue);
127-
}
128-
final DocumentImpl document = getDocument();
129-
if (document != null) {
130-
return rawOutput(getDocument());
131-
}
132-
throw new XPathException(ErrorCodes.FOXT0003, "No RAW output has been constructed by the transformation.");
119+
return Convert.ToExist.of(Objects.requireNonNull(getXdmValue()));
133120
case DOCUMENT:
134121
default:
135122
return getDocument();
136123
}
137124
}
138-
139-
private static Sequence rawOutput(final NodeValue outputDocument) throws XPathException {
140-
final Node node = outputDocument.getNode();
141-
if (node != null) {
142-
final NodeList children = node.getChildNodes();
143-
final int length = children.getLength();
144-
if (length == 0) {
145-
return Sequence.EMPTY_SEQUENCE;
146-
} else if (length == 1) {
147-
final Node item = children.item(0);
148-
if (item instanceof NodeValue) {
149-
return (NodeValue)item;
150-
}
151-
} else {
152-
final ValueSequence valueSequence = new ValueSequence();
153-
for (int i = 0; i < children.getLength(); i++) {
154-
final Node child = children.item(i);
155-
if (child instanceof NodeValue) {
156-
valueSequence.add((NodeValue)child);
157-
}
158-
}
159-
return valueSequence;
160-
}
161-
throw new XPathException(ErrorCodes.XPTY0004, "Unable to produce raw output from contents of: " + outputDocument);
162-
}
163-
return Sequence.EMPTY_SEQUENCE;
164-
}
165-
166125
}

0 commit comments

Comments
 (0)