Skip to content

Commit 9c1f795

Browse files
committed
experimental support for embedded SVG
1 parent 9937dd1 commit 9c1f795

6 files changed

Lines changed: 130 additions & 52 deletions

File tree

clean-for-DTD.xslt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
Strip rfc2629.xslt extensions, generating XML input for MTR's xml2rfc
33
4-
Copyright (c) 2006-2015, Julian Reschke (julian.reschke@greenbytes.de)
4+
Copyright (c) 2006-2016, Julian Reschke (julian.reschke@greenbytes.de)
55
All rights reserved.
66
77
Redistribution and use in source and binary forms, with or without
@@ -34,9 +34,10 @@
3434
xmlns:ed="http://greenbytes.de/2002/rfcedit"
3535
xmlns:grddl="http://www.w3.org/2003/g/data-view#"
3636
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
37+
xmlns:svg="http://www.w3.org/2000/svg"
3738
xmlns:x="http://purl.org/net/xml2rfc/ext"
3839
xmlns:xhtml="http://www.w3.org/1999/xhtml"
39-
exclude-result-prefixes="ed grddl rdf x xhtml"
40+
exclude-result-prefixes="ed grddl rdf svg x xhtml"
4041
>
4142

4243
<!-- re-use some of the default RFC2629.xslt rules -->
@@ -662,6 +663,14 @@
662663
<xsl:template name="insert-end-code"/>
663664
<xsl:template match="@x:is-code-component" mode="cleanup"/>
664665

666+
<xsl:template match="artwork[svg:svg]" mode="cleanup">
667+
<xsl:call-template name="warning">
668+
<xsl:with-param name="inline" select="'no'"/>
669+
<xsl:with-param name="msg">SVG image removed.</xsl:with-param>
670+
</xsl:call-template>
671+
<artwork>(see SVG image in HTML version)</artwork>
672+
</xsl:template>
673+
665674
<xsl:template match="artwork" mode="cleanup">
666675
<xsl:variable name="content2"><xsl:apply-templates select="."/></xsl:variable>
667676
<xsl:variable name="content" select="translate($content2,'&#160;&#x2500;&#x2502;&#x2508;&#x250c;&#x2510;&#x2514;&#x2518;&#x251c;&#x2524;',' -|+++++++')"/>

rfc2629-ext.rnc

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ namespace grddl = "http://www.w3.org/2003/g/data-view#"
1111
# Define RDF namespace
1212
namespace rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
1313

