Skip to content
Snippets Groups Projects
Commit b01614a3 authored by Goik Martin's avatar Goik Martin
Browse files

javaapi:// referencing

parent 581a16be
No related branches found
No related tags found
No related merge requests found
......@@ -178,8 +178,8 @@
<listitem>
<para>Referencing <link
xlink:href="javaapi://java.util.String">List</link> by Java
package syntax</para>
xlink:href="javaapi://java.util.List">List</link> by Java package
syntax</para>
</listitem>
<listitem>
......@@ -187,6 +187,13 @@
xlink:href="javaapi://java.lang.String">String</link> reference
for <package>java.lang</package> default package</para>
</listitem>
<listitem>
<para><link
xlink:href="javaapi://java.lang.String#join(java.lang.CharSequence,java.lang.Iterable)">String.join</link>
method reference for <package>java.lang</package> default
package</para>
</listitem>
</itemizedlist>
</figure>
......
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://docbook.org/ns/docbook" xmlns:db="http://docbook.org/ns/docbook">
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook"
xmlns:db="http://docbook.org/ns/docbook">
<xsl:include href="common.xsl"/>
<xsl:param name="javaApiBaseUrl"
>https://docs.oracle.com/en/java/javase/21/docs/api/java.base</xsl:param>
<xsl:param name="generateIdPrefix">__sdwordm4342cs__</xsl:param>
<xsl:param name="nl">
<xsl:text>
......@@ -13,7 +16,7 @@
</xsl:param>
<xsl:output indent="no"/>
<xsl:param name="lastAnswerId" select="document('lastAnswerId.xml',/)/lastAnswer/@id" />
<xsl:param name="lastAnswerId" select="document('lastAnswerId.xml', /)/lastAnswer/@id"/>
<!-- Excluding glossary self references -->
<xsl:key name="internRef" match="//*[@linkend and not(ancestor::db:glossary)]" use="@linkend"/>
......@@ -55,28 +58,76 @@
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node()| @*"/>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@db:href">
<xsl:choose>
<xsl:when test="starts-with(., 'javaapi://')">
<xsl:variable name="javaClassReference" select="substring-after(., 'javaapi://')"/>
<xsl:text>https://docs.oracle.com/en/java/javase/17/docs/api/java.base/</xsl:text>
<xsl:template match="@xlink:href">
<xsl:attribute name="xlink:href">
<xsl:choose>
<xsl:when test="starts-with(., 'javaapi://')">
<xsl:variable name="javaUrl">
<xsl:value-of select="substring-after(., 'javaapi://')"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="contains($javaUrl, '#')">
<xsl:call-template name="javaApiClassname2htmlReference">
<xsl:with-param name="javaApiClassname" select="substring-before($javaUrl, '#')"/>
</xsl:call-template>
<xsl:text>#</xsl:text>
<xsl:message>
<xsl:value-of select="substring-after($javaUrl, '#')"/>
</xsl:message>
<xsl:call-template name="javaApiArgs2htmlReference">
<xsl:with-param name="javaArguments" select="substring-after($javaUrl, '#')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="javaApiClassname2htmlReference">
<xsl:with-param name="javaApiClassname" select="$javaUrl"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:value-of select="$javaClassReference"/>
<xsl:otherwise>
<xsl:attribute name="xlink:href" select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:template>
<xsl:template name="javaApiArgs2htmlReference">
<xsl:param name="javaArguments"/>
<xsl:value-of select="$javaArguments"/>
</xsl:template>
<xsl:template name="javaApiClassname2htmlReference">
<xsl:param name="javaApiClassname"/>
<xsl:value-of select="$javaApiBaseUrl"/>
<xsl:choose>
<xsl:when test="contains($javaApiClassname, '.')">
<xsl:text>/</xsl:text>
<xsl:value-of select="replace($javaApiClassname, '\.', '/')"/>
</xsl:when>
<xsl:otherwise>
<text>otherwise</text>
<xsl:value-of select="."/>
<xsl:text>/java/lang/</xsl:text>
<xsl:value-of select="$javaApiClassname"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>.html</xsl:text>
</xsl:template>
<xsl:template match="*" mode="hdmIdGenerate">
<xsl:choose>
<xsl:when test="@xml:id">
......@@ -90,7 +141,7 @@
</xsl:template>
<!-- Providing list of exercises -->
<xsl:template match="db:book[not(db:part)]|db:part">
<xsl:template match="db:book[not(db:part)] | db:part">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
<xsl:if test=".//db:qandaset">
......@@ -101,13 +152,13 @@
<caption>
<xsl:text>Exercises in </xsl:text>
<emphasis>
<xsl:value-of select="ancestor-or-self::db:part/db:title" />
<xsl:value-of select="ancestor-or-self::db:part/db:title"/>
</emphasis>
</caption>
<col width="25%" />
<col width="2%" />
<col width="45%" />
<col width="28%" />
<col width="25%"/>
<col width="2%"/>
<col width="45%"/>
<col width="28%"/>
<tr>
<th rowspan="2">Chapter</th>
<th colspan="3">Exercise</th>
......@@ -121,7 +172,8 @@
<xsl:for-each-group select=".//db:qandaset" group-by="ancestor::db:chapter/@xml:id">
<xsl:for-each select="current-group()">
<tr>
<xsl:if test="1 = position()"> <!-- Group's key entry only present in first row -->
<xsl:if test="1 = position()">
<!-- Group's key entry only present in first row -->
<td valign="top" rowspan="{count(current-group())}">
<xref linkend="{current-grouping-key()}"/>
</td>
......@@ -132,7 +184,8 @@
<td>
<xsl:apply-templates select="." mode="selectOwnOrInheritedTitle"/>
</td>
<td/> <!-- empty status of completion -->
<td/>
<!-- empty status of completion -->
</tr>
</xsl:for-each>
......@@ -149,7 +202,8 @@
<xsl:template match="db:qandaset" mode="qandaNumber">
<xsl:variable name="parentId" select="ancestor::db:part/@xml:id"/>
<xsl:value-of select="count(preceding::db:qandaset[ancestor::db:part/@xml:id = $parentId]) + 1"/>
<xsl:value-of select="count(preceding::db:qandaset[ancestor::db:part/@xml:id = $parentId]) + 1"
/>
</xsl:template>
<xsl:template match="db:chapter" mode="genQuandaset">
......@@ -157,8 +211,8 @@
<title>
<xsl:text>Exercises in </xsl:text>
<emphasis>
<xsl:for-each select="db:title" >
<xsl:copy-of select="node()|text()"/>
<xsl:for-each select="db:title">
<xsl:copy-of select="node() | text()"/>
</xsl:for-each>
</emphasis>
</title>
......@@ -206,7 +260,8 @@
</xsl:choose>
</xsl:template>
<xsl:template match="db:glossary/db:glosslist//db:glossentry[not(key('internRef', @xml:id)) and not(key('internRef', .//*/@xml:id))]">
<xsl:template
match="db:glossary/db:glosslist//db:glossentry[not(key('internRef', @xml:id)) and not(key('internRef', .//*/@xml:id))]">
<xsl:comment>
<xsl:text>Excluding non referenced glossary entry '</xsl:text>
<xsl:value-of select="db:glossterm"/>
......@@ -232,17 +287,18 @@
-->
<!-- make annotations -->
<xsl:template match="db:annotation[@role='make']">
<xsl:template match="db:annotation[@role = 'make']">
<xsl:apply-templates select="*" mode="make"/>
</xsl:template>
<xsl:template match="db:para[@role='eclipse']" mode='make'>
<xsl:template match="db:para[@role = 'eclipse']" mode="make">
<itemizedlist>
<listitem>
<para>
<xsl:text>Maven module source code available at </xsl:text>
<filename xlink:href="https://gitlab.mi.hdm-stuttgart.de/goik/GoikLectures/tree/master/{.}">
<filename
xlink:href="https://gitlab.mi.hdm-stuttgart.de/goik/GoikLectures/tree/master/{.}">
<xsl:value-of select="."/>
</filename>
<xsl:text>.</xsl:text>
......@@ -252,7 +308,9 @@
<listitem>
<para>
<xsl:text>See </xsl:text>
<link xlink:href="https://www.jetbrains.com/help/idea/maven-support.html#maven_import_project_start"> hints regarding import</link>
<link
xlink:href="https://www.jetbrains.com/help/idea/maven-support.html#maven_import_project_start"
> hints regarding import</link>
<xsl:text>.</xsl:text>
</para>
</listitem>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment