當前位置: 首頁>>代碼示例>>Java>>正文


Java Schema.newValidatorHandler方法代碼示例

本文整理匯總了Java中javax.xml.validation.Schema.newValidatorHandler方法的典型用法代碼示例。如果您正苦於以下問題:Java Schema.newValidatorHandler方法的具體用法?Java Schema.newValidatorHandler怎麽用?Java Schema.newValidatorHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.validation.Schema的用法示例。


在下文中一共展示了Schema.newValidatorHandler方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test

import javax.xml.validation.Schema; //導入方法依賴的package包/類
@Test
public void test() throws SAXException, ParserConfigurationException, IOException {

    SchemaFactory sf = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI);
    Schema schema = sf.newSchema(new File(XML_DIR + "shiporder11.xsd"));
    validatorHandler = schema.newValidatorHandler();
    MyDefaultHandler myDefaultHandler = new MyDefaultHandler();
    validatorHandler.setContentHandler(myDefaultHandler);

    InputSource is = new InputSource(filenameToURL(XML_DIR + "shiporder11.xml"));

    SAXParserFactory parserFactory = SAXParserFactory.newInstance();
    parserFactory.setNamespaceAware(true);
    XMLReader xmlReader = parserFactory.newSAXParser().getXMLReader();
    xmlReader.setContentHandler(validatorHandler);
    xmlReader.parse(is);

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:TypeInfoProviderTest.java

示例2: ValidatingUnmarshaller

import javax.xml.validation.Schema; //導入方法依賴的package包/類
/**
 * Creates a new instance of ValidatingUnmarshaller.
 */
public ValidatingUnmarshaller( Schema schema, XmlVisitor next ) {
    this.validator = schema.newValidatorHandler();
    this.next = next;
    this.predictor = next.getPredictor();
    // if the user bothers to use a validator, make validation errors fatal
    // so that it will abort unmarshalling.
    validator.setErrorHandler(new FatalAdapter(getContext()));
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:12,代碼來源:ValidatingUnmarshaller.java

示例3: createValidatorHandler

import javax.xml.validation.Schema; //導入方法依賴的package包/類
private ValidatorHandler createValidatorHandler(String xsd) throws SAXException {
    SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");

    StringReader reader = new StringReader(xsd);
    StreamSource xsdSource = new StreamSource(reader);

    Schema schema = schemaFactory.newSchema(xsdSource);
    return schema.newValidatorHandler();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:Bug4970402.java

示例4: createValidatorHandler

import javax.xml.validation.Schema; //導入方法依賴的package包/類
private ValidatorHandler createValidatorHandler(String xsd) throws SAXException {
    SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");

    InputStreamReader reader = new InputStreamReader(new ByteArrayInputStream(xsd.getBytes()));
    StreamSource xsdSource = new StreamSource(reader);

    Schema schema = schemaFactory.newSchema(xsdSource);
    return schema.newValidatorHandler();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:Bug6509668.java

示例5: setUp

import javax.xml.validation.Schema; //導入方法依賴的package包/類
@BeforeMethod
public void setUp() throws Exception {
    SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");

    InputStreamReader reader = new InputStreamReader(new ByteArrayInputStream(XSD.getBytes()));
    StreamSource xsdSource = new StreamSource(reader);

    Schema schema = schemaFactory.newSchema(xsdSource);

    this.validatorHandler = schema.newValidatorHandler();
    this.validator = schema.newValidator();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:Bug5011500.java


注:本文中的javax.xml.validation.Schema.newValidatorHandler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。