Skip to content

Commit

Permalink
svg xslt updated, image checking added
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelligent2013 committed Feb 1, 2021
1 parent 4833139 commit 539cb20
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/resources/map2svg.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,21 @@
<xsl:variable name="width" select="java:getWidth($bufferedImage)"/>
<xsl:variable name="height" select="java:getHeight($bufferedImage)"/>

<xsl:if test="number($width) != $width">
<xsl:message>Unknown width=<xsl:value-of select="$width"/></xsl:message>
</xsl:if>
<xsl:if test="number($height) != $height">
<xsl:message>Unknown height=<xsl:value-of select="$height"/></xsl:message>
</xsl:if>

<xsl:variable name="filePath" select="java:toPath($file)"/>
<xsl:variable name="fileContent" select="java:java.nio.file.Files.readAllBytes($filePath)"/>
<xsl:variable name="encoder" select="java:java.util.Base64.getEncoder()"/>
<xsl:variable name="base64String" select="java:encodeToString($encoder, $fileContent)"/>

<xsl:if test="normalize-space($base64String) = ''">
<xsl:message>Error: empty base64 string.</xsl:message>
</xsl:if>

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
x="0px" y="0px" viewBox="0 0 {$width} {$height}" style="enable-background:new 0 0 595.28 841.89;" xml:space="preserve">
Expand Down

0 comments on commit 539cb20

Please sign in to comment.