image href - base64 string
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 14
- Joined: Thu Sep 24, 2020 8:20 pm
image href - base64 string
Hi,
I have a client using DITA with oXygen 23.1.
Their image tags looks like:
The actual image data is stored as blobs in a SQL database. I have a REST endpoint (xquery) exposed in eXist-db that makes a SQL fetch to the server and returns the blob data as a base64-encoded string. The returned string is prefixed with "data:image/jpeg;base64," followed by the actual base64 image string.
I've tried setting up the CSS like:
I've played around with the serialization parameters on the xquery side. Besides no serialization, I've tried:
Am I missing something? Is there a way for a DITA image to render in oXygen with the href attempting to display a base64 image string?
I have a client using DITA with oXygen 23.1.
Their image tags looks like:
Code: Select all
<image href="456"/>
I've tried setting up the CSS like:
Code: Select all
image {
content: oxy_url(oxy_concat("httpURLtoExistDB.../getImage.xqy?id=",attr(href))) !important;
}
Code: Select all
declare option exist:serialize "method=text media-type=image/jpeg";
...
(: tried with and without the data:image/jpeg;base64, prefix :)
(: return $imgDoc :)
return "data:image/jpeg;base64," || $imgDoc
Code: Select all
declare option exist:serialize "method=xhtml media-type=text/html";
...
let $src := "data:image/jpeg;base64," || $imgDoc
return <img src="{$src}"/>
-
- Posts: 9433
- Joined: Fri Jul 09, 2004 5:18 pm
Re: image href - base64 string
Hi,
Oxygen has support to display base 64 embedded images, but the images need to be embedded, the URL itself for the image target needs to be of form "data:image/jpeg;base64,.....".
In your case you are pointing Oxygen to an URL on an Exist server, URL which serves a string which is a base 64 URL, this does not work in general, neither in Oxygen nor in any other tool.
What you could serve from your remote URL would be a vectorial SVG image (SVG images are in XML form so they can be produced by XQuery). And SVG in turn can embed inside base 64 images like:
https://stackoverflow.com/questions/624 ... map-images
or refer to a binary image inside the SVG:
https://developer.mozilla.org/en-US/doc ... ment/image
Regards,
Radu
Oxygen has support to display base 64 embedded images, but the images need to be embedded, the URL itself for the image target needs to be of form "data:image/jpeg;base64,.....".
In your case you are pointing Oxygen to an URL on an Exist server, URL which serves a string which is a base 64 URL, this does not work in general, neither in Oxygen nor in any other tool.
What you could serve from your remote URL would be a vectorial SVG image (SVG images are in XML form so they can be produced by XQuery). And SVG in turn can embed inside base 64 images like:
https://stackoverflow.com/questions/624 ... map-images
or refer to a binary image inside the SVG:
https://developer.mozilla.org/en-US/doc ... ment/image
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 14
- Joined: Thu Sep 24, 2020 8:20 pm
Re: image href - base64 string
Thanks -- that worked. I ended up doing something like this in the xquery:Radu wrote: ↑Wed Sep 29, 2021 6:58 am Hi,
Oxygen has support to display base 64 embedded images, but the images need to be embedded, the URL itself for the image target needs to be of form "data:image/jpeg;base64,.....".
In your case you are pointing Oxygen to an URL on an Exist server, URL which serves a string which is a base 64 URL, this does not work in general, neither in Oxygen nor in any other tool.
What you could serve from your remote URL would be a vectorial SVG image (SVG images are in XML form so they can be produced by XQuery). And SVG in turn can embed inside base 64 images like:
https://stackoverflow.com/questions/624 ... map-images
or refer to a binary image inside the SVG:
https://developer.mozilla.org/en-US/doc ... ment/image
Regards,
Radu
Code: Select all
xquery version "3.1";
declare option exist:serialize "method=xml media-type=image/svg+xml";
let $id := request:get-parameter("id","")
... (: call to SQl db not included here :)
let $src := "data:image/jpeg;base64," || $imgDoc
let $width := image:get-width($imgDoc)
let $height := image:get-height($imgDoc)
return
<svg xmlns="http://www.w3.org/2000/svg" width="{$width}" height="{$height}" xmlns:xlink="http://www.w3.org/1999/xlink">
<image width="{$width}" height="{$height}" xlink:href="{$src}"/>
</svg>
Code: Select all
image:before {}
image {
content: oxy_url(oxy_concat("httpRESTPathToQuery/getImage.xqy?id=",attr(href))) !important;
}
Return to “General XML Questions”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service