javax.xml.catalog.CatalogException Java Examples
The following examples show how to use
javax.xml.catalog.CatalogException.
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: DelegatePublicTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "publicId-expectedExceptionClass") public Object[][] dataOnException() { return new Object[][] { // The matched delegatePublic entry of the specified public id // defines a non-existing delegate catalog file. That should // raise a RuntimeException. { "-//REMOTE//DTD DAVID DOCDAVID XML//EN", RuntimeException.class }, // There's no match of the specified public id in the catalog // structure. That should raise a CatalogException. { "-//REMOTE//DTD GHOST DOCGHOST XML//EN", CatalogException.class } }; }
Example #2
Source File: MCREntityResolver.java From mycore with GNU General Public License v3.0 | 5 votes |
private InputSource resolveEntity(String publicId, String systemId, MCRThrowFunction<CatalogEntityIdentifier, InputSource, IOException> alternative) throws IOException { try { InputSource entity = catalogResolver.resolveEntity(publicId, systemId); if (entity != null) { return resolvedEntity(entity); } } catch (CatalogException e) { LOGGER.debug(e.getMessage()); } return alternative.apply(new CatalogEntityIdentifier(publicId, systemId)); }
Example #3
Source File: DelegateUriTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "uri-expectedExceptionClass") public Object[][] dataOnException() { return new Object[][] { // The matched delegateURI entry of the specified URI reference // defines a non-existing delegate catalog file. That should // raise a RuntimeException. { "http://remote/dtd/david/docDavidDU.dtd", RuntimeException.class }, // There's no match of the specified URI reference in the // catalog structure. That should raise a CatalogException. { "http://ghost/xml/dtd/ghost/docGhostDS.dtd", CatalogException.class } }; }
Example #4
Source File: DelegateSystemTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "systemId-expectedExceptionClass") public Object[][] dataOnException() { return new Object[][] { // The matched delegateSystem entry of the specified system id // defines a non-existing delegate catalog file. That should // raise a RuntimeException. { "http://remote/dtd/david/docDavidDS.dtd", RuntimeException.class }, // There's no match of the specified system id in the catalog // structure. That should raise a CatalogException. { "http://ghost/xml/dtd/ghost/docGhostDS.dtd", CatalogException.class } }; }
Example #5
Source File: DeferFeatureTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "testDeferFeatureByResolve") public void testDeferFeatureByResolve(Catalog catalog, int catalogCount) throws Exception { CatalogResolver cr = createResolver(catalog); // trigger loading alternative catalogs try { cr.resolveEntity("-//REMOTE//DTD ALICE DOCALICE", "http://remote/dtd/alice/"); } catch (CatalogException ce) {} Assert.assertEquals(loadedCatalogCount(catalog), catalogCount); }
Example #6
Source File: StaxEntityResolverWrapper.java From Bytecoder with Apache License 2.0 | 5 votes |
public StaxXMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, java.io.IOException { Object object = null ; try { object = fStaxResolver.resolveEntity(resourceIdentifier.getPublicId(), resourceIdentifier.getLiteralSystemId(), resourceIdentifier.getBaseSystemId(), null); return getStaxInputSource(object) ; } catch(XMLStreamException | CatalogException streamException){ throw new XNIException(streamException) ; } }
Example #7
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 #8
Source File: StaxEntityResolverWrapper.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public StaxXMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, java.io.IOException { Object object = null ; try { object = fStaxResolver.resolveEntity(resourceIdentifier.getPublicId(), resourceIdentifier.getLiteralSystemId(), resourceIdentifier.getBaseSystemId(), null); return getStaxInputSource(object) ; } catch(XMLStreamException | CatalogException streamException){ throw new XNIException(streamException) ; } }
Example #9
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 #10
Source File: CatalogReferCircularityTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider = "catalogName", expectedExceptions = CatalogException.class) public void testReferCircularity(String catalogFile) { catalogResolver(catalogFile).resolveEntity(null, "http://remote/dtd/ghost/docGhost.dtd"); }
Example #11
Source File: RewriteUriTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions = CatalogException.class) public void testNoMatch() { checkNoUriMatch(createResolver()); }
Example #12
Source File: ResolveFeatureTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions = CatalogException.class) public void testStrictResolutionOnUriResolver() { createUriResolver(RESOLVE_STRICT).resolve( "http://remote/dtd/alice/docAliceDummy.dtd", null); }
Example #13
Source File: ResolveFeatureTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions = CatalogException.class) public void testStrictResolutionOnEntityResolver() { createEntityResolver(RESOLVE_STRICT).resolveEntity(null, "http://remote/dtd/alice/docAliceDummy.dtd"); }
Example #14
Source File: UriSuffixTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions = CatalogException.class) public void testNoMatch() { checkNoUriMatch(createResolver()); }
Example #15
Source File: ValidateCatalogTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions = CatalogException.class) public void validateWrongRootCatalogOnUriResolver() { catalogUriResolver(CATALOG_WRONGROOT); }
Example #16
Source File: ValidateCatalogTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions = CatalogException.class) public void validateWrongRootCatalogOnEntityResolver() { catalogResolver(CATALOG_WRONGROOT); }
Example #17
Source File: LoadCatalogTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider = "catalogName", expectedExceptions = CatalogException.class) public void testExceptionOnUriResolver(String[] catalogName) { catalogUriResolver(catalogName).resolve(ID_DUMMY, null); }
Example #18
Source File: LoadCatalogTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider = "catalogName", expectedExceptions = CatalogException.class) public void testExceptionOnEntityResolver(String[] catalogName) { catalogResolver(catalogName).resolveEntity(null, ID_DUMMY); }
Example #19
Source File: UriFamilyTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions = CatalogException.class) public void testNoMatch() { checkNoUriMatch(createResolver()); }
Example #20
Source File: SystemSuffixTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions = CatalogException.class) public void testNoMatch() { checkNoMatch(createResolver()); }
Example #21
Source File: TransformerImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * This class should only be used as a DOMCache for the translet if the * URIResolver has been set. * * The method implements XSLTC's DOMCache interface, which is used to * plug in an external document loader into a translet. This method acts * as an adapter between TrAX's URIResolver interface and XSLTC's * DOMCache interface. This approach is simple, but removes the * possibility of using external document caches with XSLTC. * * @param baseURI The base URI used by the document call. * @param href The href argument passed to the document function. * @param translet A reference to the translet requesting the document */ @Override public DOM retrieveDocument(String baseURI, String href, Translet translet) { try { // Argument to document function was: document(''); if (href.length() == 0) { href = baseURI; } /* * Fix for bug 24188 * Incase the _uriResolver.resolve(href,base) is null * try to still retrieve the document before returning null * and throwing the FileNotFoundException in * com.sun.org.apache.xalan.internal.xsltc.dom.LoadDocument * */ Source resolvedSource = null; if (_uriResolver != null) { resolvedSource = _uriResolver.resolve(href, baseURI); } if (resolvedSource == null && _useCatalog && _catalogFeatures.get(CatalogFeatures.Feature.FILES) != null) { if (_catalogUriResolver == null) { _catalogUriResolver = CatalogManager.catalogResolver(_catalogFeatures); } resolvedSource = _catalogUriResolver.resolve(href, baseURI); } if (resolvedSource == null) { StreamSource streamSource = new StreamSource( SystemIDResolver.getAbsoluteURI(href, baseURI)); return getDOM(streamSource) ; } return getDOM(resolvedSource); } catch (TransformerException | CatalogException e) { if (_errorListener != null) postErrorToListener("File not found: " + e.getMessage()); return(null); } }
Example #22
Source File: TransformerImpl.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * This class should only be used as a DOMCache for the translet if the * URIResolver has been set. * * The method implements XSLTC's DOMCache interface, which is used to * plug in an external document loader into a translet. This method acts * as an adapter between TrAX's URIResolver interface and XSLTC's * DOMCache interface. This approach is simple, but removes the * possibility of using external document caches with XSLTC. * * @param baseURI The base URI used by the document call. * @param href The href argument passed to the document function. * @param translet A reference to the translet requesting the document */ @Override public DOM retrieveDocument(String baseURI, String href, Translet translet) { try { // Argument to document function was: document(''); if (href.length() == 0) { href = baseURI; } /* * Fix for bug 24188 * Incase the _uriResolver.resolve(href,base) is null * try to still retrieve the document before returning null * and throwing the FileNotFoundException in * com.sun.org.apache.xalan.internal.xsltc.dom.LoadDocument * */ Source resolvedSource = null; if (_uriResolver != null) { resolvedSource = _uriResolver.resolve(href, baseURI); } if (resolvedSource == null && _useCatalog && _catalogFeatures.get(CatalogFeatures.Feature.FILES) != null) { if (_catalogUriResolver == null) { _catalogUriResolver = CatalogManager.catalogResolver(_catalogFeatures); } resolvedSource = _catalogUriResolver.resolve(href, baseURI); } if (resolvedSource == null) { StreamSource streamSource = new StreamSource( SystemIDResolver.getAbsoluteURI(href, baseURI)); return getDOM(streamSource) ; } return getDOM(resolvedSource); } catch (TransformerException | CatalogException e) { if (_errorListener != null) postErrorToListener("File not found: " + e.getMessage()); return(null); } }
Example #23
Source File: SystemTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions = CatalogException.class) public void testNoMatch() { checkNoMatch(createResolver()); }
Example #24
Source File: PublicTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions = CatalogException.class) public void testNoMatch() { checkNoMatch(createResolver()); }
Example #25
Source File: PreferFeatureTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider = "prefer-publicId-systemId", expectedExceptions = CatalogException.class) public void testPreferFeature(String prefer, String systemId, String publicId) { createResolver(prefer).resolveEntity(systemId, publicId); }
Example #26
Source File: SystemFamilyTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions = CatalogException.class) public void testNoMatch() { checkNoMatch(createResolver()); }
Example #27
Source File: PublicFamilyTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions = CatalogException.class) public void testNoMatched() { checkNoMatch(createResolver()); }
Example #28
Source File: UriTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions = CatalogException.class) public void testNoMatch() { checkNoUriMatch(createResolver()); }
Example #29
Source File: RewriteSystemTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions = CatalogException.class) public void testNoMatch() { checkNoMatch(createResolver()); }