18tree_valid=self.parse('<AAA><BBB/><CCC/></AAA>')19tree_invalid=self.parse('<AAA><BBB/><CCC/><DDD/></AAA>')20schema=self.parse('''\21<schema xmlns="http://purl.oclc.org/dsdl/schematron" >22 <pattern name="Open model">23 <rule context="AAA">24 <assert test="BBB"> BBB element is not present</assert>25 <assert test="CCC"> CCC element is not present</assert>26 </rule>27 </pattern>28 <pattern name="Closed model">29 <rule context="AAA">30 <assert test="BBB"> BBB element is not present</assert>31 <assert test="CCC"> CCC element is not present</assert>32 <assert test="count(BBB|CCC) = count (*)">There is an extra element</assert>33 </rule>34 </pattern>35</schema>36''')37schema=etree.Schematron(schema)38self.assertTrue(schema.validate(tree_valid))39self.assertFalse(schema.error_log.filter_from_errors())4041self.assertFalse(schema.validate(tree_invalid))42self.assertTrue(schema.error_log.filter_from_errors())4344self.assertTrue(schema.validate(tree_valid))# repeat valid45self.assertFalse(schema.error_log.filter_from_errors())# repeat valid