Skip to content

Commit

Permalink
Merge pull request #3264 from drmacro/feature/fix-conref-to-specializ…
Browse files Browse the repository at this point in the history
…ation

Use last-token-of-class att rather than local name to check target el…
  • Loading branch information
jelovirt committed Nov 2, 2019
2 parents b5c6878 + c04c721 commit decc7d0
Show file tree
Hide file tree
Showing 4 changed files with 41 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(PREPROCESS)
.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,12 @@
<topic xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/" class="- topic/topic "
ditaarch:DITAArchVersion="1.3" domains="(topic hi-d)" id="topic" xml:lang="en">
<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 ">APIREF element</keyword>
</p>
</body>
</topic>
@@ -0,0 +1,12 @@
<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 decc7d0

Please sign in to comment.