summaryrefslogtreecommitdiff
path: root/src/lxml/ElementInclude.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lxml/ElementInclude.py')
-rw-r--r--src/lxml/ElementInclude.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lxml/ElementInclude.py b/src/lxml/ElementInclude.py
index 6a449a5d..193c4535 100644
--- a/src/lxml/ElementInclude.py
+++ b/src/lxml/ElementInclude.py
@@ -186,9 +186,11 @@ def _include(elem, loader=None, _parent_hrefs=None):
"unknown parse type in xi:include tag (%r)" % parse
)
elif e.tag == XINCLUDE_FALLBACK:
- raise FatalIncludeError(
- "xi:fallback tag must be child of xi:include (%r)" % e.tag
- )
+ parent = e.getparent()
+ if parent is not None and parent.tag != XINCLUDE_INCLUDE:
+ raise FatalIncludeError(
+ "xi:fallback tag must be child of xi:include (%r)" % e.tag
+ )
else:
raise FatalIncludeError(
"Invalid element found in XInclude namespace (%r)" % e.tag