javax.xml.catalog.CatalogFeatures Java Examples
The following examples show how to use
javax.xml.catalog.CatalogFeatures.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MCREntityResolver.java From mycore with GNU General Public License v3.0 | 6 votes |
private MCREntityResolver() { Enumeration<URL> systemResources; try { systemResources = MCRClassTools.getClassLoader().getResources("catalog.xml"); } catch (IOException e) { throw new ExceptionInInitializerError(e); } URI[] catalogURIs = MCRStreamUtils.asStream(systemResources) .map(URL::toString) .peek(c -> LOGGER.info("Using XML catalog: {}", c)) .map(URI::create) .toArray(URI[]::new); catalogResolver = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalogURIs); int cacheSize = MCRConfiguration2.getInt(CONFIG_PREFIX + "StaticFiles.CacheSize").orElse(100); bytesCache = new MCRCache<>(cacheSize, "EntityResolver Resources"); }
Example #2
Source File: XSLTC.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Set allowed protocols for accessing external stylesheet. * @param name the name of the property * @param value the value of the property */ public void setProperty(String name, Object value) { if (name.equals(XMLConstants.ACCESS_EXTERNAL_STYLESHEET)) { _accessExternalStylesheet = (String)value; } else if (name.equals(XMLConstants.ACCESS_EXTERNAL_DTD)) { _accessExternalDTD = (String)value; } else if (name.equals(XalanConstants.SECURITY_MANAGER)) { _xmlSecurityManager = (XMLSecurityManager)value; } else if (name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) { _extensionClassLoader = (ClassLoader) value; /* Clear the external extension functions HashMap if extension class loader was changed */ _externalExtensionFunctions.clear(); } else if (JdkXmlFeatures.CATALOG_FEATURES.equals(name)) { _catalogFeatures = (CatalogFeatures)value; } else if (JdkXmlUtils.CDATA_CHUNK_SIZE.equals(name)) { _cdataChunkSize = Integer.parseInt((String)value); } }
Example #3
Source File: JdkXmlUtils.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Creates an instance of a CatalogFeatures. * * @param defer the defer property defined in CatalogFeatures * @param file the file path to a catalog * @param prefer the prefer property defined in CatalogFeatures * @param resolve the resolve property defined in CatalogFeatures * @return a {@link javax.xml.transform.Source} object */ public static CatalogFeatures getCatalogFeatures(String defer, String file, String prefer, String resolve) { CatalogFeatures.Builder builder = CatalogFeatures.builder(); if (file != null) { builder = builder.with(CatalogFeatures.Feature.FILES, file); } if (prefer != null) { builder = builder.with(CatalogFeatures.Feature.PREFER, prefer); } if (defer != null) { builder = builder.with(CatalogFeatures.Feature.DEFER, defer); } if (resolve != null) { builder = builder.with(CatalogFeatures.Feature.RESOLVE, resolve); } return builder.build(); }
Example #4
Source File: JdkXmlUtils.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Creates an instance of a CatalogFeatures. * * @param defer the defer property defined in CatalogFeatures * @param file the file path to a catalog * @param prefer the prefer property defined in CatalogFeatures * @param resolve the resolve property defined in CatalogFeatures * @return a {@link javax.xml.transform.Source} object */ public static CatalogFeatures getCatalogFeatures(String defer, String file, String prefer, String resolve) { CatalogFeatures.Builder builder = CatalogFeatures.builder(); if (file != null) { builder = builder.with(CatalogFeatures.Feature.FILES, file); } if (prefer != null) { builder = builder.with(CatalogFeatures.Feature.PREFER, prefer); } if (defer != null) { builder = builder.with(CatalogFeatures.Feature.DEFER, defer); } if (resolve != null) { builder = builder.with(CatalogFeatures.Feature.RESOLVE, resolve); } return builder.build(); }
Example #5
Source File: XSLTC.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Set allowed protocols for accessing external stylesheet. * @param name the name of the property * @param value the value of the property */ public void setProperty(String name, Object value) { if (name.equals(XMLConstants.ACCESS_EXTERNAL_STYLESHEET)) { _accessExternalStylesheet = (String)value; } else if (name.equals(XMLConstants.ACCESS_EXTERNAL_DTD)) { _accessExternalDTD = (String)value; } else if (name.equals(XalanConstants.SECURITY_MANAGER)) { _xmlSecurityManager = (XMLSecurityManager)value; } else if (name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) { _extensionClassLoader = (ClassLoader) value; /* Clear the external extension functions HashMap if extension class loader was changed */ _externalExtensionFunctions.clear(); } else if (JdkXmlFeatures.CATALOG_FEATURES.equals(name)) { _catalogFeatures = (CatalogFeatures)value; } else if (JdkXmlUtils.CDATA_CHUNK_SIZE.equals(name)) { _cdataChunkSize = Integer.parseInt((String)value); } }
Example #6
Source File: CatalogTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "hierarchyOfCatFilesData") public void hierarchyOfCatFiles2(String systemId, String expectedUri) { String file1 = getClass().getResource("first_cat.xml").toExternalForm(); String file2 = getClass().getResource("second_cat.xml").toExternalForm(); String files = file1 + ";" + file2; try { setSystemProperty(KEY_FILES, files); CatalogResolver catalogResolver = CatalogManager.catalogResolver(CatalogFeatures.defaults()); String sysId = catalogResolver.resolveEntity(null, systemId).getSystemId(); Assert.assertEquals(sysId, Paths.get(filepath + expectedUri).toUri().toString().replace("///", "/"), "System ID match not right"); } finally { clearSystemProperty(KEY_FILES); } }
Example #7
Source File: CatalogTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * @bug 8146237 * PREFER from Features API taking precedence over catalog file */ @Test public void testJDK8146237() throws Exception { URI catalogFile = getClass().getResource("JDK8146237_catalog.xml").toURI(); try { CatalogFeatures features = CatalogFeatures.builder() .with(CatalogFeatures.Feature.PREFER, "system") .build(); Catalog catalog = CatalogManager.catalog(features, catalogFile); CatalogResolver catalogResolver = CatalogManager.catalogResolver(catalog); String actualSystemId = catalogResolver.resolveEntity( "-//FOO//DTD XML Dummy V0.0//EN", "http://www.oracle.com/alt1sys.dtd") .getSystemId(); Assert.assertTrue(actualSystemId.contains("dummy.dtd"), "Resulting id should contain dummy.dtd, indicating a match by publicId"); } catch (Exception e) { Assert.fail(e.getMessage()); } }
Example #8
Source File: CatalogTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "catalog") public void testCatalogResolver(String test, String expected, String catalogFile, String xml, SAXParser saxParser) throws Exception { URI catalog = null; if (catalogFile != null) { catalog = getClass().getResource(catalogFile).toURI(); } String url = getClass().getResource(xml).getFile(); try { CatalogResolver cr = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalog); XMLReader reader = saxParser.getXMLReader(); reader.setEntityResolver(cr); MyHandler handler = new MyHandler(saxParser); reader.setContentHandler(handler); reader.parse(url); System.out.println(test + ": expected [" + expected + "] <> actual [" + handler.getResult() + "]"); Assert.assertEquals(handler.getResult(), expected); } catch (SAXException | IOException e) { Assert.fail(e.getMessage()); } }
Example #9
Source File: CatalogTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test public void testInvalidCatalog() throws Exception { String expectedMsgId = "JAXP09040001"; URI catalog = getClass().getResource("catalog_invalid.xml").toURI(); try { CatalogResolver resolver = CatalogManager.catalogResolver( CatalogFeatures.defaults(), catalog); String actualSystemId = resolver.resolveEntity( null, "http://remote/xml/dtd/sys/alice/docAlice.dtd") .getSystemId(); } catch (Exception e) { String msg = e.getMessage(); if (msg != null) { Assert.assertTrue(msg.contains(expectedMsgId), "Message shall contain the corrent message ID " + expectedMsgId); } } }
Example #10
Source File: CatalogTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test public void testIgnoreInvalidCatalog() { String catalog = getClass().getResource("catalog_invalid.xml").toExternalForm(); CatalogFeatures f = CatalogFeatures.builder() .with(Feature.FILES, catalog) .with(Feature.PREFER, "public") .with(Feature.DEFER, "true") .with(Feature.RESOLVE, "ignore") .build(); String test = "testInvalidCatalog"; try { CatalogResolver resolver = CatalogManager.catalogResolver(f); String actualSystemId = resolver.resolveEntity( null, "http://remote/xml/dtd/sys/alice/docAlice.dtd") .getSystemId(); System.out.println("testIgnoreInvalidCatalog: expected [null]"); System.out.println("testIgnoreInvalidCatalog: expected [null]"); System.out.println("actual [" + actualSystemId + "]"); Assert.assertEquals(actualSystemId, null); } catch (Exception e) { Assert.fail(e.getMessage()); } }
Example #11
Source File: CatalogSupportBase.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void testValidation(boolean setUseCatalog, boolean useCatalog, String catalog, String xsd, LSResourceResolver resolver) throws Exception { SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); // use resolver or catalog if resolver = null if (resolver != null) { factory.setResourceResolver(resolver); } if (setUseCatalog) { factory.setFeature(XMLConstants.USE_CATALOG, useCatalog); } factory.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), catalog); Schema schema = factory.newSchema(new StreamSource(new StringReader(xsd))); success("XMLSchema.dtd and datatypes.dtd are resolved."); }
Example #12
Source File: CatalogSupportBase.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Creates an XMLStreamReader. * * @param setUseCatalog a flag indicates whether USE_CATALOG shall be set * through the factory * @param useCatalog the value of USE_CATALOG * @param catalog the path to a catalog * @param xml the xml to be parsed * @param resolver a resolver to be set on the reader * @return an instance of the XMLStreamReader * @throws FileNotFoundException * @throws XMLStreamException */ XMLStreamReader getStreamReader(boolean setUseCatalog, boolean useCatalog, String catalog, String xml, XMLResolver resolver) throws FileNotFoundException, XMLStreamException { XMLInputFactory factory = XMLInputFactory.newInstance(); if (catalog != null) { factory.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), catalog); } factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, true); factory.setProperty(XMLInputFactory.IS_COALESCING, true); if (resolver != null) { factory.setProperty(XMLInputFactory.RESOLVER, resolver); } if (setUseCatalog) { factory.setProperty(XMLConstants.USE_CATALOG, useCatalog); } InputStream entityxml = new FileInputStream(xml); XMLStreamReader streamReader = factory.createXMLStreamReader(xml, entityxml); return streamReader; }
Example #13
Source File: CatalogSupportBase.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Returns an instance of TransformerFactory with either a custom URIResolver * or Catalog. * * @param setUseCatalog a flag indicates whether USE_CATALOG shall be set * through the factory * @param useCatalog the value of USE_CATALOG * @param catalog a catalog * @param resolver a custom resolver * @return an instance of TransformerFactory * @throws Exception */ TransformerFactory getTransformerFactory(boolean setUseCatalog, boolean useCatalog, String catalog, URIResolver resolver) throws Exception { TransformerFactory factory = TransformerFactory.newInstance(); if (setUseCatalog) { factory.setFeature(XMLConstants.USE_CATALOG, useCatalog); } if (catalog != null) { factory.setAttribute(CatalogFeatures.Feature.FILES.getPropertyName(), catalog); } // use resolver or catalog if resolver = null if (resolver != null) { factory.setURIResolver(resolver); } return factory; }
Example #14
Source File: CatalogSupportBase.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Returns an instance of XMLReader with a catalog if one is provided. * * @param setUseCatalog a flag indicates whether USE_CATALOG shall be set * through the factory * @param useCatalog the value of USE_CATALOG * @param catalog a catalog * @return an instance of XMLReader * @throws ParserConfigurationException * @throws SAXException */ XMLReader getXMLReader(boolean setUseCatalog, boolean useCatalog, String catalog) throws ParserConfigurationException, SAXException { SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true); XMLReader reader = spf.newSAXParser().getXMLReader(); if (setUseCatalog) { reader.setFeature(XMLConstants.USE_CATALOG, useCatalog); } reader.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), catalog); return reader; }
Example #15
Source File: CatalogSupportBase.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Returns an instance of DocumentBuilder that may have set a Catalog. * * @param setUseCatalog a flag indicates whether USE_CATALOG shall be set * through the factory * @param useCatalog the value of USE_CATALOG * @param catalog a catalog * @return an instance of DocumentBuilder * @throws ParserConfigurationException */ DocumentBuilder getDomBuilder(boolean setUseCatalog, boolean useCatalog, String catalog) throws ParserConfigurationException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); if (setUseCatalog) { dbf.setFeature(XMLConstants.USE_CATALOG, useCatalog); } dbf.setAttribute(CatalogFeatures.Feature.FILES.getPropertyName(), catalog); DocumentBuilder docBuilder = dbf.newDocumentBuilder(); return docBuilder; }
Example #16
Source File: TemplatesHandlerImpl.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Default constructor */ protected TemplatesHandlerImpl(int indentNumber, TransformerFactoryImpl tfactory, boolean hasUserErrListener) { _indentNumber = indentNumber; _tfactory = tfactory; // Instantiate XSLTC and get reference to parser object XSLTC xsltc = new XSLTC(tfactory.getJdkXmlFeatures(), hasUserErrListener); if (tfactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING)) xsltc.setSecureProcessing(true); xsltc.setProperty(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, (String)tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET)); xsltc.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, (String)tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_DTD)); xsltc.setProperty(XalanConstants.SECURITY_MANAGER, tfactory.getAttribute(XalanConstants.SECURITY_MANAGER)); if ("true".equals(tfactory.getAttribute(TransformerFactoryImpl.ENABLE_INLINING))) xsltc.setTemplateInlining(true); else xsltc.setTemplateInlining(false); _useCatalog = tfactory.getFeature(XMLConstants.USE_CATALOG); _catalogFeatures = (CatalogFeatures)tfactory.getAttribute(JdkXmlFeatures.CATALOG_FEATURES); xsltc.setProperty(JdkXmlFeatures.CATALOG_FEATURES, _catalogFeatures); _parser = xsltc.getParser(); }
Example #17
Source File: CatalogFileInputTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "invalidCatalog") public void testCatalogResolverWEmptyCatalog1(String uri, String publicId, String msg) { CatalogResolver cr = CatalogManager.catalogResolver( CatalogFeatures.builder().with(CatalogFeatures.Feature.RESOLVE, "continue").build(), uri != null? URI.create(uri) : null); Assert.assertNull(cr.resolveEntity(publicId, ""), msg); }
Example #18
Source File: TransformerFactoryImpl.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Build the CatalogFeatures object when a newTemplates or newTransformer is * created. This will read any System Properties for the CatalogFeatures that * may have been set. */ private CatalogFeatures buildCatalogFeatures() { // build will cause the CatalogFeatures to read SPs for those not set through the API if (_catalogFeatures == null) { _catalogFeatures = cfBuilder.build(); } // update fields _catalogFiles = _catalogFeatures.get(Feature.FILES); _catalogDefer = _catalogFeatures.get(Feature.DEFER); _catalogPrefer = _catalogFeatures.get(Feature.PREFER); _catalogResolve = _catalogFeatures.get(Feature.RESOLVE); return _catalogFeatures; }
Example #19
Source File: UriTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test public void testSpecifyBaseByAPI() { checkUriResolution(createResolver(), "http://remote/dtd/carl/docCarl.dtd", "http://local/carlBase/dtd/docCarlURI.dtd"); CatalogResolver continueResolver = catalogUriResolver( CatalogFeatures.builder().with(CatalogFeatures.Feature.RESOLVE, RESOLVE_CONTINUE).build(), CATALOG_URI); checkUriResolution(continueResolver, "docCarl.dtd", "http://local/alternativeBase/dtd/", "http://local/alternativeBase/dtd/docCarl.dtd"); }
Example #20
Source File: DeferFeatureTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "catalog-countOfLoadedCatalogFile") public Object[][] data() { return new Object[][]{ // By default, alternative catalogs are not loaded. {createCatalog(CatalogFeatures.defaults()), 1}, // Alternative catalogs are not loaded when DEFER is set to true. {createCatalog(createDeferFeature(DEFER_TRUE)), 1}, // The 3 alternative catalogs are pre-loaded along with the parent //when DEFER is set to false. {createCatalog(createDeferFeature(DEFER_FALSE)), 4}}; }
Example #21
Source File: JdkXmlUtils.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Returns the value of a Catalog feature by the property name. * * @param features a CatalogFeatures instance * @param name the name of a Catalog feature * @return the value of a Catalog feature, null if the name does not match * any feature supported by the Catalog. */ public static String getCatalogFeature(CatalogFeatures features, String name) { for (Feature feature : Feature.values()) { if (feature.getPropertyName().equals(name)) { return features.get(feature); } } return null; }
Example #22
Source File: CatalogFileInputTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "invalidCatalog", expectedExceptions = CatalogException.class) public void testCatalogResolverWEmptyCatalog(String uri, String publicId, String msg) { CatalogResolver cr = CatalogManager.catalogResolver( CatalogFeatures.builder().with(CatalogFeatures.Feature.RESOLVE, "strict").build(), uri != null? URI.create(uri) : null); InputSource is = cr.resolveEntity(publicId, ""); }
Example #23
Source File: CatalogSupportBase.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Returns an instance of SAXParser with a catalog if one is provided. * * @param setUseCatalog a flag indicates whether USE_CATALOG shall be set * through the factory * @param useCatalog the value of USE_CATALOG * @param catalog a catalog * @return an instance of SAXParser * @throws ParserConfigurationException * @throws SAXException */ SAXParser getSAXParser(boolean setUseCatalog, boolean useCatalog, String catalog) throws ParserConfigurationException, SAXException { SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true); spf.setXIncludeAware(true); if (setUseCatalog) { spf.setFeature(XMLConstants.USE_CATALOG, useCatalog); } SAXParser parser = spf.newSAXParser(); parser.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), catalog); return parser; }
Example #24
Source File: CatalogSupportBase.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Verifies Catalog Support for the Validator. * @param setUseCatalog1 a flag to indicate whether USE_CATALOG shall be set * on the factory. * @param setUseCatalog2 a flag to indicate whether USE_CATALOG shall be set * on the Validator. * @param source the XML source * @param resolver1 a resolver to be set on the factory if specified * @param resolver2 a resolver to be set on the Validator if specified * @param catalog1 a catalog to be set on the factory if specified * @param catalog2 a catalog to be set on the Validator if specified */ public void testValidator(boolean setUseCatalog1, boolean setUseCatalog2, boolean useCatalog, Source source, LSResourceResolver resolver1, LSResourceResolver resolver2, String catalog1, String catalog2) throws Exception { SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); if (setUseCatalog1) { schemaFactory.setFeature(XMLConstants.USE_CATALOG, useCatalog); } if (catalog1 != null) { schemaFactory.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), catalog1); } if (resolver1 != null) { schemaFactory.setResourceResolver(resolver1); } Schema schema = schemaFactory.newSchema(); Validator validator = schema.newValidator(); if (setUseCatalog2) { validator.setFeature(XMLConstants.USE_CATALOG, useCatalog); } if (catalog2 != null) { validator.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), catalog2); } if (resolver2 != null) { validator.setResourceResolver(resolver2); } validator.validate(source); }
Example #25
Source File: TransformerImpl.java From Bytecoder with Apache License 2.0 | 5 votes |
protected TransformerImpl(Translet translet, Properties outputProperties, int indentNumber, TransformerFactoryImpl tfactory) { _translet = (AbstractTranslet) translet; if (_translet != null) { _translet.setMessageHandler(new MessageHandler(_errorListener)); } _properties = createOutputProperties(outputProperties); _propertiesClone = (Properties) _properties.clone(); _indentNumber = indentNumber; _tfactory = tfactory; _overrideDefaultParser = _tfactory.overrideDefaultParser(); _accessExternalDTD = (String)_tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_DTD); _securityManager = (XMLSecurityManager)_tfactory.getAttribute(XalanConstants.SECURITY_MANAGER); _readerManager = XMLReaderManager.getInstance(_overrideDefaultParser); _readerManager.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD); _readerManager.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, _isSecureProcessing); _readerManager.setProperty(XalanConstants.SECURITY_MANAGER, _securityManager); _cdataChunkSize = JdkXmlUtils.getValue(_tfactory.getAttribute(JdkXmlUtils.CDATA_CHUNK_SIZE), JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT); _readerManager.setProperty(JdkXmlUtils.CDATA_CHUNK_SIZE, _cdataChunkSize); _useCatalog = _tfactory.getFeature(XMLConstants.USE_CATALOG); if (_useCatalog) { _catalogFeatures = (CatalogFeatures)_tfactory.getAttribute(JdkXmlFeatures.CATALOG_FEATURES); String catalogFiles = _catalogFeatures.get(CatalogFeatures.Feature.DEFER); if (catalogFiles != null) { _readerManager.setFeature(XMLConstants.USE_CATALOG, _useCatalog); _readerManager.setProperty(JdkXmlFeatures.CATALOG_FEATURES, _catalogFeatures); } } //_isIncremental = tfactory._incremental; }
Example #26
Source File: CatalogTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test public void testRewriteUri() throws Exception { URI catalog = getClass().getResource("rewriteCatalog.xml").toURI(); try { CatalogResolver resolver = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalog); String actualSystemId = resolver.resolve("http://remote.com/import/import.xsl", null).getSystemId(); Assert.assertTrue(!actualSystemId.contains("//"), "result contains duplicate slashes"); } catch (Exception e) { Assert.fail(e.getMessage()); } }
Example #27
Source File: CatalogTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test public void testRewriteSystem() throws Exception { URI catalog = getClass().getResource("rewriteCatalog.xml").toURI(); try { CatalogResolver resolver = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalog); String actualSystemId = resolver.resolveEntity(null, "http://remote.com/dtd/book.dtd").getSystemId(); Assert.assertTrue(!actualSystemId.contains("//"), "result contains duplicate slashes"); } catch (Exception e) { Assert.fail(e.getMessage()); } }
Example #28
Source File: CatalogTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * @bug 8150969 * Verifies that the defer attribute set in the catalog file takes precedence * over other settings, in which case, whether next and delegate Catalogs will * be loaded is determined by the defer attribute. */ @Test(dataProvider = "invalidAltCatalogs", expectedExceptions = CatalogException.class) public void testDeferAltCatalogs(String file) throws Exception { URI catalogFile = getClass().getResource(file).toURI(); CatalogFeatures features = CatalogFeatures.builder(). with(CatalogFeatures.Feature.DEFER, "true") .build(); /* Since the defer attribute is set to false in the specified catalog file, the parent catalog will try to load the alt catalog, which will fail since it points to an invalid catalog. */ Catalog catalog = CatalogManager.catalog(features, catalogFile); }
Example #29
Source File: TransformerFactoryImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Build the CatalogFeatures object when a newTemplates or newTransformer is * created. This will read any System Properties for the CatalogFeatures that * may have been set. */ private CatalogFeatures buildCatalogFeatures() { // build will cause the CatalogFeatures to read SPs for those not set through the API if (_catalogFeatures == null) { _catalogFeatures = cfBuilder.build(); } // update fields _catalogFiles = _catalogFeatures.get(Feature.FILES); _catalogDefer = _catalogFeatures.get(Feature.DEFER); _catalogPrefer = _catalogFeatures.get(Feature.PREFER); _catalogResolve = _catalogFeatures.get(Feature.RESOLVE); return _catalogFeatures; }
Example #30
Source File: CatalogTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "resolveWithPrefer") public void resolveWithPrefer(String prefer, String cfile, String publicId, String systemId, String expected) throws Exception { URI catalogFile = getClass().getResource(cfile).toURI(); CatalogFeatures f = CatalogFeatures.builder() .with(CatalogFeatures.Feature.PREFER, prefer) .with(CatalogFeatures.Feature.RESOLVE, "ignore") .build(); CatalogResolver catalogResolver = CatalogManager.catalogResolver(f, catalogFile); String result = catalogResolver.resolveEntity(publicId, systemId).getSystemId(); Assert.assertEquals(expected, result); }