Sort definition list of current file without resolving implicit attributes
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 160
- Joined: Mon Nov 24, 2014 1:49 pm
- Location: Greven/Germany
Sort definition list of current file without resolving implicit attributes
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
stefan-jung.org – Your DITA/DITA-OT XML consultant
-
- Posts: 280
- Joined: Thu Nov 28, 2013 9:32 am
- Location: Hamburg/Germany
- Contact:
Re: Sort definition list of current file without resolving implicit attributes
Hi Stefan,
to get rid of the default attributes just change the settings for your transformation scenario and disable "expand default attributes".
But doing that you would have to change the code as well since it can no more read the class attributes. E.g.
There is no simple way to read the default attributes in your script but keep them from beeing copied to the output
Patrik
to get rid of the default attributes just change the settings for your transformation scenario and disable "expand default attributes".
But doing that you would have to change the code as well since it can no more read the class attributes. E.g.
Code: Select all
<xsl:template match="dl">
<xsl:copy>
<xsl:apply-templates select="dlentry">
<xsl:sort select="@id" data-type="text"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
Patrik
-
- Posts: 160
- Joined: Mon Nov 24, 2014 1:49 pm
- Location: Greven/Germany
Re: Sort definition list of current file without resolving implicit attributes
Hi Patrik,
herzlichen Dank, hat funktioniert.
Works as expected.
Have a nice weekend
Stefan
herzlichen Dank, hat funktioniert.
Works as expected.
Have a nice weekend
Stefan
stefan-jung.org – Your DITA/DITA-OT XML consultant
Return to “DITA (Editing and Publishing DITA Content)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service