Need help with a Schematron rule

Hi all, I want to write a Schematron rule which checks whether a keyref'ed element contains a blank character. WRONG: <ph keyref="mykey"> </ph> CORRECT: <ph keyref="mykey"></ph> I adapted another rule and tried the following, but it does not work as expected. In addition, it should apply to any keyref'ed element, not only to <ph>. <sch:pattern id="Check_blanks" xmlns:sch="http://purl.oclc.org/dsdl/schematron"> <sch:rule context="*[contains(@class, 'ph')][@keyref]"> <sch:assert test="not(contains(text(), ' '))">No blank allowed inside keyref'ed ph elements</sch:assert> </sch:rule> </sch:pattern> Any help would be greatly appreciated. Regards, Frank -- *Frank Dissinger* Documentation Manager .................................................................... *CGS ORIS GmbH* *Email *frank.dissinger@cgs-oris.com | *Web* www.cgs-oris.com <http://www.cgs-oris.com/> *Address* Kettelerstr. 24 | D-63512 Hainburg | Germany *Phone* +49 6182 9626-27 | *Fax* +49 6182 9626-99 *Commercial register* Offenbach, HRB no. 21495 *Managing directors* Bernd Rückert, Christoph Thommessen https://www.cgs-oris.com/Signatur.png <https://www.cgs-oris.com/signatur>

Moin! On Wed, 14 Feb 2024 09:48:18 +0100, Frank Dissinger wrote:
[1 <multipart/alternative (7bit)>] [1.1 <text/plain; UTF-8 (8bit)>] [1.2 <text/html; UTF-8 (8bit)>] Hi all,
I want to write a Schematron rule which checks whether a keyref'ed element contains a blank character.
WRONG: <ph keyref="mykey"> </ph>
CORRECT: <ph keyref="mykey"></ph>
I adapted another rule and tried the following, but it does not work as expected. In addition, it should apply to any keyref'ed element, not only to <ph>.
<sch:pattern id="Check_blanks" xmlns:sch="http://purl.oclc.org/dsdl/schematron"> <sch:rule context="*[contains(@class, 'ph')][@keyref]"> <sch:assert test="not(contains(text(), ' '))">No blank allowed inside keyref'ed ph elements</sch:assert> </sch:rule> </sch:pattern>
Your rule matches all elements with @keyref and with an @class attribute that contains 'ph'. The two examples do not have a @class attribute, thus the rule doesn't fire. Maybe rewrite the rule as sch:rule context="*[@keyref]"? HTH, -- David
Any help would be greatly appreciated.
Regards,
Frank
--
Frank Dissinger
Documentation Manager
....................................................................
CGS ORIS GmbH
Email frank.dissinger@cgs-oris.com | Web www.cgs-oris.com
Address Kettelerstr. 24 | D-63512 Hainburg | Germany
Phone +49 6182 9626-27 | Fax +49 6182 9626-99
Commercial register Offenbach, HRB no. 21495
Managing directors Bernd Rückert, Christoph Thommessen
https://www.cgs-oris.com/Signatur.png [2 <text/plain; us-ascii (7bit)>] _______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com https://www.oxygenxml.com/mailman/listinfo/oxygen-user
-- David Maus Hamburg, Germany web: https://dmaus.name fediverse: @dmaus@dmaus.name

Hm, The rule incorrectly outputs the warning when there is no blank in the element, even with the change you're proposing. All DITA elements seem to have a class attribute. The other Schematron rules I am using are all written with class attributes and they work. I don't know if the following has to do with this issue. Since today I am always getting the following error when I save a Schematron rule. I then click "Save anyway". access denied ("java.security.AllPermission" "<all permissions>" "<all actions>") I don't know what is causing this. ------------------------------------------------------------------------ Am 14.02.2024 um 10:02 schrieb David Maus:
Moin!
On Wed, 14 Feb 2024 09:48:18 +0100, Frank Dissinger wrote:
[1 <multipart/alternative (7bit)>] [1.1 <text/plain; UTF-8 (8bit)>] [1.2 <text/html; UTF-8 (8bit)>] Hi all,
I want to write a Schematron rule which checks whether a keyref'ed element contains a blank character.
WRONG: <ph keyref="mykey"> </ph>
CORRECT: <ph keyref="mykey"></ph>
I adapted another rule and tried the following, but it does not work as expected. In addition, it should apply to any keyref'ed element, not only to <ph>.
<sch:pattern id="Check_blanks" xmlns:sch="http://purl.oclc.org/dsdl/schematron"> <sch:rule context="*[contains(@class, 'ph')][@keyref]"> <sch:assert test="not(contains(text(), ' '))">No blank allowed inside keyref'ed ph elements</sch:assert> </sch:rule> </sch:pattern> Your rule matches all elements with @keyref and with an @class attribute that contains 'ph'.
The two examples do not have a @class attribute, thus the rule doesn't fire.
Maybe rewrite the rule as
sch:rule context="*[@keyref]"?
HTH, -- David
Any help would be greatly appreciated.
Regards,
Frank
--
Frank Dissinger
Documentation Manager
....................................................................
CGS ORIS GmbH
Emailfrank.dissinger@cgs-oris.com | Webwww.cgs-oris.com
Address Kettelerstr. 24 | D-63512 Hainburg | Germany
Phone +49 6182 9626-27 | Fax +49 6182 9626-99
Commercial register Offenbach, HRB no. 21495
Managing directors Bernd Rückert, Christoph Thommessen --
*Frank Dissinger* Documentation Manager .................................................................... *CGS ORIS GmbH* *Email *frank.dissinger@cgs-oris.com | *Web* www.cgs-oris.com <http://www.cgs-oris.com/> *Address* Kettelerstr. 24 | D-63512 Hainburg | Germany *Phone* +49 6182 9626-27 | *Fax* +49 6182 9626-99 *Commercial register* Offenbach, HRB no. 21495 *Managing directors* Bernd Rückert, Christoph Thommessen https://www.cgs-oris.com/Signatur.png <https://www.cgs-oris.com/signatur>

