diff options
106 files changed, 575 insertions, 6 deletions
@@ -1,3 +1,8 @@ +Sun Jul 31 18:48:55 CEST 2005 Daniel Veillard <daniel@veillard.com> + + * schematron.c: report improvement + * test/schematron/zvon* result/schematron/zvon*: more tests + Sun Jul 31 16:02:59 CEST 2005 Daniel Veillard <daniel@veillard.com> * win32/Makefile.msvc win32/configure.js: applied patch from Rob diff --git a/result/schematron/zvon11_0 b/result/schematron/zvon11_0 new file mode 100644 index 00000000..49c80056 --- /dev/null +++ b/result/schematron/zvon11_0 @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<AAA> + <BBB aaa="A" bbb="B"/> +</AAA> diff --git a/result/schematron/zvon11_0.err b/result/schematron/zvon11_0.err new file mode 100644 index 00000000..ab4aa742 --- /dev/null +++ b/result/schematron/zvon11_0.err @@ -0,0 +1,2 @@ +Pattern: Attributes present +./test/schematron/zvon11_0.xml validates diff --git a/result/schematron/zvon11_1 b/result/schematron/zvon11_1 new file mode 100644 index 00000000..a5328e0f --- /dev/null +++ b/result/schematron/zvon11_1 @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<AAA> + <BBB bbb="B"/> +</AAA> diff --git a/result/schematron/zvon11_1.err b/result/schematron/zvon11_1.err new file mode 100644 index 00000000..c1ae2433 --- /dev/null +++ b/result/schematron/zvon11_1.err @@ -0,0 +1,3 @@ +Pattern: Attributes present +/AAA/BBB line 2: The element must not have an isolated bbb attribute +./test/schematron/zvon11_1.xml fails to validate diff --git a/result/schematron/zvon11_2 b/result/schematron/zvon11_2 new file mode 100644 index 00000000..673a7afd --- /dev/null +++ b/result/schematron/zvon11_2 @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<AAA> + <BBB aaa="A"/> +</AAA> diff --git a/result/schematron/zvon11_2.err b/result/schematron/zvon11_2.err new file mode 100644 index 00000000..35117f7f --- /dev/null +++ b/result/schematron/zvon11_2.err @@ -0,0 +1,3 @@ +Pattern: Attributes present +/AAA/BBB line 2: The element must not have an isolated aaa attribute +./test/schematron/zvon11_2.xml fails to validate diff --git a/result/schematron/zvon11_3 b/result/schematron/zvon11_3 new file mode 100644 index 00000000..9aae4b1e --- /dev/null +++ b/result/schematron/zvon11_3 @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<AAA> + <BBB/> +</AAA> diff --git a/result/schematron/zvon11_3.err b/result/schematron/zvon11_3.err new file mode 100644 index 00000000..18517e58 --- /dev/null +++ b/result/schematron/zvon11_3.err @@ -0,0 +1,2 @@ +Pattern: Attributes present +./test/schematron/zvon11_3.xml validates diff --git a/result/schematron/zvon12_0 b/result/schematron/zvon12_0 new file mode 100644 index 00000000..72208046 --- /dev/null +++ b/result/schematron/zvon12_0 @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<AAA> + <BBB bbb="C"/> +</AAA> diff --git a/result/schematron/zvon12_0.err b/result/schematron/zvon12_0.err new file mode 100644 index 00000000..c7e9ed25 --- /dev/null +++ b/result/schematron/zvon12_0.err @@ -0,0 +1,3 @@ +Pattern: Number of characters in an abbreviation +/AAA/BBB line 2: There is not enough letters in the abbreviation +./test/schematron/zvon12_0.xml fails to validate diff --git a/result/schematron/zvon12_1 b/result/schematron/zvon12_1 new file mode 100644 index 00000000..362de34e --- /dev/null +++ b/result/schematron/zvon12_1 @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<AAA> + <BBB bbb="CZ"/> +</AAA> diff --git a/result/schematron/zvon12_1.err b/result/schematron/zvon12_1.err new file mode 100644 index 00000000..486c0bea --- /dev/null +++ b/result/schematron/zvon12_1.err @@ -0,0 +1,2 @@ +Pattern: Number of characters in an abbreviation +./test/schematron/zvon12_1.xml validates diff --git a/result/schematron/zvon12_2 b/result/schematron/zvon12_2 new file mode 100644 index 00000000..bbbf7c7f --- /dev/null +++ b/result/schematron/zvon12_2 @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<AAA> + <BBB bbb="CZCZ"/> +</AAA> diff --git a/result/schematron/zvon12_2.err b/result/schematron/zvon12_2.err new file mode 100644 index 00000000..5edaf307 --- /dev/null +++ b/result/schematron/zvon12_2.err @@ -0,0 +1,3 @@ +Pattern: Number of characters in an abbreviation +/AAA/BBB line 2: There is too much letters in the abbreviation +./test/schematron/zvon12_2.xml fails to validate diff --git a/result/schematron/zvon13_0 b/result/schematron/zvon13_0 new file mode 100644 index 00000000..e1295c37 --- /dev/null +++ b/result/schematron/zvon13_0 @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<Total> + <Percent>20</Percent> + <Percent>30</Percent> + <Percent>10</Percent> + <Percent>50</Percent> +</Total> diff --git a/result/schematron/zvon13_0.err b/result/schematron/zvon13_0.err new file mode 100644 index 00000000..ed98cb3d --- /dev/null +++ b/result/schematron/zvon13_0.err @@ -0,0 +1,3 @@ +Pattern: Sum equals 100%. +/Total line 1: The values do not sum to 100%. +./test/schematron/zvon13_0.xml fails to validate diff --git a/result/schematron/zvon13_1 b/result/schematron/zvon13_1 new file mode 100644 index 00000000..401e919b --- /dev/null +++ b/result/schematron/zvon13_1 @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<Total> + <Percent>20</Percent> + <Percent>10</Percent> + <Percent>50</Percent> +</Total> diff --git a/result/schematron/zvon13_1.err b/result/schematron/zvon13_1.err new file mode 100644 index 00000000..e0f02c2a --- /dev/null +++ b/result/schematron/zvon13_1.err @@ -0,0 +1,3 @@ +Pattern: Sum equals 100%. +/Total line 1: The values do not sum to 100%. +./test/schematron/zvon13_1.xml fails to validate diff --git a/result/schematron/zvon13_2 b/result/schematron/zvon13_2 new file mode 100644 index 00000000..cb1df2ed --- /dev/null +++ b/result/schematron/zvon13_2 @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<Total> + <Percent>20</Percent> + <Percent>30</Percent> + <Percent>50</Percent> +</Total> diff --git a/result/schematron/zvon13_2.err b/result/schematron/zvon13_2.err new file mode 100644 index 00000000..dfab61f9 --- /dev/null +++ b/result/schematron/zvon13_2.err @@ -0,0 +1,2 @@ +Pattern: Sum equals 100%. +./test/schematron/zvon13_2.xml validates diff --git a/result/schematron/zvon14_0 b/result/schematron/zvon14_0 new file mode 100644 index 00000000..c72e0c28 --- /dev/null +++ b/result/schematron/zvon14_0 @@ -0,0 +1,13 @@ +<?xml version="1.0"?> +<AAA> + <BBB> + <CCC/> + </BBB> + <CCC/> + <DDD> + <CCC/> + <EEE> + <CCC/> + </EEE> + </DDD> +</AAA> diff --git a/result/schematron/zvon14_0.err b/result/schematron/zvon14_0.err new file mode 100644 index 00000000..60155da7 --- /dev/null +++ b/result/schematron/zvon14_0.err @@ -0,0 +1,4 @@ +Pattern: a child of selected elements +/AAA/CCC line 5: Element CCC must not be a child of element AAA +/AAA/DDD/EEE/CCC line 9: Element CCC must not be a child of element EEE +./test/schematron/zvon14_0.xml fails to validate diff --git a/result/schematron/zvon15_0 b/result/schematron/zvon15_0 new file mode 100644 index 00000000..56500fe8 --- /dev/null +++ b/result/schematron/zvon15_0 @@ -0,0 +1,5 @@ +<?xml version="1.0"?> +<AAA name="aaa"> +<BBB id="bbb"/> +<CCC color="ccc"/> +</AAA> diff --git a/result/schematron/zvon15_0.err b/result/schematron/zvon15_0.err new file mode 100644 index 00000000..52348897 --- /dev/null +++ b/result/schematron/zvon15_0.err @@ -0,0 +1,4 @@ +Pattern: id is the only permited attribute name +/AAA line 1: Attribute name is forbidden in element AAA +/AAA/CCC line 3: Attribute color is forbidden in element CCC +./test/schematron/zvon15_0.xml fails to validate diff --git a/result/schematron/zvon4_0 b/result/schematron/zvon4_0 new file mode 100644 index 00000000..b1e694e5 --- /dev/null +++ b/result/schematron/zvon4_0 @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<AAA> + <BBB> + <CCC/> + <CCC/> + </BBB> +</AAA> diff --git a/result/schematron/zvon4_0.err b/result/schematron/zvon4_0.err new file mode 100644 index 00000000..6aa6b2b5 --- /dev/null +++ b/result/schematron/zvon4_0.err @@ -0,0 +1,3 @@ +Pattern: Root test +/AAA line 1: Root element is AAA +./test/schematron/zvon4_0.xml fails to validate diff --git a/result/schematron/zvon4_1 b/result/schematron/zvon4_1 new file mode 100644 index 00000000..6b1facc6 --- /dev/null +++ b/result/schematron/zvon4_1 @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<XXX> + <BBB> + <CCC/> + <CCC/> + </BBB> +</XXX> diff --git a/result/schematron/zvon4_1.err b/result/schematron/zvon4_1.err new file mode 100644 index 00000000..4ad324f9 --- /dev/null +++ b/result/schematron/zvon4_1.err @@ -0,0 +1,3 @@ +Pattern: Root test +/XXX line 1: Root element is XXX, not AAA +./test/schematron/zvon4_1.xml fails to validate diff --git a/result/schematron/zvon5_0 b/result/schematron/zvon5_0 new file mode 100644 index 00000000..d763505b --- /dev/null +++ b/result/schematron/zvon5_0 @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<AAA> + <BBB> + <CCC/> + </BBB> +</AAA> diff --git a/result/schematron/zvon5_0.err b/result/schematron/zvon5_0.err new file mode 100644 index 00000000..91ef5f28 --- /dev/null +++ b/result/schematron/zvon5_0.err @@ -0,0 +1,7 @@ +Pattern: Select empty elements CCC +/AAA/BBB/CCC line 3: Source contains an empty element CCC +/AAA/BBB/CCC line 3: [1]An element CCC does not contain any text +/AAA/BBB/CCC line 3: [2]An element CCC does not contain any text +/AAA/BBB/CCC line 3: [1]An element CCC does not contain any child element +/AAA/BBB/CCC line 3: [2]An element CCC does not contain any child element +./test/schematron/zvon5_0.xml fails to validate diff --git a/result/schematron/zvon5_1 b/result/schematron/zvon5_1 new file mode 100644 index 00000000..c76b7562 --- /dev/null +++ b/result/schematron/zvon5_1 @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<AAA> + <BBB> + <CCC>I am CCC element</CCC> + </BBB> +</AAA> diff --git a/result/schematron/zvon5_1.err b/result/schematron/zvon5_1.err new file mode 100644 index 00000000..f4ce6d41 --- /dev/null +++ b/result/schematron/zvon5_1.err @@ -0,0 +1,5 @@ +Pattern: Select empty elements CCC +/AAA/BBB/CCC line 3: Source contains an empty element CCC +/AAA/BBB/CCC line 3: [1]An element CCC does not contain any child element +/AAA/BBB/CCC line 3: [2]An element CCC does not contain any child element +./test/schematron/zvon5_1.xml fails to validate diff --git a/result/schematron/zvon5_2 b/result/schematron/zvon5_2 new file mode 100644 index 00000000..ddc11fe3 --- /dev/null +++ b/result/schematron/zvon5_2 @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<AAA> + <BBB> + <CCC> + <DDD/> + </CCC> + </BBB> +</AAA> diff --git a/result/schematron/zvon5_2.err b/result/schematron/zvon5_2.err new file mode 100644 index 00000000..8c69e79f --- /dev/null +++ b/result/schematron/zvon5_2.err @@ -0,0 +1,5 @@ +Pattern: Select empty elements CCC +/AAA/BBB/CCC line 3: Source contains an empty element CCC +/AAA/BBB/CCC line 3: [1]An element CCC does not contain any text +/AAA/BBB/CCC line 3: [2]An element CCC does not contain any text +./test/schematron/zvon5_2.xml fails to validate diff --git a/result/schematron/zvon6_0 b/result/schematron/zvon6_0 new file mode 100644 index 00000000..65397651 --- /dev/null +++ b/result/schematron/zvon6_0 @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<AAA> +aaa +</AAA> diff --git a/result/schematron/zvon6_0.err b/result/schematron/zvon6_0.err new file mode 100644 index 00000000..5cc3b372 --- /dev/null +++ b/result/schematron/zvon6_0.err @@ -0,0 +1,3 @@ +Pattern: Predefined values +/AAA line 1: O.K. +./test/schematron/zvon6_0.xml fails to validate diff --git a/result/schematron/zvon6_1 b/result/schematron/zvon6_1 new file mode 100644 index 00000000..e0c2e73c --- /dev/null +++ b/result/schematron/zvon6_1 @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<AAA> + bbb +</AAA> diff --git a/result/schematron/zvon6_1.err b/result/schematron/zvon6_1.err new file mode 100644 index 00000000..8b728d41 --- /dev/null +++ b/result/schematron/zvon6_1.err @@ -0,0 +1,3 @@ +Pattern: Predefined values +/AAA line 1: O.K. +./test/schematron/zvon6_1.xml fails to validate diff --git a/result/schematron/zvon6_2 b/result/schematron/zvon6_2 new file mode 100644 index 00000000..edc24a97 --- /dev/null +++ b/result/schematron/zvon6_2 @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<AAA> + ccc +</AAA> diff --git a/result/schematron/zvon6_2.err b/result/schematron/zvon6_2.err new file mode 100644 index 00000000..18689342 --- /dev/null +++ b/result/schematron/zvon6_2.err @@ -0,0 +1,3 @@ +Pattern: Predefined values +/AAA line 1: The AAA value is not permitted. +./test/schematron/zvon6_2.xml fails to validate diff --git a/result/schematron/zvon7_0 b/result/schematron/zvon7_0 new file mode 100644 index 00000000..65397651 --- /dev/null +++ b/result/schematron/zvon7_0 @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<AAA> +aaa +</AAA> diff --git a/result/schematron/zvon7_0.err b/result/schematron/zvon7_0.err new file mode 100644 index 00000000..df427d68 --- /dev/null +++ b/result/schematron/zvon7_0.err @@ -0,0 +1,3 @@ +Pattern: Test integer +/AAA line 1: The AAA value is not an integer. +./test/schematron/zvon7_0.xml fails to validate diff --git a/result/schematron/zvon7_1 b/result/schematron/zvon7_1 new file mode 100644 index 00000000..0a4007ac --- /dev/null +++ b/result/schematron/zvon7_1 @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<AAA> + 12.234 +</AAA> diff --git a/result/schematron/zvon7_1.err b/result/schematron/zvon7_1.err new file mode 100644 index 00000000..aa1e0a15 --- /dev/null +++ b/result/schematron/zvon7_1.err @@ -0,0 +1,3 @@ +Pattern: Test integer +/AAA line 1: The AAA value is not an integer. +./test/schematron/zvon7_1.xml fails to validate diff --git a/result/schematron/zvon7_2 b/result/schematron/zvon7_2 new file mode 100644 index 00000000..8eb45e30 --- /dev/null +++ b/result/schematron/zvon7_2 @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<AAA> +45 +</AAA> diff --git a/result/schematron/zvon7_2.err b/result/schematron/zvon7_2.err new file mode 100644 index 00000000..abf8cc7e --- /dev/null +++ b/result/schematron/zvon7_2.err @@ -0,0 +1,3 @@ +Pattern: Test integer +/AAA line 1: O.K. +./test/schematron/zvon7_2.xml fails to validate diff --git a/result/schematron/zvon7_3 b/result/schematron/zvon7_3 new file mode 100644 index 00000000..35089dd2 --- /dev/null +++ b/result/schematron/zvon7_3 @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<AAA> +0 +</AAA> diff --git a/result/schematron/zvon7_3.err b/result/schematron/zvon7_3.err new file mode 100644 index 00000000..5b4b59fe --- /dev/null +++ b/result/schematron/zvon7_3.err @@ -0,0 +1,3 @@ +Pattern: Test integer +/AAA line 1: O.K. +./test/schematron/zvon7_3.xml fails to validate diff --git a/result/schematron/zvon7_4 b/result/schematron/zvon7_4 new file mode 100644 index 00000000..0739eb4d --- /dev/null +++ b/result/schematron/zvon7_4 @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<AAA> +-45 +</AAA> diff --git a/result/schematron/zvon7_4.err b/result/schematron/zvon7_4.err new file mode 100644 index 00000000..de1ee894 --- /dev/null +++ b/result/schematron/zvon7_4.err @@ -0,0 +1,3 @@ +Pattern: Test integer +/AAA line 1: O.K. +./test/schematron/zvon7_4.xml fails to validate diff --git a/result/schematron/zvon8_0 b/result/schematron/zvon8_0 new file mode 100644 index 00000000..1932cd04 --- /dev/null +++ b/result/schematron/zvon8_0 @@ -0,0 +1,9 @@ +<?xml version="1.0"?> +<XXX> + <BBB/> + <BBB/> + <AAA/> + <BBB/> + <AAA/> + <AAA/> +</XXX> diff --git a/result/schematron/zvon8_0.err b/result/schematron/zvon8_0.err new file mode 100644 index 00000000..085e1dee --- /dev/null +++ b/result/schematron/zvon8_0.err @@ -0,0 +1,3 @@ +Pattern: Test count +/XXX line 1: O.K. +./test/schematron/zvon8_0.xml fails to validate diff --git a/result/schematron/zvon8_1 b/result/schematron/zvon8_1 new file mode 100644 index 00000000..93e5cfdf --- /dev/null +++ b/result/schematron/zvon8_1 @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<XXX> + <BBB/> + <AAA/> + <BBB/> + <AAA/> + <AAA/> +</XXX> diff --git a/result/schematron/zvon8_1.err b/result/schematron/zvon8_1.err new file mode 100644 index 00000000..ae07d059 --- /dev/null +++ b/result/schematron/zvon8_1.err @@ -0,0 +1,3 @@ +Pattern: Test count +/XXX line 1: Some BBB are missing +./test/schematron/zvon8_1.xml fails to validate diff --git a/result/schematron/zvon8_2 b/result/schematron/zvon8_2 new file mode 100644 index 00000000..4eea77ba --- /dev/null +++ b/result/schematron/zvon8_2 @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<XXX> + <BBB/> + <BBB/> + <AAA/> + <BBB/> + <AAA/> +</XXX> diff --git a/result/schematron/zvon8_2.err b/result/schematron/zvon8_2.err new file mode 100644 index 00000000..37e8432c --- /dev/null +++ b/result/schematron/zvon8_2.err @@ -0,0 +1,3 @@ +Pattern: Test count +/XXX line 1: Some AAA are missing +./test/schematron/zvon8_2.xml fails to validate diff --git a/result/schematron/zvon9_0 b/result/schematron/zvon9_0 new file mode 100644 index 00000000..1f254ec2 --- /dev/null +++ b/result/schematron/zvon9_0 @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<AAA> + <CCC/> + <CCC/> + <BBB> + <CCC id="Q1"/> + </BBB> +</AAA> diff --git a/result/schematron/zvon9_0.err b/result/schematron/zvon9_0.err new file mode 100644 index 00000000..a39ceebe --- /dev/null +++ b/result/schematron/zvon9_0.err @@ -0,0 +1,2 @@ +Pattern: Test attribute +./test/schematron/zvon9_0.xml validates diff --git a/result/schematron/zvon9_1 b/result/schematron/zvon9_1 new file mode 100644 index 00000000..0dc0df72 --- /dev/null +++ b/result/schematron/zvon9_1 @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<AAA> + <CCC id="Q2"/> + <CCC/> + <BBB> + <CCC id="Q1"/> + </BBB> +</AAA> diff --git a/result/schematron/zvon9_1.err b/result/schematron/zvon9_1.err new file mode 100644 index 00000000..44c6f67f --- /dev/null +++ b/result/schematron/zvon9_1.err @@ -0,0 +1,3 @@ +Pattern: Test attribute +/AAA/CCC[1] line 2: Attribute id is used in wrong context +./test/schematron/zvon9_1.xml fails to validate diff --git a/result/schematron/zvon9_2 b/result/schematron/zvon9_2 new file mode 100644 index 00000000..b9218fc9 --- /dev/null +++ b/result/schematron/zvon9_2 @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<AAA> + <CCC/> + <CCC/> + <BBB> + <CCC/> + </BBB> +</AAA> diff --git a/result/schematron/zvon9_2.err b/result/schematron/zvon9_2.err new file mode 100644 index 00000000..20b08844 --- /dev/null +++ b/result/schematron/zvon9_2.err @@ -0,0 +1,3 @@ +Pattern: Test attribute +/AAA/BBB/CCC line 5: Attribute id is missing +./test/schematron/zvon9_2.xml fails to validate diff --git a/schematron.c b/schematron.c index b5c66181..67f97b66 100644 --- a/schematron.c +++ b/schematron.c @@ -1224,6 +1224,29 @@ exit: * * ************************************************************************/ +static xmlNodePtr +xmlSchematronGetNode(xmlSchematronValidCtxtPtr ctxt, + xmlNodePtr cur, const xmlChar *xpath) { + xmlNodePtr node = NULL; + xmlXPathObjectPtr ret; + + if ((ctxt == NULL) || (cur == NULL) || (xpath == NULL)) + return(NULL); + + ctxt->xctxt->doc = cur->doc; + ctxt->xctxt->node = cur; + ret = xmlXPathEval(xpath, ctxt->xctxt); + if (ret == NULL) + return(NULL); + + if ((ret->type == XPATH_NODESET) && + (ret->nodesetval != NULL) && (ret->nodesetval->nodeNr > 0)) + node = ret->nodesetval->nodeTab[0]; + + xmlXPathFreeObject(ret); + return(node); +} + /** * xmlSchematronReportOutput: * @ctxt: the validation context @@ -1255,7 +1278,7 @@ static xmlChar * xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt, xmlNodePtr test, xmlNodePtr cur) { xmlChar *ret = NULL; - xmlNodePtr child; + xmlNodePtr child, node; if ((test == NULL) || (cur == NULL)) return(ret); @@ -1266,12 +1289,24 @@ xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt, (child->type == XML_CDATA_SECTION_NODE)) ret = xmlStrcat(ret, child->content); else if (IS_SCHEMATRON(child, "name")) { - if ((cur->ns == NULL) || (cur->ns->prefix == NULL)) - ret = xmlStrcat(ret, cur->name); + xmlChar *path; + + path = xmlGetNoNsProp(child, BAD_CAST "path"); + + node = cur; + if (path != NULL) { + node = xmlSchematronGetNode(ctxt, cur, path); + if (node == NULL) + node = cur; + xmlFree(path); + } + + if ((node->ns == NULL) || (node->ns->prefix == NULL)) + ret = xmlStrcat(ret, node->name); else { - ret = xmlStrcat(ret, cur->ns->prefix); + ret = xmlStrcat(ret, node->ns->prefix); ret = xmlStrcat(ret, BAD_CAST ":"); - ret = xmlStrcat(ret, cur->name); + ret = xmlStrcat(ret, node->name); } } else { child = child->next; @@ -1358,7 +1393,7 @@ xmlSchematronReportSuccess(xmlSchematronValidCtxtPtr ctxt, } else { snprintf(msg, 999, "%s line %ld: %s\n", (const char *) path, line, (const char *) report); - xmlFree(report); + xmlFree((char *) report); } xmlSchematronReportOutput(ctxt, cur, &msg[0]); if ((path != NULL) && (path != (xmlChar *) cur->name)) diff --git a/test/schematron/zvon11.sct b/test/schematron/zvon11.sct new file mode 100644 index 00000000..79b01fdf --- /dev/null +++ b/test/schematron/zvon11.sct @@ -0,0 +1,8 @@ +<schema xmlns="http://www.ascc.net/xml/schematron" > + <pattern name="Attributes present"> + <rule context="BBB"> + <assert test="not(@aaa) or (@aaa and @bbb)">The element must not have an isolated aaa attribute</assert> + <assert test="not(@bbb) or (@aaa and @bbb)">The element must not have an isolated bbb attribute</assert> + </rule> + </pattern> +</schema> diff --git a/test/schematron/zvon11_0.xml b/test/schematron/zvon11_0.xml new file mode 100644 index 00000000..f065eed2 --- /dev/null +++ b/test/schematron/zvon11_0.xml @@ -0,0 +1,3 @@ +<AAA> + <BBB aaa="A" bbb="B"/> +</AAA> diff --git a/test/schematron/zvon11_1.xml b/test/schematron/zvon11_1.xml new file mode 100644 index 00000000..c8899331 --- /dev/null +++ b/test/schematron/zvon11_1.xml @@ -0,0 +1,3 @@ +<AAA> + <BBB bbb="B"/> +</AAA> diff --git a/test/schematron/zvon11_2.xml b/test/schematron/zvon11_2.xml new file mode 100644 index 00000000..26e12213 --- /dev/null +++ b/test/schematron/zvon11_2.xml @@ -0,0 +1,3 @@ +<AAA> + <BBB aaa="A"/> +</AAA> diff --git a/test/schematron/zvon11_3.xml b/test/schematron/zvon11_3.xml new file mode 100644 index 00000000..d3ac3884 --- /dev/null +++ b/test/schematron/zvon11_3.xml @@ -0,0 +1,3 @@ +<AAA> + <BBB/> +</AAA> diff --git a/test/schematron/zvon12.sct b/test/schematron/zvon12.sct new file mode 100644 index 00000000..049b125e --- /dev/null +++ b/test/schematron/zvon12.sct @@ -0,0 +1,8 @@ +<schema xmlns="http://www.ascc.net/xml/schematron" > + <pattern name="Number of characters in an abbreviation"> + <rule context="BBB"> + <report test="string-length(@bbb) < 2">There is not enough letters in the abbreviation</report> + <report test="string-length(@bbb) > 3">There is too much letters in the abbreviation</report> + </rule> + </pattern> +</schema> diff --git a/test/schematron/zvon12_0.xml b/test/schematron/zvon12_0.xml new file mode 100644 index 00000000..d5f28d53 --- /dev/null +++ b/test/schematron/zvon12_0.xml @@ -0,0 +1,3 @@ +<AAA> + <BBB bbb="C"/> +</AAA> diff --git a/test/schematron/zvon12_1.xml b/test/schematron/zvon12_1.xml new file mode 100644 index 00000000..3507f6b5 --- /dev/null +++ b/test/schematron/zvon12_1.xml @@ -0,0 +1,3 @@ +<AAA> + <BBB bbb="CZ"/> +</AAA> diff --git a/test/schematron/zvon12_2.xml b/test/schematron/zvon12_2.xml new file mode 100644 index 00000000..e0d81afa --- /dev/null +++ b/test/schematron/zvon12_2.xml @@ -0,0 +1,3 @@ +<AAA> + <BBB bbb="CZCZ"/> +</AAA> diff --git a/test/schematron/zvon13.sct b/test/schematron/zvon13.sct new file mode 100644 index 00000000..cd433e01 --- /dev/null +++ b/test/schematron/zvon13.sct @@ -0,0 +1,7 @@ +<schema xmlns="http://www.ascc.net/xml/schematron" > + <pattern name="Sum equals 100%."> + <rule context="Total"> + <assert test="sum(//Percent) = 100">The values do not sum to 100%. </assert> + </rule> + </pattern> +</schema> diff --git a/test/schematron/zvon13_0.xml b/test/schematron/zvon13_0.xml new file mode 100644 index 00000000..52619c3b --- /dev/null +++ b/test/schematron/zvon13_0.xml @@ -0,0 +1,6 @@ +<Total> + <Percent>20</Percent> + <Percent>30</Percent> + <Percent>10</Percent> + <Percent>50</Percent> +</Total> diff --git a/test/schematron/zvon13_1.xml b/test/schematron/zvon13_1.xml new file mode 100644 index 00000000..8fb73683 --- /dev/null +++ b/test/schematron/zvon13_1.xml @@ -0,0 +1,5 @@ +<Total> + <Percent>20</Percent> + <Percent>10</Percent> + <Percent>50</Percent> +</Total> diff --git a/test/schematron/zvon13_2.xml b/test/schematron/zvon13_2.xml new file mode 100644 index 00000000..af4d76ad --- /dev/null +++ b/test/schematron/zvon13_2.xml @@ -0,0 +1,5 @@ +<Total> + <Percent>20</Percent> + <Percent>30</Percent> + <Percent>50</Percent> +</Total> diff --git a/test/schematron/zvon14.sct b/test/schematron/zvon14.sct new file mode 100644 index 00000000..f98b6d89 --- /dev/null +++ b/test/schematron/zvon14.sct @@ -0,0 +1,10 @@ +<schema xmlns="http://www.ascc.net/xml/schematron" > + <pattern name="a child of selected elements"> + <rule context="CCC"> + <assert test="parent::*[name()='BBB' or name()='DDD']">Element CCC must not be a child of element + <name path="parent::*"/> + </assert> + </rule> + </pattern> +</schema> + diff --git a/test/schematron/zvon14_0.xml b/test/schematron/zvon14_0.xml new file mode 100644 index 00000000..b6270436 --- /dev/null +++ b/test/schematron/zvon14_0.xml @@ -0,0 +1,12 @@ +<AAA> + <BBB> + <CCC/> + </BBB> + <CCC/> + <DDD> + <CCC/> + <EEE> + <CCC/> + </EEE> + </DDD> +</AAA> diff --git a/test/schematron/zvon15.sct b/test/schematron/zvon15.sct new file mode 100644 index 00000000..7da5d868 --- /dev/null +++ b/test/schematron/zvon15.sct @@ -0,0 +1,11 @@ +<schema xmlns="http://www.ascc.net/xml/schematron" > + <pattern name="id is the only permited attribute name"> + <rule context="*"> + <report test="@*[not(name()='id')]">Attribute + <name path="@*[not(name()='id')]"/> is forbidden in element + <name/> + </report> + </rule> + </pattern> +</schema> + diff --git a/test/schematron/zvon15_0.xml b/test/schematron/zvon15_0.xml new file mode 100644 index 00000000..390aedb5 --- /dev/null +++ b/test/schematron/zvon15_0.xml @@ -0,0 +1,4 @@ +<AAA name="aaa"> +<BBB id="bbb"/> +<CCC color="ccc"/> +</AAA> diff --git a/test/schematron/zvon4.sct b/test/schematron/zvon4.sct new file mode 100644 index 00000000..0b8a4e1b --- /dev/null +++ b/test/schematron/zvon4.sct @@ -0,0 +1,10 @@ +<schema xmlns="http://www.ascc.net/xml/schematron" > + <pattern name="Root test"> + <rule context="/*"> + <assert test="name()='AAA'">Root element is + <name/>, not AAA + </assert> + <report test="name()='AAA'">Root element is AAA</report> + </rule> + </pattern> +</schema> diff --git a/test/schematron/zvon4_0.xml b/test/schematron/zvon4_0.xml new file mode 100644 index 00000000..4ba332e4 --- /dev/null +++ b/test/schematron/zvon4_0.xml @@ -0,0 +1,6 @@ +<AAA> + <BBB> + <CCC/> + <CCC/> + </BBB> +</AAA> diff --git a/test/schematron/zvon4_1.xml b/test/schematron/zvon4_1.xml new file mode 100644 index 00000000..5becbcf6 --- /dev/null +++ b/test/schematron/zvon4_1.xml @@ -0,0 +1,6 @@ +<XXX> + <BBB> + <CCC/> + <CCC/> + </BBB> +</XXX> diff --git a/test/schematron/zvon5.sct b/test/schematron/zvon5.sct new file mode 100644 index 00000000..36cb8bb1 --- /dev/null +++ b/test/schematron/zvon5.sct @@ -0,0 +1,12 @@ +<schema xmlns="http://www.ascc.net/xml/schematron" > + <pattern name="Select empty elements CCC"> + <rule context="CCC"> + <assert test="normalize-space(.) and *">Source contains an empty element CCC </assert> + <report test="normalize-space(.) = ''">[1]An element CCC does not contain any text</report> + <assert test="normalize-space(.)">[2]An element CCC does not contain any text</assert> + <report test="not(*)">[1]An element CCC does not contain any child element</report> + <assert test="*">[2]An element CCC does not contain any child element</assert> + </rule> + </pattern> +</schema> + diff --git a/test/schematron/zvon5_0.xml b/test/schematron/zvon5_0.xml new file mode 100644 index 00000000..dc7c36ba --- /dev/null +++ b/test/schematron/zvon5_0.xml @@ -0,0 +1,5 @@ +<AAA> + <BBB> + <CCC/> + </BBB> +</AAA> diff --git a/test/schematron/zvon5_1.xml b/test/schematron/zvon5_1.xml new file mode 100644 index 00000000..6915fa63 --- /dev/null +++ b/test/schematron/zvon5_1.xml @@ -0,0 +1,5 @@ +<AAA> + <BBB> + <CCC>I am CCC element</CCC> + </BBB> +</AAA> diff --git a/test/schematron/zvon5_2.xml b/test/schematron/zvon5_2.xml new file mode 100644 index 00000000..2a114004 --- /dev/null +++ b/test/schematron/zvon5_2.xml @@ -0,0 +1,7 @@ +<AAA> + <BBB> + <CCC> + <DDD/> + </CCC> + </BBB> +</AAA> diff --git a/test/schematron/zvon6.sct b/test/schematron/zvon6.sct new file mode 100644 index 00000000..678ae580 --- /dev/null +++ b/test/schematron/zvon6.sct @@ -0,0 +1,8 @@ +<schema xmlns="http://www.ascc.net/xml/schematron" > + <pattern name="Predefined values"> + <rule context="AAA"> + <report test="normalize-space(.) = 'aaa' or normalize-space(.) = 'bbb'">O.K.</report> + <assert test="normalize-space(.) = 'aaa' or normalize-space(.) = 'bbb'">The AAA value is not permitted.</assert> + </rule> + </pattern> +</schema> diff --git a/test/schematron/zvon6_0.xml b/test/schematron/zvon6_0.xml new file mode 100644 index 00000000..a3efb701 --- /dev/null +++ b/test/schematron/zvon6_0.xml @@ -0,0 +1,3 @@ +<AAA> +aaa +</AAA> diff --git a/test/schematron/zvon6_1.xml b/test/schematron/zvon6_1.xml new file mode 100644 index 00000000..7d7daf86 --- /dev/null +++ b/test/schematron/zvon6_1.xml @@ -0,0 +1,3 @@ +<AAA> + bbb +</AAA> diff --git a/test/schematron/zvon6_2.xml b/test/schematron/zvon6_2.xml new file mode 100644 index 00000000..555f24d4 --- /dev/null +++ b/test/schematron/zvon6_2.xml @@ -0,0 +1,3 @@ +<AAA> + ccc +</AAA> diff --git a/test/schematron/zvon7.sct b/test/schematron/zvon7.sct new file mode 100644 index 00000000..a22a89ed --- /dev/null +++ b/test/schematron/zvon7.sct @@ -0,0 +1,9 @@ +<schema xmlns="http://www.ascc.net/xml/schematron" > + <pattern name="Test integer"> + <rule context="AAA"> + <report test="floor(.) = number(.)">O.K.</report> + <assert test="floor(.) = number(.)">The AAA value is not an integer.</assert> + </rule> + </pattern> +</schema> + diff --git a/test/schematron/zvon7_0.xml b/test/schematron/zvon7_0.xml new file mode 100644 index 00000000..a3efb701 --- /dev/null +++ b/test/schematron/zvon7_0.xml @@ -0,0 +1,3 @@ +<AAA> +aaa +</AAA> diff --git a/test/schematron/zvon7_1.xml b/test/schematron/zvon7_1.xml new file mode 100644 index 00000000..8da0ae59 --- /dev/null +++ b/test/schematron/zvon7_1.xml @@ -0,0 +1,3 @@ +<AAA> + 12.234 +</AAA> diff --git a/test/schematron/zvon7_2.xml b/test/schematron/zvon7_2.xml new file mode 100644 index 00000000..e27cfe78 --- /dev/null +++ b/test/schematron/zvon7_2.xml @@ -0,0 +1,3 @@ +<AAA> +45 +</AAA> diff --git a/test/schematron/zvon7_3.xml b/test/schematron/zvon7_3.xml new file mode 100644 index 00000000..c17295af --- /dev/null +++ b/test/schematron/zvon7_3.xml @@ -0,0 +1,3 @@ +<AAA> +0 +</AAA> diff --git a/test/schematron/zvon7_4.xml b/test/schematron/zvon7_4.xml new file mode 100644 index 00000000..4f34fbea --- /dev/null +++ b/test/schematron/zvon7_4.xml @@ -0,0 +1,3 @@ +<AAA> +-45 +</AAA> diff --git a/test/schematron/zvon8.sct b/test/schematron/zvon8.sct new file mode 100644 index 00000000..5641ecdb --- /dev/null +++ b/test/schematron/zvon8.sct @@ -0,0 +1,10 @@ +<schema xmlns="http://www.ascc.net/xml/schematron" > + <pattern name="Test count"> + <rule context="/*"> + <report test="count(//BBB) = count(//AAA)">O.K.</report> + <assert test="count(//BBB) <= count(//AAA)">Some AAA are missing</assert> + <report test="count(//BBB) < count(//AAA)">Some BBB are missing</report> + </rule> + </pattern> +</schema> + diff --git a/test/schematron/zvon8_0.xml b/test/schematron/zvon8_0.xml new file mode 100644 index 00000000..b6739bb4 --- /dev/null +++ b/test/schematron/zvon8_0.xml @@ -0,0 +1,8 @@ +<XXX> + <BBB/> + <BBB/> + <AAA/> + <BBB/> + <AAA/> + <AAA/> +</XXX> diff --git a/test/schematron/zvon8_1.xml b/test/schematron/zvon8_1.xml new file mode 100644 index 00000000..196dbe25 --- /dev/null +++ b/test/schematron/zvon8_1.xml @@ -0,0 +1,7 @@ +<XXX> + <BBB/> + <AAA/> + <BBB/> + <AAA/> + <AAA/> +</XXX> diff --git a/test/schematron/zvon8_2.xml b/test/schematron/zvon8_2.xml new file mode 100644 index 00000000..f85de825 --- /dev/null +++ b/test/schematron/zvon8_2.xml @@ -0,0 +1,7 @@ +<XXX> + <BBB/> + <BBB/> + <AAA/> + <BBB/> + <AAA/> +</XXX> diff --git a/test/schematron/zvon9.sct b/test/schematron/zvon9.sct new file mode 100644 index 00000000..6f67877f --- /dev/null +++ b/test/schematron/zvon9.sct @@ -0,0 +1,9 @@ +<schema xmlns="http://www.ascc.net/xml/schematron" > + <pattern name="Test attribute"> + <rule context="CCC"> + <report test="parent::BBB and not(@id)">Attribute id is missing</report> + <report test="not(parent::BBB) and @id">Attribute id is used in wrong context</report> + </rule> + </pattern> +</schema> + diff --git a/test/schematron/zvon9_0.xml b/test/schematron/zvon9_0.xml new file mode 100644 index 00000000..d8715192 --- /dev/null +++ b/test/schematron/zvon9_0.xml @@ -0,0 +1,7 @@ +<AAA> + <CCC/> + <CCC/> + <BBB> + <CCC id="Q1"/> + </BBB> +</AAA> diff --git a/test/schematron/zvon9_1.xml b/test/schematron/zvon9_1.xml new file mode 100644 index 00000000..5c1c1bf0 --- /dev/null +++ b/test/schematron/zvon9_1.xml @@ -0,0 +1,7 @@ +<AAA> + <CCC id="Q2"/> + <CCC/> + <BBB> + <CCC id="Q1"/> + </BBB> +</AAA> diff --git a/test/schematron/zvon9_2.xml b/test/schematron/zvon9_2.xml new file mode 100644 index 00000000..7e09fab8 --- /dev/null +++ b/test/schematron/zvon9_2.xml @@ -0,0 +1,7 @@ +<AAA> + <CCC/> + <CCC/> + <BBB> + <CCC/> + </BBB> +</AAA> |