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

multiple schema from database #22

Closed
b0c1 opened this issue Apr 8, 2020 · 1 comment
Closed

multiple schema from database #22

b0c1 opened this issue Apr 8, 2020 · 1 comment
Labels
wontfix This will not be worked on

Comments

@b0c1
Copy link

b0c1 commented Apr 8, 2020

I try to create own xsd processor based on xsdparsercore.

public class InputStreamXsdProcessor extends XsdParserCore {
	public InputStreamXsdProcessor(List<InputStream> inputStreams) {
		this.parse(inputStreams);
	}

	public InputStreamXsdProcessor(List<InputStream> inputStreams, ParserConfig config) {
		super.updateConfig(config);
		this.parse(inputStreams);
	}

	private void parse(List <InputStream> inputStreams) {
		inputStreams.forEach(stream -> parseInputStream(stream));
		this.resolveRefs();
	}

	private void parseInputStream(InputStream inputStream) {
		try {
			Node schemaNode = getSchemaNode(inputStream);

			if (isXsdSchema(schemaNode)) {
				ConfigEntryData xsdSchemaConfig = parseMappers.getOrDefault(XsdSchema.XSD_TAG, parseMappers.getOrDefault(XsdSchema.XS_TAG, null));

				if (xsdSchemaConfig == null) {
					throw new ParserConfigurationException("XsdSchema not correctly configured.");
				}

				xsdSchemaConfig.parserFunction.apply(new ParseData(this, schemaNode, xsdSchemaConfig.visitorFunction));
			} else {
				throw new ParsingException("The top level element of a XSD file should be the xsd:schema node.");
			}
		} catch (SAXException | IOException | ParserConfigurationException e) {
			Logger.getAnonymousLogger().log(Level.SEVERE, "Exception while parsing.", e);
			throw new RuntimeException(e);
		}
	}

	private Node getSchemaNode(InputStream inputStream) throws ParserConfigurationException, IOException, SAXException {
		Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream);
		doc.getDocumentElement().normalize();
		return doc.getFirstChild();
	}
}```

I have multiple problems with this.
1. The XsdParserCore design is bad. I can't extend simple the XsdParserCore, I must put it to same package...
2. I can't access the elements and it's based on files, not namespaces and xsd content.
3. In the `XsdParserCore` we can't resolve the namespace in the dependent xsd because in the `resolveOtherNamespaceRefs` not based on the xsd targetNamespace, it's based on files

@lcduarte
Copy link
Member

lcduarte commented Apr 8, 2020

Hello,

Thanks for the issue.

The XsdParserCore wasn't planned to be extended. Currently I don't have much free time to do it so I'll take it in consideration in the future when I'm able to.

@lcduarte lcduarte added the wontfix This will not be worked on label Nov 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants