0
スキーマ入札のベースにXMLをビルドした後、pyxbに問題があります。
いくつかの単純な( 'アトミックシンプルタイプ')要素に値を当てはめる方法によって、異なるタイプが割り当てられることが分かりました。ここでPyxbがシンプルタイプを間違って認識しています
は私が何を意味するかの詳細です:
のPython 2.7
PyXBバージョン1.2.5
OS:スキーマのWindows 7の
一部:
<xs:simpleType name="Max140Text_DE_customized">
<xs:restriction base="Max140Text">
<xs:minLength value="1"/>
<xs:maxLength value="140"/>
<xs:pattern value="[ ]*[A-Za-z0-9+?/:()\.,'\-][A-Za-z0-9+?/:()\.,' \-]*"/>
</xs:restriction>
</xs:simpleType>
(...)
<xs:simpleType name="Max140Text">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="140"/>
</xs:restriction>
</xs:simpleType>
更新:
を使用スキーマ要素:私は文字列を渡す(スキーマによって)Max140Text_DE_customized
タイプである複合要素のタイプに値を割り当てるとき
# Atomic simple type: {http://www.schema-uri/de/MySchema}Max140Text
class Max140Text (pyxb.binding.datatypes.string):
"""An atomic simple type."""
_ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'Max140Text')
_XSDLocation = pyxb.utils.utility.Location('C:\\Python27\\Scripts\\MySchema.xsd', 1032, 2)
_Documentation = None
Max140Text._CF_minLength = pyxb.binding.facets.CF_minLength(value=pyxb.binding.datatypes.nonNegativeInteger(1))
Max140Text._CF_maxLength = pyxb.binding.facets.CF_maxLength(value=pyxb.binding.datatypes.nonNegativeInteger(140))
Max140Text._InitializeFacetMap(Max140Text._CF_minLength,
Max140Text._CF_maxLength)
Namespace.addCategoryObject('typeBinding', 'Max140Text', Max140Text)
_module_typeBindings.Max140Text = Max140Text
# Atomic simple type: {http://www.schema-uri/de/MySchema}Max140Text_DE_customized
class Max140Text_DE_customized (Max140Text):
"""An atomic simple type."""
_ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'Max140Text_DE_customized')
_XSDLocation = pyxb.utils.utility.Location('C:\\Python27\\Scripts\\MySchema.xsd', 1038, 2)
_Documentation = None
Max140Text_DE_customized._CF_minLength = pyxb.binding.facets.CF_minLength(value=pyxb.binding.datatypes.nonNegativeInteger(1))
Max140Text_DE_customized._CF_pattern = pyxb.binding.facets.CF_pattern()
Max140Text_DE_customized._CF_pattern.addPattern(pattern="[ ]*[A-Za-z0-9+?/:()\\.,'\\-][A-Za-z0-9+?/:()\\.,' \\-]*")
Max140Text_DE_customized._CF_maxLength = pyxb.binding.facets.CF_maxLength(value=pyxb.binding.datatypes.nonNegativeInteger(140))
Max140Text_DE_customized._InitializeFacetMap(Max140Text_DE_customized._CF_minLength,
Max140Text_DE_customized._CF_pattern, Max140Text_DE_customized._CF_maxLength)
Namespace.addCategoryObject('typeBinding', 'Max140Text_DE_customized', Max140Text_DE_customized)
_module_typeBindings.Max140Text_DE_customized = Max140Text_DE_customized
:pyxbにより入札を生成
<xs:complexType name="PartyIdentification32_CH_pacs008">
<xs:complexContent>
<xs:restriction base="PartyIdentification32">
<xs:sequence>
<xs:element name="Nm" type="Max140Text_DE_customized" minOccurs="0"/>
<xs:element name="PstlAdr" type="PostalAddress6_customized" minOccurs="0"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
この要素は正しく認識されません。
これは、ドキュメントをビルドした後でパターン検証を実行しません(誤ったタイプのため)。
my_elem = myschema_biddings() # some complex element
my_elem.Nm = "Foo" # no pattern validation !
type(my_elem.Nm) = <class'myschema_bidddings.Max140Text'> # wrong
my_elem.Nm = myschema_biddings.Max140Text_DE_customized("Bar")
type(my_elem.Nm) = <class'myschema_bidddings.Max140Text_DE_customized'> # correct
'myschema_biddings'クラスのスキーマを見ることなく、何が起こっているのかを理解するのに十分な情報がありません。 – pabigot