XSLTOperation should not expand @class

Post here questions and problems related to editing and publishing DITA content.
xephon
Posts: 140
Joined: Mon Nov 24, 2014 1:49 pm
Location: Greven/Germany

XSLTOperation should not expand @class

Post by xephon »

Hi,

I have a simple ro.sync.ecss.extensions.commons.operations.XSLTOperation for sorting DITA elements. After applying the XSL transformation, the @class attributes are expanded. Because we use DITA, we cannot deactivate the Saxon -expand parameter, because otherwise, elements cannot be selected with the @class selector anymore. So, is it possible (and how) to avoid, that the @class attributes are (permanently) expanded in the XML files?

Greetings,
Stefan
stefan-jung.org – Your DITA/DITA-OT XML consultant
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: XSLTOperation should not expand @class

Post by Radu »

Hi Stefan,

Have you tried instead of probably using xsl:copy-of to apply a copy template in a certain mode so that you can remove the @class attributes from the generated XML content?

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
xephon
Posts: 140
Joined: Mon Nov 24, 2014 1:49 pm
Location: Greven/Germany

Re: XSLTOperation should not expand @class

Post by xephon »

Hi Radu,

thanks for your reply. While reading more about modes, I figured out, that I could simply avoid the processing of the attribute by using match="@class".

So I came up with:

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">

<xsl:output method="xml" indent="no" omit-xml-declaration="yes"/>

<!-- This line has helped -->
<xsl:template match="@class"/>

<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="ul">
<xsl:copy>
<xsl:apply-templates select="li">
<xsl:sort select="(keyword | ph)/@id"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>
Thanks for your advice, you pointed me to the right direction.


Greetings,
Stefan
stefan-jung.org – Your DITA/DITA-OT XML consultant
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: XSLTOperation should not expand @class

Post by Radu »

Hi Stefan,

Yes, exactly, thanks for posting the solution.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply