Page 1 of 1

Formatting results in the "Results pane"

Posted: Fri Apr 28, 2017 7:33 pm
by grethelgomez
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.

Re: Formatting results in the "Results pane"

Posted: Tue May 02, 2017 4:50 pm
by tavy
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

Re: Formatting results in the "Results pane"

Posted: Mon May 08, 2017 6:31 pm
by grethelgomez
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.

Re: Formatting results in the "Results pane"

Posted: Tue May 09, 2017 4:18 pm
by tavy
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

Re: Formatting results in the "Results pane"

Posted: Wed May 17, 2017 9:11 pm
by grethelgomez
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.