Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ndw/xmlcalabash1-deltaxml
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: DeltaXML/xmlcalabash1-deltaxml
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Feb 19, 2021

  1. An initial idea of what the code should look like if using our cores9api

    packages.  Not compiled or tested - gradle problems to resolve first.
    Nigel Whitaker committed Feb 19, 2021
    Copy the full SHA
    b1dbf9f View commit details
  2. Copy the full SHA
    9fec9c2 View commit details
Showing with 7 additions and 30 deletions.
  1. +1 −1 gradle/wrapper/gradle-wrapper.properties
  2. +6 −29 src/main/java/com/xmlcalabash/extensions/DeltaXML.java
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
35 changes: 6 additions & 29 deletions src/main/java/com/xmlcalabash/extensions/DeltaXML.java
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@
import com.xmlcalabash.core.XProcException;
import com.xmlcalabash.runtime.XAtomicStep;
import com.xmlcalabash.util.S9apiUtils;
import com.deltaxml.core.DXPConfiguration;
import com.deltaxml.core.PipelinedComparator;
import com.deltaxml.cores9api.DXPConfigurationS9;
import com.deltaxml.cores9api.PipelinedComparatorS9;
import com.xmlcalabash.util.XProcURIResolver;
import net.sf.saxon.s9api.*;

@@ -86,34 +86,11 @@ public void run() throws SaxonApiException {
XdmNode docA = source.read();
XdmNode docB = alternate.read();
XdmNode dxpdoc = dxp.read();

try {
DXPConfiguration dxpconfig = new DXPConfiguration(S9apiUtils.xdmToInputSource(runtime, dxpdoc), null, false);
PipelinedComparator comparator = dxpconfig.generate();

// FIXME: Grotesque hackery!

StringWriter sw = new StringWriter();
Serializer serializer = runtime.getProcessor().newSerializer();
serializer.setOutputWriter(sw);
S9apiUtils.serialize(runtime, docA, serializer);

String docAxml = sw.toString();

sw = new StringWriter();
serializer = runtime.getProcessor().newSerializer();
serializer.setOutputWriter(sw);
S9apiUtils.serialize(runtime, docB, serializer);

String docBxml = sw.toString();

StringBuffer buf = new StringBuffer();

comparator.compare(docAxml, docBxml, buf);

StringReader sr = new StringReader(buf.toString());
XdmNode doc = runtime.parse(new InputSource(sr));
result.write(doc);
DXPConfigurationS9 dxpconfig = new DXPConfigurationS9(dxpdoc);
PipelinedComparatorS9 comparator = dxpconfig.generate();
XdmNode ab= comparator.compare(docA, docB);
result.write(ab);
} catch (Exception e) {
throw new XProcException(e);
}