Sort definition list of current file without resolving implicit attributes
Posted: Fri Oct 30, 2015 2:51 pm
Hi,
I have a small XSLT that sorts a definition list. In a transformation scenario I defined:
Sample Topic
XSLT
The script works, but it resolves implicit attributes:
Output
How can I avoid that? Is a transformations scenario the correct way to implement a simple sort mechanism like that? How would you implement this?
Thanks and best regards,
Stefan
I have a small XSLT that sorts a definition list. In a transformation scenario I defined:
- XML URL: ${currentFileURL}
- XSL URL: myScript.xsl
- Output file: ${currentFileURL}
Sample Topic
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="foo">
<title></title>
<body>
<dl>
<dlentry id="C">
<dt>C</dt>
<dd></dd>
</dlentry>
<dlentry id="B">
<dt>B</dt>
<dd></dd>
</dlentry>
<dlentry id="A">
<dt>A</dt>
<dd></dd>
</dlentry>
</dl>
</body>
</topic>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
exclude-result-prefixes="xs xd"
version="2.0">
<xd:doc scope="stylesheet">
<xd:desc>
<xd:p><xd:b>Created on:</xd:b> Oct 30, 2015</xd:p>
<xd:p><xd:b>Author:</xd:b> Stefan Eike</xd:p>
<xd:p></xd:p>
</xd:desc>
</xd:doc>
<xsl:output omit-xml-declaration="yes" indent="yes"
doctype-public="-//OASIS//DTD DITA Topic//EN"
doctype-system="topic.dtd"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[contains(@class,' topic/dl ')]">
<xsl:copy>
<xsl:apply-templates select="*[contains(@class,' topic/dlentry ')]">
<xsl:sort select="@id" data-type="text"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Output
Code: Select all
<!DOCTYPE topic
PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/"
id="foo"
ditaarch:DITAArchVersion="1.2"
domains="(topic hi-d)
(topic ut-d)
(topic indexing-d)
(topic hazard-d)
(topic abbrev-d)
(topic pr-d)
(topic sw-d)
(topic ui-d)"
class="- topic/topic ">
<title class="- topic/title "/>
<body class="- topic/body ">
<dl>
<dlentry id="A" class="- topic/dlentry ">
<dt class="- topic/dt ">A</dt>
<dd class="- topic/dd "/>
</dlentry>
<dlentry id="B" class="- topic/dlentry ">
<dt class="- topic/dt ">B</dt>
<dd class="- topic/dd "/>
</dlentry>
<dlentry id="C" class="- topic/dlentry ">
<dt class="- topic/dt ">C</dt>
<dd class="- topic/dd "/>
</dlentry>
</dl>
</body>
</topic>
Thanks and best regards,
Stefan