diff options
author | hq <hq@FreeBSD.org> | 2004-11-18 00:54:29 +0800 |
---|---|---|
committer | hq <hq@FreeBSD.org> | 2004-11-18 00:54:29 +0800 |
commit | ed2165feb22a2e5e0184a6f043fbd653d5b17e7d (patch) | |
tree | 4bebbd16acbc3fdf1c326e69f04a48d5ca419b6a /textproc/jaxup/files | |
parent | 85651cce7e746b36c3afda369496c1fb50533f60 (diff) | |
download | freebsd-ports-gnome-ed2165feb22a2e5e0184a6f043fbd653d5b17e7d.tar.gz freebsd-ports-gnome-ed2165feb22a2e5e0184a6f043fbd653d5b17e7d.tar.zst freebsd-ports-gnome-ed2165feb22a2e5e0184a6f043fbd653d5b17e7d.zip |
Added a new class and a launcher shell script to perform command-line XUpdate
processing using Jaxup:
$ jaxup-xupdater <source-doc.xml> <xupdate-doc.xml>
Bumped PORTREVISION to reflect this new feature.
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" "$@" |