Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support org.w3c.dom.Document input to SVGImageReader #722

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

stanio
Copy link

@stanio stanio commented Dec 31, 2022

Use case: Allow reading an SVG source once, and tweaking its content in memory like changing viewBox, colors, and styles to produce multiple image variants in succession.

Similar to: DynamicSvgOffscreen - Rendering a dynamic SVG document to an offscreen buffer (Batik HowTos)

@stanio
Copy link
Author

stanio commented Dec 31, 2022

Just noticed there's a previous #452. It is slightly different from my suggestion here – it appears to perform some unnecessary hoops for org.w3c.dom.svg.SVGDocument vs. org.w3c.dom.Document, serializing the latter so it would be parsed back. As far as I see org.apache.batik.transcoder.TranscoderInput could be initialized with any org.w3c.dom.Document, and given the instance is namespace-aware it is processed just fine by Batik (as proven by the test case I've added here).

Allow reading an SVG source once, and tweak its content in memory like
changing viewBox, colors, and styles to produce multiple image variants
in succession.

See "DynamicSvgOffscreen - Rendering a dynamic SVG document to an offscreen buffer" (Batik HowTos)
	<https://cwiki.apache.org/confluence/display/XMLGRAPHICSBATIK/DynamicSvgOffscreen>
Handle DOM exceptions to signal IIOException.  Avoid unexpected
unchecked exception popping up.
@haraldk
Copy link
Owner

haraldk commented Jan 2, 2023

Thanks!

I'll look into the changes as soon as I find the time!

Declare SVG_ROOT QName instead of just the namespace.
Extract SVGImageReaderSpi DOM tests into separate class/suite.
Replace unintended DocumentBuilderFactory.newDefaultInstance() (Java 9+)
usage -> DocumentBuilderFactory.newInstance(), in tests.
haraldk added a commit that referenced this pull request Jun 5, 2023
haraldk added a commit that referenced this pull request Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants