Page 1 of 1

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

Posted: Wed Oct 11, 2023 9:27 pm
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

To run,
  1. Open the project file.
  2. Open the glossary.dita file.
  3. Apply a Schematron quick-fix to the glossary term.

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

Posted: Wed Oct 11, 2023 10:07 pm
by chrispitude
This removed the superfluous attributes:

Code: Select all

<xsl:template match="@class|@domains|@*:DITAArchVersion" mode="fix-glossterm-acronym"/>

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

Posted: Fri Oct 13, 2023 10:46 am
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

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

Posted: Fri Oct 13, 2023 1:28 pm
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. :)