草庐IT

jaxb-episode

全部标签

android - 将 JAXB 与 Google Android 一起使用

我需要解析通过xml传递的java对象。我想将JAXB框架用于这些目的,因为我已经预先注释(使用JAXB)java类。这原则上可行吗?InputStreaminput=entity.getContent();JAXBContextjc=JAXBContext.newInstance(newClass[]{Response.LoginResponse.class});Unmarshallerun=jc.createUnmarshaller();LoginResponseresponse=(LoginResponse)un.unmarshal(input);在第4行,我有一个警告:“无法解

android - 将 JAXB 与 Google Android 一起使用

我需要解析通过xml传递的java对象。我想将JAXB框架用于这些目的,因为我已经预先注释(使用JAXB)java类。这原则上可行吗?InputStreaminput=entity.getContent();JAXBContextjc=JAXBContext.newInstance(newClass[]{Response.LoginResponse.class});Unmarshallerun=jc.createUnmarshaller();LoginResponseresponse=(LoginResponse)un.unmarshal(input);在第4行,我有一个警告:“无法解

java - JAXB - 解码 OutOfMemory : Java Heap Space

我目前正在尝试使用JAXB解码XML文件,但似乎XML文件太大(~500mb),解码器无法处理。我不断收到java.lang.OutOfMemoryError:Javaheapspace@Unmarshallerum=JAXBContext.newInstance("com.sample.xml");Exporte=(Export)um.unmarhsal(newFile("SAMPLE.XML"));我猜这是因为它试图将大型XML文件作为对象打开,但该文件对于java堆空间来说太大了。还有其他更“节省内存”的方法来解析大约500mb的大型XML文件吗?或者也许是一个可以帮助我处理大型

java - JAXB - 解码 OutOfMemory : Java Heap Space

我目前正在尝试使用JAXB解码XML文件,但似乎XML文件太大(~500mb),解码器无法处理。我不断收到java.lang.OutOfMemoryError:Javaheapspace@Unmarshallerum=JAXBContext.newInstance("com.sample.xml");Exporte=(Export)um.unmarhsal(newFile("SAMPLE.XML"));我猜这是因为它试图将大型XML文件作为对象打开,但该文件对于java堆空间来说太大了。还有其他更“节省内存”的方法来解析大约500mb的大型XML文件吗?或者也许是一个可以帮助我处理大型

java - 获取像 "Two classes have the same XML type name..."这样的 JAXB 异常

获取JAXB异常,例如“两个类具有相同的XML类型名称...”,这里是异常详情:Exceptioninthread"main"com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException:1countsofIllegalAnnotationExceptionsTwoclasseshavethesameXMLtypename"city".Use@XmlType.nameand@XmlType.namespacetoassigndifferentnamestothem.thisproblemisrelatedtothefo

java - 获取像 "Two classes have the same XML type name..."这样的 JAXB 异常

获取JAXB异常,例如“两个类具有相同的XML类型名称...”,这里是异常详情:Exceptioninthread"main"com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException:1countsofIllegalAnnotationExceptionsTwoclasseshavethesameXMLtypename"city".Use@XmlType.nameand@XmlType.namespacetoassigndifferentnamestothem.thisproblemisrelatedtothefo

java - JAXB 给我 : java. lang.IllegalArgumentException: is parameter must not be null

我正在使用JAXB将一些XML解码为Java对象:我的代码看起来有点像这样:InputStreamtestMsg=getClass().getResourceAsStream("TestDocumentEvent.xml");Unmarshallerunmarshaller=JAXBContext.newInstance(DocumentEvent.class).createUnmarshaller();DocumentEventunmarshalled=(DocumentEvent)unmarshaller.unmarshal(testMsg);但是,当我运行此代码时出现异常:jav

java - JAXB 给我 : java. lang.IllegalArgumentException: is parameter must not be null

我正在使用JAXB将一些XML解码为Java对象:我的代码看起来有点像这样:InputStreamtestMsg=getClass().getResourceAsStream("TestDocumentEvent.xml");Unmarshallerunmarshaller=JAXBContext.newInstance(DocumentEvent.class).createUnmarshaller();DocumentEventunmarshalled=(DocumentEvent)unmarshaller.unmarshal(testMsg);但是,当我运行此代码时出现异常:jav

java - 可以使用 JAXB 2.0 验证编码的 XML 吗?

显然在JAXB的第2版中-validator类已被弃用-这是否意味着编码器正在自动验证您的XML?如果是这样,它似乎并没有提示我正在形成的一些不正确的XML!谁能给我一些关于如何验证编码XML以确保它符合XSD架构的建议。非常感谢。 最佳答案 通过使用JAXP1.3SchemaValidationFramework,验证功能在JAXB2.0中得到了扩展。你之前在哪里:unmarshaller.setValidating(true);现在你需要做的:SchemaFactorysf=SchemaFactory.newInstance(j

java - 可以使用 JAXB 2.0 验证编码的 XML 吗?

显然在JAXB的第2版中-validator类已被弃用-这是否意味着编码器正在自动验证您的XML?如果是这样,它似乎并没有提示我正在形成的一些不正确的XML!谁能给我一些关于如何验证编码XML以确保它符合XSD架构的建议。非常感谢。 最佳答案 通过使用JAXP1.3SchemaValidationFramework,验证功能在JAXB2.0中得到了扩展。你之前在哪里:unmarshaller.setValidating(true);现在你需要做的:SchemaFactorysf=SchemaFactory.newInstance(j