textproc/xincluder: Fix processing using JDOM

JDOM could not be used due to mismatch with the included JDOM.

PR:		272559
Reported by:	saper@saper.info
This commit is contained in:
Marcin Cieślak 2023-07-21 16:59:58 +02:00 committed by Fernando Apesteguía
parent 78f09f8454
commit 860aa846f7
2 changed files with 39 additions and 3 deletions

View file

@ -1,6 +1,6 @@
PORTNAME= xincluder
PORTVERSION= 1.0.d11
PORTREVISION= 6
PORTREVISION= 7
CATEGORIES= textproc java
MASTER_SITES= ftp://ftp.ibiblio.org/pub/languages/java/javafaq/
DISTNAME= ${PORTNAME}-1.0d11
@ -12,22 +12,34 @@ WWW= http://xincluder.sourceforge.net/
LICENSE= LGPL21
LICENSE_FILE= ${WRKSRC}/lgpl.txt
BUILD_DEPENDS= ${JAVALIBDIR}/jdom.jar:java/jdom \
${JAVALIBDIR}/xercesImpl.jar:textproc/xerces-j
RUN_DEPENDS= ${JAVALIBDIR}/jdom.jar:java/jdom \
${JAVALIBDIR}/xercesImpl.jar:textproc/xerces-j
USE_JAVA= yes
NO_BUILD= yes
USE_ANT= yes
ALL_TARGET= clean jar
NO_ARCH= yes
WRKSRC= ${WRKDIR}/${PORTNAME}
SUFFIXES= -sax -dom -jdom
PLIST_FILES= %%JAVAJARDIR%%/${PORTNAME}.jar bin/xincluder ${SUFFIXES:S,^,bin/xincluder,}
PLIST_FILES= ${JAVAJARDIR}/${PORTNAME}.jar bin/xincluder ${SUFFIXES:S,^,bin/xincluder,}
PORTDOCS= apidoc index.html
SUB_FILES= xincluder.sh
OPTIONS_DEFINE= DOCS
post-patch:
@${REINPLACE_CMD} \
-e "s,\./lib/jdom-1.0b9rc.jar,${JAVAJARDIR}/jdom.jar," \
-e "s,\./lib/xercesImpl-2.0.2.jar,${JAVAJARDIR}/xercesImpl.jar," \
-e "s,\./lib/xmlParserAPIs-2.0.2.jar,${JAVAJARDIR}/xml-apis.jar," \
-e 's,<javac srcdir,<javac source="1.8" target="1.8" debug="true" \
includeantruntime="false" srcdir,' \
${WRKSRC}/build.xml
do-install:
@${MKDIR} ${STAGEDIR}${JAVAJARDIR}
${INSTALL_DATA} ${WRKSRC}/${PORTNAME}.jar ${STAGEDIR}${JAVAJARDIR}/

View file

@ -0,0 +1,24 @@
--- src/com/elharo/xml/xinclude/JDOMXIncluder.java.orig 2003-03-09 16:01:34 UTC
+++ src/com/elharo/xml/xinclude/JDOMXIncluder.java
@@ -54,6 +54,7 @@ import org.jdom.CDATA;
import org.jdom.Namespace;
import org.jdom.Comment;
import org.jdom.CDATA;
+import org.jdom.DocType;
import org.jdom.Text;
import org.jdom.JDOMException;
import org.jdom.Attribute;
@@ -404,6 +405,13 @@ public class JDOMXIncluder {
// I need to return the full document child list including comments and PIs,
// not just the resolved root
List topLevelNodes = doc.getContent();
+ for (int i = 0; i < topLevelNodes.size(); i++) {
+ Object o = topLevelNodes.get(i);
+ if (o instanceof DocType) {
+ DocType docType = (DocType) o;
+ docType.detach();
+ }
+ }
int rootPosition = topLevelNodes.indexOf(root);
List beforeRoot = topLevelNodes.subList(0, rootPosition);
List afterRoot = topLevelNodes.subList(rootPosition+1, topLevelNodes.size());