Skip to content
Permalink
Browse files
Fix issue #162 make sure descendants are copied correctly.
Also switch from RelevantNodes to AxisNodes.
  • Loading branch information
ndw committed Aug 17, 2014
1 parent b6eadf1 commit a9cc0030d89d7713a322153359c6a6112bf53e5f
Showing with 15 additions and 6 deletions.
  1. +15 −6 src/com/xmlcalabash/extensions/SetBaseURI.java
@@ -1,17 +1,17 @@
package com.xmlcalabash.extensions;

import com.xmlcalabash.core.XProcConstants;
import com.xmlcalabash.core.XProcException;
import com.xmlcalabash.core.XProcRuntime;
import com.xmlcalabash.io.ReadablePipe;
import com.xmlcalabash.io.WritablePipe;
import com.xmlcalabash.library.DefaultStep;
import com.xmlcalabash.runtime.XAtomicStep;
import com.xmlcalabash.util.RelevantNodes;
import com.xmlcalabash.util.AxisNodes;
import com.xmlcalabash.util.TreeWriter;
import net.sf.saxon.s9api.*;

import java.net.URI;
import java.net.URISyntaxException;

/**
* Created by IntelliJ IDEA.
@@ -64,19 +64,28 @@ public void run() throws SaxonApiException {
tree = new TreeWriter(runtime);
tree.startDocument(baseURI);

for (XdmNode node : new RelevantNodes(doc, Axis.CHILD, true)) {
write(node);
for (XdmNode node : new AxisNodes(doc, Axis.CHILD)) {
write(node,false);
}

tree.endDocument();

result.write(tree.getResult());
}

private void write(XdmNode node) {
private void write(XdmNode node, boolean underXmlBase) {
switch (node.getNodeKind()) {
case ELEMENT:
tree.addStartElement(node, baseURI);
underXmlBase = underXmlBase || (node.getAttributeValue(XProcConstants.xml_base) != null);
if (underXmlBase) {
tree.addStartElement(node);
} else {
tree.addStartElement(node, baseURI);
}
for (XdmNode child : new AxisNodes(node, Axis.CHILD)) {
write(child,underXmlBase);
}
tree.addEndElement();
break;
case TEXT:
tree.addSubtree(node);

0 comments on commit a9cc003

Please sign in to comment.