当前位置: 首页>>代码示例>>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;未经允许,请勿转载。