package com.test;import java.io.IOException;
import java.io.UnsupportedEncodingException;import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
import org.dom4j.util.XMLErrorHandler;
import org.xml.sax.SAXException;public class SimpleValidationDemo { public void validation(String filepath) {
SAXReader reader = new SAXReader(); reader.setValidation(true); // specify the schema to use
String url = getClass().getResource("/jpdl-3.0.xsd").toString();
try { reader.setFeature("http://apache.org/xml/features/validation/schema", true); reader
.setProperty(
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
url);
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} // add error handler which turns any errors into XML
XMLErrorHandler errorHandler = new XMLErrorHandler();
reader.setErrorHandler(errorHandler); // parse the document
try {
Document document = reader.read(filepath);
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} // output the errors XML
XMLWriter writer;
try {
writer = new XMLWriter(OutputFormat.createPrettyPrint());
writer.write(errorHandler.getErrors());
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} } public void createXmlBySchema(String schemapath) { } public static void main(String[] args) {
SimpleValidationDemo svd = new SimpleValidationDemo();
svd.validation("processdefinition.xml");
}}
import java.io.UnsupportedEncodingException;import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
import org.dom4j.util.XMLErrorHandler;
import org.xml.sax.SAXException;public class SimpleValidationDemo { public void validation(String filepath) {
SAXReader reader = new SAXReader(); reader.setValidation(true); // specify the schema to use
String url = getClass().getResource("/jpdl-3.0.xsd").toString();
try { reader.setFeature("http://apache.org/xml/features/validation/schema", true); reader
.setProperty(
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
url);
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} // add error handler which turns any errors into XML
XMLErrorHandler errorHandler = new XMLErrorHandler();
reader.setErrorHandler(errorHandler); // parse the document
try {
Document document = reader.read(filepath);
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} // output the errors XML
XMLWriter writer;
try {
writer = new XMLWriter(OutputFormat.createPrettyPrint());
writer.write(errorHandler.getErrors());
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} } public void createXmlBySchema(String schemapath) { } public static void main(String[] args) {
SimpleValidationDemo svd = new SimpleValidationDemo();
svd.validation("processdefinition.xml");
}}
解决方案 »
- java实现的图形按钮,抛砖引玉
- 求axis xfire OSGI实现
- 知识库系统,关于数据库元数据的提取问题;现在要做的是手动录入元数据,请教各位大侠
- Hibernate多表查询问题!
- 高吞吐量,低时延和复杂计算的解决方案
- hibernate String长度超过65535怎么办?
- response.setCharacterEncoding("GBK"); 有什么作用
- 再次求助面试题,还有个不会:(
- 如果数据库这么设计表结构!Hibernate的HQL语句应该怎么写????
- 急求struts+spring+hibernate的应用
- 关于UTF_8到SHIFT_JIS转换出现乱码的问题?
- 使用hibernate进行两表关联查询,非得进行关联配置吗
<!-- edited with XMLSPY v2004 rel. 4 U (http://www.xmlspy.com) by Jim Rigsbee (private) -->
<xs:schema targetNamespace="http://jbpm.org/3/jpdl" elementFormDefault="qualified" attributeFormDefault="unqualified" version="3.0" xmlns="http://jbpm.org/3/jpdl" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="process-definition" type="process-definition-v3.0">
<xs:annotation>
<xs:documentation>jBPM Process Definition Language (JPDL) version 3.0 </xs:documentation>
</xs:annotation>
</xs:element>
<xs:simpleType name="configType">
<xs:annotation>
<xs:documentation>Indicates how to use the metadata within a handler</xs:documentation>
</xs:annotation>
xmlns="http://jbpm.org/3/jpdl" name="demo">
<start-state name="enter request">
<task name="request entry">
<assignment class="com.cheng.demo.ApplyAssignment"></assignment>
<controller>
<variable name="startdate"></variable>
</controller>
</task>
<transition name="" to="evaluate request"></transition>
</start-state>
<task-node name="evaluate request">
<task name="request evaluate">
<assignment class="com.cheng.demo.LookAssignment"></assignment>
<controller>
<variable name="startdate" access="read"></variable>
<variable name="decison"></variable>
</controller>
</task>
<transition name="more info needed" to="gave additional info"></transition>
<transition name="approve/disapprove" to="end"></transition>
</task-node>
<task-node name="gave additional info">
<task name="additional info enry">
<assignment class="com.cheng.demo.EditAssignment"></assignment>
<controller>
<variable name="startdate"></variable>
</controller>
</task>
<transition name="" to="evaluate request"></transition>
</task-node>
<end-state name="end"></end-state>
</process-definition>