In Schematron quick-fix XSLT, can default attributes be suppressed?

Post here questions and problems related to editing and publishing DITA content.
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

In Schematron quick-fix XSLT, can default attributes be suppressed?

Post by chrispitude »

I have a Schematron quick-fix that adds <glossAcronym> and <glossSurfaceForm> to a <glossEntry>. It does this by calling a small bit of XSLT to update the <glossEntry>.

When I run the quick-fix on this:

Code: Select all

<glossgroup id="glossary">
  <title>My Glossary</title>
  <glossentry id="ddl">
    <glossterm>DITA</glossterm>
    <glossdef>This is some definition text.</glossdef>
  </glossentry>
</glossgroup>
the result is this:

Code: Select all

<glossgroup id="glossary">
  <title>My Glossary</title>
  <glossentry class="- topic/topic concept/concept glossentry/glossentry "
    ditaarch:DITAArchVersion="1.3"
    domains="(topic abbrev-d) (topic concept glossentry) (topic concept glossgroup) (topic concept) (topic equation-d) (topic hazard-d) (topic hi-d) (topic indexing-d) (topic markup-d xml-d) (topic markup-d) (topic mathml-d) (topic pr-d) (topic relmgmt-d) (topic svg-d) (topic sw-d) (topic ui-d) (topic ut-d) a(props deliveryTarget)"
    id="ddl">
    <glossterm class="- topic/title concept/title glossentry/glossterm "/>
    <glossdef class="- topic/abstract concept/abstract glossentry/glossdef ">This is some
      definition text.</glossdef>
    <glossBody>
      <glossSurfaceForm/>
      <glossAlt id="glossAlt_abf_sws_bzb">
        <glossAcronym>DITA</glossAcronym>
      </glossAlt>
    </glossBody>
  </glossentry>
</glossgroup>
The newly added elements (<glossBody> and down) are fine. But the existing copied elements (<glossentry>, <glossterm>, and <glossdef>) get explicit copies of the normally-implicit attributes.

For now, I will add more refactoring code to strip them out, but it would be nice if this could somehow be handled automatically (if possible).

Testcase:
oxygen-glossary-2.zip
(19.26 KiB) Downloaded 36 times

To run,
  1. Open the project file.
  2. Open the glossary.dita file.
  3. Apply a Schematron quick-fix to the glossary term.
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: In Schematron quick-fix XSLT, can default attributes be suppressed?

Post by chrispitude »

This removed the superfluous attributes:

Code: Select all

<xsl:template match="@class|@domains|@*:DITAArchVersion" mode="fix-glossterm-acronym"/>
tavy
Posts: 365
Joined: Thu Jul 01, 2004 12:29 pm

Re: In Schematron quick-fix XSLT, can default attributes be suppressed?

Post by tavy »

Hello,

Thanks for your feedback.
The solution that you found is good. We cannot determine in XSLT the default attributes for an element. All the attributes will be copied and you need to filter them. We have a similar example in the samples project ([oxygenInstallDir]\samples\quick-fixes\flowers.sch).

Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: In Schematron quick-fix XSLT, can default attributes be suppressed?

Post by chrispitude »

Thanks Octavian! The fix proved to be simple and compact. And when using a refactoring operation in Schematron like this, I will always use a moded template to apply the fix, so it is no problem. Now this discussion can document the solution for others. :)
Post Reply