Skip to content

Commit

Permalink
Use last-token-of-class att rather than local name to check target el…
Browse files Browse the repository at this point in the history
…ement

Added unit test for conref to specialization

Signed-off-by: Eliot Kimber <ekimber@contrext.com>
  • Loading branch information
contrext committed Mar 25, 2019
1 parent d0e6197 commit 181d60e
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/main/plugins/org.dita.base/xsl/preprocess/conrefImpl.xsl
Expand Up @@ -212,6 +212,7 @@ See the accompanying LICENSE file for applicable license.

<xsl:variable name="topicid" select="dita-ot:get-topic-id(@conref)" as="xs:string?"/>
<xsl:variable name="elemid" select="dita-ot:get-element-id(@conref)" as="xs:string?"/>
<xsl:variable name="lastClassToken" select="concat(' ', tokenize(normalize-space(@class), ' ')[last()], ' ')" as="xs:string"/>

<xsl:choose>
<!-- exportanchors defined in topicmeta-->
Expand Down Expand Up @@ -293,22 +294,22 @@ See the accompanying LICENSE file for applicable license.
<xsl:variable name="target" as="element()*">
<xsl:choose>
<xsl:when test="exists($elemid)">
<xsl:sequence select="key('id', $elemid)[local-name() = $element][ancestor::*[contains(@class, ' topic/topic ')][1][@id = $topicid]]"/>
<xsl:sequence select="key('id', $elemid)[contains(@class, $lastClassToken)][ancestor::*[contains(@class, ' topic/topic ')][1][@id = $topicid]]"/>
</xsl:when>
<xsl:when test="exists($topicid) and contains($current-element/@class, ' topic/topic ')">
<xsl:sequence select="key('id', $topicid)[contains(@class, ' topic/topic ')][local-name() = $element]"/>
<xsl:sequence select="key('id', $topicid)[contains(@class, ' topic/topic ')][contains(@class, $lastClassToken)]"/>
</xsl:when>
<xsl:when test="exists($topicid) and contains($current-element/@class, ' map/topicref ')">
<xsl:sequence select="key('id', $topicid)[contains(@class, ' map/topicref ')][local-name() = $element]"/>
<xsl:sequence select="key('id', $topicid)[contains(@class, ' map/topicref ')][contains(@class, $lastClassToken)]"/>
</xsl:when>
<xsl:when test="exists($topicid) and contains(root($current-element)/*/@class, ' map/map ')">
<xsl:sequence select="key('id', $topicid)[local-name() = $element]"/>
<xsl:sequence select="key('id', $topicid)[contains(@class, $lastClassToken)]"/>
</xsl:when>
<xsl:when test="exists($topicid)">
<xsl:sequence select="key('id', $topicid)[local-name() = $element]"/>
<xsl:sequence select="key('id', $topicid)[contains(@class, $lastClassToken)]"/>
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="//*[contains(@class, ' topic/topic ')][1][local-name() = $element]"/>
<xsl:sequence select="//*[contains(@class, ' topic/topic ')][1][contains(@class, $lastClassToken)]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/org/dita/dost/IntegrationTest.java
Expand Up @@ -346,6 +346,16 @@ public void testconref_topiconly() throws Throwable {
.test();
}

@Test
public void testconref_to_specialization() throws Throwable {
builder().name("conref_to_specialization")
.transtype(XHTML)
.input(Paths.get("conref_to_specialization.dita"))
.put("validate", "false")
.warnCount(1)
.test();
}

@Test
public void testpushAfter_between_Specialization() throws Throwable {
builder().name("pushAfter_between_Specialization")
Expand Down
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<meta name="copyright" content="(C) Copyright 2019" />
<meta name="DC.rights.owner" content="(C) Copyright 2019" />
<meta name="DC.type" content="topic" />
<meta name="DC.title" content="Conref test for #3264" />
<meta name="DC.format" content="XHTML" />
<meta name="DC.identifier" content="topic" />
<meta name="DC.language" content="en" />
<link rel="stylesheet" type="text/css" href="commonltr.css" />
<title>Conref test for #3264</title>
</head>
<body id="topic">

<h1 class="title topictitle1" id="ariaid-title1">Conref test for #3264</h1>

<div class="body">
<p class="p" id="topic__test">apiref element (specialization of keyword): <span class="keyword apiref" id="topic__apiref">APIREF element</span></p>

<p class="p">Conref from keyword: <span class="keyword">APIREF element</span></p>

</div>

</body>
</html>
@@ -0,0 +1,8 @@
<topic class="- topic/topic " domains="(topic hi-d)" id="topic" ditaarch:DITAArchVersion="1.3" xml:lang="en"
xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/">
<title class="- topic/title ">Conref test for #3264</title>
<body class="- topic/body ">
<p class="- topic/p " id="test">apiref element (specialization of keyword): <apiref class="+ topic/keyword api-d/apiref " id="apiref">APIREF element</apiref></p>
<p class="- topic/p ">Conref from keyword: <keyword class="- topic/keyword " conref="#./apiref"/></p>
</body>
</topic>

0 comments on commit 181d60e

Please sign in to comment.