Add XSL stylesheet to fix up SVG files
authorPeter Eisentraut
Wed, 19 Jun 2019 19:26:42 +0000 (21:26 +0200)
committerPeter Eisentraut
Wed, 19 Jun 2019 19:26:42 +0000 (21:26 +0200)
The SVG output produced by external tools needs some postprocessing.
This is implemented by this new XSL stylesheet.

Issues are:

- SVG produced by Ditaa does not add a viewBox attribute to the svg
  element, needed to make the image scalable.

- SVG produced by Graphviz uses a stroke="transparent" attribute,
  which is not valid SVG.  It appears to mostly work, but FOP
  complains.

Other tweaks can be added over time.

This reverts 7dc78d8ef3e62f7e06d7767c63dcede048377b9a and
29046c44f36099f4c979b1491fcf27db2f9184f9, which applied these fixes
manually.

.gitattributes
doc/src/sgml/images/Makefile
doc/src/sgml/images/README
doc/src/sgml/images/fixup-svg.xsl [new file with mode: 0644]
doc/src/sgml/images/gin.svg
doc/src/sgml/images/pagelayout.svg

index 2b72ef7e557e10b486491856a6305f8acfa08fd3..3ac99972812b7dfce00952096555f5af94e2c285 100644 (file)
@@ -13,7 +13,6 @@ README.*  conflict-marker-size=32
 
 # Certain data files that contain special whitespace, and other special cases
 *.data                     -whitespace
-*.svg                      whitespace=-blank-at-eol
 contrib/pgcrypto/sql/pgp-armor.sql     whitespace=-blank-at-eol
 src/backend/catalog/sql_features.txt       whitespace=space-before-tab,blank-at-eof,-blank-at-eol
 
index bb508dd0dd04c89080809a552805b44845aeb718..1e7993020b523b83e392e260a0516ceddc1a386f 100644 (file)
@@ -8,11 +8,19 @@ ALL_IMAGES = \
 
 DITAA = ditaa
 DOT = dot
+XSLTPROC = xsltproc
 
 all: $(ALL_IMAGES)
 
-%.svg: %.gv
+%.svg.tmp: %.gv
    $(DOT) -T svg -o $@ $<
 
-%.svg: %.txt
+%.svg.tmp: %.txt
    $(DITAA) -E -S --svg $< $@
+
+# Post-processing for SVG files coming from other tools
+#
+# Use --novalid to avoid loading SVG DTD if a file specifies it, since
+# it might not be available locally, and we don't need it.
+%.svg: %.svg.tmp fixup-svg.xsl
+   $(XSLTPROC) --novalid -o $@ $(word 2,$^) $<
index ade627bda2db05247d4b01bbf5707094bd16f18b..07c458025534575100dc950b6b99a6647b4fa4bc 100644 (file)
@@ -22,6 +22,10 @@ Therefore, any tool used needs to be able to produce SVG.
 This directory contains makefile rules to build SVG from common input
 formats, using some common styling.
 
+fixup-svg.xsl applies some postprocessing to the SVG files produced by
+those external tools to address assorted issues.  See comments in
+there, and adjust and expand as necessary.
+
 Both the source and the SVG output file are committed in this
 directory.  That way, we don't need all developers to have all the
 tools installed.  While we accept that there could be some gratuitous
@@ -59,10 +63,3 @@ Notes:
 - The width should be set to something.  This ensures that the image
   is scaled to fit the page in PDF output.  (Other widths than 100%
   might be appropriate.)
-
-- SVG images should be scalable as they will be rendered in a variety
-  of places (web, PDF, etc.) as well as in different viewports
-  (desktop, mobile, etc.). To help the images successfully scale,
-  employ a "viewBox" attribute in the SVG tag. For example,
-  to create an image with a default width and height of 400x300,
-  you would use viewBox="0.00 0.00 400.00 300.00"
diff --git a/doc/src/sgml/images/fixup-svg.xsl b/doc/src/sgml/images/fixup-svg.xsl
new file mode 100644 (file)
index 0000000..d6c46b3
--- /dev/null
@@ -0,0 +1,44 @@
+
+
+                xmlns:svg="http://www.w3.org/2000/svg"
+                version="1.0">
+
+
+
+
+
+  
+    
+      
+        0 0 
+        
+         
+        
+      
+    
+    
+  
+
+
+
+
+  none
+
+
+
+
+  
+    
+  
+
+
+
index eacb5c8c160cdcd8cf45bfe15a3fce02a497e0d5..04fe85ba44e6909a6f829eed9aded4214df53d22 100644 (file)
@@ -1,14 +1,11 @@
-
-
- "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+
 
 
-
- viewBox="0.00 0.00 836.00 432.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+
 
 gin
-transparent" points="-4,4 -4,-428 832,-428 832,4 -4,4"/>
+none" points="-4,4 -4,-428 832,-428 832,4 -4,4"/>
 
 cluster01
 
@@ -47,7 +44,7 @@
 
 
 
-m1<span class="marked">-</span>>e1
+m1<span class="marked">-</span>>e1
 
 
 
@@ -58,7 +55,7 @@
 
 
 
-m1<span class="marked">-</span>>n1
+m1<span class="marked">-</span>>n1
 
 
 
@@ -69,7 +66,7 @@
 
 
 
-e1<span class="marked">-</span>>e2
+e1<span class="marked">-</span>>e2
 
 
 
@@ -80,7 +77,7 @@
 
 
 
-e1<span class="marked">-</span>>e3
+e1<span class="marked">-</span>>e3
 
 
 
 
 
 
-e1<span class="marked">-</span>>e4
+e1<span class="marked">-</span>>e4
 
 
 
 
 
-e2<span class="marked">-</span>>e3
+e2<span class="marked">-</span>>e3
 
 
 
 
 
 
-e2<span class="marked">-</span>>e5
+e2<span class="marked">-</span>>e5
 
 
 
 
 
 
-e2<span class="marked">-</span>>e6
+e2<span class="marked">-</span>>e6
 
 
 
 
 
-e3<span class="marked">-</span>>e4
+e3<span class="marked">-</span>>e4
 
 
 
 
 
 
-e3<span class="marked">-</span>>e7
+e3<span class="marked">-</span>>e7
 
 
 
 
 
 
-e4<span class="marked">-</span>>e8
+e4<span class="marked">-</span>>e8
 
 
 
 
 
 
-e4<span class="marked">-</span>>e9
+e4<span class="marked">-</span>>e9
 
 
 
 
 
-e5<span class="marked">-</span>>e6
+e5<span class="marked">-</span>>e6
 
 
 
 
 
 
-e5<span class="marked">-</span>>p1
+e5<span class="marked">-</span>>p1
 
 
 
 
 
-e6<span class="marked">-</span>>e7
+e6<span class="marked">-</span>>e7
 
 
 
 
 
-e7<span class="marked">-</span>>e8
+e7<span class="marked">-</span>>e8
 
 
 
 
 
 
-e7<span class="marked">-</span>>p4
+e7<span class="marked">-</span>>p4
 
 
 
 
 
 
-e7<span class="marked">-</span>>p5
+e7<span class="marked">-</span>>p5
 
 
 
 
 
-e8<span class="marked">-</span>>e9
+e8<span class="marked">-</span>>e9
 
 
 
 
 
 
-p1<span class="marked">-</span>>p2
+p1<span class="marked">-</span>>p2
 
 
 
 
 
 
-p1<span class="marked">-</span>>p3
+p1<span class="marked">-</span>>p3
 
 
 
 
 
-p2<span class="marked">-</span>>p3
+p2<span class="marked">-</span>>p3
 
 
 
 
 
 
-p5<span class="marked">-</span>>p6
+p5<span class="marked">-</span>>p6
 
 
 
 
 
 
-p5<span class="marked">-</span>>p7
+p5<span class="marked">-</span>>p7
 
 
 
 
 
-p6<span class="marked">-</span>>p7
+p6<span class="marked">-</span>>p7
 
 
 
 
 
 
-n1<span class="marked">-</span>>n2
+n1<span class="marked">-</span>>n2
 
 
 
 
 
 
-n2<span class="marked">-</span>>n3
+n2<span class="marked">-</span>>n3
 
 
 
 
 
 
-n3<span class="marked">-</span>>n4
+n3<span class="marked">-</span>>n4
 
 
 
index 3cf89f0a14e405de6046fb31df38c78d56966ce1..5b2caaf170884d20a7f34b3ddc583b7176fc52c8 100644 (file)
@@ -1,41 +1,35 @@
-
-
-    xmlns='http://www.w3.org/2000/svg'
-    width='610'
-    height='210'
-    viewBox='0.00 0.00 610.00 210.00'
-    shape-rendering='geometricPrecision'
-    version='1.0'>
+
+
   
