File: nb-extra.diff

package info (click to toggle)
libxml-commons-resolver1.1-java 1.2-9
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,404 kB
  • sloc: java: 5,615; xml: 265; makefile: 6
file content (1166 lines) | stat: -rw-r--r-- 35,154 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
Index: libxml-commons-resolver1.1-java-1.2/src/org/apache/xml/resolver/NbCatalogManager.java
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ libxml-commons-resolver1.1-java-1.2/src/org/apache/xml/resolver/NbCatalogManager.java	2009-01-30 23:02:32.000000000 +0100
@@ -0,0 +1,840 @@
+// CatalogManager.java - Access CatalogManager.properties
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xml.resolver;
+
+import java.io.InputStream;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+
+import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
+import java.util.ResourceBundle;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import org.apache.xml.resolver.helpers.Debug;
+import org.apache.xml.resolver.helpers.BootstrapResolver;
+import org.apache.xml.resolver.Catalog;
+
+/**
+ * CatalogManager provides an interface to the catalog properties.
+ *
+ * <p>Properties can come from two places: from system properties or
+ * from a <i>CatalogManager.properties</i> file. This class provides a transparent
+ * interface to both, with system properties preferred over property file values.</p>
+ *
+ * <p>The following table summarizes the properties:</p>
+ *
+ * <table border="1">
+ * <thead>
+ * <tr>
+ * <td>System Property</td>
+ * <td>CatalogManager.properties<br/>Property</td>
+ * <td>Description</td>
+ * </tr>
+ * </thead>
+ * <tbody>
+ * <tr>
+ * <td>xml.catalog.ignoreMissing</td>
+ * <td>&#160;</td>
+ * <td>If true, a missing <i>CatalogManager.properties</i> file or missing properties
+ * within that file will not generate warning messages. See also the
+ * <i>ignoreMissingProperties</i> method.</td>
+ * </tr>
+ *
+ * <tr>
+ * <td>xml.catalog.files</td>
+ * <td>catalogs</td>
+ * <td>The <emph>semicolon-delimited</emph> list of catalog files.</td>
+ * </tr>
+ *
+ * <tr>
+ * <td>&#160;</td>
+ * <td>relative-catalogs</td>
+ * <td>If false, relative catalog URIs are made absolute with respect to the base URI of
+ * the <i>CatalogManager.properties</i> file. This setting only applies to catalog
+ * URIs obtained from the <i>catalogs</i> property <emph>in the</emph>
+ * <i>CatalogManager.properties</i> file</td>
+ * </tr>
+ *
+ * <tr>
+ * <td>xml.catalog.verbosity</td>
+ * <td>verbosity</td>
+ * <td>If non-zero, the Catalog classes will print informative and debugging messages.
+ * The higher the number, the more messages.</td>
+ * </tr>
+ *
+ * <tr>
+ * <td>xml.catalog.prefer</td>
+ * <td>prefer</td>
+ * <td>Which identifier is preferred, "public" or "system"?</td>
+ * </tr>
+ *
+ * <tr>
+ * <td>xml.catalog.staticCatalog</td>
+ * <td>static-catalog</td>
+ * <td>Should a single catalog be constructed for all parsing, or should a different
+ * catalog be created for each parser?</td>
+ * </tr>
+ *
+ * <tr>
+ * <td>xml.catalog.allowPI</td>
+ * <td>allow-oasis-xml-catalog-pi</td>
+ * <td>If the source document contains "oasis-xml-catalog" processing instructions,
+ * should they be used?</td>
+ * </tr>
+ *
+ * <tr>
+ * <td>xml.catalog.className</td>
+ * <td>catalog-class-name</td>
+ * <td>If you're using the convenience classes
+ * <tt>org.apache.xml.resolver.tools.*</tt>), this setting
+ * allows you to specify an alternate class name to use for the underlying
+ * catalog.</td>
+ * </tr>
+ * </tbody>
+ * </table>
+ *
+ * @see Catalog
+ *
+ * @author Norman Walsh
+ * <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
+ *
+ * @version 1.0
+ */
+
+public class NbCatalogManager extends CatalogManager {
+  private static String pFiles         = "xml.catalog.files";
+  private static String pVerbosity     = "xml.catalog.verbosity";
+  private static String pPrefer        = "xml.catalog.prefer";
+  private static String pStatic        = "xml.catalog.staticCatalog";
+  private static String pAllowPI       = "xml.catalog.allowPI";
+  private static String pClassname     = "xml.catalog.className";
+  private static String pIgnoreMissing = "xml.catalog.ignoreMissing";
+
+  /** A static CatalogManager instance for sharing */
+  private static NbCatalogManager staticManager = new NbCatalogManager();
+
+  /** The bootstrap resolver to use when loading XML Catalogs. */
+  private BootstrapResolver bResolver = new BootstrapResolver();
+
+  /** Flag to ignore missing property files and/or properties */
+  private boolean ignoreMissingProperties
+    = (System.getProperty(pIgnoreMissing) != null
+       || System.getProperty(pFiles) != null);
+
+  /** Holds the resources after they are loaded from the file. */
+  private ResourceBundle resources;
+
+  /** The name of the CatalogManager properties file. */
+  private String propertyFile = "CatalogManager.properties";
+
+  /** The location of the propertyFile */
+  private URL propertyFileURI = null;
+
+  /** Default catalog files list. */
+  private String defaultCatalogFiles = "./xcatalog";
+
+  /** Current catalog files list. */
+  private String catalogFiles = null;
+
+  /** Did the catalogFiles come from the properties file? */
+  private boolean fromPropertiesFile = false;
+
+  /** Default verbosity level if there is no property setting for it. */
+  private int defaultVerbosity = 1;
+
+  /** Current verbosity level. */
+  private Integer verbosity = null;
+
+  /** Default preference setting. */
+  private boolean defaultPreferPublic = true;
+
+  /** Current preference setting. */
+  private Boolean preferPublic = null;
+
+  /** Default setting of the static catalog flag. */
+  private boolean defaultUseStaticCatalog = true;
+
+  /** Current setting of the static catalog flag. */
+  private Boolean useStaticCatalog = null;
+
+  /** The static catalog used by this manager. */
+  private static Catalog staticCatalog = null;
+
+  /** Default setting of the oasisXMLCatalogPI flag. */
+  private boolean defaultOasisXMLCatalogPI = true;
+
+  /** Current setting of the oasisXMLCatalogPI flag. */
+  private Boolean oasisXMLCatalogPI = null;
+
+  /** Default setting of the relativeCatalogs flag. */
+  private boolean defaultRelativeCatalogs = true;
+
+  /** Current setting of the relativeCatalogs flag. */
+  private Boolean relativeCatalogs = null;
+
+  /** Current catalog class name. */
+  private String catalogClassName = null;
+
+  /** The manager's debug object. Used for printing debugging messages.
+   *
+   * <p>This field is public so that objects that have access to this
+   * CatalogManager can use this debug object.</p>
+   */
+  public Debug debug = null;
+
+  /** Constructor. */
+  public NbCatalogManager() {
+    debug = new Debug();
+    // Note that we don't setDebug() here; we do that lazily. Either the
+    // user will set it explicitly, or we'll do it automagically if they
+    // read from the propertyFile for some other reason. That way, there's
+    // no attempt to read from the file before the caller has had a chance
+    // to avoid it.
+  }
+
+  /**
+   * Constructor that specifies an explicit property file.
+   * @param propertyFile path to poperty file (e.g. com/resources/CatalogManager).
+   * <code>null</code> means that no property file is consulted at all.
+   */
+  public NbCatalogManager(String propertyFile) {
+    this.propertyFile = propertyFile;
+
+    debug = new Debug();
+    // Note that we don't setDebug() here; we do that lazily. Either the
+    // user will set it explicitly, or we'll do it automagically if they
+    // read from the propertyFile for some other reason. That way, there's
+    // no attempt to read from the file before the caller has had a chance
+    // to avoid it.
+  }
+
+  /** Set the bootstrap resolver.*/
+  public void setBootstrapResolver(BootstrapResolver resolver) {
+    bResolver = resolver;
+  }
+
+  /** Get the bootstrap resolver.*/
+  public BootstrapResolver getBootstrapResolver() {
+    return bResolver;
+  }
+
+  /**
+   * Load the properties from the propertyFile and build the
+   * resources from it.
+   */
+  private synchronized void readProperties() {
+      if (propertyFile == null) return;
+    try {
+      propertyFileURI = NbCatalogManager.class.getResource("/"+propertyFile);
+      InputStream in =
+	NbCatalogManager.class.getResourceAsStream("/"+propertyFile);
+      if (in==null) {
+	if (!ignoreMissingProperties) {
+        debug.message(2, "Cannot find "+propertyFile);
+	  // there's no reason to give this warning more than once
+	  ignoreMissingProperties = true;
+	}
+	return;
+      }
+      resources = new PropertyResourceBundle(in);
+    } catch (MissingResourceException mre) {
+      if (!ignoreMissingProperties) {
+	System.err.println("Cannot read "+propertyFile);
+      }
+    } catch (java.io.IOException e) {
+      if (!ignoreMissingProperties) {
+	System.err.println("Failure trying to read "+propertyFile);
+      }
+    }
+
+    // This is a bit of a hack. After we've successfully read the properties,
+    // use them to set the default debug level, if the user hasn't already set
+    // the default debug level.
+    if (verbosity == null) {
+      try {
+	String verbStr = resources.getString("verbosity");
+	int verb = Integer.parseInt(verbStr.trim());
+	debug.setDebug(verb);
+	verbosity = new Integer(verb);
+      } catch (Exception e) {
+	// nop
+      }
+    }
+  }
+
+  /**
+   * Allow access to the static CatalogManager
+   */
+  public static CatalogManager getStaticManager() {
+    return staticManager;
+  }
+
+  /**
+   * How are missing properties handled?
+   *
+   * <p>If true, missing or unreadable property files will
+   * not be reported. Otherwise, a message will be sent to System.err.
+   * </p>
+   */
+  public boolean getIgnoreMissingProperties() {
+    return ignoreMissingProperties;
+  }
+
+  /**
+   * How should missing properties be handled?
+   *
+   * <p>If ignore is true, missing or unreadable property files will
+   * not be reported. Otherwise, a message will be sent to System.err.
+   * </p>
+   */
+  public void setIgnoreMissingProperties(boolean ignore) {
+    ignoreMissingProperties = ignore;
+  }
+
+  /**
+   * How are missing properties handled?
+   *
+   * <p>If ignore is true, missing or unreadable property files will
+   * not be reported. Otherwise, a message will be sent to System.err.
+   * </p>
+   *
+   * @deprecated No longer static; use get/set methods.
+   */
+  public void ignoreMissingProperties(boolean ignore) {
+    setIgnoreMissingProperties(ignore);
+  }
+
+  /**
+   * Obtain the verbosity setting from the properties.
+   *
+   * @return The verbosity level from the propertyFile or the
+   * defaultVerbosity.
+   */
+  private int queryVerbosity () {
+    String defaultVerbStr = Integer.toString(defaultVerbosity);
+
+    String verbStr = System.getProperty(pVerbosity);
+
+    if (verbStr == null) {
+      if (resources==null) readProperties();
+      if (resources != null) {
+	try {
+	  verbStr = resources.getString("verbosity");
+	} catch (MissingResourceException e) {
+	  verbStr = defaultVerbStr;
+	}
+      } else {
+	verbStr = defaultVerbStr;
+      }
+    }
+
+    int verb = defaultVerbosity;
+
+    try {
+      verb = Integer.parseInt(verbStr.trim());
+    } catch (Exception e) {
+      System.err.println("Cannot parse verbosity: \"" + verbStr + "\"");
+    }
+
+    // This is a bit of a hack. After we've successfully got the verbosity,
+    // we have to use it to set the default debug level,
+    // if the user hasn't already set the default debug level.
+    if (verbosity == null) {
+      debug.setDebug(verb);
+      verbosity = new Integer(verb);
+    }
+
+    return verb;
+  }
+
+  /**
+   * What is the current verbosity?
+   */
+  public int getVerbosity() {
+    if (verbosity == null) {
+      verbosity = new Integer(queryVerbosity());
+    }
+
+    return verbosity.intValue();
+  }
+
+  /**
+   * Set the current verbosity.
+   */
+  public void setVerbosity (int verbosity) {
+    this.verbosity = new Integer(verbosity);
+    debug.setDebug(verbosity);
+  }
+
+  /**
+   * What is the current verbosity?
+   *
+   * @deprecated No longer static; use get/set methods.
+   */
+  public int verbosity () {
+    return getVerbosity();
+  }
+
+  /**
+   * Obtain the relativeCatalogs setting from the properties.
+   *
+   * @return The relativeCatalogs setting from the propertyFile or the
+   * defaultRelativeCatalogs.
+   */
+  private boolean queryRelativeCatalogs () {
+    if (resources==null) readProperties();
+
+    if (resources==null) return defaultRelativeCatalogs;
+
+    try {
+      String allow = resources.getString("relative-catalogs");
+      return (allow.equalsIgnoreCase("true")
+	      || allow.equalsIgnoreCase("yes")
+	      || allow.equalsIgnoreCase("1"));
+    } catch (MissingResourceException e) {
+      return defaultRelativeCatalogs;
+    }
+  }
+
+  /**
+   * Get the relativeCatalogs setting.
+   *
+   * <p>This property is used when the catalogFiles property is
+   * interrogated. If true, then relative catalog entry file names
+   * are returned. If false, relative catalog entry file names are
+   * made absolute with respect to the properties file before returning
+   * them.</p>
+   *
+   * <p>This property <emph>only applies</emph> when the catalog files
+   * come from a properties file. If they come from a system property or
+   * the default list, they are never considered relative. (What would
+   * they be relative to?)</p>
+   *
+   * <p>In the properties, a value of 'yes', 'true', or '1' is considered
+   * true, anything else is false.</p>
+   *
+   * @return The relativeCatalogs setting from the propertyFile or the
+   * defaultRelativeCatalogs.
+   */
+  public boolean getRelativeCatalogs () {
+    if (relativeCatalogs == null) {
+      relativeCatalogs = new Boolean(queryRelativeCatalogs());
+    }
+
+    return relativeCatalogs.booleanValue();
+  }
+
+  /**
+   * Set the relativeCatalogs setting.
+   *
+   * @see #getRelativeCatalogs()
+   */
+  public void setRelativeCatalogs (boolean relative) {
+    relativeCatalogs = new Boolean(relative);
+  }
+
+  /**
+   * Get the relativeCatalogs setting.
+   *
+   * @deprecated No longer static; use get/set methods.
+   */
+  public boolean relativeCatalogs () {
+    return getRelativeCatalogs();
+  }
+
+  /**
+   * Obtain the list of catalog files from the properties.
+   *
+   * @return A semicolon delimited list of catlog file URIs
+   */
+  private String queryCatalogFiles () {
+    String catalogList = System.getProperty(pFiles);
+    fromPropertiesFile = false;
+
+    if (catalogList == null) {
+      if (resources == null) readProperties();
+      if (resources != null) {
+	try {
+	  catalogList = resources.getString("catalogs");
+	  fromPropertiesFile = true;
+	} catch (MissingResourceException e) {
+	  System.err.println(propertyFile + ": catalogs not found.");
+	  catalogList = null;
+	}
+      }
+    }
+
+    if (catalogList == null) {
+      catalogList = defaultCatalogFiles;
+    }
+
+    return catalogList;
+  }
+
+  /**
+   * Return the current list of catalog files.
+   *
+   * @return A vector of the catalog file names or null if no catalogs
+   * are available in the properties.
+   */
+  public Vector getCatalogFiles() {
+    if (catalogFiles == null) {
+      catalogFiles = queryCatalogFiles();
+    }
+
+    StringTokenizer files = new StringTokenizer(catalogFiles, ";");
+    Vector catalogs = new Vector();
+    while (files.hasMoreTokens()) {
+      String catalogFile = files.nextToken();
+      URL absURI = null;
+
+      if (fromPropertiesFile && !relativeCatalogs()) {
+	try {
+	  absURI = new URL(propertyFileURI, catalogFile);
+	  catalogFile = absURI.toString();
+	} catch (MalformedURLException mue) {
+	  absURI = null;
+	}
+      }
+
+      catalogs.add(catalogFile);
+    }
+
+    return catalogs;
+  }
+
+  /**
+   * Set the list of catalog files.
+   */
+  public void setCatalogFiles(String fileList) {
+    catalogFiles = fileList;
+    fromPropertiesFile = false;
+  }
+
+  /**
+   * Return the current list of catalog files.
+   *
+   * @return A vector of the catalog file names or null if no catalogs
+   * are available in the properties.
+   *
+   * @deprecated No longer static; use get/set methods.
+   */
+  public Vector catalogFiles() {
+    return getCatalogFiles();
+  }
+
+  /**
+   * Obtain the preferPublic setting from the properties.
+   *
+   * <p>In the properties, a value of 'public' is true,
+   * anything else is false.</p>
+   *
+   * @return True if prefer is public or the
+   * defaultPreferSetting.
+   */
+  private boolean queryPreferPublic () {
+    String prefer = System.getProperty(pPrefer);
+
+    if (prefer == null) {
+      if (resources==null) readProperties();
+      if (resources==null) return defaultPreferPublic;
+      try {
+	prefer = resources.getString("prefer");
+      } catch (MissingResourceException e) {
+	return defaultPreferPublic;
+      }
+    }
+
+    if (prefer == null) {
+      return defaultPreferPublic;
+    }
+
+    return (prefer.equalsIgnoreCase("public"));
+  }
+
+  /**
+   * Return the current prefer public setting.
+   *
+   * @return True if public identifiers are preferred.
+   */
+  public boolean getPreferPublic () {
+    if (preferPublic == null) {
+      preferPublic = new Boolean(queryPreferPublic());
+    }
+    return preferPublic.booleanValue();
+  }
+
+  /**
+   * Set the prefer public setting.
+   */
+  public void setPreferPublic (boolean preferPublic) {
+    this.preferPublic = new Boolean(preferPublic);
+  }
+
+  /**
+   * Return the current prefer public setting.
+   *
+   * @return True if public identifiers are preferred.
+   *
+   * @deprecated No longer static; use get/set methods.
+   */
+  public boolean preferPublic () {
+    return getPreferPublic();
+  }
+
+  /**
+   * Obtain the static-catalog setting from the properties.
+   *
+   * <p>In the properties, a value of 'yes', 'true', or '1' is considered
+   * true, anything else is false.</p>
+   *
+   * @return The static-catalog setting from the propertyFile or the
+   * defaultUseStaticCatalog.
+   */
+  private boolean queryUseStaticCatalog () {
+    String staticCatalog = System.getProperty(pStatic);
+
+    if (staticCatalog == null) {
+      if (resources==null) readProperties();
+      if (resources==null) return defaultUseStaticCatalog;
+      try {
+	staticCatalog = resources.getString("static-catalog");
+      } catch (MissingResourceException e) {
+	return defaultUseStaticCatalog;
+      }
+    }
+
+    if (staticCatalog == null) {
+      return defaultUseStaticCatalog;
+    }
+
+    return (staticCatalog.equalsIgnoreCase("true")
+	    || staticCatalog.equalsIgnoreCase("yes")
+	    || staticCatalog.equalsIgnoreCase("1"));
+  }
+
+  /**
+   * Get the current use static catalog setting.
+   */
+  public boolean getUseStaticCatalog() {
+    if (useStaticCatalog == null) {
+      useStaticCatalog = new Boolean(queryUseStaticCatalog());
+    }
+
+    return useStaticCatalog.booleanValue();
+  }
+
+  /**
+   * Set the use static catalog setting.
+   */
+  public void setUseStaticCatalog(boolean useStatic) {
+    useStaticCatalog = new Boolean(useStatic);
+  }
+
+  /**
+   * Get the current use static catalog setting.
+   *
+   * @deprecated No longer static; use get/set methods.
+   */
+  public boolean staticCatalog() {
+    return getUseStaticCatalog();
+  }
+
+  /**
+   * Get a new catalog instance.
+   *
+   * This method always returns a new instance of the underlying catalog class.
+   */
+  public Catalog getPrivateCatalog() {
+    Catalog catalog = staticCatalog;
+
+    if (useStaticCatalog == null) {
+      useStaticCatalog = new Boolean(getUseStaticCatalog());
+    }
+
+    if (catalog == null || !useStaticCatalog.booleanValue()) {
+
+      try {
+	String catalogClassName = getCatalogClassName();
+
+	if (catalogClassName == null) {
+	  catalog = new Catalog();
+	} else {
+	  try {
+	    catalog = (Catalog) Class.forName(catalogClassName).newInstance();
+	  } catch (ClassNotFoundException cnfe) {
+	    debug.message(1,"Catalog class named '"
+			  + catalogClassName
+			  + "' could not be found. Using default.");
+	    catalog = new Catalog();
+	  } catch (ClassCastException cnfe) {
+	    debug.message(1,"Class named '"
+			  + catalogClassName
+			  + "' is not a Catalog. Using default.");
+	    catalog = new Catalog();
+	  }
+	}
+
+	catalog.setCatalogManager(this);
+	catalog.setupReaders();
+	catalog.loadSystemCatalogs();
+      } catch (Exception ex) {
+	ex.printStackTrace();
+      }
+
+      if (useStaticCatalog.booleanValue()) {
+	staticCatalog = catalog;
+      }
+    }
+
+    return catalog;
+  }
+
+  /**
+   * Get a catalog instance.
+   *
+   * If this manager uses static catalogs, the same static catalog will
+   * always be returned. Otherwise a new catalog will be returned.
+   */
+  public Catalog getCatalog() {
+    Catalog catalog = staticCatalog;
+
+    if (useStaticCatalog == null) {
+      useStaticCatalog = new Boolean(getUseStaticCatalog());
+    }
+
+    if (catalog == null || !useStaticCatalog.booleanValue()) {
+      catalog = getPrivateCatalog();
+      if (useStaticCatalog.booleanValue()) {
+	staticCatalog = catalog;
+      }
+    }
+
+    return catalog;
+  }
+
+  /**
+   * <p>Obtain the oasisXMLCatalogPI setting from the properties.</p>
+   *
+   * <p>In the properties, a value of 'yes', 'true', or '1' is considered
+   * true, anything else is false.</p>
+   *
+   * @return The oasisXMLCatalogPI setting from the propertyFile or the
+   * defaultOasisXMLCatalogPI.
+   */
+  public boolean queryAllowOasisXMLCatalogPI () {
+    String allow = System.getProperty(pAllowPI);
+
+    if (allow == null) {
+      if (resources==null) readProperties();
+      if (resources==null) return defaultOasisXMLCatalogPI;
+      try {
+	allow = resources.getString("allow-oasis-xml-catalog-pi");
+      } catch (MissingResourceException e) {
+	return defaultOasisXMLCatalogPI;
+      }
+    }
+
+    if (allow == null) {
+      return defaultOasisXMLCatalogPI;
+    }
+
+    return (allow.equalsIgnoreCase("true")
+	    || allow.equalsIgnoreCase("yes")
+	    || allow.equalsIgnoreCase("1"));
+  }
+
+  /**
+   * Get the current XML Catalog PI setting.
+   */
+  public boolean getAllowOasisXMLCatalogPI () {
+    if (oasisXMLCatalogPI == null) {
+      oasisXMLCatalogPI = new Boolean(queryAllowOasisXMLCatalogPI());
+    }
+
+    return oasisXMLCatalogPI.booleanValue();
+  }
+
+  /**
+   * Set the XML Catalog PI setting
+   */
+  public void setAllowOasisXMLCatalogPI(boolean allowPI) {
+    oasisXMLCatalogPI = new Boolean(allowPI);
+  }
+
+  /**
+   * Get the current XML Catalog PI setting.
+   *
+   * @deprecated No longer static; use get/set methods.
+   */
+  public boolean allowOasisXMLCatalogPI() {
+    return getAllowOasisXMLCatalogPI();
+  }
+
+  /**
+   * Obtain the Catalog class name setting from the properties.
+   *
+   */
+  public String queryCatalogClassName () {
+    String className = System.getProperty(pClassname);
+
+    if (className == null) {
+      if (resources==null) readProperties();
+      if (resources==null) return null;
+      try {
+	return resources.getString("catalog-class-name");
+      } catch (MissingResourceException e) {
+	return null;
+      }
+    }
+
+    return className;
+  }
+
+  /**
+   * Get the current Catalog class name.
+   */
+  public String getCatalogClassName() {
+    if (catalogClassName == null) {
+      catalogClassName = queryCatalogClassName();
+    }
+
+    return catalogClassName;
+  }
+
+  /**
+   * Set the Catalog class name.
+   */
+  public void setCatalogClassName(String className) {
+    catalogClassName = className;
+  }
+
+  /**
+   * Get the current Catalog class name.
+   *
+   * @deprecated No longer static; use get/set methods.
+   */
+  public String catalogClassName() {
+    return getCatalogClassName();
+  }
+}
Index: libxml-commons-resolver1.1-java-1.2/src/org/apache/xml/resolver/tools/NbCatalogResolver.java
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ libxml-commons-resolver1.1-java-1.2/src/org/apache/xml/resolver/tools/NbCatalogResolver.java	2009-01-30 23:02:49.000000000 +0100
@@ -0,0 +1,316 @@
+// CatalogResolver.java - A SAX EntityResolver/JAXP URI Resolver
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xml.resolver.tools;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.MalformedURLException;
+
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.InputSource;
+import org.xml.sax.EntityResolver;
+
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.Source;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.TransformerException;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.apache.xml.resolver.Catalog;
+import org.apache.xml.resolver.CatalogManager;
+import org.apache.xml.resolver.NbCatalogManager;
+import org.apache.xml.resolver.helpers.FileURL;
+
+/**
+ * A SAX EntityResolver/JAXP URIResolver that uses catalogs.
+ *
+ * <p>This class implements both a SAX EntityResolver and a JAXP URIResolver.
+ * </p>
+ *
+ * <p>This resolver understands OASIS TR9401 catalogs, XCatalogs, and the
+ * current working draft of the OASIS Entity Resolution Technical
+ * Committee specification.</p>
+ *
+ * @see Catalog
+ * @see org.xml.sax.EntityResolver
+ * @see javax.xml.transform.URIResolver
+ *
+ * @author Norman Walsh
+ * <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
+ *
+ * @version 1.0
+ */
+public class NbCatalogResolver implements EntityResolver, URIResolver {
+  /** Make the parser Namespace aware? */
+  public boolean namespaceAware = true;
+
+  /** Make the parser validating? */
+  public boolean validating = false;
+
+  /** The underlying catalog */
+  private Catalog catalog = null;
+
+  /** The catalog manager */
+  private CatalogManager catalogManager = NbCatalogManager.getStaticManager();
+
+  /** Constructor */
+  public NbCatalogResolver() {
+    initializeCatalogs(false);
+  }
+
+  /** Constructor */
+  public NbCatalogResolver(boolean privateCatalog) {
+    initializeCatalogs(privateCatalog);
+  }
+
+  /** Constructor */
+  public NbCatalogResolver(NbCatalogManager manager) {
+    catalogManager = manager;
+    initializeCatalogs(!catalogManager.getUseStaticCatalog());
+  }
+
+  /** Initialize catalog */
+  private void initializeCatalogs(boolean privateCatalog) {
+    catalog = catalogManager.getCatalog();
+  }
+
+  /** Return the underlying catalog */
+  public Catalog getCatalog() {
+    return catalog;
+  }
+
+  /**
+   * Implements the guts of the <code>resolveEntity</code> method
+   * for the SAX interface.
+   *
+   * <p>Presented with an optional public identifier and a system
+   * identifier, this function attempts to locate a mapping in the
+   * catalogs.</p>
+   *
+   * <p>If such a mapping is found, it is returned.  If no mapping is
+   * found, null is returned.</p>
+   *
+   * @param publicId  The public identifier for the entity in question.
+   * This may be null.
+   *
+   * @param systemId  The system identifier for the entity in question.
+   * XML requires a system identifier on all external entities, so this
+   * value is always specified.
+   *
+   * @return The resolved identifier (a URI reference).
+   */
+  public String getResolvedEntity (String publicId, String systemId) {
+    String resolved = null;
+
+    if (catalog == null) {
+      catalogManager.debug.message(1, "Catalog resolution attempted with null catalog; ignored");
+      return null;
+    }
+
+    if (systemId != null) {
+      try {
+	resolved = catalog.resolveSystem(systemId);
+      } catch (MalformedURLException me) {
+	catalogManager.debug.message(1, "Malformed URL exception trying to resolve",
+		      publicId);
+	resolved = null;
+      } catch (IOException ie) {
+	catalogManager.debug.message(1, "I/O exception trying to resolve", publicId);
+	resolved = null;
+      }
+    }
+
+    if (resolved == null) {
+      if (publicId != null) {
+	try {
+	  resolved = catalog.resolvePublic(publicId, systemId);
+	} catch (MalformedURLException me) {
+	  catalogManager.debug.message(1, "Malformed URL exception trying to resolve",
+			publicId);
+	} catch (IOException ie) {
+	  catalogManager.debug.message(1, "I/O exception trying to resolve", publicId);
+	}
+      }
+
+      if (resolved != null) {
+	catalogManager.debug.message(2, "Resolved public", publicId, resolved);
+      }
+    } else {
+      catalogManager.debug.message(2, "Resolved system", systemId, resolved);
+    }
+
+    return resolved;
+  }
+
+  /**
+   * Implements the <code>resolveEntity</code> method
+   * for the SAX interface.
+   *
+   * <p>Presented with an optional public identifier and a system
+   * identifier, this function attempts to locate a mapping in the
+   * catalogs.</p>
+   *
+   * <p>If such a mapping is found, the resolver attempts to open
+   * the mapped value as an InputSource and return it. Exceptions are
+   * ignored and null is returned if the mapped value cannot be opened
+   * as an input source.</p>
+   *
+   * <p>If no mapping is found (or an error occurs attempting to open
+   * the mapped value as an input source), null is returned and the system
+   * will use the specified system identifier as if no entityResolver
+   * was specified.</p>
+   *
+   * @param publicId  The public identifier for the entity in question.
+   * This may be null.
+   *
+   * @param systemId  The system identifier for the entity in question.
+   * XML requires a system identifier on all external entities, so this
+   * value is always specified.
+   *
+   * @return An InputSource for the mapped identifier, or null.
+   */
+  public InputSource resolveEntity (String publicId, String systemId) {
+    String resolved = getResolvedEntity(publicId, systemId);
+
+    if (resolved != null) {
+      InputSource iSource = new InputSource(resolved);
+      iSource.setPublicId(publicId);
+      return iSource;
+    }
+
+    return null;
+  }
+  /** JAXP URIResolver API */
+  public Source resolve(String href, String base)
+    throws TransformerException {
+
+    String uri = href;
+    String fragment = null;
+    int hashPos = href.indexOf("#");
+    if (hashPos >= 0) {
+      uri = href.substring(0, hashPos);
+      fragment = href.substring(hashPos+1);
+    }
+
+    String result = null;
+
+    try {
+      result = catalog.resolveURI(href);
+    } catch (Exception e) {
+      // nop;
+    }
+
+    if (result == null) {
+      try {
+	URL url = null;
+
+	if (base==null) {
+	  url = new URL(uri);
+	  result = url.toString();
+	} else {
+	  URL baseURL = new URL(base);
+	  url = (href.length()==0 ? baseURL : new URL(baseURL, uri));
+	  result = url.toString();
+	}
+      } catch (java.net.MalformedURLException mue) {
+	// try to make an absolute URI from the current base
+	String absBase = makeAbsolute(base);
+	if (!absBase.equals(base)) {
+	  // don't bother if the absBase isn't different!
+	  return resolve(href, absBase);
+	} else {
+	  throw new TransformerException("Malformed URL "
+					 + href + "(base " + base + ")",
+					 mue);
+	}
+      }
+    }
+
+    catalogManager.debug.message(2, "Resolved URI", href, result);
+
+    SAXSource source = new SAXSource();
+    source.setInputSource(new InputSource(result));
+    setEntityResolver(source);
+    return source;
+  }
+
+  /**
+   * <p>Establish an entityResolver for newly resolved URIs.</p>
+   *
+   * <p>This is called from the URIResolver to set an EntityResolver
+   * on the SAX parser to be used for new XML documents that are
+   * encountered as a result of the document() function, xsl:import,
+   * or xsl:include.  This is done because the XSLT processor calls
+   * out to the SAXParserFactory itself to create a new SAXParser to
+   * parse the new document.  The new parser does not automatically
+   * inherit the EntityResolver of the original (although arguably
+   * it should).  See below:</p>
+   *
+   * <tt>"If an application wants to set the ErrorHandler or
+   * EntityResolver for an XMLReader used during a transformation,
+   * it should use a URIResolver to return the SAXSource which
+   * provides (with getXMLReader) a reference to the XMLReader"</tt>
+   *
+   * <p>...quoted from page 118 of the Java API for XML
+   * Processing 1.1 specification</p>
+   *
+   */
+  private void setEntityResolver(SAXSource source) throws TransformerException {
+    XMLReader reader = source.getXMLReader();
+    if (reader == null) {
+      SAXParserFactory spFactory = SAXParserFactory.newInstance();
+      spFactory.setNamespaceAware(true);
+      try {
+	reader = spFactory.newSAXParser().getXMLReader();
+      }
+      catch (ParserConfigurationException ex) {
+	throw new TransformerException(ex);
+      }
+      catch (SAXException ex) {
+	throw new TransformerException(ex);
+      }
+    }
+    reader.setEntityResolver(this);
+    source.setXMLReader(reader);
+  }
+
+  /** Attempt to construct an absolute URI */
+  private String makeAbsolute(String uri) {
+    if (uri == null) {
+      uri = "";
+    }
+
+    try {
+      URL url = new URL(uri);
+      return url.toString();
+    } catch (MalformedURLException mue) {
+      try {
+	URL fileURL = FileURL.makeURL(uri);
+	return fileURL.toString();
+      } catch (MalformedURLException mue2) {
+	// bail
+	return uri;
+      }
+    }
+  }
+}