Moving a list out of a paragraph, copyExceptClass not working?

Post here questions and problems related to oXygen frameworks/document types.
raybiss
Posts: 31
Joined: Sat Jan 17, 2015 6:21 pm

Moving a list out of a paragraph, copyExceptClass not working?

Post by raybiss »

Hi,
I'm trying to move a list (ol or ul) out of a paragraph if it's found inside one.
The following Quick Fix works but the @class attribute is copied even if I have the mode="copyExceptClass" templates.
These templates are working fine in other fixes.

Code: Select all

<pattern id="list_inside_paragraph">
        <rule context="p">
            <assert test="not(ol) and not(ul)" role="error" sqf:fix="moveListOutsideParagraph"> Une liste ne devrait pas être à l'intérieur d'un paragraphe. </assert>
            <sqf:fix id="moveListOutsideParagraph">
                <sqf:description>
                    <sqf:title>Déplacer la liste en dehors du paragraphe.</sqf:title>
                </sqf:description>
                <!-- copy the list after the paragraph -->
                <sqf:add match="." position="after" select="ol | ul">
                    <xsl:apply-templates mode="copyExceptClass" select="ol | ul"/>
                </sqf:add>
                <!-- remove the list from the paragraph -->
                <sqf:delete match="ol | ul"/>
            </sqf:fix>
        </rule>
        <!-- Template used to copy the current node -->
        <xsl:template match="node() | @*" mode="copyExceptClass">
            <xsl:copy copy-namespaces="no">
                <xsl:apply-templates select="node() | @*" mode="copyExceptClass"/>
            </xsl:copy>
        </xsl:template>
        <!-- Template used to skip the @class attribute from being copied -->
        <xsl:template match="@class" mode="copyExceptClass"/>
    </pattern>
On strange thing I'm observing.
If I run the fix in Author mode, the ul and li have the class attribute copied. class="- topic/ul " and class="- topic/li "
If I run the fix in text mode, the xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/" is also copied on the ul element.
Any idea what I'm missing?
Regards,
Raymond
tavy
Posts: 368
Joined: Thu Jul 01, 2004 12:29 pm

Re: Moving a list out of a paragraph, copyExceptClass not working?

Post by tavy »

Hi Raymond,

The quick fix that you created contains in the "sqf:add" operation both the xsl:apply-templates mode="copyExceptClass" and select="ol | ul". You need to use only the xsl:apply-templates mode="copyExceptClass" in the cotent of the "sqf:add" operation. Something like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"
  xmlns:sqf="http://www.schematron-quickfix.com/validator/process" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <pattern id="list_inside_paragraph">
    <rule context="p">
      <assert test="not(ol) and not(ul)" role="error" sqf:fix="moveListOutsideParagraph"> Une liste ne devrait pas être à l'intérieur d'un paragraphe. </assert>
      <sqf:fix id="moveListOutsideParagraph">
        <sqf:description>
          <sqf:title>Déplacer la liste en dehors du paragraphe.</sqf:title>
        </sqf:description>
        <!-- copy the list after the paragraph -->
        <sqf:add match="." position="after">
          <xsl:apply-templates mode="copyExceptClass" select="ol | ul"/>
        </sqf:add>
        <!-- remove the list from the paragraph -->
        <sqf:delete match="ol | ul"/>
      </sqf:fix>
    </rule>
    <!-- Template used to copy the current node -->
    <xsl:template match="node() | @*" mode="copyExceptClass">
      <xsl:copy copy-namespaces="no">
        <xsl:apply-templates select="node() | @*" mode="copyExceptClass"/>
      </xsl:copy>
    </xsl:template>
    <!-- Template used to skip the @class attribute from being copied -->
    <xsl:template match="@class" mode="copyExceptClass"/>
  </pattern>
</schema>
Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply