Page 1 of 1

XSLTOperation should not expand @class

Posted: Wed Sep 14, 2016 12:23 pm
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

Re: XSLTOperation should not expand @class

Posted: Wed Sep 14, 2016 4:21 pm
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

Re: XSLTOperation should not expand @class

Posted: Wed Sep 14, 2016 5:19 pm
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

Re: XSLTOperation should not expand @class

Posted: Thu Sep 15, 2016 8:22 am
by Radu
Hi Stefan,

Yes, exactly, thanks for posting the solution.

Regards,
Radu