How to use transmissive voxels with color gradients?
You don't need volumetric shading to do this -  you just need to return where surfaces intersect a 3D texture space.

To make a solid color cube:




The Geometry node returns the 3D coordinates of the point being shaded in World space, measured in Blender units from World 0,0,0. As a first shot, all we have to do is plug the X, Y and Z values straight into the R,G and B values of the color of a diffuse shader. (The elements cast automatically from position XYZ to color RGB in the range 0 - 1, and clamp outside the range.)
But it would be nice to have  our X, Y and Z  measured from the origin of the cube, not the world, whatever translation, scale or rotation the cube is subjected to. The Vector Transform derives the (cube) object space coordinate from the world space coordinate, so you can move the cube around, and the color sticks to it. (The cube was made 1x1x1, with its origin at its minimum XYZ, when untransformed.)
The Math > Power nodes roughly map the linear coordinates to sRGB to display OK with my color management settings. 0 and 1 remain where they were, the curve between them is altered.. (gamma correction).
Cycles bounces light around the scene from one surface to another. Scattering of color between faces wasn't helpful, so the Light Path and Mix nodes make the material black, as far as the diffuse bounces are concerned (but not to the camera).


This shows the color cube with a Boolean modifier .. another (unrendered) cutting cube is taking a chunk out of it. You may see artifacts from the Boolean in the preview, but they don't appear in the final render.

 

A 'Voxel' representation .. 




An applied array , 10x10x10, of small cubes in a 1x1x1 volume, whose origin is at minimum X,Y,Z.
Most of the details as above, but this time, to get per-voxel-cube  shading, using an Object Info node, which can return the world coordinates, not of the shading point, but of the origin of the currently shaded object. When that is plugged into RGB, each voxel-cube  is colored with the XYZ of its origin.
I can't think of a brief, general, way to measure those locations in another object's space. So as it stands, this one is sensitive to being moved about. You could obviously tweak by hand to deal with changing scale, other transformations, but.., I'll be posting this as a question myself. Suggestions welcome in the comments.