Tag: xml

xpath 2.0 for java possible

我应该为XPath使用什么包? 我想要查询元素,然后在这些节点周围提取一些值。 也许一个或多个级别更高,一些属性。 javax.xml.xpath是XPath 1.0。 javax.xml.xpath和org.w3c.dom是正确的方法,还是有更现代的实现? org.w3c.dom很尴尬,JDOM看起来很简单。

XercesImpl与JavaSE 6的内部xerces实现相冲突。 两者都需要……可以做些什么?

我确信我不是第一个遇到这种冲突的人。 我inheritance的代码执行以下操作: org.w3c.dom.Document dom; // declaration javax.xml.validation.Schema schema; // declaration … … … javax.xml.validation.Validator validator = schema.newValidator(); validator.validate(new DOMSource(dom)); …代表看似不重要/不相关的代码 使用JDK 6编译和运行代码可以工作(并且总是有……) 最近我不得不将我公司其他地方编写的另一个组件集成到我的代码中。 该组件绝对需要包含在xercesImpl-2.8.1.jar的类路径中 我绝对需要这个第三方组件, 但现在运行上面的代码不再有效,我得到以下内容: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element ‘Root’. at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown […]

JAXB可以处理java.time对象吗?

我知道JAXB(用于XML绑定的Java体系结构)可以编组/解组java.util.Date对象,如Blaise Doughan的回答所示 。 但是Java 8中新的java.time包对象ZonedDateTime样呢,比如ZonedDateTime呢? JAXB是否已更新以处理这种新的内置数据类型?

Apple的pListforms的XML可以通过Android Java解析吗?

我们可以在Android上解析基于iPhone / iPad的pList XML吗? 请告诉我您使用或了解过的任何此类图书馆?

SAX与XmlTextReader – C#中的SAX

我正在尝试阅读一个大型XML文档,我希望以块的forms与XmlDocument将整个文件读入内存的方式进行。 我知道我可以使用XmlTextReader来做到这一点,但我想知道是否有人使用过SAX for .NET? 我知道Java开发人员发誓它,我想知道是否值得试一试,如果是这样,使用它有什么好处。 我正在寻找细节。

JAXB需要一个公共的无参数构造函数?

在编组期间,JAXB需要一个公共的无参数构造函数? Marshaller msh = ctx.createMarshaller(); msh.marshal(object, System.out); 我正在传递一个对象,而不是一个类。 为什么JAXB需要构造函数? 构建什么?

用不正确的urlvalidationjdoconfig

我正在使用jdo并使用jdoconfig.xml配置持久性管理器 然而,无论我在哪里找到有关jdoconfig.xml的文档,它都声明应该使用http://java.sun.com/xml/ns/jdo/jdoconfig进行validation。 etc 此URL指向不存在的文件,我的xmlvalidation程序报告错误。 甚至使用它的目的是什么,我们是否可以相信url不会改变,我们所有的xml文件都会突然停止validation? 有谁知道新的url?

强制Spring RestTemplate使用XmlConverter

我们正在与第三方集成,该第三方将带有内容类型标头的xml发送为text / html。 我们计划使用Spring的RestTemplate将它映射到我们从xsds生成的类,但是RestTemplate无法找到用于内容的适当转换器。 第三方拒绝修复内容类型,因为它可能会破坏其他合作伙伴的集成。 Spring的RestTemplate是否有办法强制它使用特定的转换器? 我们基本上只是做以下事情: RestTemplate restTemplate = new RestTemplate(); XmlClass xmlClass = restTemplate.getForObject(“http://example.com/”, XmlClass.class); 并获得以下exception: org.springframework.web.client.RestClientException:无法提取响应:在org.springframework.web.client中找不到适合的响应类型[XmlClass]和内容类型[text / html; charset = ISO-8859-1]的HttpMessageConverter。 HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:84)

如何使用EMF读取XML文件?

EMF = Eclipse Modeling Framework 我必须在我的一个class级项目中使用EMF。 我试图了解如何使用EMF执行以下操作: 读XML, 将值获取到对象中。 使用ORM将对象中的值持久保存到数据库。 – 完成 使用ORM从数据库获取数据并生成XML。 我需要使用以下所有内容:EMF(不知道是什么)和JPA(DONE)。 我使用过JAXB,我知道,这可以使用JAXB完成,但是(EMF == JAXB)怎么办?! 我使用EMF创建了许多java类,但是它们有很多! 我在哪里实现读/写方法以及如何运行EMF项目? 谢谢 UPDATE1提示http://www.eclipsezone.com/eclipse/forums/t58829.html UPDATE2 我有架构,我使用.xsd生成了模型代码。 现在我在从XML文件中读取数据时遇到了问题。

如何将JAXB对象封送到org.w3c.dom.Document?

这给了我一个Document对象,其顶级节点没有子节点: public static Document getDocument(Object jaxb) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); //dbf.setNamespaceAware(true); Document doc = dbf.newDocumentBuilder().newDocument(); JAXBContext context = JAXBContext.newInstance(jaxb.getClass()); context.createMarshaller().marshal(jaxb, doc); return doc; } 这是解决方法,它看起来效率更低,因为它转换为String然后转换为Document。 public static Document getDocument(Object jaxb) { StringWriter writer = new StringWriter(); JAXBContext context = JAXBContext.newInstance(jaxb.getClass()); context.createMarshaller().marshal(jaxb, writer); return DocumentBuilderFactory.newInstance().newDocumentBuilder(). parse(new InputSource(new StringReader(writer.toString())); } 是否有可能完成我想要完成的任务?