14+
# Define SVG namespace
15+
namespace svg = "http://www.w3.org/2000/svg"
16+
1417
# Include rfc2629bis RNC grammar
1518
include "rfc2629.rnc" {
1619

@@ -32,24 +35,26 @@ include "rfc2629.rnc" {
3235
artwork =
3336
element artwork {
3437
attlist.artwork,
35-
(TEXT
36-
| eref
37-
| iref
38-
| spanx
39-
| xref
40-
| v3_em
41-
| v3_strong
42-
| x_abnf-char-sequence
43-
| x_bb
44-
| x_bc
45-
| x_bcp14
46-
| x_bt
47-
| x_highlight
48-
| x_length-of
49-
| x_parse-xml
50-
| x_ref
51-
| x_span
52-
| x_x)*
38+
( v3_svg |
39+
(TEXT
40+
| eref
41+
| iref
42+
| spanx
43+
| xref
44+
| v3_em
45+
| v3_strong
46+
| x_abnf-char-sequence
47+
| x_bb
48+
| x_bc
49+
| x_bcp14
50+
| x_bt
51+
| x_highlight
52+
| x_length-of
53+
| x_parse-xml
54+
| x_ref
55+
| x_span
56+
| x_x)*
57+
)
5358
}
5459

5560
# Redefine <back> to allow boilerplate
@@ -485,7 +490,7 @@ v3_sup =
485490
(TEXT)*
486491
}
487492

488-
# Monospaced Text (see Section 12.20)
493+
# Monospaced Text (see Section 12.21)
489494
v3_tt =
490495
element tt {
491496
(TEXT
@@ -494,14 +499,29 @@ v3_tt =
494499
| x_ref)*
495500
}
496501

497-
# Unordered List (see Section 12.21)
502+
# Unordered List (see Section 12.22)
498503
v3_ul =
499504
element ul {
500505
attribute anchor { xsd:ID }?,
501506
attribute empty { TEXT }?,
502507
v3_li+
503508
}
504509

510+
# SVG (see Section 12.20)
511+
v3_svg =
512+
element svg:svg {
513+
(attribute * { text }
514+
| text
515+
| anySVGElement)*
516+
}
517+
518+
anySVGElement =
519+
element svg:* {
520+
(attribute * { text }
521+
| text
522+
| anySVGElement)*
523+
}
524+
505525
# Conversion to ABNF char sequence (see Section 11.1)
506526
x_abnf-char-sequence =
507527
element x:abnf-char-sequence {

rfc2629.xslt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@
4040
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
4141
xmlns:saxon="http://saxon.sf.net/"
4242
xmlns:saxon-old="http://icl.com/saxon"
43+
xmlns:svg="http://www.w3.org/2000/svg"
4344
xmlns:x="http://purl.org/net/xml2rfc/ext"
4445
xmlns:xhtml="http://www.w3.org/1999/xhtml"
4546

46-
exclude-result-prefixes="date ed exslt msxsl myns rdf saxon saxon-old x xhtml"
47+
exclude-result-prefixes="date ed exslt msxsl myns rdf saxon saxon-old svg x xhtml"
4748
>
4849

4950
<xsl:strip-space elements="abstract author back figure front list middle note postal reference references rfc section texttable"/>
@@ -817,6 +818,10 @@
817818
</xsl:if>
818819
</xsl:template>
819820

821+
<xsl:template match="artwork[svg:svg]">
822+
<xsl:copy-of select="svg:svg"/>
823+
</xsl:template>
824+
820825
<xsl:template match="artwork|sourcecode">
821826
<xsl:if test="not(ancestor::ed:del) and $xml2rfc-ext-parse-xml-in-artwork='yes' and function-available('myns:parseXml')" use-when="function-available('myns:parseXml')">
822827
<xsl:if test="contains(.,'&lt;?xml')">
@@ -5047,7 +5052,14 @@ ul.ind li li {
50475052
font-weight: normal;
50485053
line-height: 150%;
50495054
margin-left: 0em;
5055+
}<xsl:if test="//svg:svg">
5056+
@namespace svg url(http://www.w3.org/2000/svg);
5057+
svg|svg {
5058+
margin-left: 3em;
50505059
}
5060+
svg {
5061+
margin-left: 3em;
5062+
}</xsl:if>
50515063
.avoidbreakinside {
50525064
page-break-inside: avoid;
50535065
}
@@ -8112,11 +8124,11 @@ dd, li, p {
81128124
<xsl:variable name="gen">
81138125
<xsl:text>http://greenbytes.de/tech/webdav/rfc2629.xslt, </xsl:text>
81148126
<!-- when RCS keyword substitution in place, add version info -->
8115-
<xsl:if test="contains('$Revision: 1.763 $',':')">
8116-
<xsl:value-of select="concat('Revision ',normalize-space(translate(substring-after('$Revision: 1.763 $', 'Revision: '),'$','')),', ')" />
8127+
<xsl:if test="contains('$Revision: 1.764 $',':')">
8128+
<xsl:value-of select="concat('Revision ',normalize-space(translate(substring-after('$Revision: 1.764 $', 'Revision: '),'$','')),', ')" />
81178129
</xsl:if>
8118-
<xsl:if test="contains('$Date: 2016/02/12 13:46:41 $',':')">
8119-
<xsl:value-of select="concat(normalize-space(translate(substring-after('$Date: 2016/02/12 13:46:41 $', 'Date: '),'$','')),', ')" />
8130+
<xsl:if test="contains('$Date: 2016/02/13 15:06:48 $',':')">
8131+
<xsl:value-of select="concat(normalize-space(translate(substring-after('$Date: 2016/02/13 15:06:48 $', 'Date: '),'$','')),', ')" />
81208132
</xsl:if>
81218133
<xsl:value-of select="concat('XSLT vendor: ',system-property('xsl:vendor'),' ',system-property('xsl:vendor-url'))" />
81228134
</xsl:variable>

rfc2629toFO.xslt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@
3737
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
3838
xmlns:myns="mailto:julian.reschke@greenbytes.de?subject=rcf2629.xslt"
3939
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
40+
xmlns:svg="http://www.w3.org/2000/svg"
4041
xmlns:x="http://purl.org/net/xml2rfc/ext"
4142

42-
exclude-result-prefixes="ed exslt msxsl myns rdf x"
43+
exclude-result-prefixes="ed exslt msxsl myns rdf svg x"
4344
>
4445

4546
<xsl:import href="rfc2629.xslt" />
@@ -177,6 +178,12 @@
177178
</xsl:choose>
178179
</xsl:template>
179180

181+
<xsl:template match="artwork[svg:svg]">
182+
<fo:instream-foreign-object>
183+
<xsl:copy-of select="svg:svg"/>
184+
</fo:instream-foreign-object>
185+
</xsl:template>
186+
180187
<xsl:template match="artwork|sourcecode">
181188
<fo:block>
182189
<xsl:if test="not(ancestor::figure)">

rfc2629xslt.xml

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,6 +1433,14 @@ Content-Length: &lt;x:length-of target="req"/>
14331433
</t>
14341434
</section>
14351435

1436+
<section title="svg Element" anchor="v3.svg">
1437+
<iref item="V3 Extension Elements" subitem="svg" primary="true"/>
1438+
<iref item="svg V3 Extension Element" primary="true"/>
1439+
<t>
1440+
See <xref target="XML2RFCV3" x:fmt="of" x:rel="#element.svg"/>.
1441+
</t>
1442+
</section>
1443+
14361444
<section title="tt Element" anchor="v3.tt">
14371445
<iref item="V3 Extension Elements" subitem="tt" primary="true"/>
14381446
<iref item="tt V3 Extension Element" primary="true"/>
@@ -1448,6 +1456,7 @@ Content-Length: &lt;x:length-of target="req"/>
14481456
See <xref target="XML2RFCV3" x:fmt="of" x:rel="#element.ul"/>.
14491457
</t>
14501458
</section>
1459+
14511460
</section>
14521461

14531462
<section title="Utilities" anchor="utilities">
@@ -2090,10 +2099,10 @@ ocasionally save.
20902099
<front>
20912100
<title>The "xml2rfc" version 3 Vocabulary</title>
20922101
<author initials="P." surname="Hoffman" fullname="Paul Hoffman"/>
2093-
<date month="February" year="2016"/>
2102+
<date month="January" year="2016"/>
20942103
</front>
2095-
<seriesInfo name="Internet-Draft" value="draft-iab-xml2rfc-03"/>
2096-
<x:source href="/projects/ietf/xml2rfc/vocabulary/v3/iab03/draft-iab-xml2rfc-latest.xml"/>
2104+
<seriesInfo name="Internet-Draft" value="draft-iab-xml2rfc-02"/>
2105+
<x:source href="/projects/ietf/xml2rfc/vocabulary/v3/iab02/draft-iab-xml2rfc-latest.xml"/>
20972106
</reference>
20982107

20992108
</references>
@@ -2123,6 +2132,9 @@ namespace grddl = "http://www.w3.org/2003/g/data-view#"
21232132
<em># Define RDF namespace</em>
21242133
namespace rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
21252134

2135+
<em># Define SVG namespace</em>
2136+
namespace svg = "http://www.w3.org/2000/svg"
2137+
21262138
<em># Include rfc2629bis RNC grammar</em>
21272139
include "rfc2629.rnc" {
21282140

@@ -2144,24 +2156,26 @@ include "rfc2629.rnc" {
21442156
artwork =
21452157
element artwork {
21462158
attlist.artwork,
2147-
(TEXT
2148-
<strong>| eref</strong>
2149-
<strong>| iref</strong>
2150-
<strong>| spanx</strong>
2151-
<strong>| xref</strong>
2152-
<strong>| <x:ref>v3_em</x:ref></strong>
2153-
<strong>| <x:ref>v3_strong</x:ref></strong>
2154-
<strong>| <x:ref>x_abnf-char-sequence</x:ref></strong>
2155-
<strong>| <x:ref>x_bb</x:ref></strong>
2156-
<strong>| <x:ref>x_bc</x:ref></strong>
2157-
<strong>| <x:ref>x_bcp14</x:ref></strong>
2158-
<strong>| <x:ref>x_bt</x:ref></strong>
2159-
<strong>| <x:ref>x_highlight</x:ref></strong>
2160-
<strong>| <x:ref>x_length-of</x:ref></strong>
2161-
<strong>| <x:ref>x_parse-xml</x:ref></strong>
2162-
<strong>| <x:ref>x_ref</x:ref></strong>
2163-
<strong>| <x:ref>x_span</x:ref></strong>
2164-
<strong>| <x:ref>x_x</x:ref></strong>)*
2159+
( <strong><x:ref>v3_svg</x:ref> |
2160+
</strong>(TEXT
2161+
<strong>| eref</strong>
2162+
<strong>| iref</strong>
2163+
<strong>| spanx</strong>
2164+
<strong>| xref</strong>
2165+
<strong>| <x:ref>v3_em</x:ref></strong>
2166+
<strong>| <x:ref>v3_strong</x:ref></strong>
2167+
<strong>| <x:ref>x_abnf-char-sequence</x:ref></strong>
2168+
<strong>| <x:ref>x_bb</x:ref></strong>
2169+
<strong>| <x:ref>x_bc</x:ref></strong>
2170+
<strong>| <x:ref>x_bcp14</x:ref></strong>
2171+
<strong>| <x:ref>x_bt</x:ref></strong>
2172+
<strong>| <x:ref>x_highlight</x:ref></strong>
2173+
<strong>| <x:ref>x_length-of</x:ref></strong>
2174+
<strong>| <x:ref>x_parse-xml</x:ref></strong>
2175+
<strong>| <x:ref>x_ref</x:ref></strong>
2176+
<strong>| <x:ref>x_span</x:ref></strong>
2177+
<strong>| <x:ref>x_x</x:ref></strong>)*
2178+
)
21652179
}
21662180

21672181
<em># Redefine &lt;back> to allow boilerplate</em>
@@ -2633,6 +2647,22 @@ attlist.xref &amp;=
26332647
<x:ref>v3_li</x:ref>+
26342648
}
26352649

2650+
<em anchor="v3_svg"><iref item="svg V3 Extension Element"/><iref item="V3 Extension Elements" subitem="svg"
2651+
/># SVG (see <xref target="v3.svg"/>)</em>
2652+
<x:ref>v3_svg</x:ref> =
2653+
element svg:svg {
2654+
(attribute * { text }
2655+
| text
2656+
| anySVGElement)*
2657+
}
2658+
2659+
anySVGElement =
2660+
element svg:* {
2661+
(attribute * { text }
2662+
| text
2663+
| anySVGElement)*
2664+
}
2665+
26362666
<em anchor="x_abnf-char-sequence"><iref item="abnf-char-sequence Extension Element"/><iref item="Extension Elements" subitem="abnf-char-sequence"
26372667
/># Conversion to ABNF char sequence (see <xref target="ext.element.abnf-char-sequence"/>)</em>
26382668
<x:ref>x_abnf-char-sequence</x:ref> =

xsl11toFop.xslt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
Transform XSL 1.1 extensions to Apache FOP
33
4-
Copyright (c) 2007-2010, Julian Reschke (julian.reschke@greenbytes.de)
4+
Copyright (c) 2007-2016, Julian Reschke (julian.reschke@greenbytes.de)
55
All rights reserved.
66
77
Redistribution and use in source and binary forms, with or without
@@ -57,8 +57,8 @@
5757

5858
<!-- remove third-party extensions -->
5959

60-
<xsl:template match="*[not(ancestor::fo:declarations) and namespace-uri()!='http://www.w3.org/1999/XSL/Format' and namespace-uri()!='http://xml.apache.org/fop/extensions']" />
61-
<xsl:template match="@*[not(ancestor::fo:declarations) and namespace-uri()!='' and namespace-uri()!='http://www.w3.org/1999/XSL/Format' and namespace-uri()!='http://xml.apache.org/fop/extensions']" />
60+
<xsl:template match="*[not(ancestor::fo:declarations) and namespace-uri()!='http://www.w3.org/1999/XSL/Format' and namespace-uri()!='http://www.w3.org/2000/svg' and namespace-uri()!='http://xml.apache.org/fop/extensions']" />
61+
<xsl:template match="@*[not(ancestor::fo:declarations) and namespace-uri()!='' and namespace-uri()!='http://www.w3.org/2000/svg' and namespace-uri()!='http://www.w3.org/1999/XSL/Format' and namespace-uri()!='http://xml.apache.org/fop/extensions']" />
6262

6363
<!-- index-page-citation-list -->
6464

0 commit comments

Comments
 (0)