1 package net.sf.saxon; 2 3 import net.sf.saxon.event.Builder; 4 import net.sf.saxon.event.PipelineConfiguration; 5 import net.sf.saxon.event.Receiver; 6 import net.sf.saxon.event.StandardOutputResolver; 7 import net.sf.saxon.expr.Optimizer; 8 import net.sf.saxon.expr.XPathContext; 9 import net.sf.saxon.functions.*; 10 import net.sf.saxon.instruct.Debugger; 11 import net.sf.saxon.instruct.SlotManager; 12 import net.sf.saxon.om.*; 13 import net.sf.saxon.pattern.NodeTest; 14 import net.sf.saxon.trace.TraceListener; 15 import net.sf.saxon.trans.XPathException; 16 import net.sf.saxon.trans.DynamicError; 17 import net.sf.saxon.type.*; 18 import net.sf.saxon.sort.CollationURIResolver; 19 import net.sf.saxon.sort.StandardCollationURIResolver; 20 import net.sf.saxon.pull.PullProvider; 21 import net.sf.saxon.query.ModuleURIResolver; 22 import net.sf.saxon.query.StandardModuleURIResolver; 23 import org.xml.sax.SAXException ; 24 import org.xml.sax.SAXNotRecognizedException ; 25 import org.xml.sax.SAXNotSupportedException ; 26 import org.xml.sax.XMLReader ; 27 28 import javax.xml.parsers.ParserConfigurationException ; 29 import javax.xml.parsers.SAXParserFactory ; 30 import javax.xml.transform.*; 31 import javax.xml.transform.dom.DOMSource ; 32 import javax.xml.transform.sax.SAXSource ; 33 import javax.xml.transform.stream.StreamSource ; 34 import java.io.Serializable ; 35 import java.util.*; 36 37 38 59 60 61 public class Configuration implements ConversionContext, Serializable , SourceResolver { 62 63 private transient URIResolver uriResolver; 64 private StandardURIResolver systemURIResolver = new StandardURIResolver(this); 65 protected transient ErrorListener listener; 66 private int treeModel = Builder.TINY_TREE; 67 private boolean lineNumbering = false; 68 private TraceListener traceListener = null; 69 private FunctionLibrary extensionBinder; 70 private CollationURIResolver collationResolver = StandardCollationURIResolver.getInstance(); 71 private CollectionURIResolver collectionResolver = new StandardCollectionURIResolver(); 72 private ModuleURIResolver moduleURIResolver = null; 73 private ModuleURIResolver standardModuleURIResolver = new StandardModuleURIResolver(); 74 private SourceResolver sourceResolver = this; 75 protected VendorFunctionLibrary vendorFunctionLibrary; 76 protected int recoveryPolicy = RECOVER_WITH_WARNINGS; 77 private String messageEmitterClass = "net.sf.saxon.event.MessageEmitter"; 78 private String sourceParserClass; 79 private String styleParserClass; 80 private transient OutputURIResolver outputURIResolver; 81 private boolean timing = false; 82 private boolean versionWarning = true; 83 private boolean allowExternalFunctions = true; 84 private boolean traceExternalFunctions = false; 85 private boolean validation = false; 86 private boolean allNodesUntyped = false; 87 private boolean lazyConstructionMode = false; 88 private boolean allowMultiThreading = false; 89 private NamePool targetNamePool = null; 90 private DocumentNumberAllocator documentNumberAllocator = new DocumentNumberAllocator(); 91 private boolean stripsAllWhiteSpace = false; 92 private int hostLanguage = XSLT; 93 private int schemaValidationMode = Validation.PRESERVE; 94 private boolean validationWarnings = false; 95 private boolean retainDTDattributeTypes = false; 96 private Debugger debugger = null; 97 protected Optimizer optimizer = null; 98 private ExtensionFunctionFactory extensionFunctionFactory = new ExtensionFunctionFactory(this); 99 private List externalObjectModels = new ArrayList(4); 100 private transient ClassLoader classLoader; 101 private int implicitTimezone; 102 private transient List sourceParserPool = new ArrayList(5); 103 private transient List styleParserPool = new ArrayList(5); 104 105 109 public static final int RECOVER_SILENTLY = 0; 110 115 public static final int RECOVER_WITH_WARNINGS = 1; 116 121 public static final int DO_NOT_RECOVER = 2; 122 123 126 public static final int XSLT = 10; 127 128 131 public static final int XQUERY = 11; 132 133 136 public static final int XML_SCHEMA = 12; 137 138 142 public static final int JAVA_APPLICATION = 13; 143 144 147 public static final int XPATH = 14; 148 149 153 154 public Configuration() { 155 targetNamePool = NamePool.getDefaultNamePool(); 156 extensionBinder = new JavaExtensionLibrary(this); 157 registerStandardObjectModels(); 158 159 GregorianCalendar calendar = new GregorianCalendar(); 161 int tzmsecs = (calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET)); 162 implicitTimezone = tzmsecs / 60000; 163 } 164 165 171 172 public String getProductTitle() { 173 return "Saxon " + Version.getProductVersion() + " from Saxonica"; 174 } 175 176 181 182 public boolean isSchemaAware(int language) { 183 return false; 184 } 186 187 190 191 public void displayLicenseMessage() {} 192 193 206 207 public int getHostLanguage() { 208 return hostLanguage; 209 } 210 211 216 217 public void setHostLanguage(int hostLanguage) { 218 this.hostLanguage = hostLanguage; 219 } 220 221 227 228 public URIResolver getURIResolver() { 229 if (uriResolver==null) { 230 return systemURIResolver; 231 } 232 return uriResolver; 233 } 234 235 245 246 public void setURIResolver(URIResolver resolver) { 247 this.uriResolver = resolver; 248 } 249 250 254 255 public StandardURIResolver getSystemURIResolver() { 256 return systemURIResolver; 257 } 258 259 267 public URIResolver makeURIResolver(String className) throws TransformerException { 268 Object obj = getInstance(className, null); 269 if (obj instanceof URIResolver) { 270 return (URIResolver)obj; 271 } 272 throw new DynamicError("Class " + className + " is not a URIResolver"); 273 } 274 275 281 282 public ErrorListener getErrorListener() { 283 if (listener == null) { 284 listener = new StandardErrorListener(); 285 ((StandardErrorListener)listener).setRecoveryPolicy(recoveryPolicy); 286 } 287 return listener; 288 } 289 290 297 298 public void setErrorListener(ErrorListener listener) { 299 this.listener = listener; 300 } 301 302 305 306 public void setMultiThreading(boolean multithreading) { 307 allowMultiThreading = multithreading; 308 } 309 310 313 314 public boolean isMultiThreading() { 315 return allowMultiThreading; 316 } 317 318 325 326 public int getTreeModel() { 327 return treeModel; 328 } 329 330 337 338 public void setTreeModel(int treeModel) { 339 this.treeModel = treeModel; 340 } 341 342 349 350 public boolean isLineNumbering() { 351 return lineNumbering; 352 } 353 354 361 362 public void setLineNumbering(boolean lineNumbering) { 363 this.lineNumbering = lineNumbering; 364 } 365 366 371 372 public TraceListener getTraceListener() { 373 return traceListener; 374 } 375 376 381 382 public void setTraceListener(TraceListener traceListener) { 383 this.traceListener = traceListener; 384 setMultiThreading(false); 385 } 386 387 395 396 public TraceListener makeTraceListener (String className) 397 throws XPathException 398 { 399 Object obj = getInstance(className, null); 400 if (obj instanceof TraceListener) { 401 return (TraceListener)obj; 402 } 403 throw new DynamicError("Class " + className + " is not a TraceListener"); 404 } 405 406 423 424 public void setExtensionBinder(FunctionLibrary binder) { 425 extensionBinder = binder; 426 } 427 428 435 436 public FunctionLibrary getExtensionBinder() { 437 return extensionBinder; 438 } 439 440 445 446 public VendorFunctionLibrary getVendorFunctionLibrary() { 447 if (vendorFunctionLibrary == null) { 448 vendorFunctionLibrary = new VendorFunctionLibrary(); 449 } 450 return vendorFunctionLibrary; 451 } 452 453 467 468 public void setCollationURIResolver(CollationURIResolver resolver) { 469 collationResolver = resolver; 470 } 471 472 479 480 public CollationURIResolver getCollationURIResolver() { 481 return collationResolver; 482 } 483 484 494 495 public void setCollectionURIResolver(CollectionURIResolver resolver) { 496 collectionResolver = resolver; 497 } 498 499 506 507 public CollectionURIResolver getCollectionURIResolver() { 508 return collectionResolver; 509 } 510 511 515 516 public void setModuleURIResolver(ModuleURIResolver resolver) { 517 moduleURIResolver = resolver; 518 } 519 520 527 public void setModuleURIResolver(String className) throws TransformerException { 528 Object obj = getInstance(className, null); 529 if (obj instanceof ModuleURIResolver) { 530 setModuleURIResolver((ModuleURIResolver)obj); 531 } 532 throw new DynamicError("Class " + className + " is not a ModuleURIResolver"); 533 } 534 535 539 540 public ModuleURIResolver getModuleURIResolver() { 541 return moduleURIResolver; 542 } 543 544 548 549 public ModuleURIResolver getStandardModuleURIResolver() { 550 return standardModuleURIResolver; 551 } 552 553 560 561 public int getRecoveryPolicy() { 562 return recoveryPolicy; 563 } 564 565 575 576 public void setRecoveryPolicy(int recoveryPolicy) { 577 this.recoveryPolicy = recoveryPolicy; 578 } 579 580 586 587 public String getMessageEmitterClass() { 588 return messageEmitterClass; 589 } 590 591 598 599 public void setMessageEmitterClass(String messageEmitterClass) { 600 this.messageEmitterClass = messageEmitterClass; 601 } 602 603 613 614 public String getSourceParserClass() { 615 return sourceParserClass; 616 } 617 618 630 631 public void setSourceParserClass(String sourceParserClass) { 632 this.sourceParserClass = sourceParserClass; 633 } 634 635 645 646 public String getStyleParserClass() { 647 return styleParserClass; 648 } 649 650 660 661 public void setStyleParserClass(String styleParserClass) { 662 this.styleParserClass = styleParserClass; 663 } 664 665 672 673 public OutputURIResolver getOutputURIResolver() { 674 if (outputURIResolver==null) { 675 outputURIResolver = StandardOutputResolver.getInstance(); 676 } 677 return outputURIResolver; 678 } 679 680 686 687 public void setOutputURIResolver(OutputURIResolver outputURIResolver) { 688 this.outputURIResolver = outputURIResolver; 689 } 690 691 701 702 public boolean isTiming() { 703 return timing; 704 } 705 706 715 716 public void setTiming(boolean timing) { 717 this.timing = timing; 718 } 719 720 726 727 public boolean isVersionWarning() { 728 return versionWarning; 729 } 730 731 737 738 public void setVersionWarning(boolean warn) { 739 this.versionWarning = warn; 740 } 741 742 747 748 public boolean isAllowExternalFunctions() { 749 return allowExternalFunctions; 750 } 751 752 763 764 public void setAllowExternalFunctions(boolean allowExternalFunctions) { 765 this.allowExternalFunctions = allowExternalFunctions; 766 } 767 768 773 774 public boolean isTraceExternalFunctions() { 775 return traceExternalFunctions; 776 } 777 778 785 786 public void setRetainDTDAttributeTypes(boolean useTypes) throws TransformerFactoryConfigurationError { 787 if (useTypes && !isSchemaAware(Configuration.XML_SCHEMA)) { 788 throw new TransformerFactoryConfigurationError( 789 "Retaining DTD attribute types requires the schema-aware product"); 790 } 791 retainDTDattributeTypes = useTypes; 792 } 793 794 801 802 public boolean isRetainDTDAttributeTypes() { 803 return retainDTDattributeTypes; 804 } 805 811 812 public void setTraceExternalFunctions(boolean traceExternalFunctions) { 813 this.traceExternalFunctions = traceExternalFunctions; 814 } 815 816 826 827 public ExtensionFunctionFactory getExtensionFunctionFactory() { 828 return extensionFunctionFactory; 829 } 830 831 841 842 public void setExtensionFunctionFactory(ExtensionFunctionFactory factory) { 843 extensionFunctionFactory = factory; 844 } 845 851 852 public boolean isValidation() { 853 return validation; 854 } 855 856 862 863 public void setValidation(boolean validation) { 864 this.validation = validation; 865 } 866 867 870 871 public void setAllNodesUntyped(boolean allUntyped) { 872 allNodesUntyped = allUntyped; 873 } 874 875 879 880 public boolean areAllNodesUntyped() { 881 return allNodesUntyped; 882 } 883 884 890 891 public int getSchemaValidationMode() { 892 return schemaValidationMode; 893 } 894 895 903 904 public void setSchemaValidationMode(int validationMode) { 905 switch (validationMode) { 906 case Validation.STRIP: 907 case Validation.PRESERVE: 908 break; 909 case Validation.LAX: 910 case Validation.STRICT: 911 if (!isSchemaAware(XML_SCHEMA)) { 912 needSchemaAwareVersion(); 913 } 914 break; 915 default: 916 throw new IllegalArgumentException ("Unsupported validation mode " + validationMode); 917 } 918 schemaValidationMode = validationMode; 919 } 920 921 929 930 public void setValidationWarnings(boolean warn) { 931 validationWarnings = warn; 932 } 933 934 942 943 public boolean isValidationWarnings() { 944 return validationWarnings; 945 } 946 947 953 954 public NamePool getNamePool() { 955 return targetNamePool; 956 } 957 958 972 973 public void setNamePool(NamePool targetNamePool) { 974 this.targetNamePool = targetNamePool; 975 } 976 977 982 983 public DocumentNumberAllocator getDocumentNumberAllocator() { 984 return documentNumberAllocator; 985 } 986 987 993 994 public boolean isStripsAllWhiteSpace() { 995 return stripsAllWhiteSpace; 996 } 997 998 1004 1005 public void setStripsAllWhiteSpace(boolean stripsAllWhiteSpace) { 1006 this.stripsAllWhiteSpace = stripsAllWhiteSpace; 1007 } 1008 1009 1016 1017 public synchronized XMLReader getSourceParser() throws TransformerFactoryConfigurationError { 1018 if (sourceParserPool == null) { 1019 sourceParserPool = new ArrayList(10); 1020 } 1021 if (sourceParserPool.size() > 0) { 1022 int n = sourceParserPool.size()-1; 1023 XMLReader parser = (XMLReader )sourceParserPool.get(n); 1024 sourceParserPool.remove(n); 1025 return parser; 1026 } 1027 XMLReader parser; 1028 if (getSourceParserClass()!=null) { 1029 parser = makeParser(getSourceParserClass()); 1030 } else { 1031 parser = loadParser(); 1032 } 1033 if (isValidation()) { 1034 try { 1035 parser.setFeature("http://xml.org/sax/features/validation", true); 1036 } catch (SAXException err) { 1037 throw new TransformerFactoryConfigurationError("The XML parser does not support validation"); 1038 } 1039 } 1040 1041 return parser; 1042 } 1043 1044 1049 1050 public synchronized void reuseSourceParser(XMLReader parser) { 1051 if (sourceParserPool == null) { 1052 sourceParserPool = new ArrayList(10); 1053 } 1054 sourceParserPool.add(parser); 1055 } 1056 1057 1061 1062 private XMLReader loadParser() { 1063 XMLReader parser; 1064 try { 1065 parser = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); 1066 } catch (ParserConfigurationException err) { 1067 throw new TransformerFactoryConfigurationError(err); 1068 } catch (SAXException err) { 1069 throw new TransformerFactoryConfigurationError(err); 1070 } 1071 return parser; 1072 } 1073 1074 1080 1081 public synchronized XMLReader getStyleParser() throws TransformerFactoryConfigurationError { 1082 if (styleParserPool == null) { 1083 styleParserPool = new ArrayList(10); 1084 } 1085 if (styleParserPool.size() > 0) { 1086 int n = styleParserPool.size()-1; 1087 XMLReader parser = (XMLReader )styleParserPool.get(n); 1088 styleParserPool.remove(n); 1089 return parser; 1090 } 1091 XMLReader parser; 1092 if (getStyleParserClass()!=null) { 1093 parser = makeParser(getStyleParserClass()); 1094 } else { 1095 parser = loadParser(); 1096 } 1097 try { 1098 parser.setFeature("http://xml.org/sax/features/namespaces", true); 1099 parser.setFeature("http://xml.org/sax/features/namespace-prefixes", false); 1100 } catch (SAXNotRecognizedException e) { 1101 throw new TransformerFactoryConfigurationError(e); 1102 } catch (SAXNotSupportedException e) { 1103 throw new TransformerFactoryConfigurationError(e); 1104 } 1105 return parser; 1106 } 1107 1108 1113 1114 public synchronized void reuseStyleParser(XMLReader parser) { 1115 if (styleParserPool == null) { 1116 styleParserPool = new ArrayList(10); 1117 } 1118 styleParserPool.add(parser); 1119 } 1120 1121 1127 1128 public String readSchema(PipelineConfiguration pipe, String baseURI, String schemaLocation, String expected) 1129 throws TransformerConfigurationException { 1130 needSchemaAwareVersion(); 1131 return null; 1132 } 1133 1134 1139 1140 public void readMultipleSchemas(PipelineConfiguration pipe, String baseURI, List schemaLocations, String expected) 1141 throws SchemaException { 1142 needSchemaAwareVersion(); 1143 } 1144 1145 1146 1157 1158 public String readInlineSchema(PipelineConfiguration pipe, NodeInfo root, String expected) 1159 throws SchemaException { 1160 needSchemaAwareVersion(); 1161 return null; 1162 } 1163 1164 private void needSchemaAwareVersion() { 1165 throw new UnsupportedOperationException ( 1166 "You need the schema-aware version of Saxon for this operation"); 1167 } 1168 1169 1176 1177 public void addSchemaSource(Source schemaSource) throws SchemaException { 1178 needSchemaAwareVersion(); 1179 } 1180 1181 1188 1189 public void addSchema(Object schema) 1190 throws TransformerConfigurationException { 1191 needSchemaAwareVersion(); 1192 } 1193 1194 1201 1202 public Object getSchema(String namespace) { 1203 return null; 1204 } 1205 1206 1214 1215 public SchemaDeclaration getElementDeclaration(int fingerprint) { 1216 return null; 1217 } 1218 1219 1227 1228 public SchemaDeclaration getAttributeDeclaration(int fingerprint) { 1229 return null; 1230 } 1231 1232 1243 1244 public SchemaType getSchemaType(int fingerprint) { 1245 if (fingerprint < 1023) { 1246 return BuiltInSchemaFactory.getSchemaType(fingerprint); 1247 } 1248 return null; 1249 } 1250 1251 1265 1266 public Receiver getDocumentValidator(Receiver receiver, 1267 String systemId, 1268 NamePool namePool, 1269 int validationMode, 1270 SchemaType schemaType) { 1271 return receiver; 1273 } 1274 1275 1291 public Receiver getElementValidator(Receiver receiver, 1292 int nameCode, 1293 int locationId, 1294 SchemaType schemaType, 1295 int validation, 1296 NamePool pool) 1297 throws XPathException { 1298 return receiver; 1299 } 1300 1301 1311 1312 public int validateAttribute(int nameCode, CharSequence value, int validation) 1313 throws ValidationException { 1314 return -1; 1315 } 1316 1317 1324 1325 public Receiver getAnnotationStripper(Receiver destination) { 1326 return destination; 1327 } 1328 1329 1334 1335 public NodeTest makeSubstitutionGroupTest(SchemaDeclaration elementDecl) { 1336 needSchemaAwareVersion(); 1337 return null; 1338 } 1339 1340 1341 1357 public XMLReader makeParser (String className) 1358 throws TransformerFactoryConfigurationError 1359 { 1360 Object obj; 1361 try { 1362 obj = getInstance(className, null); 1363 } catch (XPathException err) { 1364 throw new TransformerFactoryConfigurationError(err); 1365 } 1366 if (obj instanceof XMLReader ) { 1367 return (XMLReader )obj; 1368 } 1369 throw new TransformerFactoryConfigurationError("Class " + className + 1370 " is not a SAX2 XMLReader"); 1371 } 1372 1373 1378 1379 public static Locale getLocale(String lang) { 1380 int hyphen = lang.indexOf("-"); 1381 String language, country; 1382 if (hyphen < 1) { 1383 language = lang; 1384 country = ""; 1385 } else { 1386 language = lang.substring(1, hyphen); 1387 country = lang.substring(hyphen+1); 1388 } 1389 return new Locale(language, country); 1390 } 1391 1392 1397 1398 public void setDebugger(Debugger debugger) { 1399 this.debugger = debugger; 1400 } 1401 1402 1407 1408 public Debugger getDebugger() { 1409 return debugger; 1410 } 1411 1412 1417 1418 public SlotManager makeSlotManager() { 1419 if (debugger == null) { 1420 return new SlotManager(); 1421 } else { 1422 return debugger.makeSlotManager(); 1423 } 1424 } 1425 1426 1431 1432 public Optimizer getOptimizer() { 1433 if (optimizer == null) { 1434 optimizer = new Optimizer(this); 1435 } 1436 return optimizer; 1437 } 1438 1439 1449 1450 public void setClassLoader(ClassLoader loader) { 1451 this.classLoader = loader; 1452 } 1453 1454 1461 1462 public ClassLoader getClassLoader() { 1463 return classLoader; 1464 } 1465 1466 1485 1486 public Class getClass(String className, boolean tracing, ClassLoader classLoader) throws XPathException { 1487 if (tracing) { 1488 System.err.println("Loading " + className); 1489 } 1490 1491 try { 1492 ClassLoader loader = classLoader; 1493 if (loader == null) { 1494 loader = this.classLoader; 1495 } 1496 if (loader == null) { 1497 loader = Thread.currentThread().getContextClassLoader(); 1498 } 1499 if (loader != null) { 1500 try { 1501 return loader.loadClass(className); 1502 } catch (Exception ex) { 1503 return Class.forName(className); 1504 } 1505 } else { 1506 return Class.forName(className); 1507 } 1508 } 1509 catch (Exception e) { 1510 if (tracing) { 1511 System.err.println("No Java class " + className + " could be loaded"); 1514 } 1515 throw new DynamicError("Failed to load " + className, e ); 1516 } 1517 1518 } 1519 1520 1539 1540 public Object getInstance(String className, ClassLoader classLoader) throws XPathException { 1541 Class theclass = getClass(className, false, classLoader); 1542 try { 1543 return theclass.newInstance(); 1544 } catch (Exception err) { 1545 throw new DynamicError("Failed to instantiate class " + className, err); 1546 } 1547 } 1548 1549 1554 1555 public Comparator makeCollator (String className) throws XPathException 1556 { 1557 Object handler = getInstance(className, null); 1558 1559 if (handler instanceof Comparator ) { 1560 return (Comparator )handler; 1561 } else { 1562 throw new DynamicError("Failed to load collation class " + className + 1563 ": it is not an instance of java.util.Comparator"); 1564 } 1565 1566 } 1567 1568 1574 1575 public void setLazyConstructionMode(boolean lazy) { 1576 lazyConstructionMode = lazy; 1577 } 1578 1579 1585 1586 public boolean isLazyConstructionMode() { 1587 return lazyConstructionMode; 1588 } 1589 1590 1591 1596 1597 public void registerStandardObjectModels() { 1598 String [] models = {"net.sf.saxon.dom.DOMEnvelope", 1603 "net.sf.saxon.dom.DOMObjectModel", 1604 "net.sf.saxon.jdom.JDOMObjectModel", 1605 "net.sf.saxon.xom.XOMObjectModel"}; 1606 String [] nodes = {"net.sf.saxon.dom.NodeOverNodeInfo", 1607 "org.w3c.dom.Node", 1608 "org.jdom.Element", 1609 "nu.xom.Node"}; 1610 1611 for (int i=0; i<models.length; i++) { 1612 try { 1613 getClass(nodes[i], false, null); 1614 ExternalObjectModel model = (ExternalObjectModel)getInstance(models[i], null); 1615 registerExternalObjectModel(model); 1616 } catch (XPathException err) { 1617 } catch (ClassCastException err) { 1622 System.err.println("Warning: external object model " + models[i] + 1626 " has been loaded, but is not an instance of net.sf.saxon.om.ExternalObjectModel"); 1627 } 1628 } 1629 } 1630 1631 1632 1637 1638 public void registerExternalObjectModel(ExternalObjectModel model) { 1639 externalObjectModels.add(model); 1640 } 1641 1642 1651 1652 public ExternalObjectModel findExternalObjectModel(Object node) { 1653 Iterator it = externalObjectModels.iterator(); 1654 while (it.hasNext()) { 1655 final ExternalObjectModel model = (ExternalObjectModel)it.next(); 1656 if (model.isRecognizedNode(node)) { 1657 return model; 1658 } 1659 } 1660 return null; 1661 } 1662 1663 1668 1669 public List getExternalObjectModels() { 1670 return externalObjectModels; 1671 } 1672 1673 1677 1678 public PipelineConfiguration makePipelineConfiguration() { 1679 PipelineConfiguration pipe = new PipelineConfiguration(); 1680 pipe.setConfiguration(this); 1681 pipe.setErrorListener(getErrorListener()); 1682 pipe.setURIResolver(getURIResolver()); 1683 return pipe; 1684 } 1685 1686 1690 public void setImplicitTimezone(int minutes) { 1691 if (minutes < -14*60 || minutes > +14*60) { 1692 throw new IllegalArgumentException ("Implicit timezone is out of range: range is " + (-14*60) 1693 + " to +" + (+14*60) + " minutes"); 1694 } 1695 implicitTimezone = minutes; 1696 } 1697 1698 1704 public int getImplicitTimezone() { 1705 return implicitTimezone; 1706 } 1707 1708 1712 1713 public static Configuration getConfiguration(XPathContext context) { 1714 return context.getController().getConfiguration(); 1715 } 1716 1717 1720 1721 public void setSourceResolver(SourceResolver resolver) { 1722 sourceResolver = resolver; 1723 } 1724 1725 1730 1731 public SourceResolver getSourceResolver() { 1732 return sourceResolver; 1733 } 1734 1735 1738 1739 public Source resolveSource(Source source, Configuration config) throws XPathException { 1740 if (source instanceof AugmentedSource) return source; 1741 if (source instanceof StreamSource ) return source; 1742 if (source instanceof SAXSource ) return source; 1743 if (source instanceof DOMSource ) return source; 1744 if (source instanceof NodeInfo) return source; 1745 if (source instanceof PullProvider) return source; 1746 return null; 1747 } 1748 1749 1753 1754 public Receiver getOutputMethod(String clarkName) { 1755 return null; 1756 } 1757} 1758 1759 | Popular Tags |