Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/how_it_works.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ text and children elements within a node. When using
[`Document.to_xml`](api/document.md#xml2db.document.Document.to_xml), text value will always appear before children
elements.

#### Wildcards

Wildcards (`xs:any` elements and `xs:anyAttribute` attributes) allow content that the schema does not describe. Schemas
containing them are accepted, but the matching content is not imported and a warning is logged.

## Loading process

This section explains in detail how parsing and loading work. Loading an XML file breaks down into the following steps.
Expand Down
5 changes: 5 additions & 0 deletions src/xml2db/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,11 @@ def get_occurs(particle):
# go through item attributes and add them as columns, adding a suffix if an element with the same name exists
children_names = None
for attrib_name, attrib in parent_node.attributes.items():
if attrib_name is None:
logger.warning(
f"type '{parent_type}' contains a xsd:anyAttribute, which is ignored"
)
continue
if children_names is None:
children_names = [child.local_name for child in parent_node]
(
Expand Down
2 changes: 1 addition & 1 deletion tests/sample_models/orders/equivalent_xml/order1a.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<companyId>
<bic>JIDAZIO786DAZH</bic>
</companyId>
<extra>
<extra source="crm">
<profileName>profile 1</profileName>
</extra>
</orderperson>
Expand Down
1 change: 1 addition & 0 deletions tests/sample_models/orders/orders.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<xs:sequence>
<xs:any minOccurs="0" maxOccurs="unbounded" processContents="skip" />
</xs:sequence>
<xs:anyAttribute processContents="skip" />
</xs:complexType>

<xs:complexType name="contacttype">
Expand Down
Loading