|
| 1 | +/* |
| 2 | + * Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package io.adminshell.aas.v3.dataformat.aasx; |
| 17 | + |
| 18 | +import io.adminshell.aas.v3.dataformat.xml.XmlSchemaValidator; |
| 19 | +import org.apache.poi.openxml4j.exceptions.InvalidFormatException; |
| 20 | +import org.apache.poi.openxml4j.opc.OPCPackage; |
| 21 | +import org.xml.sax.SAXException; |
| 22 | + |
| 23 | +import java.io.IOException; |
| 24 | +import java.io.InputStream; |
| 25 | +import java.util.Set; |
| 26 | + |
| 27 | +public class AASXValidator { |
| 28 | + |
| 29 | + private XmlSchemaValidator xmlValidator; |
| 30 | + private AASXDeserializer deserializer; |
| 31 | + |
| 32 | + public AASXValidator(InputStream is) throws SAXException, IOException, InvalidFormatException { |
| 33 | + this.xmlValidator = new XmlSchemaValidator(); |
| 34 | + this.deserializer = new AASXDeserializer(is); |
| 35 | + } |
| 36 | + |
| 37 | + public Set<String> validateSchema(OPCPackage p) throws IOException, InvalidFormatException { |
| 38 | + String file = deserializer.getXMLResourceString(p); |
| 39 | + return xmlValidator.validateSchema(file); |
| 40 | + } |
| 41 | + |
| 42 | +} |
0 commit comments