diff options
author | hq <hq@FreeBSD.org> | 2004-11-17 16:54:29 +0000 |
---|---|---|
committer | hq <hq@FreeBSD.org> | 2004-11-17 16:54:29 +0000 |
commit | ed2165feb22a2e5e0184a6f043fbd653d5b17e7d (patch) | |
tree | 4bebbd16acbc3fdf1c326e69f04a48d5ca419b6a /textproc | |
parent | 85651cce7e746b36c3afda369496c1fb50533f60 (diff) | |
download | FreeBSD-ports-ed2165feb22a2e5e0184a6f043fbd653d5b17e7d.zip FreeBSD-ports-ed2165feb22a2e5e0184a6f043fbd653d5b17e7d.tar.gz |
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')
-rw-r--r-- | textproc/jaxup/Makefile | 27 | ||||
-rw-r--r-- | textproc/jaxup/files/DOMXUpdater.java | 52 | ||||
-rw-r--r-- | textproc/jaxup/files/jaxup-xupdater.sh | 5 |
3 files changed, 81 insertions, 3 deletions
diff --git a/textproc/jaxup/Makefile b/textproc/jaxup/Makefile index f0370d7..c21006e 100644 --- a/textproc/jaxup/Makefile +++ b/textproc/jaxup/Makefile @@ -6,6 +6,7 @@ PORTNAME= jaxup PORTVERSION= 1.01 +PORTREVISION= 1 CATEGORIES= textproc java MASTER_SITES= http://klomp.org/jaxup/ DISTNAME= ${PORTNAME}-${PORTVERSION}-src @@ -13,9 +14,11 @@ DISTNAME= ${PORTNAME}-${PORTVERSION}-src MAINTAINER= hq@FreeBSD.org COMMENT= Java XUpdate engine +BUILD_DEPENDS= classpath:${PORTSDIR}/java/javavmwrapper RUN_DEPENDS= ${JAVALIBDIR}/jdom.jar:${PORTSDIR}/java/jdom \ ${JAVALIBDIR}/jaxen-core.jar:${PORTSDIR}/java/jaxen \ - ${JAVALIBDIR}/xercesImpl.jar:${PORTSDIR}/textproc/xerces-j + ${JAVALIBDIR}/xercesImpl.jar:${PORTSDIR}/textproc/xerces-j \ + java:${PORTSDIR}/java/javavmwrapper USE_ZIP= yes WRKSRC= ${WRKDIR}/${PORTNAME} @@ -23,13 +26,17 @@ WRKSRC= ${WRKDIR}/${PORTNAME} USE_JAVA= yes JAVA_VERSION= 1.3+ +DATADIR= ${JAVASHAREDIR}/${PORTNAME} + USE_ANT= yes ALL_TARGET= jar .if !defined(NOPORTDOCS) ALL_TARGET+= docs .endif -PLIST_FILES+= %%JAVAJARDIR%%/${PORTNAME}.jar +PLIST_FILES+= %%DATADIR%%/jaxup-xupdater.jar bin/jaxup-xupdater \ + %%JAVAJARDIR%%/${PORTNAME}.jar +PLIST_DIRS= %%DATADIR%% .if !defined(NOPORTDOCS) PORTDOCS= LICENSE.txt api index.html jaxup_files xupdate-wd.html xupdate-wd_files @@ -37,12 +44,26 @@ PORTDOCS= LICENSE.txt api index.html jaxup_files xupdate-wd.html xupdate-wd_file post-extract: @${CP} ${FILESDIR}/build.xml ${WRKSRC}/ + @${CP} ${FILESDIR}/DOMXUpdater.java ${WRKDIR}/ + @${SED} -e 's,%%LOCALBASE%%,${LOCALBASE},g ; s,%%DATADIR%%,${DATADIR},g' \ + ${FILESDIR}/jaxup-xupdater.sh >${WRKDIR}/jaxup-xupdater + +post-build: + @${ECHO_MSG} ">> Building utility classes..." + cd ${WRKDIR} && ${JAVAC} -classpath "`${LOCALBASE}/bin/classpath`:${WRKSRC}/build/lib/jaxup.jar" DOMXUpdater.java + ${ECHO_CMD} "Main-Class: DOMXUpdater" >${WRKDIR}/MANIFEST + cd ${WRKDIR} && ${JAR} -cmf MANIFEST jaxup-xupdater.jar DOMXUpdater.class do-install: - @${ECHO_MSG} -n ">> Installing JAR files as ${JAVAJARDIR}/${PORTNAME}.jar..." + @${ECHO_MSG} -n ">> Installing JAR file as ${JAVAJARDIR}/${PORTNAME}.jar..." @${MKDIR} ${JAVAJARDIR} @${INSTALL_DATA} ${WRKSRC}/build/lib/${PORTNAME}.jar ${JAVAJARDIR}/ @${ECHO_MSG} " [ DONE ]" + @${ECHO_MSG} ">> Installing utility scripts and classes..." + ${MKDIR} ${DATADIR} + ${INSTALL_DATA} ${WRKDIR}/jaxup-xupdater.jar ${DATADIR}/ + ${INSTALL_SCRIPT} ${WRKDIR}/jaxup-xupdater ${PREFIX}/bin/ + @${ECHO_MSG} " [ DONE ]" .if !defined(NOPORTDOCS) @${ECHO_MSG} -n ">> Installing documentation in ${DOCSDIR}..." @${MKDIR} ${DOCSDIR} diff --git a/textproc/jaxup/files/DOMXUpdater.java b/textproc/jaxup/files/DOMXUpdater.java new file mode 100644 index 0000000..ebafa37 --- /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 0000000..aabc8ca --- /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" "$@" |