- 浏览: 119853 次
- 性别:
- 来自: 南京
文章分类
- 全部博客 (97)
- Jquery (3)
- Oracle (11)
- JS (12)
- Struts2 (4)
- java (17)
- 课程 (1)
- Jboss (0)
- EJB (0)
- MAVEN (1)
- Design Pattern (0)
- css (2)
- axis1.4 (2)
- hessian (1)
- big data (1)
- Tomcat (3)
- redis (1)
- OVAL validate (1)
- express (1)
- eclipse (1)
- name node 无法启动 (1)
- hadoop (2)
- mysql (1)
- spring (1)
- sbt (1)
- angular (1)
- cas (1)
- JSSDK (1)
- 微信支付 (1)
- 小程序 (1)
- mybatis (1)
- jxta (1)
- idea (2)
- lay ui (1)
- sofa (1)
最新评论
-
duanwenping520:
这也太省事了把!
sj22
1.采用dom解析的时候,遇到Xerces.jar,会出现
Exception in thread "main" java.lang.AbstractMethodError: org.apache.crimson.tree.ElementNode.getTextContent()Ljava/lang/String;
去掉xerces.jar或者
构建dom之前加上
System.setProperty("javax.xml.parsers.DocumentBuilderFactory","com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
可参考:http://www.iteye.com/topic/587404
2.当jaxb与xerces.jar冲突时,
指定jaxb的解析方式,为dom解析,并采用1的设置参数
view plaincopy to clipboardprint?
Marshalling to a javax.xml.transform.SAXResult:
// assume MyContentHandler instanceof ContentHandler
SAXResult result = new SAXResult( new MyContentHandler() );
m.marshal( element, result );
Marshalling to a javax.xml.transform.DOMResult:
DOMResult result = new DOMResult();
m.marshal( element, result );
Marshalling to a javax.xml.transform.StreamResult:
StreamResult result = new StreamResult( System.out );
m.marshal( element, result );
Marshalling to a javax.xml.stream.XMLStreamWriter:
XMLStreamWriter xmlStreamWriter =
XMLOutputFactory.newInstance().createXMLStreamWriter( ... );
m.marshal( element, xmlStreamWriter );
Marshalling to a javax.xml.stream.XMLEventWriter:
XMLEventWriter xmlEventWriter =
XMLOutputFactory.newInstance().createXMLEventWriter( ... );
m.marshal( element, xmlEventWriter );
Unmarshalling from a org.w3c.dom.Node:
JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
Unmarshaller u = jc.createUnmarshaller();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new File( "nosferatu.xml"));
Object o = u.unmarshal( doc );
Unmarshalling from a javax.xml.transform.sax.SAXSource using a client specified validating SAX2.0 parser:
// configure a validating SAX2.0 parser (Xerces2)
static final String JAXP_SCHEMA_LANGUAGE =
"http://java.sun.com/xml/jaxp/properties/schemaLanguage";
static final String JAXP_SCHEMA_LOCATION =
"http://java.sun.com/xml/jaxp/properties/schemaSource";
static final String W3C_XML_SCHEMA =
"http://www.w3.org/2001/XMLSchema";
System.setProperty( "javax.xml.parsers.SAXParserFactory",
"org.apache.xerces.jaxp.SAXParserFactoryImpl" );
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setValidating(true);
SAXParser saxParser = spf.newSAXParser();
try {
saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
saxParser.setProperty(JAXP_SCHEMA_LOCATION, "http://....");
} catch (SAXNotRecognizedException x) {
// exception handling omitted
}
XMLReader xmlReader = saxParser.getXMLReader();
SAXSource source =
new SAXSource( xmlReader, new InputSource( "http://..." ) );
// Setup JAXB to unmarshal
JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
Unmarshaller u = jc.createUnmarshaller();
ValidationEventCollector vec = new ValidationEventCollector();
u.setEventHandler( vec );
// turn off the JAXB provider's default validation mechanism to
// avoid duplicate validation
u.setValidating( false )
// unmarshal
Object o = u.unmarshal( source );
// check for events
if( vec.hasEvents() ) {
// iterate over events
}
Unmarshalling from a StAX XMLStreamReader:
JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
Unmarshaller u = jc.createUnmarshaller();
javax.xml.stream.XMLStreamReader xmlStreamReader =
javax.xml.stream.XMLInputFactory().newInstance().createXMLStreamReader( ... );
Object o = u.unmarshal( xmlStreamReader );
Unmarshalling from a StAX XMLEventReader:
JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
Unmarshaller u = jc.createUnmarshaller();
javax.xml.stream.XMLEventReader xmlEventReader =
javax.xml.stream.XMLInputFactory().newInstance().createXMLEventReader( ... );
Object o = u.unmarshal( xmlEventReader );
Marshalling to a javax.xml.transform.SAXResult:
// assume MyContentHandler instanceof ContentHandler
SAXResult result = new SAXResult( new MyContentHandler() );
m.marshal( element, result );
Marshalling to a javax.xml.transform.DOMResult:
DOMResult result = new DOMResult();
m.marshal( element, result );
Marshalling to a javax.xml.transform.StreamResult:
StreamResult result = new StreamResult( System.out );
m.marshal( element, result );
Marshalling to a javax.xml.stream.XMLStreamWriter:
XMLStreamWriter xmlStreamWriter =
XMLOutputFactory.newInstance().createXMLStreamWriter( ... );
m.marshal( element, xmlStreamWriter );
Marshalling to a javax.xml.stream.XMLEventWriter:
XMLEventWriter xmlEventWriter =
XMLOutputFactory.newInstance().createXMLEventWriter( ... );
m.marshal( element, xmlEventWriter );
Unmarshalling from a org.w3c.dom.Node:
JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
Unmarshaller u = jc.createUnmarshaller();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new File( "nosferatu.xml"));
Object o = u.unmarshal( doc );
Unmarshalling from a javax.xml.transform.sax.SAXSource using a client specified validating SAX2.0 parser:
// configure a validating SAX2.0 parser (Xerces2)
static final String JAXP_SCHEMA_LANGUAGE =
"http://java.sun.com/xml/jaxp/properties/schemaLanguage";
static final String JAXP_SCHEMA_LOCATION =
"http://java.sun.com/xml/jaxp/properties/schemaSource";
static final String W3C_XML_SCHEMA =
"http://www.w3.org/2001/XMLSchema";
System.setProperty( "javax.xml.parsers.SAXParserFactory",
"org.apache.xerces.jaxp.SAXParserFactoryImpl" );
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setValidating(true);
SAXParser saxParser = spf.newSAXParser();
try {
saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
saxParser.setProperty(JAXP_SCHEMA_LOCATION, "http://....");
} catch (SAXNotRecognizedException x) {
// exception handling omitted
}
XMLReader xmlReader = saxParser.getXMLReader();
SAXSource source =
new SAXSource( xmlReader, new InputSource( "http://..." ) );
// Setup JAXB to unmarshal
JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
Unmarshaller u = jc.createUnmarshaller();
ValidationEventCollector vec = new ValidationEventCollector();
u.setEventHandler( vec );
// turn off the JAXB provider's default validation mechanism to
// avoid duplicate validation
u.setValidating( false )
// unmarshal
Object o = u.unmarshal( source );
// check for events
if( vec.hasEvents() ) {
// iterate over events
}
Unmarshalling from a StAX XMLStreamReader:
JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
Unmarshaller u = jc.createUnmarshaller();
javax.xml.stream.XMLStreamReader xmlStreamReader =
javax.xml.stream.XMLInputFactory().newInstance().createXMLStreamReader( ... );
Object o = u.unmarshal( xmlStreamReader );
Unmarshalling from a StAX XMLEventReader:
JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
Unmarshaller u = jc.createUnmarshaller();
javax.xml.stream.XMLEventReader xmlEventReader =
javax.xml.stream.XMLInputFactory().newInstance().createXMLEventReader( ... );
Object o = u.unmarshal( xmlEventReader );
可参考:http://www.coderanch.com/t/495263/Web-Services/java/type-marshalling-does-JAXB
Exception in thread "main" java.lang.AbstractMethodError: org.apache.crimson.tree.ElementNode.getTextContent()Ljava/lang/String;
去掉xerces.jar或者
构建dom之前加上
System.setProperty("javax.xml.parsers.DocumentBuilderFactory","com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
可参考:http://www.iteye.com/topic/587404
2.当jaxb与xerces.jar冲突时,
指定jaxb的解析方式,为dom解析,并采用1的设置参数
view plaincopy to clipboardprint?
Marshalling to a javax.xml.transform.SAXResult:
// assume MyContentHandler instanceof ContentHandler
SAXResult result = new SAXResult( new MyContentHandler() );
m.marshal( element, result );
Marshalling to a javax.xml.transform.DOMResult:
DOMResult result = new DOMResult();
m.marshal( element, result );
Marshalling to a javax.xml.transform.StreamResult:
StreamResult result = new StreamResult( System.out );
m.marshal( element, result );
Marshalling to a javax.xml.stream.XMLStreamWriter:
XMLStreamWriter xmlStreamWriter =
XMLOutputFactory.newInstance().createXMLStreamWriter( ... );
m.marshal( element, xmlStreamWriter );
Marshalling to a javax.xml.stream.XMLEventWriter:
XMLEventWriter xmlEventWriter =
XMLOutputFactory.newInstance().createXMLEventWriter( ... );
m.marshal( element, xmlEventWriter );
Unmarshalling from a org.w3c.dom.Node:
JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
Unmarshaller u = jc.createUnmarshaller();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new File( "nosferatu.xml"));
Object o = u.unmarshal( doc );
Unmarshalling from a javax.xml.transform.sax.SAXSource using a client specified validating SAX2.0 parser:
// configure a validating SAX2.0 parser (Xerces2)
static final String JAXP_SCHEMA_LANGUAGE =
"http://java.sun.com/xml/jaxp/properties/schemaLanguage";
static final String JAXP_SCHEMA_LOCATION =
"http://java.sun.com/xml/jaxp/properties/schemaSource";
static final String W3C_XML_SCHEMA =
"http://www.w3.org/2001/XMLSchema";
System.setProperty( "javax.xml.parsers.SAXParserFactory",
"org.apache.xerces.jaxp.SAXParserFactoryImpl" );
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setValidating(true);
SAXParser saxParser = spf.newSAXParser();
try {
saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
saxParser.setProperty(JAXP_SCHEMA_LOCATION, "http://....");
} catch (SAXNotRecognizedException x) {
// exception handling omitted
}
XMLReader xmlReader = saxParser.getXMLReader();
SAXSource source =
new SAXSource( xmlReader, new InputSource( "http://..." ) );
// Setup JAXB to unmarshal
JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
Unmarshaller u = jc.createUnmarshaller();
ValidationEventCollector vec = new ValidationEventCollector();
u.setEventHandler( vec );
// turn off the JAXB provider's default validation mechanism to
// avoid duplicate validation
u.setValidating( false )
// unmarshal
Object o = u.unmarshal( source );
// check for events
if( vec.hasEvents() ) {
// iterate over events
}
Unmarshalling from a StAX XMLStreamReader:
JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
Unmarshaller u = jc.createUnmarshaller();
javax.xml.stream.XMLStreamReader xmlStreamReader =
javax.xml.stream.XMLInputFactory().newInstance().createXMLStreamReader( ... );
Object o = u.unmarshal( xmlStreamReader );
Unmarshalling from a StAX XMLEventReader:
JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
Unmarshaller u = jc.createUnmarshaller();
javax.xml.stream.XMLEventReader xmlEventReader =
javax.xml.stream.XMLInputFactory().newInstance().createXMLEventReader( ... );
Object o = u.unmarshal( xmlEventReader );
Marshalling to a javax.xml.transform.SAXResult:
// assume MyContentHandler instanceof ContentHandler
SAXResult result = new SAXResult( new MyContentHandler() );
m.marshal( element, result );
Marshalling to a javax.xml.transform.DOMResult:
DOMResult result = new DOMResult();
m.marshal( element, result );
Marshalling to a javax.xml.transform.StreamResult:
StreamResult result = new StreamResult( System.out );
m.marshal( element, result );
Marshalling to a javax.xml.stream.XMLStreamWriter:
XMLStreamWriter xmlStreamWriter =
XMLOutputFactory.newInstance().createXMLStreamWriter( ... );
m.marshal( element, xmlStreamWriter );
Marshalling to a javax.xml.stream.XMLEventWriter:
XMLEventWriter xmlEventWriter =
XMLOutputFactory.newInstance().createXMLEventWriter( ... );
m.marshal( element, xmlEventWriter );
Unmarshalling from a org.w3c.dom.Node:
JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
Unmarshaller u = jc.createUnmarshaller();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new File( "nosferatu.xml"));
Object o = u.unmarshal( doc );
Unmarshalling from a javax.xml.transform.sax.SAXSource using a client specified validating SAX2.0 parser:
// configure a validating SAX2.0 parser (Xerces2)
static final String JAXP_SCHEMA_LANGUAGE =
"http://java.sun.com/xml/jaxp/properties/schemaLanguage";
static final String JAXP_SCHEMA_LOCATION =
"http://java.sun.com/xml/jaxp/properties/schemaSource";
static final String W3C_XML_SCHEMA =
"http://www.w3.org/2001/XMLSchema";
System.setProperty( "javax.xml.parsers.SAXParserFactory",
"org.apache.xerces.jaxp.SAXParserFactoryImpl" );
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setValidating(true);
SAXParser saxParser = spf.newSAXParser();
try {
saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
saxParser.setProperty(JAXP_SCHEMA_LOCATION, "http://....");
} catch (SAXNotRecognizedException x) {
// exception handling omitted
}
XMLReader xmlReader = saxParser.getXMLReader();
SAXSource source =
new SAXSource( xmlReader, new InputSource( "http://..." ) );
// Setup JAXB to unmarshal
JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
Unmarshaller u = jc.createUnmarshaller();
ValidationEventCollector vec = new ValidationEventCollector();
u.setEventHandler( vec );
// turn off the JAXB provider's default validation mechanism to
// avoid duplicate validation
u.setValidating( false )
// unmarshal
Object o = u.unmarshal( source );
// check for events
if( vec.hasEvents() ) {
// iterate over events
}
Unmarshalling from a StAX XMLStreamReader:
JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
Unmarshaller u = jc.createUnmarshaller();
javax.xml.stream.XMLStreamReader xmlStreamReader =
javax.xml.stream.XMLInputFactory().newInstance().createXMLStreamReader( ... );
Object o = u.unmarshal( xmlStreamReader );
Unmarshalling from a StAX XMLEventReader:
JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
Unmarshaller u = jc.createUnmarshaller();
javax.xml.stream.XMLEventReader xmlEventReader =
javax.xml.stream.XMLInputFactory().newInstance().createXMLEventReader( ... );
Object o = u.unmarshal( xmlEventReader );
可参考:http://www.coderanch.com/t/495263/Web-Services/java/type-marshalling-does-JAXB
发表评论
-
微信 h5 分享
2019-09-30 09:53 218微信 h5分享 1.前端jsp 需要去除追加字符,传到后端进行 ... -
url 二级域名匹配
2016-10-14 16:32 548private static void urlMatche(S ... -
Https Basic Auth
2016-03-21 15:16 1116最近测试 Https 连接,遇到了些问题。 1. Cause ... -
unicdoe 转码
2015-12-04 16:15 440开始以为是乱码,我日。 http://www.faqs.org ... -
eclipse中取消show in Breadcrumb方法
2015-11-23 18:01 1634eclipse中取消show in Breadcrumb方法 ... -
sqserver order by 与java compareTo ,xml sting getBytes乱码
2015-08-04 23:10 5711.sqlsever orderby 顺序,取出list, 然 ... -
手动构建xml xls 日期 datetime number type
2014-10-28 19:07 1358http://ewbi.blogs.com/develops/ ... -
压缩 inputstream to zipoutputstream to bytearrayoutputstream
2014-10-21 20:06 1510http://stackoverflow.com/questi ... -
JMX demo
2014-02-07 11:05 540http://docs.oracle.com/javase/6 ... -
xsl dom 一个xml 引用另一个xml的某些节点
2014-02-07 11:07 625http://www.coderanch.com/t/1263 ... -
excel 导入导出
2013-03-20 21:35 776else if (type.equalsIgnoreCase( ... -
servlet 线程安全 application.setattribute,加上synchronized
2013-03-20 20:35 1626http://www.alixixi.com/Dev/Web/ ... -
sj22
2013-01-09 21:37 941Organizations 字段名 含义 类型 缺省值 备 ... -
jaxb style
2012-10-12 11:55 626http://www.coderanch.com/t/4952 ... -
jsp out.print 乱码
2014-02-07 11:07 1264response.setContentType( " ... -
定时器使用Timer,timerTask
2012-02-01 17:14 8021.每隔10分钟触发 web.xml <listener ...
相关推荐
mail.jar, activation.jar, xerces.jar, xmlsec-1.2.1.jar 做Axis开发必备
web service 必要包 activation.jar mail.jar soap.jar xerces.jar
xerces.jar
xerces.jar xerces.jar xerces.jar xerces.jar xerces.jar
Xerces解析文档Xerces解析文档Xerces解析文档Xerces解析文档
工程包括 DOM4J 处理 xml 全过程(读取,增加,修改,删除) ...[在IBM developerWorks上面可以找到一篇文章,对主流的Java XML API进行的性能、功能和易用性的评测,dom4j无论在那个方面都是非常出色的。]
利用xerces对xml文件进行解析,以实例来进行说明。
标签:apache-xml-xerces.jar.zip,apache,xml,xerces,jar.zip包下载,依赖包
xalan.jar, xerces.jar, xml-apis.jar: Xerces是XML解析器,Xalan是格式化器,xml-apis实际上是JAXP。一般App Server都会带上,JDK1.4也包含了解析器,不过不是Xerces,是Crimson,效率比较差。
lib中包含 activation.jar mail.jar xerces.jar
有时编译需要这个东西,没有就会报错。亦可自行下载。具体参考: https://quantum6.blog.csdn.net/article/details/110426444
用dom4j解析xml时必不可少的jar包,xerces.jar/crimson.jar两者选其一即可。
xerces-2.6.0.jar 解决与strus2 jar包冲突 解析xml文件
dom4j解析时必备的一些jar包,包含dom4j.jar, dom4j-2.0.0-ALPHA-2-sources.java, jaxen-1.1-beta-5.jar, xerces.jar
xerces-2.6.2.jar xerces-2.6.2.jar
xerces是用于解析多种编程语言用于XML 的jar包
xerces-2.9.0.jar
xerces-2.2.1.jar架包,需要的快下吧,希望大家程序调试成功