Hi Frank, the provided code works: added it to my rules.sch and removed the ph to catch all keyref‘ed elements: <sch:pattern> <sch:rule context="*[@keyref]"> <sch:assert test="not(contains(text(), ' '))">No blanks allowed inside keyref'ed elements</sch:assert> </sch:rule> </sch:pattern> Now it reports correctly – the yellow elements have red underlines in Oxy – they don’t come over with the clipboard: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd"> <topic id="Untitled1"> <title>Test Schematron</title> <body> <p><ph keyref="prod-short"> </ph></p> <p><ph keyref="prod-short"/></p> <p><keyword keyref="prod-name"> </keyword></p> <p><keyword keyref="prod-name"/> </p> </body> </topic> And only these 2 in the “Problems” pod: No blanks allowed inside keyref'ed elements No blanks allowed inside keyref'ed elements Must be something else in your configuration… Greetings, Franz-Josef Franz-Josef Knelangen Leiter Dokumentation Main: +49 7634 5612-0 Facebook<https://www.facebook.com/akgsoftware/> | Xing<https://www.xing.com/pages/akgsoftware> | LinkedIn<https://www.linkedin.com/company/18590571> | YouTube<https://www.youtube.com/c/AKGSoftware-infrastructure> [cid:image002_01fef2d4-1f7d-4ea5-9727-748ef31e8852.png] AKG Software Consulting GmbH Uhlandstr. 12 D-79423 Heitersheim www.akgsoftware.de<https://www.akgsoftware.de/> Geschäftsführer: Dipl.-Ing. Artur K. Günther, Dipl.-Ing. Arno Brüggemann, Dipl.-Ing. (FH) Bernhard Feser, Dipl.-Ing. Jens Günther Sitz der Gesellschaft: Heitersheim, HRB 310383 (Amtsgericht Freiburg i. Br.)

Hi Franz-Josef, Thank you very much for your help. Your code indeed does work! I don't know what made it fail previously... Any idea about this error message which keeps popping up at the bottom of the window when I save a Schematron rule file? access denied ("java.security.AllPermission" "<all permissions>" "<all actions>") I can save the *.sch file despite this message, but it's annoying because it requires an additional click on the "Save anyway" button. Regards, Frank ------------------------------------------------------------------------ Am 14.02.2024 um 13:05 schrieb Franz-Josef Knelangen:
Hi Frank,
the provided code works: added it to my rules.sch and removed the ph to catch all keyref‘ed elements:
<sch:pattern> <sch:rulecontext="*[*/@keyref/*]"> <sch:asserttest="/not/(/contains/(/text/(),' '))">No blanks allowed inside keyref'ed elements</sch:assert> </sch:rule> </sch:pattern>
Now it reports correctly – the yellow elements have red underlines in Oxy – they don’t come over with the clipboard:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd"> <topicid="Untitled1"> <title>Test Schematron</title> <body> <p><ph keyref="prod-short"></ph></p> <p><phkeyref="prod-short"/></p> <p><keywordkeyref="prod-name"></keyword></p> <p><keywordkeyref="prod-name"/> </p> </body> </topic>
And only these 2 in the “Problems” pod:
No blanks allowed inside keyref'ed elements
No blanks allowed inside keyref'ed elements
Must be something else in your configuration…
Greetings,
Franz-Josef
* Franz-Josef Knelangen** *Leiter Dokumentation
Main: +49 7634 5612-0
Facebook <https://www.facebook.com/akgsoftware/>| Xing <https://www.xing.com/pages/akgsoftware>| LinkedIn <https://www.linkedin.com/company/18590571>| YouTube <https://www.youtube.com/c/AKGSoftware-infrastructure>
AKG Software Consulting GmbH
*AKG Software Consulting GmbH* Uhlandstr. 12 D-79423 Heitersheim www.akgsoftware.de <https://www.akgsoftware.de/>
Geschäftsführer: Dipl.-Ing. Artur K. Günther, Dipl.-Ing. Arno Brüggemann, Dipl.-Ing. (FH) Bernhard Feser, Dipl.-Ing. Jens Günther Sitz der Gesellschaft: Heitersheim, HRB 310383 (Amtsgericht Freiburg i. Br.)**
-- *Frank Dissinger* Documentation Manager .................................................................... *CGS ORIS GmbH* *Email *frank.dissinger@cgs-oris.com | *Web* www.cgs-oris.com <http://www.cgs-oris.com/> *Address* Kettelerstr. 24 | D-63512 Hainburg | Germany *Phone* +49 6182 9626-27 | *Fax* +49 6182 9626-99 *Commercial register* Offenbach, HRB no. 21495 *Managing directors* Bernd Rückert, Christoph Thommessen https://www.cgs-oris.com/Signatur.png <https://www.cgs-oris.com/signatur>
participants (3)
-
David Maus
-
Frank Dissinger
-
Franz-Josef Knelangen