Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code to set the EntityResolver #8

Merged
merged 1 commit into from
Mar 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@

package com.sun.msv.reader.xmlschema;

import java.io.IOException;
import java.util.Map;

import org.w3c.dom.ls.LSInput;
import org.w3c.dom.ls.LSResourceResolver;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;

import com.sun.msv.reader.GrammarReaderController2;

Expand All @@ -47,6 +50,7 @@ public class WSDLGrammarReaderController implements
GrammarReaderController2, LSResourceResolver {

private GrammarReaderController2 nextController;
private EntityResolver entityResolver;

private Map<String, EmbeddedSchema> schemas;
private String baseURI;
Expand Down Expand Up @@ -75,8 +79,28 @@ public void warning(Locator[] locs, String errorMessage) {
}
}

public InputSource resolveEntity(String publicId, String systemId) {
return null;
public void setEntityResolver(EntityResolver entityResolver)
{
this.entityResolver = entityResolver;
}

public InputSource resolveEntity(String publicId, String systemId)
{
InputSource is = null;

if (entityResolver != null)
{
try
{
is = entityResolver.resolveEntity(publicId, systemId);
}
catch (SAXException | IOException ex)
{
ex.printStackTrace();
}
}

return is;
}

public LSResourceResolver getLSResourceResolver() {
Expand Down