-    'f2' x='0' y='0' width='200%' height='200%'>
-      'offOut' in='SourceGraphic' dx='5' dy='5' />
-      'blurOut' in='offOut' stdDeviation='3' />
-      'SourceGraphic' in2='blurOut' mode='normal' />
+    "f2" x="0" y="0" width="200%" height="200%">
+      "offOut" in="SourceGraphic" dx="5" dy="5"/>
+      "blurOut" in="offOut" stdDeviation="3"/>
+      "SourceGraphic" in2="blurOut" mode="normal"/>
     
   
-  '1' stroke-linecap='square' stroke-linejoin='round'>
-    '0' y='0' width='610' height='210' style='fill: #ffffff'/>
-    '#000000' stroke-width='1.000000' stroke-linecap='round' stroke-linejoin='round' fill='white' d='M25.0 35.0 L25.0 175.0 L585.0 175.0 L585.0 35.0 z' />
-    '#000000' stroke-width='1.000000' stroke-linecap='round' stroke-linejoin='round' fill='white' d='M305.0 175.0 L485.0 175.0 L485.0 147.0 L305.0 147.0 z' />
-    '#000000' stroke-width='1.000000' stroke-linecap='round' stroke-linejoin='round' fill='white' d='M25.0 35.0 L25.0 63.0 L195.0 63.0 L195.0 35.0 z' />
-    '#000000' stroke-width='1.000000' stroke-linecap='round' stroke-linejoin='round' fill='white' d='M305.0 147.0 L305.0 175.0 L195.0 175.0 L195.0 147.0 z' />
-    '#000000' stroke-width='1.000000' stroke-linecap='round' stroke-linejoin='round' fill='white' d='M325.0 63.0 L325.0 91.0 L265.0 91.0 L265.0 105.0 L235.0 105.0 L235.0 63.0 z' />
-    '#000000' stroke-width='1.000000' stroke-linecap='round' stroke-linejoin='round' fill='white' d='M585.0 147.0 L585.0 175.0 L485.0 175.0 L485.0 147.0 z' />
-    '#000000' stroke-width='1.000000' stroke-linecap='round' stroke-linejoin='round' fill='white' d='M195.0 35.0 L285.0 35.0 L285.0 63.0 L195.0 63.0 z' />
-    '#000000' stroke-width='1.000000' stroke-linecap='round' stroke-linejoin='round' fill='white' d='M375.0 35.0 L375.0 63.0 L285.0 63.0 L285.0 35.0 z' />
-    '#000000' stroke-width='1.000000' stroke-linecap='round' stroke-linejoin='round' fill='none' d='M335.0 133.0 L335.0 105.0 L265.0 105.0 ' />
-    'none' stroke-width='1.000000' stroke-linecap='round' stroke-linejoin='round' fill='#000000' d='M470.0 42.0 L480.0 49.0 L470.0 56.0 z' />
-    'none' stroke-width='1.000000' stroke-linecap='round' stroke-linejoin='round' fill='#000000' d='M260.0 126.0 L265.0 140.0 L270.0 126.0 z' />
-    'none' stroke-width='1.000000' stroke-linecap='round' stroke-linejoin='round' fill='#000000' d='M330.0 126.0 L335.0 140.0 L340.0 126.0 z' />
-    'none' stroke-width='1.000000' stroke-linecap='round' stroke-linejoin='round' fill='#000000' d='M140.0 154.0 L130.0 161.0 L140.0 168.0 z' />
-    '#000000' stroke-width='1.000000' stroke-linecap='round' stroke-linejoin='round' fill='none' d='M265.0 105.0 L265.0 133.0 ' />
-    '#000000' stroke-width='1.000000' stroke-dasharray='5.000000,5.000000' stroke-miterlimit='0' stroke-linecap='butt' stroke-linejoin='round' fill='white' d='M375.0 49.0 L475.0 49.0 ' />
-    '#000000' stroke-width='1.000000' stroke-dasharray='5.000000,5.000000' stroke-miterlimit='0' stroke-linecap='butt' stroke-linejoin='round' fill='white' d='M135.0 161.0 L195.0 161.0 ' />
-    '48' y='54' font-family='Courier' font-size='15' stroke='none' fill='#000000' >
-    '214' y='166' font-family='Courier' font-size='15' stroke='none' fill='#000000' >
-    '216' y='54' font-family='Courier' font-size='15' stroke='none' fill='#000000' >
-    '306' y='54' font-family='Courier' font-size='15' stroke='none' fill='#000000' >
-    '324' y='166' font-family='Courier' font-size='15' stroke='none' fill='#000000' >
-    '509' y='166' font-family='Courier' font-size='15' stroke='none' fill='#000000' >
+  "1" stroke-linecap="square" stroke-linejoin="round">
+    "0" y="0" width="610" height="210" style="fill: #ffffff"/>
+    "#000000" stroke-width="1.000000" stroke-linecap="round" stroke-linejoin="round" fill="white" d="M25.0 35.0 L25.0 175.0 L585.0 175.0 L585.0 35.0 z"/>
+    "#000000" stroke-width="1.000000" stroke-linecap="round" stroke-linejoin="round" fill="white" d="M305.0 175.0 L485.0 175.0 L485.0 147.0 L305.0 147.0 z"/>
+    "#000000" stroke-width="1.000000" stroke-linecap="round" stroke-linejoin="round" fill="white" d="M25.0 35.0 L25.0 63.0 L195.0 63.0 L195.0 35.0 z"/>
+    "#000000" stroke-width="1.000000" stroke-linecap="round" stroke-linejoin="round" fill="white" d="M305.0 147.0 L305.0 175.0 L195.0 175.0 L195.0 147.0 z"/>
+    "#000000" stroke-width="1.000000" stroke-linecap="round" stroke-linejoin="round" fill="white" d="M325.0 63.0 L325.0 91.0 L265.0 91.0 L265.0 105.0 L235.0 105.0 L235.0 63.0 z"/>
+    "#000000" stroke-width="1.000000" stroke-linecap="round" stroke-linejoin="round" fill="white" d="M585.0 147.0 L585.0 175.0 L485.0 175.0 L485.0 147.0 z"/>
+    "#000000" stroke-width="1.000000" stroke-linecap="round" stroke-linejoin="round" fill="white" d="M195.0 35.0 L285.0 35.0 L285.0 63.0 L195.0 63.0 z"/>
+    "#000000" stroke-width="1.000000" stroke-linecap="round" stroke-linejoin="round" fill="white" d="M375.0 35.0 L375.0 63.0 L285.0 63.0 L285.0 35.0 z"/>
+    "#000000" stroke-width="1.000000" stroke-linecap="round" stroke-linejoin="round" fill="none" d="M335.0 133.0 L335.0 105.0 L265.0 105.0 "/>
+    "none" stroke-width="1.000000" stroke-linecap="round" stroke-linejoin="round" fill="#000000" d="M470.0 42.0 L480.0 49.0 L470.0 56.0 z"/>
+    "none" stroke-width="1.000000" stroke-linecap="round" stroke-linejoin="round" fill="#000000" d="M260.0 126.0 L265.0 140.0 L270.0 126.0 z"/>
+    "none" stroke-width="1.000000" stroke-linecap="round" stroke-linejoin="round" fill="#000000" d="M330.0 126.0 L335.0 140.0 L340.0 126.0 z"/>
+    "none" stroke-width="1.000000" stroke-linecap="round" stroke-linejoin="round" fill="#000000" d="M140.0 154.0 L130.0 161.0 L140.0 168.0 z"/>
+    "#000000" stroke-width="1.000000" stroke-linecap="round" stroke-linejoin="round" fill="none" d="M265.0 105.0 L265.0 133.0 "/>
+    "#000000" stroke-width="1.000000" stroke-dasharray="5.000000,5.000000" stroke-miterlimit="0" stroke-linecap="butt" stroke-linejoin="round" fill="white" d="M375.0 49.0 L475.0 49.0 "/>
+    "#000000" stroke-width="1.000000" stroke-dasharray="5.000000,5.000000" stroke-miterlimit="0" stroke-linecap="butt" stroke-linejoin="round" fill="white" d="M135.0 161.0 L195.0 161.0 "/>
+    "48" y="54" font-family="Courier" font-size="15" stroke="none" fill="#000000">PageHeaderData
+    "214" y="166" font-family="Courier" font-size="15" stroke="none" fill="#000000">Item
+    "216" y="54" font-family="Courier" font-size="15" stroke="none" fill="#000000">ItemId
+    "306" y="54" font-family="Courier" font-size="15" stroke="none" fill="#000000">ItemId
+    "324" y="166" font-family="Courier" font-size="15" stroke="none" fill="#000000">Item
+    "509" y="166" font-family="Courier" font-size="15" stroke="none" fill="#000000">Special