XSLTOperation should not expand @class

xephon
Posts: 98
Joined: Mon Nov 24, 2014 1:49 pm
Location: Münster/Germany

XSLTOperation should not expand @class

Post by xephon » Wed Sep 14, 2016 12:23 pm

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
Join the DOCTALES DITA development team :arrow: https://doctales.atlassian.net/wiki

Radu
Posts: 6649
Joined: Fri Jul 09, 2004 5:18 pm

Re: XSLTOperation should not expand @class

Post by Radu » Wed Sep 14, 2016 4:21 pm

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: 98
Joined: Mon Nov 24, 2014 1:49 pm
Location: Münster/Germany

Re: XSLTOperation should not expand @class

Post by xephon » Wed Sep 14, 2016 5:19 pm

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
Join the DOCTALES DITA development team :arrow: https://doctales.atlassian.net/wiki

Radu
Posts: 6649
Joined: Fri Jul 09, 2004 5:18 pm

Re: XSLTOperation should not expand @class

Post by Radu » Thu Sep 15, 2016 8:22 am

Hi Stefan,

Yes, exactly, thanks for posting the solution.

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

Post Reply