0
以下程序集的schemaLanguage爲「http://www.w3.org/XML/XMLSchema/v1.1」,newSchema()返回{org.apache.xerces.jaxp.validation.SimpleXMLSchema}類型的Schema。 即─類型org.apache.xerces.jaxp.validation.SimpleXMLSchema是不可見的我不能導入類,錯誤如何獲取XSD1.1模式解析?
我的目的是解析XSD(版本1.1)斷言值(如下所示)作爲XPath表達式,它在SimpleXMLSchema對象中可用。
Example: <assert test="starts-with(@partnumber,../@partnumber)"/>
是否有任何其他方式獲取XSD1.1 Schema對象?
罐使用:xercesImpl-xsd11-2.12-β-r1667115.jar,org.eclipse.wst.xml.xpath2.processor-2.1.100.jar
任何建議/幫助會幫我解決問題。 謝謝。
/*
* Xsd11SchemaValidator.java
import javax.xml.validation.SchemaFactory;*/
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.XMLConstants;
import javax.xml.transform.sax.SAXSource;
import org.xml.sax.InputSource;
import javax.xml.validation.Validator;
import java.io.*;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.ErrorHandler;
import org.apache.xerces.impl.xs.SchemaGrammar;
import org.apache.xerces.jaxp.validation.*;
class Xsd11SchemaValidator {
private static int errorCount = 0;
public static void main() {
String schemaName = "Path to XSD 1.1 File";;
Schema schema = loadSchema(schemaName);
}
}
public static Schema loadSchema(String name) {
Schema schema = null;
try {
String language = "http://www.w3.org/XML/XMLSchema/v1.1";
SchemaFactory factory = SchemaFactory.newInstance(language);
schema = factory.newSchema(new File(name));
} catch (Exception e) {
System.out.println(e.toString());
}
return schema;
}
}