summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Milosavljevic <dannym@friendly-machines.com>2026-04-01 01:15:13 +0200
committerDanny Milosavljevic <dannym@friendly-machines.com>2026-05-03 02:30:27 +0200
commit472c94ff67ba84676be980ca2ec58f8f4b296552 (patch)
tree0ff1fcb6ce72ddff4e631f40d01ae1d48bb945e5
parent0755746aadd43d33709cecfcf711fd35f3a5cb52 (diff)
gnu: Add java-apache-xml-commons-resolver-netbeans.
* gnu/packages/patches/java-apache-xml-commons-resolver-1.2-netbeans.patch: New file. * gnu/local.mk (patch_dist_DATA): Add reference to it. * gnu/packages/netbeans.scm (java-apache-xml-commons-resolver-netbeans-1.2): New variable. Change-Id: I606c0fa70aec1d455f5d00370b329350ce5591d3
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/netbeans.scm12
-rw-r--r--gnu/packages/patches/java-apache-xml-commons-resolver-1.2-netbeans.patch890
3 files changed, 903 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index e7f089e3887..7f221ddfd53 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1977,6 +1977,7 @@ dist_patch_DATA = \
1977 %D%/packages/patches/netcdf-date-time.patch \ 1977 %D%/packages/patches/netcdf-date-time.patch \
1978 %D%/packages/patches/netdde-build-fix.patch \ 1978 %D%/packages/patches/netdde-build-fix.patch \
1979 %D%/packages/patches/netdde-csum.patch \ 1979 %D%/packages/patches/netdde-csum.patch \
1980 %D%/packages/patches/java-apache-xml-commons-resolver-1.2-netbeans.patch \
1980 %D%/packages/patches/java-simplevalidation-1.14.1.patch \ 1981 %D%/packages/patches/java-simplevalidation-1.14.1.patch \
1981 %D%/packages/patches/netpbm-CVE-2017-2586.patch \ 1982 %D%/packages/patches/netpbm-CVE-2017-2586.patch \
1982 %D%/packages/patches/netpbm-CVE-2017-2587.patch \ 1983 %D%/packages/patches/netpbm-CVE-2017-2587.patch \
diff --git a/gnu/packages/netbeans.scm b/gnu/packages/netbeans.scm
index 28cdca9bdfd..b2fd9943737 100644
--- a/gnu/packages/netbeans.scm
+++ b/gnu/packages/netbeans.scm
@@ -108,3 +108,15 @@ interfaces.")
108 (native-inputs 108 (native-inputs
109 (list unzip)) 109 (list unzip))
110 (license license:cddl1.0))) 110 (license license:cddl1.0)))
111
112(define java-apache-xml-commons-resolver-netbeans-1.2
113 (package
114 (inherit java-apache-xml-commons-resolver)
115 (name "java-apache-xml-commons-resolver-netbeans")
116 (source
117 (origin
118 (inherit (package-source java-apache-xml-commons-resolver))
119 (patches
120 (search-patches
121 "java-apache-xml-commons-resolver-1.2-netbeans.patch"))))))
122
diff --git a/gnu/packages/patches/java-apache-xml-commons-resolver-1.2-netbeans.patch b/gnu/packages/patches/java-apache-xml-commons-resolver-1.2-netbeans.patch
new file mode 100644
index 00000000000..82e5538b102
--- /dev/null
+++ b/gnu/packages/patches/java-apache-xml-commons-resolver-1.2-netbeans.patch
@@ -0,0 +1,890 @@
1# Licensed to the Apache Software Foundation (ASF) under one
2# or more contributor license agreements. See the NOTICE file
3# distributed with this work for additional information
4# regarding copyright ownership. The ASF licenses this file
5# to you under the Apache License, Version 2.0 (the
6# "License"); you may not use this file except in compliance
7# with the License. You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing,
12# software distributed under the License is distributed on an
13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14# KIND, either express or implied. See the License for the
15# specific language governing permissions and limitations
16# under the License.
17#
18# This is the Apache NetBeans patch
19# ide/o.apache.xml.resolver/external/xml-resolver-1.2-netbeans.patch,
20# rewritten only as needed to apply to the xml-commons-resolver source tree
21# packaged by Guix.
22#
23# NetBeans-side provenance:
24# - Antonio Vieiro: introduced the patch file in commit
25# 4f4debf776ff247b33fe49b876379fbd90d65fe3
26# - Junichi Yamamoto: later edited the patch file text
27#
28# Apache NetBeans expects a patched xml-resolver 1.2. Its source tree and
29# build metadata use the following additions from this patch:
30# - Catalog.getPublicIDs()
31# - a CatalogManager.readProperties() guard for propertyFile == null
32# - org.apache.xml.resolver.NbCatalogManager
33# - org.apache.xml.resolver.tools.NbCatalogResolver
34#
35# This Guix copy is functionally equivalent to the NetBeans patch.
36
37diff -urN orig/src/org/apache/xml/resolver/Catalog.java mod/src/org/apache/xml/resolver/Catalog.java
38--- orig/src/org/apache/xml/resolver/Catalog.java 1970-01-01 00:00:01.000000000 +0000
39+++ mod/src/org/apache/xml/resolver/Catalog.java 2026-03-18 08:06:04.365313076 +0000
40@@ -393,6 +393,26 @@
41 }
42
43 /**
44+ * Return all registered public IDs.
45+ * This method added for solving the following issues in NetBeans codebase:
46+ * http://www.netbeans.org/issues/show_bug.cgi?id=98212
47+ * and
48+ * http://www.netbeans.org/issues/show_bug.cgi?id=112679
49+ */
50+ public java.util.Iterator getPublicIDs() {
51+ Vector v = new Vector();
52+ Enumeration enumeration = catalogEntries.elements();
53+
54+ while (enumeration.hasMoreElements()) {
55+ CatalogEntry e = (CatalogEntry) enumeration.nextElement();
56+ if (e.getEntryType() == PUBLIC) {
57+ v.add(e.getEntryArg(0));
58+ }
59+ }
60+ return v.iterator();
61+ }
62+
63+ /**
64 * Setup readers.
65 */
66 public void setupReaders() {
67diff -urN orig/src/org/apache/xml/resolver/CatalogManager.java mod/src/org/apache/xml/resolver/CatalogManager.java
68--- orig/src/org/apache/xml/resolver/CatalogManager.java 1970-01-01 00:00:01.000000000 +0000
69+++ mod/src/org/apache/xml/resolver/CatalogManager.java 2026-03-18 08:06:04.368781753 +0000
70@@ -239,6 +239,9 @@
71 * resources from it.
72 */
73 private synchronized void readProperties() {
74+ if (propertyFile == null) {
75+ return;
76+ }
77 try {
78 propertyFileURI = CatalogManager.class.getResource("/"+propertyFile);
79 InputStream in =
80diff -urN orig/src/org/apache/xml/resolver/NbCatalogManager.java mod/src/org/apache/xml/resolver/NbCatalogManager.java
81--- orig/src/org/apache/xml/resolver/NbCatalogManager.java 1970-01-01 00:00:00.000000000 +0000
82+++ mod/src/org/apache/xml/resolver/NbCatalogManager.java 2026-03-18 08:04:38.762268746 +0000
83@@ -0,0 +1,570 @@
84+/*
85+ * Licensed to the Apache Software Foundation (ASF) under one or more
86+ * contributor license agreements. See the NOTICE file distributed with
87+ * this work for additional information regarding copyright ownership.
88+ * The ASF licenses this file to You under the Apache License, Version 2.0
89+ * (the "License"); you may not use this file except in compliance with
90+ * the License. You may obtain a copy of the License at
91+ *
92+ * http://www.apache.org/licenses/LICENSE-2.0
93+ *
94+ * Unless required by applicable law or agreed to in writing, software
95+ * distributed under the License is distributed on an "AS IS" BASIS,
96+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
97+ * See the License for the specific language governing permissions and
98+ * limitations under the License.
99+ */
100+package org.apache.xml.resolver;
101+
102+import java.io.IOException;
103+import java.io.InputStream;
104+import java.io.PrintStream;
105+import java.net.MalformedURLException;
106+import java.net.URL;
107+import java.util.MissingResourceException;
108+import java.util.PropertyResourceBundle;
109+import java.util.ResourceBundle;
110+import java.util.StringTokenizer;
111+import java.util.Vector;
112+import org.apache.xml.resolver.helpers.BootstrapResolver;
113+import org.apache.xml.resolver.helpers.Debug;
114+
115+public class NbCatalogManager
116+ extends CatalogManager
117+{
118+ private static String pFiles = "xml.catalog.files";
119+ private static String pVerbosity = "xml.catalog.verbosity";
120+ private static String pPrefer = "xml.catalog.prefer";
121+ private static String pStatic = "xml.catalog.staticCatalog";
122+ private static String pAllowPI = "xml.catalog.allowPI";
123+ private static String pClassname = "xml.catalog.className";
124+ private static String pIgnoreMissing = "xml.catalog.ignoreMissing";
125+ private static NbCatalogManager staticManager = new NbCatalogManager();
126+ private BootstrapResolver bResolver = new BootstrapResolver();
127+ private boolean ignoreMissingProperties = (System.getProperty(pIgnoreMissing) != null) || (System.getProperty(pFiles) != null);
128+ private ResourceBundle resources;
129+ private String propertyFile = "CatalogManager.properties";
130+ private URL propertyFileURI = null;
131+ private String defaultCatalogFiles = "./xcatalog";
132+ private String catalogFiles = null;
133+ private boolean fromPropertiesFile = false;
134+ private int defaultVerbosity = 1;
135+ private Integer verbosity = null;
136+ private boolean defaultPreferPublic = true;
137+ private Boolean preferPublic = null;
138+ private boolean defaultUseStaticCatalog = true;
139+ private Boolean useStaticCatalog = null;
140+ private static Catalog staticCatalog = null;
141+ private boolean defaultOasisXMLCatalogPI = true;
142+ private Boolean oasisXMLCatalogPI = null;
143+ private boolean defaultRelativeCatalogs = true;
144+ private Boolean relativeCatalogs = null;
145+ private String catalogClassName = null;
146+ public Debug debug = null;
147+
148+ public NbCatalogManager()
149+ {
150+ this.debug = new Debug();
151+ }
152+
153+ public NbCatalogManager(String propertyFile)
154+ {
155+ this.propertyFile = propertyFile;
156+
157+ this.debug = new Debug();
158+ }
159+
160+ public void setBootstrapResolver(BootstrapResolver resolver)
161+ {
162+ this.bResolver = resolver;
163+ }
164+
165+ public BootstrapResolver getBootstrapResolver()
166+ {
167+ return this.bResolver;
168+ }
169+
170+ private synchronized void readProperties()
171+ {
172+ if (this.propertyFile == null) {
173+ return;
174+ }
175+ try
176+ {
177+ this.propertyFileURI = NbCatalogManager.class.getResource("/" + this.propertyFile);
178+ InputStream in = NbCatalogManager.class.getResourceAsStream("/" + this.propertyFile);
179+ if (in == null)
180+ {
181+ if (!this.ignoreMissingProperties)
182+ {
183+ this.debug.message(2, "Cannot find " + this.propertyFile);
184+
185+ this.ignoreMissingProperties = true;
186+ }
187+ return;
188+ }
189+ this.resources = new PropertyResourceBundle(in);
190+ }
191+ catch (MissingResourceException mre)
192+ {
193+ if (!this.ignoreMissingProperties) {
194+ System.err.println("Cannot read " + this.propertyFile);
195+ }
196+ }
197+ catch (IOException e)
198+ {
199+ if (!this.ignoreMissingProperties) {
200+ System.err.println("Failure trying to read " + this.propertyFile);
201+ }
202+ }
203+ if (this.verbosity == null) {
204+ try
205+ {
206+ String verbStr = this.resources.getString("verbosity");
207+ int verb = Integer.parseInt(verbStr.trim());
208+ this.debug.setDebug(verb);
209+ this.verbosity = new Integer(verb);
210+ }
211+ catch (Exception e) {}
212+ }
213+ }
214+
215+ public static CatalogManager getStaticManager()
216+ {
217+ return staticManager;
218+ }
219+
220+ public boolean getIgnoreMissingProperties()
221+ {
222+ return this.ignoreMissingProperties;
223+ }
224+
225+ public void setIgnoreMissingProperties(boolean ignore)
226+ {
227+ this.ignoreMissingProperties = ignore;
228+ }
229+
230+ /**
231+ * @deprecated
232+ */
233+ public void ignoreMissingProperties(boolean ignore)
234+ {
235+ setIgnoreMissingProperties(ignore);
236+ }
237+
238+ private int queryVerbosity()
239+ {
240+ String defaultVerbStr = Integer.toString(this.defaultVerbosity);
241+
242+ String verbStr = System.getProperty(pVerbosity);
243+ if (verbStr == null)
244+ {
245+ if (this.resources == null) {
246+ readProperties();
247+ }
248+ if (this.resources != null) {
249+ try
250+ {
251+ verbStr = this.resources.getString("verbosity");
252+ }
253+ catch (MissingResourceException e)
254+ {
255+ verbStr = defaultVerbStr;
256+ }
257+ } else {
258+ verbStr = defaultVerbStr;
259+ }
260+ }
261+ int verb = this.defaultVerbosity;
262+ try
263+ {
264+ verb = Integer.parseInt(verbStr.trim());
265+ }
266+ catch (Exception e)
267+ {
268+ System.err.println("Cannot parse verbosity: \"" + verbStr + "\"");
269+ }
270+ if (this.verbosity == null)
271+ {
272+ this.debug.setDebug(verb);
273+ this.verbosity = new Integer(verb);
274+ }
275+ return verb;
276+ }
277+
278+ public int getVerbosity()
279+ {
280+ if (this.verbosity == null) {
281+ this.verbosity = new Integer(queryVerbosity());
282+ }
283+ return this.verbosity.intValue();
284+ }
285+
286+ public void setVerbosity(int verbosity)
287+ {
288+ this.verbosity = new Integer(verbosity);
289+ this.debug.setDebug(verbosity);
290+ }
291+
292+ /**
293+ * @deprecated
294+ */
295+ public int verbosity()
296+ {
297+ return getVerbosity();
298+ }
299+
300+ private boolean queryRelativeCatalogs()
301+ {
302+ if (this.resources == null) {
303+ readProperties();
304+ }
305+ if (this.resources == null) {
306+ return this.defaultRelativeCatalogs;
307+ }
308+ try
309+ {
310+ String allow = this.resources.getString("relative-catalogs");
311+ return (allow.equalsIgnoreCase("true")) || (allow.equalsIgnoreCase("yes")) || (allow.equalsIgnoreCase("1"));
312+ }
313+ catch (MissingResourceException e) {}
314+ return this.defaultRelativeCatalogs;
315+ }
316+
317+ public boolean getRelativeCatalogs()
318+ {
319+ if (this.relativeCatalogs == null) {
320+ this.relativeCatalogs = new Boolean(queryRelativeCatalogs());
321+ }
322+ return this.relativeCatalogs.booleanValue();
323+ }
324+
325+ public void setRelativeCatalogs(boolean relative)
326+ {
327+ this.relativeCatalogs = new Boolean(relative);
328+ }
329+
330+ /**
331+ * @deprecated
332+ */
333+ public boolean relativeCatalogs()
334+ {
335+ return getRelativeCatalogs();
336+ }
337+
338+ private String queryCatalogFiles()
339+ {
340+ String catalogList = System.getProperty(pFiles);
341+ this.fromPropertiesFile = false;
342+ if (catalogList == null)
343+ {
344+ if (this.resources == null) {
345+ readProperties();
346+ }
347+ if (this.resources != null) {
348+ try
349+ {
350+ catalogList = this.resources.getString("catalogs");
351+ this.fromPropertiesFile = true;
352+ }
353+ catch (MissingResourceException e)
354+ {
355+ System.err.println(this.propertyFile + ": catalogs not found.");
356+ catalogList = null;
357+ }
358+ }
359+ }
360+ if (catalogList == null) {
361+ catalogList = this.defaultCatalogFiles;
362+ }
363+ return catalogList;
364+ }
365+
366+ public Vector getCatalogFiles()
367+ {
368+ if (this.catalogFiles == null) {
369+ this.catalogFiles = queryCatalogFiles();
370+ }
371+ StringTokenizer files = new StringTokenizer(this.catalogFiles, ";");
372+ Vector catalogs = new Vector();
373+ while (files.hasMoreTokens())
374+ {
375+ String catalogFile = files.nextToken();
376+ URL absURI = null;
377+ if ((this.fromPropertiesFile) && (!relativeCatalogs())) {
378+ try
379+ {
380+ absURI = new URL(this.propertyFileURI, catalogFile);
381+ catalogFile = absURI.toString();
382+ }
383+ catch (MalformedURLException mue)
384+ {
385+ absURI = null;
386+ }
387+ }
388+ catalogs.add(catalogFile);
389+ }
390+ return catalogs;
391+ }
392+
393+ public void setCatalogFiles(String fileList)
394+ {
395+ this.catalogFiles = fileList;
396+ this.fromPropertiesFile = false;
397+ }
398+
399+ /**
400+ * @deprecated
401+ */
402+ public Vector catalogFiles()
403+ {
404+ return getCatalogFiles();
405+ }
406+
407+ private boolean queryPreferPublic()
408+ {
409+ String prefer = System.getProperty(pPrefer);
410+ if (prefer == null)
411+ {
412+ if (this.resources == null) {
413+ readProperties();
414+ }
415+ if (this.resources == null) {
416+ return this.defaultPreferPublic;
417+ }
418+ try
419+ {
420+ prefer = this.resources.getString("prefer");
421+ }
422+ catch (MissingResourceException e)
423+ {
424+ return this.defaultPreferPublic;
425+ }
426+ }
427+ if (prefer == null) {
428+ return this.defaultPreferPublic;
429+ }
430+ return prefer.equalsIgnoreCase("public");
431+ }
432+
433+ public boolean getPreferPublic()
434+ {
435+ if (this.preferPublic == null) {
436+ this.preferPublic = new Boolean(queryPreferPublic());
437+ }
438+ return this.preferPublic.booleanValue();
439+ }
440+
441+ public void setPreferPublic(boolean preferPublic)
442+ {
443+ this.preferPublic = new Boolean(preferPublic);
444+ }
445+
446+ /**
447+ * @deprecated
448+ */
449+ public boolean preferPublic()
450+ {
451+ return getPreferPublic();
452+ }
453+
454+ private boolean queryUseStaticCatalog()
455+ {
456+ String staticCatalog = System.getProperty(pStatic);
457+ if (staticCatalog == null)
458+ {
459+ if (this.resources == null) {
460+ readProperties();
461+ }
462+ if (this.resources == null) {
463+ return this.defaultUseStaticCatalog;
464+ }
465+ try
466+ {
467+ staticCatalog = this.resources.getString("static-catalog");
468+ }
469+ catch (MissingResourceException e)
470+ {
471+ return this.defaultUseStaticCatalog;
472+ }
473+ }
474+ if (staticCatalog == null) {
475+ return this.defaultUseStaticCatalog;
476+ }
477+ return (staticCatalog.equalsIgnoreCase("true")) || (staticCatalog.equalsIgnoreCase("yes")) || (staticCatalog.equalsIgnoreCase("1"));
478+ }
479+
480+ public boolean getUseStaticCatalog()
481+ {
482+ if (this.useStaticCatalog == null) {
483+ this.useStaticCatalog = new Boolean(queryUseStaticCatalog());
484+ }
485+ return this.useStaticCatalog.booleanValue();
486+ }
487+
488+ public void setUseStaticCatalog(boolean useStatic)
489+ {
490+ this.useStaticCatalog = new Boolean(useStatic);
491+ }
492+
493+ /**
494+ * @deprecated
495+ */
496+ public boolean staticCatalog()
497+ {
498+ return getUseStaticCatalog();
499+ }
500+
501+ public Catalog getPrivateCatalog()
502+ {
503+ Catalog catalog = staticCatalog;
504+ if (this.useStaticCatalog == null) {
505+ this.useStaticCatalog = new Boolean(getUseStaticCatalog());
506+ }
507+ if ((catalog == null) || (!this.useStaticCatalog.booleanValue()))
508+ {
509+ try
510+ {
511+ String catalogClassName = getCatalogClassName();
512+ if (catalogClassName == null) {
513+ catalog = new Catalog();
514+ } else {
515+ try
516+ {
517+ catalog = (Catalog)Class.forName(catalogClassName).newInstance();
518+ }
519+ catch (ClassNotFoundException cnfe)
520+ {
521+ this.debug.message(1, "Catalog class named '" + catalogClassName + "' could not be found. Using default.");
522+
523+ catalog = new Catalog();
524+ }
525+ catch (ClassCastException cnfe)
526+ {
527+ this.debug.message(1, "Class named '" + catalogClassName + "' is not a Catalog. Using default.");
528+
529+ catalog = new Catalog();
530+ }
531+ }
532+ catalog.setCatalogManager(this);
533+ catalog.setupReaders();
534+ catalog.loadSystemCatalogs();
535+ }
536+ catch (Exception ex)
537+ {
538+ ex.printStackTrace();
539+ }
540+ if (this.useStaticCatalog.booleanValue()) {
541+ staticCatalog = catalog;
542+ }
543+ }
544+ return catalog;
545+ }
546+
547+ public Catalog getCatalog()
548+ {
549+ Catalog catalog = staticCatalog;
550+ if (this.useStaticCatalog == null) {
551+ this.useStaticCatalog = new Boolean(getUseStaticCatalog());
552+ }
553+ if ((catalog == null) || (!this.useStaticCatalog.booleanValue()))
554+ {
555+ catalog = getPrivateCatalog();
556+ if (this.useStaticCatalog.booleanValue()) {
557+ staticCatalog = catalog;
558+ }
559+ }
560+ return catalog;
561+ }
562+
563+ public boolean queryAllowOasisXMLCatalogPI()
564+ {
565+ String allow = System.getProperty(pAllowPI);
566+ if (allow == null)
567+ {
568+ if (this.resources == null) {
569+ readProperties();
570+ }
571+ if (this.resources == null) {
572+ return this.defaultOasisXMLCatalogPI;
573+ }
574+ try
575+ {
576+ allow = this.resources.getString("allow-oasis-xml-catalog-pi");
577+ }
578+ catch (MissingResourceException e)
579+ {
580+ return this.defaultOasisXMLCatalogPI;
581+ }
582+ }
583+ if (allow == null) {
584+ return this.defaultOasisXMLCatalogPI;
585+ }
586+ return (allow.equalsIgnoreCase("true")) || (allow.equalsIgnoreCase("yes")) || (allow.equalsIgnoreCase("1"));
587+ }
588+
589+ public boolean getAllowOasisXMLCatalogPI()
590+ {
591+ if (this.oasisXMLCatalogPI == null) {
592+ this.oasisXMLCatalogPI = new Boolean(queryAllowOasisXMLCatalogPI());
593+ }
594+ return this.oasisXMLCatalogPI.booleanValue();
595+ }
596+
597+ public void setAllowOasisXMLCatalogPI(boolean allowPI)
598+ {
599+ this.oasisXMLCatalogPI = new Boolean(allowPI);
600+ }
601+
602+ /**
603+ * @deprecated
604+ */
605+ public boolean allowOasisXMLCatalogPI()
606+ {
607+ return getAllowOasisXMLCatalogPI();
608+ }
609+
610+ public String queryCatalogClassName()
611+ {
612+ String className = System.getProperty(pClassname);
613+ if (className == null)
614+ {
615+ if (this.resources == null) {
616+ readProperties();
617+ }
618+ if (this.resources == null) {
619+ return null;
620+ }
621+ try
622+ {
623+ return this.resources.getString("catalog-class-name");
624+ }
625+ catch (MissingResourceException e)
626+ {
627+ return null;
628+ }
629+ }
630+ return className;
631+ }
632+
633+ public String getCatalogClassName()
634+ {
635+ if (this.catalogClassName == null) {
636+ this.catalogClassName = queryCatalogClassName();
637+ }
638+ return this.catalogClassName;
639+ }
640+
641+ public void setCatalogClassName(String className)
642+ {
643+ this.catalogClassName = className;
644+ }
645+
646+ /**
647+ * @deprecated
648+ */
649+ public String catalogClassName()
650+ {
651+ return getCatalogClassName();
652+ }
653+}
654diff -urN orig/src/org/apache/xml/resolver/tools/NbCatalogResolver.java mod/src/org/apache/xml/resolver/tools/NbCatalogResolver.java
655--- orig/src/org/apache/xml/resolver/tools/NbCatalogResolver.java 1970-01-01 00:00:00.000000000 +0000
656+++ mod/src/org/apache/xml/resolver/tools/NbCatalogResolver.java 2026-03-18 08:04:38.765863057 +0000
657@@ -0,0 +1,233 @@
658+/*
659+ * Licensed to the Apache Software Foundation (ASF) under one or more
660+ * contributor license agreements. See the NOTICE file distributed with
661+ * this work for additional information regarding copyright ownership.
662+ * The ASF licenses this file to You under the Apache License, Version 2.0
663+ * (the "License"); you may not use this file except in compliance with
664+ * the License. You may obtain a copy of the License at
665+ *
666+ * http://www.apache.org/licenses/LICENSE-2.0
667+ *
668+ * Unless required by applicable law or agreed to in writing, software
669+ * distributed under the License is distributed on an "AS IS" BASIS,
670+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
671+ * See the License for the specific language governing permissions and
672+ * limitations under the License.
673+ */
674+package org.apache.xml.resolver.tools;
675+
676+import java.io.IOException;
677+import java.net.MalformedURLException;
678+import java.net.URL;
679+import javax.xml.parsers.ParserConfigurationException;
680+import javax.xml.parsers.SAXParser;
681+import javax.xml.parsers.SAXParserFactory;
682+import javax.xml.transform.Source;
683+import javax.xml.transform.TransformerException;
684+import javax.xml.transform.URIResolver;
685+import javax.xml.transform.sax.SAXSource;
686+import org.apache.xml.resolver.Catalog;
687+import org.apache.xml.resolver.CatalogManager;
688+import org.apache.xml.resolver.NbCatalogManager;
689+import org.apache.xml.resolver.helpers.Debug;
690+import org.apache.xml.resolver.helpers.FileURL;
691+import org.xml.sax.EntityResolver;
692+import org.xml.sax.InputSource;
693+import org.xml.sax.SAXException;
694+import org.xml.sax.XMLReader;
695+
696+public class NbCatalogResolver
697+ implements EntityResolver, URIResolver
698+{
699+ public boolean namespaceAware = true;
700+ public boolean validating = false;
701+ private Catalog catalog = null;
702+ private CatalogManager catalogManager = NbCatalogManager.getStaticManager();
703+
704+ public NbCatalogResolver()
705+ {
706+ initializeCatalogs(false);
707+ }
708+
709+ public NbCatalogResolver(boolean privateCatalog)
710+ {
711+ initializeCatalogs(privateCatalog);
712+ }
713+
714+ public NbCatalogResolver(NbCatalogManager manager)
715+ {
716+ this.catalogManager = manager;
717+ initializeCatalogs(!this.catalogManager.getUseStaticCatalog());
718+ }
719+
720+ private void initializeCatalogs(boolean privateCatalog)
721+ {
722+ this.catalog = this.catalogManager.getCatalog();
723+ }
724+
725+ public Catalog getCatalog()
726+ {
727+ return this.catalog;
728+ }
729+
730+ public String getResolvedEntity(String publicId, String systemId)
731+ {
732+ String resolved = null;
733+ if (this.catalog == null)
734+ {
735+ this.catalogManager.debug.message(1, "Catalog resolution attempted with null catalog; ignored");
736+ return null;
737+ }
738+ if (systemId != null) {
739+ try
740+ {
741+ resolved = this.catalog.resolveSystem(systemId);
742+ }
743+ catch (MalformedURLException me)
744+ {
745+ this.catalogManager.debug.message(1, "Malformed URL exception trying to resolve", publicId);
746+
747+ resolved = null;
748+ }
749+ catch (IOException ie)
750+ {
751+ this.catalogManager.debug.message(1, "I/O exception trying to resolve", publicId);
752+ resolved = null;
753+ }
754+ }
755+ if (resolved == null)
756+ {
757+ if (publicId != null) {
758+ try
759+ {
760+ resolved = this.catalog.resolvePublic(publicId, systemId);
761+ }
762+ catch (MalformedURLException me)
763+ {
764+ this.catalogManager.debug.message(1, "Malformed URL exception trying to resolve", publicId);
765+ }
766+ catch (IOException ie)
767+ {
768+ this.catalogManager.debug.message(1, "I/O exception trying to resolve", publicId);
769+ }
770+ }
771+ if (resolved != null) {
772+ this.catalogManager.debug.message(2, "Resolved public", publicId, resolved);
773+ }
774+ }
775+ else
776+ {
777+ this.catalogManager.debug.message(2, "Resolved system", systemId, resolved);
778+ }
779+ return resolved;
780+ }
781+
782+ public InputSource resolveEntity(String publicId, String systemId)
783+ {
784+ String resolved = getResolvedEntity(publicId, systemId);
785+ if (resolved != null)
786+ {
787+ InputSource iSource = new InputSource(resolved);
788+ iSource.setPublicId(publicId);
789+ return iSource;
790+ }
791+ return null;
792+ }
793+
794+ public Source resolve(String href, String base)
795+ throws TransformerException
796+ {
797+ String uri = href;
798+ String fragment = null;
799+ int hashPos = href.indexOf("#");
800+ if (hashPos >= 0)
801+ {
802+ uri = href.substring(0, hashPos);
803+ fragment = href.substring(hashPos + 1);
804+ }
805+ String result = null;
806+ try
807+ {
808+ result = this.catalog.resolveURI(href);
809+ }
810+ catch (Exception e) {}
811+ if (result == null) {
812+ try
813+ {
814+ URL url = null;
815+ if (base == null)
816+ {
817+ url = new URL(uri);
818+ result = url.toString();
819+ }
820+ else
821+ {
822+ URL baseURL = new URL(base);
823+ url = href.length() == 0 ? baseURL : new URL(baseURL, uri);
824+ result = url.toString();
825+ }
826+ }
827+ catch (MalformedURLException mue)
828+ {
829+ String absBase = makeAbsolute(base);
830+ if (!absBase.equals(base)) {
831+ return resolve(href, absBase);
832+ }
833+ throw new TransformerException("Malformed URL " + href + "(base " + base + ")", mue);
834+ }
835+ }
836+ this.catalogManager.debug.message(2, "Resolved URI", href, result);
837+
838+ SAXSource source = new SAXSource();
839+ source.setInputSource(new InputSource(result));
840+ setEntityResolver(source);
841+ return source;
842+ }
843+
844+ private void setEntityResolver(SAXSource source)
845+ throws TransformerException
846+ {
847+ XMLReader reader = source.getXMLReader();
848+ if (reader == null)
849+ {
850+ SAXParserFactory spFactory = SAXParserFactory.newInstance();
851+ spFactory.setNamespaceAware(true);
852+ try
853+ {
854+ reader = spFactory.newSAXParser().getXMLReader();
855+ }
856+ catch (ParserConfigurationException ex)
857+ {
858+ throw new TransformerException(ex);
859+ }
860+ catch (SAXException ex)
861+ {
862+ throw new TransformerException(ex);
863+ }
864+ }
865+ reader.setEntityResolver(this);
866+ source.setXMLReader(reader);
867+ }
868+
869+ private String makeAbsolute(String uri)
870+ {
871+ if (uri == null) {
872+ uri = "";
873+ }
874+ try
875+ {
876+ URL url = new URL(uri);
877+ return url.toString();
878+ }
879+ catch (MalformedURLException mue)
880+ {
881+ try
882+ {
883+ URL fileURL = FileURL.makeURL(uri);
884+ return fileURL.toString();
885+ }
886+ catch (MalformedURLException mue2) {}
887+ }
888+ return uri;
889+ }
890+}