This repository has been archived by the owner on Apr 29, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #6: SF/192: non-global complex types permit names
Be aware this impacts generated code: in the past these invalid names were used for the corresponding classes in the generated bindings. Now those classes are CTD_ANON instances.
- Loading branch information
Showing
5 changed files
with
81 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# -*- coding: utf-8 -*- | ||
import logging | ||
if __name__ == '__main__': | ||
logging.basicConfig() | ||
_log = logging.getLogger(__name__) | ||
# Undeclared XML namespace | ||
import pyxb.binding.generate | ||
import pyxb.binding.datatypes as xs | ||
import pyxb.utils.domutils | ||
from xml.dom import Node | ||
|
||
import os.path | ||
|
||
|
||
import unittest | ||
|
||
class TestIssue0006 (unittest.TestCase): | ||
|
||
local_xsd = '''<?xml version="1.0" encoding="UTF-8"?> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<xs:element name="ce"> | ||
<xs:complexType name="cet"> | ||
<xs:sequence> | ||
<xs:element name="s" type="xs:string"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:schema> | ||
''' | ||
|
||
top_xsd = '''<?xml version="1.0" encoding="UTF-8"?> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<xs:complexType name="cet"> | ||
<xs:sequence> | ||
<xs:element name="s" type="xs:string"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:schema> | ||
''' | ||
|
||
def testNamedLocal (self): | ||
with self.assertRaises(pyxb.SchemaValidationError) as cm: | ||
code = pyxb.binding.generate.GeneratePython(schema_text=self.local_xsd) | ||
e = cm.exception | ||
|
||
def testUnnamedLocal (self): | ||
fixed = self.local_xsd.replace('name="cet"', '') | ||
code = pyxb.binding.generate.GeneratePython(schema_text=fixed) | ||
|
||
def testNamedTop (self): | ||
code = pyxb.binding.generate.GeneratePython(schema_text=self.top_xsd) | ||
|
||
def testUnnamedTop (self): | ||
broken = self.top_xsd.replace('name="cet"', '') | ||
with self.assertRaises(pyxb.SchemaValidationError) as cm: | ||
code = pyxb.binding.generate.GeneratePython(schema_text=broken) | ||
e = cm.exception | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters