Formatting results in the "Results pane"

<oXygen/> general issues.
grethelgomez
Posts: 8

Formatting results in the "Results pane"

Fri Apr 28, 2017 7:33 pm

Hello.
I’m working on a Schematron rule that detects forbidden words in DITA topics and triggers warning messages in the Results pane, suggesting different types of solutions in each case.
In order to better explain my situation, I include a simplified version of this pattern:

Code: Select all

<sch:pattern id="example">
        <sch:rule id=" example1" context="*[contains(@class, ' topic/topic ')]//text()">
            <xsl:variable name="context" select="."/>
            <xsl:variable name="list-words">
                <xsl:for-each select="document('list_of_words.dita')//tbody/row/entry[1]">
                    <xsl:variable name="word" select="."/>
                    <xsl:if test="matches($context, $word, 'i')">
                        <xsl:value-of select="concat('|message|This word should not be used: ', $word, '., ')"/>
                    </xsl:if>
                 </xsl:for-each>
            </xsl:variable>
            <sch:report test="string-length($list-words) > 0" role="warning">
                <xsl:for-each select="tokenize($list-words, ', ')">
                    <xsl:value-of select="substring-after(.,'|message|')"/>
                </xsl:for-each>
            </sch:report>
        </sch:rule>
</sch:pattern>


In the description column of the Results pane, the following messages are displayed for each context=text() that contains forbidden words:
- [ISO SCHEMATRON] This word should not be used: WordA.
- [ISO SCHEMATRON] This word should not be used: WordB.
- [ISO SCHEMATRON] This word should not be used: WordC.
- [ISO SCHEMATRON] This word should not be used: WordA. This word should

Depending on the context, it could happen that more than one word is detected. As in the last example, the list becomes too long, so it gets hidden. To see the complete description, the user has to press F2:
This word should not be used: WordA. This word should not be used: WordB. This word should not be used: WordC. This word should not be used: WordD.


What I would like to do is to be able to see the whole list in the Results pane, without pressing F2. It would also be easier for users if the messages that belong to the same context could be listed one under the other. The ideal result would look like:

- [ISO SCHEMATRON] This word should not be used: WordA.
- [ISO SCHEMATRON] This word should not be used: WordA.
This word should not be used: WordB.
This word should not be used: WordC.
This word should not be used: WordD.
<!--Where the first message refers to context A: the first paragraph of the topic, and the second message refers to context B: the second paragraph of the topic-->

Do you have any suggestions on how I could do this?
Thanks in advance,
Grethel.
tavy
Posts: 123

Re: Formatting results in the "Results pane"

Tue May 02, 2017 4:50 pm

Hello Grethel,

A solution is to change the message and add the text "This word should not be used:" only once. Something like this:

Code: Select all

<xsl:variable name="list-words">
    <xsl:for-each select="document('list_of_words.dita')//tbody/row/entry[1]">
        <xsl:variable name="word" select="."/>
        <xsl:if test="matches($context, $word, 'i')">
            <xsl:value-of select="concat('''', $word, ''' ')"/>
        </xsl:if>
    </xsl:for-each>
</xsl:variable>
<sch:report test="string-length($list-words) > 0" role="warning">
    |message|This words should not be used: <sch:value-of select="$list-words"/>
</sch:report>


Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
grethelgomez
Posts: 8

Re: Formatting results in the "Results pane"

Mon May 08, 2017 6:31 pm

Hello, Octavian.

Thank you for your reply. According to my question, the best solution is to create a list of words that should not be used.

In fact, I forgot to mention before that, for each forbidden word, I suggest an alternative. That’s why I wanted to split the messages. Otherwise, it would be too long and difficult to understand in some cases. I also condition the messages to the type of word detected, what means a combined result would look like this:
- [ISO SCHEMATRON] MESS-1: This word should not be used: WordA. Replace it with SolutionA. MESS-2: These words are not necessary. Remove WordB and check your text again. MESS-3: These words? Try replacing WordC with SolutionC.

Ideally, I would have a group of reports for the same context, and not a group of messages concatenated and displayed in one report, something similar to this:

Code: Select all

<xsl:for-each select="tokenize($list-words, ', ')>
   <sch:report test="string-length(.) > 0" role="warning">
      <xsl:value-of select="substring-after(.,'|message|')"/>
   </sch:report>
</xsl:for-each>

But that is not the way it works. If you have any other suggestions on I how I could achieve this, I would really appreciate it.
Thanks in advance for your help,
Grethel.
tavy
Posts: 123

Re: Formatting results in the "Results pane"

Tue May 09, 2017 4:18 pm

Hello Grethel,

The solution that I can think of is to use abstract patterns. You can create an abstract pattern with the report, and instantiate this pattern for each forbidden word with some specific parameters (the forbidden word, the replace word, maybe a different message). In the abstract pattern you can create also some quick fixes that will replace or remove the word automatically.
But this means that you need to have an instantiation of the abstract pattern for each forbidden word. If you don't want to create this Schematron manually, you can generate it using an XSLT from the 'list_of_words.dita' file.

Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
grethelgomez
Posts: 8

Re: Formatting results in the "Results pane"

Wed May 17, 2017 9:11 pm

Hello, Octavian.

Thank you very much for your suggestions. I really appreciate it.
At the beginning, I tried using the abstract patterns, but I didn’t get the results I wanted. I might go back to it and do more tests.

Thanks again,
Grethel.

Return to “Other Issues”

Who is online

Users browsing this forum: No registered users and 1 guest