unmarshalling

JAXB partial-unmarshalling Elements without @XMLRootElement

烈酒焚心 提交于 2019-12-23 07:24:15
问题 I am using the partial-unmarshalling example of JAXB , but I am unable to unmarshal XML-Elements which are not on the root-level (cause they don't have an @XmlRootElement tag). In my example I tried to read the shipTo-Element instead of the purchaseOrder-Element. Normally I would work with JAXBElement unmarshal(Source source,Class declaredType) but since the example is using an UnmarshallerHandler and a XMLFilterImpl I don't know where to tell Jaxb which Class it should use. My error message

How to properly release memory when doing custom marshaling (ICustomMarshaler) from native to managed?

最后都变了- 提交于 2019-12-23 05:16:23
问题 My main app is in C# and I'm now trying to write a DLL (for input-output) that should be portable (in C or C++ for both Windows and Linux) and accessible both from others C++ apps and from my main C# app. Although inside my DLL I use C++ to make my life easier, I use C-style methods for the interface, i.e. I have extern "C" { /* methods */} in my headers. I thought this was better than having a C++/CLI wrapper (hope that was the right choice since I'm already far enough, but I would be glad

TypeScript - passing a class as an argument, and reflection

我只是一个虾纸丫 提交于 2019-12-23 03:00:40
问题 I am writing a generic unmarshaller. It converts graph DB data to generated TypeScript (1.8.7) model classes. The input is JSON. The output should be an instance of a model class. My ultimate goal is to create something like Hibernate OGM, only for Tinkerpop Frames and TypeScript, with REST endpoint in the middle. What's the right way to pass a class as a parameter and reach it's static members? I want to have something like this: SomeModel some = <SomeModel> unmarshaller.fromJSON({/*Object

JAXB2 type restriction not working?

陌路散爱 提交于 2019-12-22 10:34:20
问题 I have set up a test unit at github. Could someone please check why this is not working though the XML to unmarshal looks good? https://github.com/jjYBdx4IL/misc-tests/blob/master/src/test/java/jjybdx4il/jaxb/bugs/Stackoverflow26618647Test.java "<?xml version=\"1.0\" encoding=\"UTF-8\"?><message:GenericData xmlns:message=\"http://www.sdmx.org/resources/sdmxml/schemas/v2_1/message\" xmlns:common=\"http://www.sdmx.org/resources/sdmxml/schemas/v2_1/common\" xmlns:xsi=\"http://www.w3.org/2001

Serializing C++ objects

纵然是瞬间 提交于 2019-12-22 09:13:31
问题 I would like to implement a Serialization Class which takes in an object and converts it into a binary stream and stored in a file. Later, the object should be reconstructed from a file. Though this functionality is provided by BinaryFormatter in C#, I would like to design my own Serialization class from scratch. Can someone point to some resources ? Thanks in advance 回答1: I have been using boost::serialization library for a while now and I think it is very good. You just need to create the

json unmarshal embedded struct

僤鯓⒐⒋嵵緔 提交于 2019-12-22 08:15:12
问题 I would like to unmarshal to struct Outer defined as: type Outer struct { Inner Num int } type Inner struct { Data string } func (i *Inner) UnmarshalJSON(data []byte) error { i.Data = string(data) return nil } Using json.Unmarshal(data, &Outer{}) seems only to use Inner 's UnmarshalJSON and ignores the Num field: https://play.golang.org/p/WUBfzpheMl I have an unwieldy solution where I set the Num field manually, but I was wondering if anybody had a cleaner or simpler way to do it. Thanks! 回答1

Null Pointer Exception in JAXB RI ClassFactory

a 夏天 提交于 2019-12-22 04:42:22
问题 Intro My friend and I are working on a JavaFX application that acts as a planner for our school. We have tasks (homework for classes), events, courses and student info. In an attempt to store data persistently on the user's hard drive we are using JAXB. We have annotated our classes and can successfully marshall the Task class in a wrapper. The problem is unmarshalling from the tasks.xml file. Here are the relevant lines of code: Task.java @XmlRootElement public class Task { //constructors /

Invalid XML Character During Unmarshall

人盡茶涼 提交于 2019-12-22 03:55:54
问题 I am marshalling objects to XML file using encoding "UTF-8". It generates file successfully. But when I try to unmarshal it back, there is an error: An invalid XML character (Unicode: 0x{2}) was found in the value of attribute "{1}" and element is "0" The character is 0x1A or \u001a, which is valid in UTF-8 but illegal in XML. Marshaller in JAXB allows writing this character into XML file, but Unmarshaller cannot parse it back. I tried to use another encoding (UTF-16, ASCII, etc) but still

Invalid XML Character During Unmarshall

你说的曾经没有我的故事 提交于 2019-12-22 03:55:10
问题 I am marshalling objects to XML file using encoding "UTF-8". It generates file successfully. But when I try to unmarshal it back, there is an error: An invalid XML character (Unicode: 0x{2}) was found in the value of attribute "{1}" and element is "0" The character is 0x1A or \u001a, which is valid in UTF-8 but illegal in XML. Marshaller in JAXB allows writing this character into XML file, but Unmarshaller cannot parse it back. I tried to use another encoding (UTF-16, ASCII, etc) but still

How do I unmarshal nested XML elements into an array?

女生的网名这么多〃 提交于 2019-12-21 17:44:42
问题 My XML contains an array of predefined elements, but I can't pick up the array. Here is the XML structure: var xml_data = `<Parent> <Val>Hello</Val> <Children> <Child><Val>Hello</Val></Child> <Child><Val>Hello</Val></Child> <Child><Val>Hello</Val></Child> </Children> </Parent>` Here is the full code and here is the playground link. Running this will pick up Parent.Val, but not Parent.Children. package main import ( "fmt" "encoding/xml" ) func main() { container := Parent{} err := xml