Commits

Shlomi Fish  committed d4b88e7

XSLT progress.

  • Participants
  • Parent commits 0f9b91f

Comments (0)

Files changed (2)

File lib/XML-Grammar-Vered/vered-xml.rng

     </define>
     <define name="a">
         <element name="vrd:a">
-            <ref name="common_attrs" />
+            <ref name="global_attrs" />
+            <attribute name="xlink:href">
+                <data type="anyURI"/>
+            </attribute>
             <oneOrMore>
                 <ref name="text_with_style" />
             </oneOrMore>

File src/tutorials/bad-elements/vered-xml-to-docbook.xslt

 
 <xsl:template match="vrd:preface">
     <db:preface>
-        <xsl:copy-of select="@xml:id" />
-        <xsl:if test="@xml:lang">
-            <xsl:copy-of select="@xml:lang" />
-        </xsl:if>
-        <db:info>
-            <db:title>
-                <xsl:choose>
-                    <xsl:when test="vrd:info/vrd:title">
-                        <xsl:value-of select="vrd:info/vrd:title" />
-                    </xsl:when>
-                    <xsl:otherwise>
-                        <xsl:value-of select="@xml:id" />
-                    </xsl:otherwise>
-                </xsl:choose>
-            </db:title>
-        </db:info>
+        <xsl:call-template name="preface_or_section" />
     </db:preface>
 </xsl:template>
 
+<xsl:template name="preface_or_section">
+    <xsl:copy-of select="@xml:id" />
+    <xsl:if test="@xml:lang">
+        <xsl:copy-of select="@xml:lang" />
+    </xsl:if>
+    <db:info>
+        <db:title>
+            <xsl:choose>
+                <xsl:when test="vrd:info/vrd:title">
+                    <xsl:value-of select="vrd:info/vrd:title" />
+                </xsl:when>
+                <xsl:otherwise>
+                    <xsl:value-of select="@xml:id" />
+                </xsl:otherwise>
+            </xsl:choose>
+        </db:title>
+    </db:info>
+    <xsl:apply-templates select="vrd:section|vrd:blockquote|vrd:p|vrd:ol|vrd:ul|vrd:programlisting" />
+</xsl:template>
+
 <xsl:template match="vrd:section">
     <section>
-        <xsl:copy-of select="@xml:id" />
-        <xsl:if test="@xml:lang">
-            <xsl:copy-of select="@xml:lang" />
-        </xsl:if>
-        <!-- Make the title the title attribute or "ID" if does not exist. -->
-        <db:info>
-            <db:title>
-                <xsl:choose>
-                    <xsl:when test="vrd:title">
-                        <xsl:value-of select="vrd:title" />
-                    </xsl:when>
-                    <xsl:otherwise>
-                        <xsl:value-of select="@xml:id" />
-                    </xsl:otherwise>
-                </xsl:choose>
-            </db:title>
-        </db:info>
-        <xsl:apply-templates select="vrd:section|vrd:blockquote|vrd:p|vrd:ol|vrd:ul|vrd:programlisting" />
+        <xsl:call-template name="preface_or_section" />
     </section>
 </xsl:template>
 
     </db:listitem>
 </xsl:template>
 
+<xsl:template match="vrd:a">
+    <xsl:element name="db:link">
+        <xsl:call-template name="common_attributes" />
+        <xsl:apply-templates/>
+    </xsl:element>
+</xsl:template>
+
 <xsl:template match="vrd:span">
     <xsl:variable name="tag_name">
         <xsl:choose>