Re: [basex-talk] XML + HTML to JSON

2017-12-14 Thread Maximilian Gärber
Hi,

yes, thanks!

I guess this would be a rather common case when you try to call JSON
APIs. So a type declaration for the serializer might be useful.



Br,
Max

2017-12-14 17:09 GMT+01:00 Michael Seiferle :
> Hi Max,
>
> I am not aware of any direct way, but you might consider the following:
>
> https://gist.github.com/micheee/c5a55ca8b49435934c006cfc5df7ba0f
>
>
> What it does:
>
> 1. Replace the contents of xhtml with its string serialization
> 2. Wrap the info node in an element named json, according to our own JSON
> serialization format
> 3. Serialize the contents as JSON.
> …to go back:
> 4. Serialize the JSON as XML
> 5. Remove our JSON-Mapping Attributes
> 6. Replace the value of the element with its (parse:html() in case it is a
> valid document with a single root node) parse-xml-fragment() contents.
>
>
> Hope this kind of helps ;)
>
> Michael
>
>
> --
> Michael Seiferle, BaseX GmbH, http://www.basexgmbh.de
> |-- Firmensitz: Obere Laube 73, 78462 Konstanz
> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
> |   Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle
> `-- Tel: +49 7531 916 82 77
>
> Am 14.12.2017 um 16:16 schrieb Maximilian Gärber :
>
> Hi,
>
> we've content similar to:
>
> 
> Foo
> 
>Some para 
> 
> 
>
> How can I tell the JSON serializer to treat the content of  as html?
>
>
> Br,
>
> Max
>
>


Re: [basex-talk] XML + HTML to JSON

2017-12-14 Thread Michael Seiferle
Hi Max, 

I am not aware of any direct way, but you might consider the following:

https://gist.github.com/micheee/c5a55ca8b49435934c006cfc5df7ba0f


What it does: 

1. Replace the contents of xhtml with its string serialization
2. Wrap the info node in an element named json, according to our own JSON 
serialization format
3. Serialize the contents as JSON.
…to go back:
4. Serialize the JSON as XML
5. Remove our JSON-Mapping Attributes
6. Replace the value of the element with its (parse:html() in case it is a 
valid document with a single root node) parse-xml-fragment() contents.


Hope this kind of helps ;)

Michael


--
Michael Seiferle, BaseX GmbH, http://www.basexgmbh.de
|-- Firmensitz: Obere Laube 73, 78462 Konstanz
|-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
|   Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle
`-- Tel: +49 7531 916 82 77

> Am 14.12.2017 um 16:16 schrieb Maximilian Gärber :
> 
> Hi,
> 
> we've content similar to:
> 
> 
> Foo
> 
>Some para 
> 
> 
> 
> How can I tell the JSON serializer to treat the content of  as html?
> 
> 
> Br,
> 
> Max



[basex-talk] XML + HTML to JSON

2017-12-14 Thread Maximilian Gärber
Hi,

we've content similar to:


Foo

Some para 



How can I tell the JSON serializer to treat the content of  as html?


Br,

Max