diff options
Diffstat (limited to 'textproc/jaxup/files')
-rw-r--r-- | textproc/jaxup/files/DOMXUpdater.java | 52 | ||||
-rw-r--r-- | textproc/jaxup/files/jaxup-xupdater.sh | 5 |
2 files changed, 57 insertions, 0 deletions
diff --git a/textproc/jaxup/files/DOMXUpdater.java b/textproc/jaxup/files/DOMXUpdater.java new file mode 100644 index 000000000000..ebafa3735c4d --- /dev/null +++ b/textproc/jaxup/files/DOMXUpdater.java @@ -0,0 +1,52 @@ +/**
+ * DOMXUpdater: a command-line XUpdate processor.
+ *
+ * $FreeBSD$
+ */
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.xml.serialize.OutputFormat;
+import org.apache.xml.serialize.XMLSerializer;
+import org.jaxen.dom.DocumentNavigator;
+import org.jaxup.dom.DOMDocumentUpdater;
+import org.jaxup.xupdate.XUpdate;
+import org.w3c.dom.Document;
+
+public class DOMXUpdater
+{
+ public static void main(String[] args)
+ {
+ if (args.length != 2)
+ {
+ System.out.println("usage: DOMXUpdater <source document url> <XUpdate document url>");
+ System.exit(1);
+ }
+
+ try
+ {
+ DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ DocumentBuilder builder=factory.newDocumentBuilder();
+
+ Document doc=builder.parse(args[0]);
+ Document updateDoc=builder.parse(args[1]);
+
+ XUpdate updater=new XUpdate(new DOMDocumentUpdater(), DocumentNavigator.getInstance());
+ updater.runUpdate(doc, updateDoc.getDocumentElement());
+
+ OutputFormat o=new OutputFormat("xml", "ISO-8859-1", true);
+ o.setIndenting(true);
+ o.setIndent(2);
+ o.setPreserveSpace(true);
+ XMLSerializer serial=new XMLSerializer(System.out, o);
+ serial.serialize(doc);
+ System.out.println();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+}
diff --git a/textproc/jaxup/files/jaxup-xupdater.sh b/textproc/jaxup/files/jaxup-xupdater.sh new file mode 100644 index 000000000000..aabc8ca05828 --- /dev/null +++ b/textproc/jaxup/files/jaxup-xupdater.sh @@ -0,0 +1,5 @@ +#!/bin/sh +# +# $FreeBSD$ + +JAVA_VERSION="1.3+" %%LOCALBASE%%/bin/java -cp "`"%%LOCALBASE%%/bin/classpath"`:%%DATADIR%%/jaxup-xupdater.jar" "DOMXUpdater" "$@" |