- 浏览: 125472 次
- 性别:
- 来自: 南京
-
文章分类
- 全部博客 (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 258微信 h5分享 1.前端jsp 需要去除追加字符,传到后端进行 ... -
url 二级域名匹配
2016-10-14 16:32 589private static void urlMatche(S ... -
Https Basic Auth
2016-03-21 15:16 1206最近测试 Https 连接,遇到了些问题。 1. Cause ... -
unicdoe 转码
2015-12-04 16:15 502开始以为是乱码,我日。 http://www.faqs.org ... -
eclipse中取消show in Breadcrumb方法
2015-11-23 18:01 1677eclipse中取消show in Breadcrumb方法 ... -
sqserver order by 与java compareTo ,xml sting getBytes乱码
2015-08-04 23:10 6011.sqlsever orderby 顺序,取出list, 然 ... -
手动构建xml xls 日期 datetime number type
2014-10-28 19:07 1396http://ewbi.blogs.com/develops/ ... -
压缩 inputstream to zipoutputstream to bytearrayoutputstream
2014-10-21 20:06 1580http://stackoverflow.com/questi ... -
JMX demo
2014-02-07 11:05 945http://docs.oracle.com/javase/6 ... -
xsl dom 一个xml 引用另一个xml的某些节点
2014-02-07 11:07 659http://www.coderanch.com/t/1263 ... -
excel 导入导出
2013-03-20 21:35 830else if (type.equalsIgnoreCase( ... -
servlet 线程安全 application.setattribute,加上synchronized
2013-03-20 20:35 1669http://www.alixixi.com/Dev/Web/ ... -
sj22
2013-01-09 21:37 1019Organizations 字段名 含义 类型 缺省值 备 ... -
jaxb style
2012-10-12 11:55 718http://www.coderanch.com/t/4952 ... -
jsp out.print 乱码
2014-02-07 11:07 1310response.setContentType( " ... -
定时器使用Timer,timerTask
2012-02-01 17:14 8451.每隔10分钟触发 web.xml <listener ...
相关推荐
JDOM的1.x系列版本(如提供的jdom.jar)适用于许多旧项目,但在现代项目中,可能已被更新的API如DOM4J或Java 7引入的Java/XML绑定工具如JAXB所取代。 3. XercesImpl.jar Xerces是Apache软件基金会开发的一个开源XML...
- **xercesImpl**:Apache Xerces是一个开源的XML解析器,提供了DOM、SAX和XSLT的实现。 - **xml-apis**:XML API接口,包含SAX、DOM和其他XML相关接口。 4. **XML解析流程** - 读取XML文件:使用BufferedReader...
Xerces是Apache软件基金会开发的一个开源XML解析器,它可以作为DOM、SAX和XML Schema处理器。Xerces提供了高度可配置的解析选项,对于需要深度定制XML解析的项目非常有用。 8. **JAXB RI (Runtime Implementation)...
8. **xercesImpl-2.8.1.jar**:Xerces是Apache的一个XML解析器项目,它实现了XML 1.0和1.1规范,以及DOM、SAX和XML Schema接口。版本2.8.1是这个解析器的一个版本。 9. **jaxb-impl-2.1.6.jar**:这是JAXB实现的主...
2. **resolver.jar**:这个文件通常包含XML解析器的依赖,如Apache的Xerces解析器,用于解析XML文档并处理DTD(文档类型定义)和XML Schema。 3. **xbean.jar**:这是XMLBeans的核心库,它实现了XML Schema到Java类...
在Java项目中,常见的XML处理库有Apache的Xerces和Woodstox,它们提供了高效的XML解析器和实现。此外,Spring框架也内置了对XML配置的支持,使得开发者可以使用XML来定义bean和配置。 在使用XML的jar包时,需要注意...
压缩包中的JAR文件涵盖了各种依赖,例如XML解析器(如Xerces或DOM4J)、HTTP客户端库(如Commons HttpClient)、 logging框架(如Log4j)、以及一些通用工具类库(如Commons Lang、Commons Collections)。...
然而,尽管Apache Crimson曾经是一个流行的XML解析库,但它现在已经被更现代、更高效的库如Java自带的JAXB(Java Architecture for XML Binding)和Apache Xerces所取代。这些现代库提供了更好的性能和更多的XML标准...
- Xerces是Apache软件基金会开发的一个开源XML解析器,提供了对DOM、SAX和XSLT的支持,`xercesImpl.jar`是这个解析器的实现。 5. **JSP和Servlet**: - `servlet-api.jar`和`jsp-api.jar`是Java服务器页面(JSP)...
5. **xercesImpl-2.6.2.jar**:Xerces是Apache的一个XML解析器实现,它实现了XML 1.0和1.1规范,以及相关的DOM、SAX和XML Schema接口。这个库对于处理XML文档至关重要。 6. **xfire-all-1.2.6.jar**:XFire是早期的...
5. **xercesImpl-2.8.1.jar**:Xerces是Apache的XML解析器实现,它解析XML文档并将其转换为DOM(Document Object Model)或其他形式的数据结构。 6. **jaxb-impl-2.1.7.jar**:这是JAXB的实现库,用于处理XML和Java...
Xerces2 Java是其第二代产品,提供DOM(文档对象模型)、SAX(简单API for XML)和XP(XPath)接口,支持XML Schema、DTD(文档类型定义)以及命名空间。 2. **Apache XML APIs**: 这是一组与XML相关的API集合,...
10. **xercesImpl-2.6.2.jar**:Xerces是Apache的一个XML解析器,实现了W3C的DOM、SAX和XML Schema规范,用于解析和验证XML文档。 这些库组合在一起,可以构建出一个功能强大的Java应用,包括SSH连接、数据库操作、...