Element is not known in this context, could not determine its type, or trying to use marshaller.
See original GitHub issueHi
I have an issue while using the marshaller. I am new to JSONIX and I would like to convert JavaScript object to XML document. I generated mapping based on Schemat_JPK_FA(1)_v1-0.xsd
file (in the project).
Could You @highsource please take a look and tell me why I get “Element [JPK] is not known in this context” error?
Here is my project https://github.com/gitowiec/jsonix-tryout
And here is sample of XML I want to get from JSON:
<?xml version="1.0" encoding="UTF-8"?>
<JPK xmlns="http://jpk.mf.gov.pl/wzor/2016/03/09/03095/" xmlns:ns2="http://crd.gov.pl/xml/schematy/dziedzinowe/mf/2016/01/25/eD/DefinicjeTypy/">
<Naglowek>
<KodFormularza kodSystemowy="JPK_FA (1)" wersjaSchemy="1-0">JPK_FA</KodFormularza>
<WariantFormularza>1</WariantFormularza>
<CelZlozenia>1</CelZlozenia>
<DataWytworzeniaJPK>2018-02-23T13:47:59.311+01:00</DataWytworzeniaJPK>
<DataOd>2018-01-01</DataOd>
<DataDo>2018-01-31</DataDo>
<DomyslnyKodWaluty>PLN</DomyslnyKodWaluty>
<KodUrzedu>2205</KodUrzedu>
</Naglowek>
<Podmiot1>
<IdentyfikatorPodmiotu>
<ns2:NIP>123123123</ns2:NIP>
<ns2:PelnaNazwa>qwerty</ns2:PelnaNazwa>
<ns2:REGON>123123</ns2:REGON>
</IdentyfikatorPodmiotu>
<AdresPodmiotu>
<ns2:KodKraju>PL</ns2:KodKraju>
<ns2:Wojewodztwo>pomorskie</ns2:Wojewodztwo>
<ns2:Powiat>dsadasd</ns2:Powiat>
<ns2:Gmina>dsadasd</ns2:Gmina>
<ns2:Ulica>gfdsgdsf</ns2:Ulica>
<ns2:NrDomu>11</ns2:NrDomu>
<ns2:Miejscowosc>fdsfdsf</ns2:Miejscowosc>
<ns2:KodPocztowy>44-444</ns2:KodPocztowy>
<ns2:Poczta>dsadasdsa</ns2:Poczta>
</AdresPodmiotu>
</Podmiot1>
<Faktura typ="G">
<P_1>2018-01-12</P_1>
<P_2A>FV SP / 198 / 01 / 2018</P_2A>
<P_3A>dsadasdsadasf</P_3A>
<P_3B>fdsfdsfdsfsdf</P_3B>
<P_3C>fdsfdsfdsfsdfsad</P_3C>
<P_3D>dsadsadsafgdsgsdfsdf</P_3D>
<P_4B>4324324324</P_4B>
<P_5B>4324324234</P_5B>
<P_6>2018-01-10</P_6>
<P_13_1>5316.00</P_13_1>
<P_14_1>1222.68</P_14_1>
<P_13_2>0.00</P_13_2>
<P_14_2>0.00</P_14_2>
<P_13_3>0.00</P_13_3>
<P_14_3>0.00</P_14_3>
<P_13_5>0.00</P_13_5>
<P_14_5>0.00</P_14_5>
<P_13_6>0.00</P_13_6>
<P_13_7>0.00</P_13_7>
<P_15>6538.68</P_15>
<P_16>false</P_16>
<P_17>false</P_17>
<P_18>false</P_18>
<P_19>false</P_19>
<P_20>false</P_20>
<P_21>false</P_21>
<P_23>false</P_23>
<P_106E_2>false</P_106E_2>
<P_106E_3>false</P_106E_3>
<RodzajFaktury>VAT</RodzajFaktury>
</Faktura>
<FakturaWiersz typ="G">
<P_2B>FV SP / 9 / 02 / 2018</P_2B>
<P_7>Transport - UPS</P_7>
<P_8A>sztuk</P_8A>
<P_8B>1</P_8B>
<P_9A>15.37</P_9A>
<P_11>15.37</P_11>
<P_12>23</P_12>
</FakturaWiersz>
<FakturaWierszCtrl>
<LiczbaWierszyFaktur>399</LiczbaWierszyFaktur>
<WartoscWierszyFaktur>20383.81</WartoscWierszyFaktur>
</FakturaWierszCtrl>
</JPK>
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
xml - jsonix: Element [] is not known in this context, could not ...
Now I want to produce an xml-String by using jsonix and the above json-mapping-object: var context = new Jsonix.Context([IdentPerson]); var ...
Read more >Chapter 8. Marshalling XML using O/X Mappers - Spring
In this chapter, we will describe Spring's Object/XML Mapping support. Object/XML Mapping, or O/X mapping for short, is the act of converting an...
Read more >api documentation for jsonix (v2.4.1)
PO; // First we construct a Jsonix context - a factory for unmarshaller (parser) // and marshaller (serializer) var context = new Jsonix.Context([PO]);...
Read more >Guide to JAXB - Baeldung
JAXB provides a fast and convenient way to marshal (write) Java objects into XML and unmarshal (read) XML into objects. It supports a...
Read more >Java Architecture for XML Binding (JAXB) - Oracle
For example, there's no need to create or use a SAX parser or write callback methods. Bind the Schema. JAXB simplifies access to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve sent you a PR with the fix:
https://github.com/gitowiec/jsonix-tryout/pull/1
There were three problems with your code:
require('./mappings/JPK')
as mapping, should berequire('./mappings/JPK').JPK
. Generated modules export mappings as a property of the mapping’s name.{JPK: value}
to work, your target namespace has to be associated with the empty namespace.nip
instead ofNIP
.With a few fixes I could generate the following XML:
Correct. Well done, thanks!